From 2f7dbf629f1c7ba9accf3fb650839f6e623f33b8 Mon Sep 17 00:00:00 2001 From: Nicolas Goudry Date: Sat, 8 Jun 2024 00:26:19 +0200 Subject: [PATCH] fix(plugins/treesitter): incremental selection keymaps set twice --- plugins/treesitter.nix | 22 ++++++++++++---------- plugins/which-key.nix | 1 + 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/plugins/treesitter.nix b/plugins/treesitter.nix index 030c22c..db99899 100644 --- a/plugins/treesitter.nix +++ b/plugins/treesitter.nix @@ -1,6 +1,6 @@ # homepage: https://github.com/nvim-treesitter/nvim-treesitter # nixvim doc: https://nix-community.github.io/nixvim/plugins/treesitter/index.html -_: +{ lib, ... }: { opts = { @@ -10,9 +10,13 @@ _: # Enable treesitter based indentation (use '=' to auto-indent) indent = true; - # Enable incremental selection - # Keymaps are defined as global nixvim keymaps - incrementalSelection.enable = true; + # Workaround to enable incremental selection without setting default keymaps (keymaps are set globally) + # This is needed in order to set custom descriptions and avoid to have multiple keymaps + # See https://github.com/nix-community/nixvim/issues/1506 + moduleConfig.incremental_selection = { + enable = true; + keymaps = lib.mkForce { }; + }; }; rootOpts = { @@ -33,31 +37,29 @@ _: action.__raw = "function() require('nvim-treesitter.textobjects.repeatable_move').repeat_last_move_opposite() end"; 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"; key = "ss"; action.__raw = "function() require('nvim-treesitter.incremental_selection').init_selection() end"; - options.desc = "Start incremental selection"; + options.desc = "Start"; } { mode = "v"; key = "sd"; action.__raw = "function() require('nvim-treesitter.incremental_selection').node_decremental() end"; - options.desc = "Decrement selection"; + options.desc = "Decrement"; } { mode = "v"; key = "si"; action.__raw = "function() require('nvim-treesitter.incremental_selection').node_incremental() end"; - options.desc = "Increment selection by node"; + options.desc = "Increment node"; } { mode = "v"; key = "sc"; action.__raw = "function() require('nvim-treesitter.incremental_selection').scope_incremental() end"; - options.desc = "Increment selection by scope"; + options.desc = "Increment scope"; } ]; diff --git a/plugins/which-key.nix b/plugins/which-key.nix index 937cad4..d715a5f 100644 --- a/plugins/which-key.nix +++ b/plugins/which-key.nix @@ -23,6 +23,7 @@ "f".name = "${icons.Search} Find"; "g".name = "${icons.Git} Git"; "l".name = "${icons.ActiveLSP} Language Tools"; + "s".name = " Incremental Selection"; "S".name = "${icons.Session} Session"; "t".name = "${icons.Terminal} Terminal"; "u".name = "${icons.Window} UI/UX";