nixvim
nixvim copied to clipboard
Allow to set descriptions to treesitter incremental selection keymaps
| Field | Description |
|---|---|
| Plugin | treesitter |
| Nixpkgs | unstable |
- [x] I have read the FAQ and my bug is not listed there.
Description
The incrementalSelection.keymaps option is an attribute set of plain strings, preventing to set a desc label to those keymaps. AFAIK, most of the other plugins (as well as the root level keymaps attribute) allow to set additional information about a keymap. Hence it would be really great to have this also for the treesitter plugin :slightly_smiling_face:
I would be willing to implement this myself if nobody else wishes to add support, but am not sure when/if I’ll have any bandwidth to do so. Also, I don’t have a very deep knowledge of nixvim (yet).
EDIT: sorry about the wrong label, it’s not a bug. I used the bug template by mistake.
After taking a better look at nvim-treesitter project, it seems that setting the keymap description is not supported on their side. I’m not a lua expert, neither have I a deep knowledge of nvim-treesitter, so I may be wrong.
Until someone better suited than me can confirm this fact, and in case someone else wants to set a description to these keymaps, here is how I deal with this lack of support in my config:
{
plugins.treesitter.enable = true;
plugins.treesitter.incrementalSelection.enable = true;
keymaps = [
{
mode = "n";
key = "<leader>ss";
action = "function() require('nvim-treesitter.incremental_selection').init_selection() end";
lua = true;
options.desc = "[S]tart [S]election";
}
{
mode = "v";
key = "<leader>sd";
action = "function() require('nvim-treesitter.incremental_selection').node_decremental() end";
lua = true;
options.desc = "[S]election [D]ecrement";
}
{
mode = "v";
key = "<leader>si";
action = "function() require('nvim-treesitter.incremental_selection').node_incremental() end";
lua = true;
options.desc = "[S]election [I]ncrement";
}
{
mode = "v";
key = "<leader>sc";
action = "function() require('nvim-treesitter.incremental_selection').scope_incremental() end";
lua = true;
options.desc = "[S]elect S[C]ope";
}
];
}
Hey !
Thanks for the detailed description and sorry for the delay.
Indeed, we cannot do much here because we stick to the options exposed by the plugin.
Here, the incremental_selection.keymaps options are plain strings.
The solution is indeed to add the mappings yourself, or maybe to register the descriptions within the which-key plugin configuration (but I am not too familiar with that).
I will thus close this issue as it does not expect a fix per say. Please, feel free to re-open it if needed.