Compare commits

..

2 Commits

6 changed files with 65 additions and 94 deletions

View File

@ -26,6 +26,8 @@ in
config.nix = { config.nix = {
package = pkgs.nix-super; package = pkgs.nix-super;
extraOptions = "experimental-features = nix-command flakes";
gc = { gc = {
automatic = cfg.gc.enable; automatic = cfg.gc.enable;
options = "--max-freed ${cfg.gc.minimumFreedGB} --delete-older-than 14d"; options = "--max-freed ${cfg.gc.minimumFreedGB} --delete-older-than 14d";

View File

@ -9,7 +9,10 @@ let
cfg = config.my.programs.nvim; cfg = config.my.programs.nvim;
boolToString = bool: if bool then "true" else "false"; boolToString = bool: if bool then "true" else "false";
quote = str: ''"${toString str}"''; quote = str: ''"${toString str}"'';
listToString = list: ''{ ${concatStringsSep ", " (map quote list)} }''; id = x: x;
listToString = sep: f: list: ''{ ${concatStringsSep sep (map f list)} }'';
listToStringOneLine = listToString ", ";
listToStringMultiLine = listToString ",\n";
keybinding = keybinding =
{ key { key
, cmd , cmd
@ -42,31 +45,23 @@ let
, priority , priority
, keys , keys
}: }:
'' listToStringMultiLine id
{ ([
dir = "${plugin}", "dir = ${quote plugin}"
name = "${plugin.name}", "name = ${quote plugin.name}"
lazy = ${boolToString lazy}, "lazy = ${boolToString lazy}"
enabled = ${boolToString enabled}, ]
dependencies = { ${concatStringsSep ", " (map lazySpecFromPlugin dependencies)} }, ++ (optional (!enabled) "enabled = ${boolToString enabled}")
${optionalString (init != null) ++ (optional (dependencies != [ ]) "dependencies = ${listToStringMultiLine id (map lazySpecFromPlugin dependencies)}")
"init = function(plugin) ++ (optional (init != null) "init = function(plugin)\n${toString init}\nend")
${toString init} ++ (optional (conf != null) "config = function(plugin, opts)\n${toString conf}\nend")
end," ++ (optional (keys != [ ]) "keys = ${listToStringMultiLine id (map keybinding keys)}")
} ++ (optional (event != [ ]) "event = ${listToStringOneLine quote event}")
${optionalString (conf != null) ++ (optional (cmd != [ ]) "cmd = ${listToStringOneLine quote cmd}")
"config = function(plugin, opts) ++ (optional (ft != [ ]) "ft = ${listToStringOneLine quote ft}")
${toString conf} ++ (optional (priority != 50) "priority = ${toString priority}")
end," );
} lazySpecs = listToStringMultiLine id (map lazySpecFromPlugin cfg.plugins);
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 = '' lazy = ''
require("lazy").setup({ require("lazy").setup({
${lazySpecs} ${lazySpecs}
@ -117,7 +112,7 @@ in
}; };
lazy = mkOption { lazy = mkOption {
type = bool; type = bool;
default = false; default = true;
description = '' description = ''
Whether to load the plugin lazily. Whether to load the plugin lazily.
''; '';

View File

@ -5,42 +5,46 @@ with builtins;
config.my.programs.nvim.plugins = with pkgs.vimPlugins; [ config.my.programs.nvim.plugins = with pkgs.vimPlugins; [
{ {
plugin = which-key-nvim; plugin = which-key-nvim;
lazy = false;
conf = readFile ./which-key-nvim.lua; conf = readFile ./which-key-nvim.lua;
} }
{ {
plugin = catppuccin-nvim; plugin = catppuccin-nvim;
conf = readFile ./catppuccin-nvim.lua; conf = readFile ./catppuccin-nvim.lua;
lazy = false;
priority = 99; priority = 99;
} }
{ {
plugin = formatter-nvim; plugin = formatter-nvim;
lazy = true;
keys = [ keys = [
{ key = "="; cmd = "<cmd>Format<cr>"; desc = "format (formatter)"; } { key = "="; cmd = "<cmd>Format<cr>"; desc = "format (formatter)"; }
]; ];
conf = readFile ./formatter-nvim.lua; conf = readFile ./formatter-nvim.lua;
dependencies = [{ plugin = which-key-nvim; lazy = true; }]; dependencies = [{ plugin = which-key-nvim; }];
} }
{ {
plugin = oil-nvim; plugin = oil-nvim;
lazy = false;
conf = readFile ./oil-nvim.lua; conf = readFile ./oil-nvim.lua;
dependencies = [ dependencies = [
{ plugin = which-key-nvim; lazy = true; } { plugin = which-key-nvim; }
{ plugin = nvim-web-devicons; lazy = true; } { plugin = nvim-web-devicons; }
]; ];
} }
{ plugin = nvim-ts-context-commentstring; }
{ {
plugin = mini-nvim; plugin = mini-nvim;
lazy = false;
conf = readFile ./mini-nvim.lua; conf = readFile ./mini-nvim.lua;
} }
{ {
plugin = noice-nvim; plugin = noice-nvim;
lazy = false;
conf = readFile ./noice-nvim.lua; conf = readFile ./noice-nvim.lua;
dependencies = [{ plugin = nui-nvim; lazy = true; }]; dependencies = [{ plugin = nui-nvim; }];
} }
{ {
plugin = trouble-nvim; plugin = trouble-nvim;
lazy = true;
keys = [ keys = [
{ key = "<leader>xx"; cmd = "<cmd>TroubleToggle document_diagnostics<cr>"; desc = "Document Diagnostics (Trouble)"; } { key = "<leader>xx"; cmd = "<cmd>TroubleToggle document_diagnostics<cr>"; desc = "Document Diagnostics (Trouble)"; }
{ key = "<leader>xX"; cmd = "<cmd>TroubleToggle workspace_diagnostics<cr>"; desc = "Workspace Diagnostics (Troule)"; } { key = "<leader>xX"; cmd = "<cmd>TroubleToggle workspace_diagnostics<cr>"; desc = "Workspace Diagnostics (Troule)"; }
@ -75,13 +79,12 @@ with builtins;
conf = readFile ./trouble-nvim.lua; conf = readFile ./trouble-nvim.lua;
dependencies = [ dependencies = [
{ plugin = which-key-nvim; } { plugin = which-key-nvim; }
{ plugin = nvim-web-devicons; lazy = true; } { plugin = nvim-web-devicons; }
]; ];
} }
{ {
plugin = nvim-cmp; plugin = nvim-cmp;
conf = readFile ./nvim-cmp.lua; conf = readFile ./nvim-cmp.lua;
lazy = true;
event = [ "InsertEnter" ]; event = [ "InsertEnter" ];
dependencies = [ dependencies = [
{ plugin = cmp-async-path; } { plugin = cmp-async-path; }
@ -98,131 +101,94 @@ with builtins;
]; ];
} }
{ plugin = friendly-snippets; } { plugin = friendly-snippets; }
{ plugin = luasnip; lazy = true; } { plugin = luasnip; }
]; ];
} }
{ {
plugin = todo-comments-nvim; plugin = todo-comments-nvim;
lazy = true;
event = [ "BufReadPost" "BufNewFile" ]; event = [ "BufReadPost" "BufNewFile" ];
conf = readFile ./todo-comments-nvim.lua; conf = readFile ./todo-comments-nvim.lua;
dependencies = [{ plugin = plenary-nvim; lazy = true; }]; dependencies = [{ plugin = plenary-nvim; }];
} }
{ {
plugin = direnv-vim; plugin = direnv-vim;
lazy = false;
} }
{ {
plugin = nvim-treesitter.withAllGrammars; plugin = nvim-treesitter.withAllGrammars;
lazy = true;
event = [ "BufReadPost" "BufNewFile" ]; event = [ "BufReadPost" "BufNewFile" ];
conf = readFile ./nvim-treesitter.lua; conf = readFile ./nvim-treesitter.lua;
dependencies = [ dependencies = [
{ plugin = nvim-ts-context-commentstring; }
{ {
plugin = orgmode; plugin = orgmode;
lazy = true;
conf = readFile ./orgmode.lua; conf = readFile ./orgmode.lua;
} }
]; ];
} }
{ {
plugin = nvim-lspconfig; plugin = nvim-lspconfig;
lazy = true;
event = [ "BufReadPre" "BufNewFile" ]; event = [ "BufReadPre" "BufNewFile" ];
conf = readFile ./nvim-lspconfig.lua; conf = readFile ./nvim-lspconfig.lua;
dependencies = [ dependencies = [
{ {
plugin = null-ls-nvim; plugin = null-ls-nvim;
lazy = true;
conf = readFile ./null-ls-nvim.lua; conf = readFile ./null-ls-nvim.lua;
dependencies = [ dependencies = [
{ plugin = which-key-nvim; lazy = true; } { plugin = which-key-nvim; }
{ plugin = plenary-nvim; lazy = true; } { plugin = plenary-nvim; }
]; ];
} }
{ { plugin = which-key-nvim; }
plugin = which-key-nvim; { plugin = lspkind-nvim; }
lazy = true; { plugin = lsp_lines-nvim; }
}
{
plugin = lspkind-nvim;
lazy = true;
}
{
plugin = lsp_lines-nvim;
lazy = true;
}
{ {
plugin = lspsaga-nvim-original; plugin = lspsaga-nvim-original;
lazy = true;
dependencies = [ dependencies = [
{ plugin = nvim-web-devicons; lazy = true; } { plugin = nvim-web-devicons; }
{ plugin = nvim-treesitter.withAllGrammars; lazy = true; } { plugin = nvim-treesitter.withAllGrammars; }
]; ];
} }
{ {
plugin = nvim-ufo; plugin = nvim-ufo;
lazy = true;
dependencies = [ dependencies = [
{ plugin = promise-async; lazy = true; } { plugin = promise-async; }
]; ];
} }
]; ];
} }
{ {
event = [ "VeryLazy" ]; event = [ "VeryLazy" ];
lazy = true;
plugin = vim-fugitive; plugin = vim-fugitive;
} }
{ {
plugin = vim-tmux-navigator; plugin = vim-tmux-navigator;
lazy = false;
} }
{ {
plugin = gitsigns-nvim; plugin = gitsigns-nvim;
lazy = true;
event = [ "BufReadPost" "BufNewFile" ]; event = [ "BufReadPost" "BufNewFile" ];
conf = readFile ./gitsigns-nvim.lua; conf = readFile ./gitsigns-nvim.lua;
dependencies = [{ plugin = which-key-nvim; }]; dependencies = [{ plugin = which-key-nvim; }];
} }
{ {
plugin = nvim-lastplace; plugin = nvim-lastplace;
lazy = true;
event = [ "BufReadPost" "BufNewFile" ]; event = [ "BufReadPost" "BufNewFile" ];
conf = readFile ./nvim-lastplace.lua; conf = readFile ./nvim-lastplace.lua;
} }
{ {
plugin = nvim-treesitter-textsubjects; plugin = nvim-treesitter-textsubjects;
lazy = true;
event = [ "BufReadPost" "BufNewFile" ]; event = [ "BufReadPost" "BufNewFile" ];
conf = readFile ./nvim-treesitter-textsubjects.lua; 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; plugin = smartcolumn-nvim;
lazy = true;
event = [ "BufReadPost" "BufNewFile" ]; event = [ "BufReadPost" "BufNewFile" ];
conf = readFile ./smartcolumn-nvim.lua; conf = readFile ./smartcolumn-nvim.lua;
} }
{ {
plugin = telescope-fzf-native-nvim; plugin = telescope-fzf-native-nvim;
conf = readFile ./telescope-fzf-native-nvim.lua; conf = readFile ./telescope-fzf-native-nvim.lua;
lazy = true;
keys = [ keys = [
{ key = "<leader>ff"; cmd = "<cmd>Telescope find_files<cr>"; desc = "Find files"; } { key = "<leader>ff"; cmd = "<cmd>Telescope find_files<cr>"; desc = "Find files"; }
{ key = "<leader>fb"; cmd = "<cmd>Telescope buffers<cr>"; desc = "Find buffers"; } { key = "<leader>fb"; cmd = "<cmd>Telescope buffers<cr>"; desc = "Find buffers"; }
@ -242,13 +208,17 @@ with builtins;
dependencies = [ dependencies = [
{ {
plugin = telescope-nvim; plugin = telescope-nvim;
lazy = true;
dependencies = [ dependencies = [
{ plugin = plenary-nvim; lazy = true; } { plugin = plenary-nvim; }
{ plugin = which-key-nvim; lazy = true; } { plugin = which-key-nvim; }
]; ];
} }
]; ];
} }
{
plugin = vim-startuptime;
cmd = [ "StartupTime" ];
conf = readFile ./vim-startuptime.lua;
}
]; ];
} }

View File

@ -1,5 +1,11 @@
require("mini.align").setup() require("mini.align").setup()
require("mini.comment").setup() require("mini.comment").setup({
options = {
custom_commentstring = function()
return require("ts_context_commentstring.internal").calculate_commentstring() or vim.bo.commentstring
end,
},
})
require("mini.surround").setup() require("mini.surround").setup()
require("mini.move").setup() require("mini.move").setup()
require("mini.pairs").setup() require("mini.pairs").setup()

View File

@ -9,4 +9,7 @@ require("nvim-treesitter.configs").setup({
-- code block highlights that do not have ts grammar -- code block highlights that do not have ts grammar
additional_vim_regex_highlighting = { "org" }, additional_vim_regex_highlighting = { "org" },
}, },
context_commentstring = {
enable = true,
},
}) })

View File

@ -1,5 +0,0 @@
require("nvim-treesitter.configs").setup({
context_commentstring = {
enable = true,
},
})