mirror of
https://github.com/NotAShelf/nvf.git
synced 2024-11-01 11:01:15 +00: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
|
||||
inherit (lib.options) mkEnableOption;
|
||||
inherit (lib.nvim.binds) mkMappingOption;
|
||||
inherit (lib.nvim.types) mkPluginSetupOption;
|
||||
in {
|
||||
options.vim.comments.comment-nvim = {
|
||||
enable = mkEnableOption "smart and powerful comment plugin for neovim comment-nvim";
|
||||
|
@ -15,5 +16,12 @@ in {
|
|||
toggleSelectedLine = mkMappingOption "Toggle selected comment" "gc";
|
||||
toggleSelectedBlock = mkMappingOption "Toggle selected block" "gb";
|
||||
};
|
||||
|
||||
setupOpts = mkPluginSetupOption "Comment-nvim" {
|
||||
mappings = {
|
||||
basic = mkEnableOption "basic mappings";
|
||||
extra = mkEnableOption "extra mappings";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -3,9 +3,8 @@
|
|||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib.modules) mkIf mkMerge;
|
||||
inherit (lib.nvim.binds) mkExprBinding mkBinding;
|
||||
inherit (lib.nvim.dag) entryAnywhere;
|
||||
inherit (lib.modules) mkIf;
|
||||
inherit (lib.nvim.binds) mkLznExprBinding mkLznBinding;
|
||||
|
||||
cfg = config.vim.comments.comment-nvim;
|
||||
self = import ./comment-nvim.nix {inherit lib;};
|
||||
|
@ -16,35 +15,33 @@ in {
|
|||
"comment-nvim"
|
||||
];
|
||||
|
||||
vim.maps.normal = mkMerge [
|
||||
(mkBinding cfg.mappings.toggleOpLeaderLine "<Plug>(comment_toggle_linewise)" mappings.toggleOpLeaderLine.description)
|
||||
(mkBinding cfg.mappings.toggleOpLeaderBlock "<Plug>(comment_toggle_blockwise)" mappings.toggleOpLeaderBlock.description)
|
||||
vim.lazy.plugins = [
|
||||
{
|
||||
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()
|
||||
return vim.api.nvim_get_vvar('count') == 0 and '<Plug>(comment_toggle_linewise_current)'
|
||||
or '<Plug>(comment_toggle_linewise_count)'
|
||||
end
|
||||
''
|
||||
mappings.toggleCurrentLine.description)
|
||||
(mkExprBinding cfg.mappings.toggleCurrentBlock ''
|
||||
(mkLznExprBinding ["n"] cfg.mappings.toggleCurrentBlock ''
|
||||
function()
|
||||
return vim.api.nvim_get_vvar('count') == 0 and '<Plug>(comment_toggle_blockwise_current)'
|
||||
or '<Plug>(comment_toggle_blockwise_count)'
|
||||
end
|
||||
''
|
||||
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