fix(plugins/treesitter): incremental selection keymaps set twice

This commit is contained in:
Nicolas Goudry 2024-06-08 00:26:19 +02:00
parent ec180d7365
commit 2f7dbf629f
No known key found for this signature in database
GPG key ID: 5FC434D9FFD1DF44
2 changed files with 13 additions and 10 deletions

View file

@ -1,6 +1,6 @@
# homepage: https://github.com/nvim-treesitter/nvim-treesitter # homepage: https://github.com/nvim-treesitter/nvim-treesitter
# nixvim doc: https://nix-community.github.io/nixvim/plugins/treesitter/index.html # nixvim doc: https://nix-community.github.io/nixvim/plugins/treesitter/index.html
_: { lib, ... }:
{ {
opts = { opts = {
@ -10,9 +10,13 @@ _:
# Enable treesitter based indentation (use '=' to auto-indent) # Enable treesitter based indentation (use '=' to auto-indent)
indent = true; indent = true;
# Enable incremental selection # Workaround to enable incremental selection without setting default keymaps (keymaps are set globally)
# Keymaps are defined as global nixvim keymaps # This is needed in order to set custom descriptions and avoid to have multiple keymaps
incrementalSelection.enable = true; # See https://github.com/nix-community/nixvim/issues/1506
moduleConfig.incremental_selection = {
enable = true;
keymaps = lib.mkForce { };
};
}; };
rootOpts = { rootOpts = {
@ -33,31 +37,29 @@ _:
action.__raw = "function() require('nvim-treesitter.textobjects.repeatable_move').repeat_last_move_opposite() end"; action.__raw = "function() require('nvim-treesitter.textobjects.repeatable_move').repeat_last_move_opposite() end";
options.desc = "Repeat last move in the opposite direction"; options.desc = "Repeat last move in the opposite direction";
} }
# Workaround for setting descriptions to treesitter incremental selection keymaps
# See https://github.com/nix-community/nixvim/issues/1506
{ {
mode = "n"; mode = "n";
key = "<leader>ss"; key = "<leader>ss";
action.__raw = "function() require('nvim-treesitter.incremental_selection').init_selection() end"; action.__raw = "function() require('nvim-treesitter.incremental_selection').init_selection() end";
options.desc = "Start incremental selection"; options.desc = "Start";
} }
{ {
mode = "v"; mode = "v";
key = "<leader>sd"; key = "<leader>sd";
action.__raw = "function() require('nvim-treesitter.incremental_selection').node_decremental() end"; action.__raw = "function() require('nvim-treesitter.incremental_selection').node_decremental() end";
options.desc = "Decrement selection"; options.desc = "Decrement";
} }
{ {
mode = "v"; mode = "v";
key = "<leader>si"; key = "<leader>si";
action.__raw = "function() require('nvim-treesitter.incremental_selection').node_incremental() end"; action.__raw = "function() require('nvim-treesitter.incremental_selection').node_incremental() end";
options.desc = "Increment selection by node"; options.desc = "Increment node";
} }
{ {
mode = "v"; mode = "v";
key = "<leader>sc"; key = "<leader>sc";
action.__raw = "function() require('nvim-treesitter.incremental_selection').scope_incremental() end"; action.__raw = "function() require('nvim-treesitter.incremental_selection').scope_incremental() end";
options.desc = "Increment selection by scope"; options.desc = "Increment scope";
} }
]; ];

View file

@ -23,6 +23,7 @@
"<leader>f".name = "${icons.Search} Find"; "<leader>f".name = "${icons.Search} Find";
"<leader>g".name = "${icons.Git} Git"; "<leader>g".name = "${icons.Git} Git";
"<leader>l".name = "${icons.ActiveLSP} Language Tools"; "<leader>l".name = "${icons.ActiveLSP} Language Tools";
"<leader>s".name = " Incremental Selection";
"<leader>S".name = "${icons.Session} Session"; "<leader>S".name = "${icons.Session} Session";
"<leader>t".name = "${icons.Terminal} Terminal"; "<leader>t".name = "${icons.Terminal} Terminal";
"<leader>u".name = "${icons.Window} UI/UX"; "<leader>u".name = "${icons.Window} UI/UX";