2023-02-16 21:32:46 +01:00
|
|
|
{
|
2024-11-17 19:48:59 +01:00
|
|
|
options,
|
2023-02-16 21:32:46 +01:00
|
|
|
config,
|
|
|
|
lib,
|
|
|
|
...
|
2023-11-07 01:50:27 +01:00
|
|
|
}: let
|
2024-11-04 16:50:50 +01:00
|
|
|
inherit (lib.modules) mkIf;
|
2024-11-17 19:48:59 +01:00
|
|
|
inherit (lib.nvim.binds) mkKeymap;
|
2023-11-07 01:50:27 +01:00
|
|
|
|
2023-02-16 21:32:46 +01:00
|
|
|
cfg = config.vim.comments.comment-nvim;
|
2024-11-17 19:48:59 +01:00
|
|
|
inherit (options.vim.comments.comment-nvim) mappings;
|
2023-02-16 21:32:46 +01:00
|
|
|
in {
|
|
|
|
config = mkIf cfg.enable {
|
2024-11-04 16:50:50 +01:00
|
|
|
vim.lazy.plugins.comment-nvim = {
|
|
|
|
package = "comment-nvim";
|
|
|
|
setupModule = "Comment";
|
|
|
|
inherit (cfg) setupOpts;
|
|
|
|
keys = [
|
2024-11-17 19:48:59 +01:00
|
|
|
(mkKeymap ["n"] cfg.mappings.toggleOpLeaderLine "<Plug>(comment_toggle_linewise)" {desc = mappings.toggleOpLeaderLine.description;})
|
|
|
|
(mkKeymap ["n"] cfg.mappings.toggleOpLeaderBlock "<Plug>(comment_toggle_blockwise)" {desc = mappings.toggleOpLeaderBlock.description;})
|
|
|
|
(mkKeymap ["n"] cfg.mappings.toggleCurrentLine ''
|
2024-11-04 16:50:50 +01:00
|
|
|
function()
|
|
|
|
return vim.api.nvim_get_vvar('count') == 0 and '<Plug>(comment_toggle_linewise_current)'
|
|
|
|
or '<Plug>(comment_toggle_linewise_count)'
|
|
|
|
end
|
2024-11-17 19:48:59 +01:00
|
|
|
'' {
|
|
|
|
expr = true;
|
|
|
|
desc = mappings.toggleCurrentLine.description;
|
|
|
|
})
|
|
|
|
(mkKeymap ["n"] cfg.mappings.toggleCurrentBlock ''
|
2024-11-04 16:50:50 +01:00
|
|
|
function()
|
|
|
|
return vim.api.nvim_get_vvar('count') == 0 and '<Plug>(comment_toggle_blockwise_current)'
|
|
|
|
or '<Plug>(comment_toggle_blockwise_count)'
|
|
|
|
end
|
2024-11-17 19:48:59 +01:00
|
|
|
'' {
|
|
|
|
expr = true;
|
|
|
|
desc = mappings.toggleCurrentBlock.description;
|
|
|
|
})
|
|
|
|
(mkKeymap ["x"] cfg.mappings.toggleSelectedLine "<Plug>(comment_toggle_linewise_visual)" {desc = mappings.toggleSelectedLine.description;})
|
|
|
|
(mkKeymap ["x"] cfg.mappings.toggleSelectedBlock "<Plug>(comment_toggle_blockwise_visual)" {desc = mappings.toggleSelectedBlock.description;})
|
2024-11-04 16:50:50 +01:00
|
|
|
];
|
|
|
|
};
|
2023-02-16 21:32:46 +01:00
|
|
|
};
|
|
|
|
}
|