diff --git a/modules/programs/nix.nix b/modules/programs/nix.nix index 39b47a2..309e2ed 100644 --- a/modules/programs/nix.nix +++ b/modules/programs/nix.nix @@ -26,8 +26,6 @@ in config.nix = { package = pkgs.nix-super; - extraOptions = "experimental-features = nix-command flakes"; - gc = { automatic = cfg.gc.enable; options = "--max-freed ${cfg.gc.minimumFreedGB} --delete-older-than 14d"; diff --git a/modules/programs/nvim/default.nix b/modules/programs/nvim/default.nix index 47411b9..aacfb4c 100644 --- a/modules/programs/nvim/default.nix +++ b/modules/programs/nvim/default.nix @@ -9,10 +9,7 @@ let cfg = config.my.programs.nvim; boolToString = bool: if bool then "true" else "false"; quote = str: ''"${toString str}"''; - id = x: x; - listToString = sep: f: list: ''{ ${concatStringsSep sep (map f list)} }''; - listToStringOneLine = listToString ", "; - listToStringMultiLine = listToString ",\n"; + listToString = list: ''{ ${concatStringsSep ", " (map quote list)} }''; keybinding = { key , cmd @@ -45,23 +42,31 @@ let , priority , keys }: - listToStringMultiLine id - ([ - "dir = ${quote plugin}" - "name = ${quote plugin.name}" - "lazy = ${boolToString lazy}" - ] - ++ (optional (!enabled) "enabled = ${boolToString enabled}") - ++ (optional (dependencies != [ ]) "dependencies = ${listToStringMultiLine id (map lazySpecFromPlugin dependencies)}") - ++ (optional (init != null) "init = function(plugin)\n${toString init}\nend") - ++ (optional (conf != null) "config = function(plugin, opts)\n${toString conf}\nend") - ++ (optional (keys != [ ]) "keys = ${listToStringMultiLine id (map keybinding keys)}") - ++ (optional (event != [ ]) "event = ${listToStringOneLine quote event}") - ++ (optional (cmd != [ ]) "cmd = ${listToStringOneLine quote cmd}") - ++ (optional (ft != [ ]) "ft = ${listToStringOneLine quote ft}") - ++ (optional (priority != 50) "priority = ${toString priority}") - ); - lazySpecs = listToStringMultiLine id (map lazySpecFromPlugin cfg.plugins); + '' + { + dir = "${plugin}", + name = "${plugin.name}", + lazy = ${boolToString lazy}, + enabled = ${boolToString enabled}, + dependencies = { ${concatStringsSep ", " (map lazySpecFromPlugin dependencies)} }, + ${optionalString (init != null) + "init = function(plugin) + ${toString init} + end," + } + ${optionalString (conf != null) + "config = function(plugin, opts) + ${toString conf} + end," + } + keys = { ${concatStringsSep ",\n" (map keybinding keys)} }, + event = ${listToString event}, + cmd = ${listToString cmd}, + ft = ${listToString ft}, + priority = ${toString priority}, + } + ''; + lazySpecs = concatStringsSep ", " (map lazySpecFromPlugin cfg.plugins); lazy = '' require("lazy").setup({ ${lazySpecs} @@ -112,7 +117,7 @@ in }; lazy = mkOption { type = bool; - default = true; + default = false; description = '' Whether to load the plugin lazily. ''; diff --git a/modules/programs/nvim/plugins/default.nix b/modules/programs/nvim/plugins/default.nix index cf9026b..3b40c98 100644 --- a/modules/programs/nvim/plugins/default.nix +++ b/modules/programs/nvim/plugins/default.nix @@ -5,46 +5,42 @@ with builtins; config.my.programs.nvim.plugins = with pkgs.vimPlugins; [ { plugin = which-key-nvim; - lazy = false; conf = readFile ./which-key-nvim.lua; } { plugin = catppuccin-nvim; conf = readFile ./catppuccin-nvim.lua; - lazy = false; priority = 99; } { plugin = formatter-nvim; + lazy = true; keys = [ { key = "="; cmd = "Format"; desc = "format (formatter)"; } ]; conf = readFile ./formatter-nvim.lua; - dependencies = [{ plugin = which-key-nvim; }]; + dependencies = [{ plugin = which-key-nvim; lazy = true; }]; } { plugin = oil-nvim; - lazy = false; conf = readFile ./oil-nvim.lua; dependencies = [ - { plugin = which-key-nvim; } - { plugin = nvim-web-devicons; } + { plugin = which-key-nvim; lazy = true; } + { plugin = nvim-web-devicons; lazy = true; } ]; } - { plugin = nvim-ts-context-commentstring; } { plugin = mini-nvim; - lazy = false; conf = readFile ./mini-nvim.lua; } { plugin = noice-nvim; - lazy = false; conf = readFile ./noice-nvim.lua; - dependencies = [{ plugin = nui-nvim; }]; + dependencies = [{ plugin = nui-nvim; lazy = true; }]; } { plugin = trouble-nvim; + lazy = true; keys = [ { key = "xx"; cmd = "TroubleToggle document_diagnostics"; desc = "Document Diagnostics (Trouble)"; } { key = "xX"; cmd = "TroubleToggle workspace_diagnostics"; desc = "Workspace Diagnostics (Troule)"; } @@ -79,12 +75,13 @@ with builtins; conf = readFile ./trouble-nvim.lua; dependencies = [ { plugin = which-key-nvim; } - { plugin = nvim-web-devicons; } + { plugin = nvim-web-devicons; lazy = true; } ]; } { plugin = nvim-cmp; conf = readFile ./nvim-cmp.lua; + lazy = true; event = [ "InsertEnter" ]; dependencies = [ { plugin = cmp-async-path; } @@ -101,94 +98,131 @@ with builtins; ]; } { plugin = friendly-snippets; } - { plugin = luasnip; } + { plugin = luasnip; lazy = true; } ]; } { plugin = todo-comments-nvim; + lazy = true; event = [ "BufReadPost" "BufNewFile" ]; conf = readFile ./todo-comments-nvim.lua; - dependencies = [{ plugin = plenary-nvim; }]; + dependencies = [{ plugin = plenary-nvim; lazy = true; }]; } { plugin = direnv-vim; - lazy = false; } { plugin = nvim-treesitter.withAllGrammars; + lazy = true; event = [ "BufReadPost" "BufNewFile" ]; conf = readFile ./nvim-treesitter.lua; dependencies = [ - { plugin = nvim-ts-context-commentstring; } { plugin = orgmode; + lazy = true; conf = readFile ./orgmode.lua; } ]; } { plugin = nvim-lspconfig; + lazy = true; event = [ "BufReadPre" "BufNewFile" ]; conf = readFile ./nvim-lspconfig.lua; dependencies = [ { plugin = null-ls-nvim; + lazy = true; conf = readFile ./null-ls-nvim.lua; dependencies = [ - { plugin = which-key-nvim; } - { plugin = plenary-nvim; } + { plugin = which-key-nvim; lazy = true; } + { plugin = plenary-nvim; lazy = true; } ]; } - { plugin = which-key-nvim; } - { plugin = lspkind-nvim; } - { plugin = lsp_lines-nvim; } + { + plugin = which-key-nvim; + lazy = true; + } + { + plugin = lspkind-nvim; + lazy = true; + } + { + plugin = lsp_lines-nvim; + lazy = true; + } { plugin = lspsaga-nvim-original; + lazy = true; dependencies = [ - { plugin = nvim-web-devicons; } - { plugin = nvim-treesitter.withAllGrammars; } + { plugin = nvim-web-devicons; lazy = true; } + { plugin = nvim-treesitter.withAllGrammars; lazy = true; } ]; } { plugin = nvim-ufo; + lazy = true; dependencies = [ - { plugin = promise-async; } + { plugin = promise-async; lazy = true; } ]; } ]; } { event = [ "VeryLazy" ]; + lazy = true; plugin = vim-fugitive; } { plugin = vim-tmux-navigator; - lazy = false; } { plugin = gitsigns-nvim; + lazy = true; event = [ "BufReadPost" "BufNewFile" ]; conf = readFile ./gitsigns-nvim.lua; dependencies = [{ plugin = which-key-nvim; }]; } { plugin = nvim-lastplace; + lazy = true; event = [ "BufReadPost" "BufNewFile" ]; conf = readFile ./nvim-lastplace.lua; } { plugin = nvim-treesitter-textsubjects; + lazy = true; event = [ "BufReadPost" "BufNewFile" ]; conf = readFile ./nvim-treesitter-textsubjects.lua; + dependencies = [ + { + plugin = nvim-treesitter.withAllGrammars; + lazy = true; + } + ]; + } + { + plugin = nvim-ts-context-commentstring; + lazy = true; + event = [ "BufReadPost" "BufNewFile" ]; + conf = readFile ./nvim-ts-context-commentstring.lua; + dependencies = [ + { + plugin = nvim-treesitter.withAllGrammars; + lazy = true; + } + ]; } { plugin = smartcolumn-nvim; + lazy = true; event = [ "BufReadPost" "BufNewFile" ]; conf = readFile ./smartcolumn-nvim.lua; } { plugin = telescope-fzf-native-nvim; conf = readFile ./telescope-fzf-native-nvim.lua; + lazy = true; keys = [ { key = "ff"; cmd = "Telescope find_files"; desc = "Find files"; } { key = "fb"; cmd = "Telescope buffers"; desc = "Find buffers"; } @@ -208,17 +242,13 @@ with builtins; dependencies = [ { plugin = telescope-nvim; + lazy = true; dependencies = [ - { plugin = plenary-nvim; } - { plugin = which-key-nvim; } + { plugin = plenary-nvim; lazy = true; } + { plugin = which-key-nvim; lazy = true; } ]; } ]; } - { - plugin = vim-startuptime; - cmd = [ "StartupTime" ]; - conf = readFile ./vim-startuptime.lua; - } ]; } diff --git a/modules/programs/nvim/plugins/mini-nvim.lua b/modules/programs/nvim/plugins/mini-nvim.lua index e2824f6..fa40eda 100644 --- a/modules/programs/nvim/plugins/mini-nvim.lua +++ b/modules/programs/nvim/plugins/mini-nvim.lua @@ -1,11 +1,5 @@ require("mini.align").setup() -require("mini.comment").setup({ - options = { - custom_commentstring = function() - return require("ts_context_commentstring.internal").calculate_commentstring() or vim.bo.commentstring - end, - }, -}) +require("mini.comment").setup() require("mini.surround").setup() require("mini.move").setup() require("mini.pairs").setup() diff --git a/modules/programs/nvim/plugins/nvim-treesitter.lua b/modules/programs/nvim/plugins/nvim-treesitter.lua index 0c13317..c856c13 100644 --- a/modules/programs/nvim/plugins/nvim-treesitter.lua +++ b/modules/programs/nvim/plugins/nvim-treesitter.lua @@ -9,7 +9,4 @@ require("nvim-treesitter.configs").setup({ -- code block highlights that do not have ts grammar additional_vim_regex_highlighting = { "org" }, }, - context_commentstring = { - enable = true, - }, }) diff --git a/modules/programs/nvim/plugins/nvim-ts-context-commentstring.lua b/modules/programs/nvim/plugins/nvim-ts-context-commentstring.lua new file mode 100644 index 0000000..42a4bb9 --- /dev/null +++ b/modules/programs/nvim/plugins/nvim-ts-context-commentstring.lua @@ -0,0 +1,5 @@ +require("nvim-treesitter.configs").setup({ + context_commentstring = { + enable = true, + }, +})