mirror of
https://github.com/NotAShelf/neovim-flake.git
synced 2024-11-08 12:35:59 +01:00
comment-nvim: lazy load
This commit is contained in:
parent
283ea5b92c
commit
6ae18403a8
2 changed files with 36 additions and 31 deletions
|
@ -1,6 +1,7 @@
|
||||||
{lib, ...}: let
|
{lib, ...}: let
|
||||||
inherit (lib.options) mkEnableOption;
|
inherit (lib.options) mkEnableOption;
|
||||||
inherit (lib.nvim.binds) mkMappingOption;
|
inherit (lib.nvim.binds) mkMappingOption;
|
||||||
|
inherit (lib.nvim.types) mkPluginSetupOption;
|
||||||
in {
|
in {
|
||||||
options.vim.comments.comment-nvim = {
|
options.vim.comments.comment-nvim = {
|
||||||
enable = mkEnableOption "smart and powerful comment plugin for neovim comment-nvim";
|
enable = mkEnableOption "smart and powerful comment plugin for neovim comment-nvim";
|
||||||
|
@ -15,5 +16,12 @@ in {
|
||||||
toggleSelectedLine = mkMappingOption "Toggle selected comment" "gc";
|
toggleSelectedLine = mkMappingOption "Toggle selected comment" "gc";
|
||||||
toggleSelectedBlock = mkMappingOption "Toggle selected block" "gb";
|
toggleSelectedBlock = mkMappingOption "Toggle selected block" "gb";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
setupOpts = mkPluginSetupOption "Comment-nvim" {
|
||||||
|
mappings = {
|
||||||
|
basic = mkEnableOption "basic mappings";
|
||||||
|
extra = mkEnableOption "extra mappings";
|
||||||
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,8 @@
|
||||||
lib,
|
lib,
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
inherit (lib.modules) mkIf mkMerge;
|
inherit (lib.modules) mkIf;
|
||||||
inherit (lib.nvim.binds) mkExprBinding mkBinding;
|
inherit (lib.nvim.binds) mkLznExprBinding mkLznBinding;
|
||||||
inherit (lib.nvim.dag) entryAnywhere;
|
|
||||||
|
|
||||||
cfg = config.vim.comments.comment-nvim;
|
cfg = config.vim.comments.comment-nvim;
|
||||||
self = import ./comment-nvim.nix {inherit lib;};
|
self = import ./comment-nvim.nix {inherit lib;};
|
||||||
|
@ -16,35 +15,33 @@ in {
|
||||||
"comment-nvim"
|
"comment-nvim"
|
||||||
];
|
];
|
||||||
|
|
||||||
vim.maps.normal = mkMerge [
|
vim.lazy.plugins = [
|
||||||
(mkBinding cfg.mappings.toggleOpLeaderLine "<Plug>(comment_toggle_linewise)" mappings.toggleOpLeaderLine.description)
|
{
|
||||||
(mkBinding cfg.mappings.toggleOpLeaderBlock "<Plug>(comment_toggle_blockwise)" mappings.toggleOpLeaderBlock.description)
|
package = "comment-nvim";
|
||||||
|
setupModule = "Comment";
|
||||||
|
inherit (cfg) setupOpts;
|
||||||
|
keys = [
|
||||||
|
(mkLznBinding ["n"] cfg.mappings.toggleOpLeaderLine "<Plug>(comment_toggle_linewise)" mappings.toggleOpLeaderLine.description)
|
||||||
|
(mkLznBinding ["n"] cfg.mappings.toggleOpLeaderBlock "<Plug>(comment_toggle_blockwise)" mappings.toggleOpLeaderBlock.description)
|
||||||
|
|
||||||
(mkExprBinding cfg.mappings.toggleCurrentLine ''
|
(mkLznExprBinding ["n"] cfg.mappings.toggleCurrentLine ''
|
||||||
function()
|
function()
|
||||||
return vim.api.nvim_get_vvar('count') == 0 and '<Plug>(comment_toggle_linewise_current)'
|
return vim.api.nvim_get_vvar('count') == 0 and '<Plug>(comment_toggle_linewise_current)'
|
||||||
or '<Plug>(comment_toggle_linewise_count)'
|
or '<Plug>(comment_toggle_linewise_count)'
|
||||||
end
|
end
|
||||||
''
|
''
|
||||||
mappings.toggleCurrentLine.description)
|
mappings.toggleCurrentLine.description)
|
||||||
(mkExprBinding cfg.mappings.toggleCurrentBlock ''
|
(mkLznExprBinding ["n"] cfg.mappings.toggleCurrentBlock ''
|
||||||
function()
|
function()
|
||||||
return vim.api.nvim_get_vvar('count') == 0 and '<Plug>(comment_toggle_blockwise_current)'
|
return vim.api.nvim_get_vvar('count') == 0 and '<Plug>(comment_toggle_blockwise_current)'
|
||||||
or '<Plug>(comment_toggle_blockwise_count)'
|
or '<Plug>(comment_toggle_blockwise_count)'
|
||||||
end
|
end
|
||||||
''
|
''
|
||||||
mappings.toggleCurrentBlock.description)
|
mappings.toggleCurrentBlock.description)
|
||||||
|
(mkLznBinding ["x"] cfg.mappings.toggleSelectedLine "<Plug>(comment_toggle_linewise_visual)" mappings.toggleSelectedLine.description)
|
||||||
|
(mkLznBinding ["x"] cfg.mappings.toggleSelectedBlock "<Plug>(comment_toggle_blockwise_visual)" mappings.toggleSelectedBlock.description)
|
||||||
|
];
|
||||||
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
vim.maps.visualOnly = mkMerge [
|
|
||||||
(mkBinding cfg.mappings.toggleSelectedLine "<Plug>(comment_toggle_linewise_visual)" mappings.toggleSelectedLine.description)
|
|
||||||
(mkBinding cfg.mappings.toggleSelectedBlock "<Plug>(comment_toggle_blockwise_visual)" mappings.toggleSelectedBlock.description)
|
|
||||||
];
|
|
||||||
|
|
||||||
vim.pluginRC.comment-nvim = entryAnywhere ''
|
|
||||||
require('Comment').setup({
|
|
||||||
mappings = { basic = false, extra = false, },
|
|
||||||
})
|
|
||||||
'';
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue