aboutsummaryrefslogtreecommitdiffstats
path: root/lua
diff options
context:
space:
mode:
authorStephan Seitz <stephan.seitz@fau.de>2022-07-31 16:42:29 +0200
committerChristian Clason <christian.clason@uni-due.de>2022-07-31 17:33:41 +0200
commit22824614163c54ef5d366b15c8685e24d33763db (patch)
tree371269ca50bdeeb0ad12ddc786ed20f9a606559f /lua
parentUpdate lockfile.json (diff)
downloadnvim-treesitter-22824614163c54ef5d366b15c8685e24d33763db.tar
nvim-treesitter-22824614163c54ef5d366b15c8685e24d33763db.tar.gz
nvim-treesitter-22824614163c54ef5d366b15c8685e24d33763db.tar.bz2
nvim-treesitter-22824614163c54ef5d366b15c8685e24d33763db.tar.lz
nvim-treesitter-22824614163c54ef5d366b15c8685e24d33763db.tar.xz
nvim-treesitter-22824614163c54ef5d366b15c8685e24d33763db.tar.zst
nvim-treesitter-22824614163c54ef5d366b15c8685e24d33763db.zip
docs: add descriptions to incremental_selection keymaps
Diffstat (limited to 'lua')
-rw-r--r--lua/nvim-treesitter/incremental_selection.lua19
1 files changed, 15 insertions, 4 deletions
diff --git a/lua/nvim-treesitter/incremental_selection.lua b/lua/nvim-treesitter/incremental_selection.lua
index 857f4a482..1bacd07f8 100644
--- a/lua/nvim-treesitter/incremental_selection.lua
+++ b/lua/nvim-treesitter/incremental_selection.lua
@@ -120,6 +120,13 @@ function M.node_decremental()
ts_utils.update_selection(buf, node)
end
+local FUNCTION_DESCRIPTIONS = {
+ init_selection = "Start selecting nodes with nvim-treesitter",
+ node_incremental = "Increment selection to named node",
+ scope_incremental = "Increment selection to surrounding scope",
+ node_decremental = "Shrink selection to previous named node",
+}
+
function M.attach(bufnr)
local config = configs.get_module "incremental_selection"
for funcname, mapping in pairs(config.keymaps) do
@@ -129,8 +136,12 @@ function M.attach(bufnr)
else
mode = "x"
end
- local cmd = string.format(":lua require'nvim-treesitter.incremental_selection'.%s()<CR>", funcname)
- api.nvim_buf_set_keymap(bufnr, mode, mapping, cmd, { silent = true, noremap = true })
+ vim.keymap.set(
+ mode,
+ mapping,
+ M[funcname],
+ { buffer = bufnr, silent = true, noremap = true, desc = FUNCTION_DESCRIPTIONS[funcname] }
+ )
end
end
@@ -138,9 +149,9 @@ function M.detach(bufnr)
local config = configs.get_module "incremental_selection"
for f, mapping in pairs(config.keymaps) do
if f == "init_selection" then
- api.nvim_buf_del_keymap(bufnr, "n", mapping)
+ vim.keymap.del("n", mapping, { buffer = bufnr })
else
- api.nvim_buf_del_keymap(bufnr, "x", mapping)
+ vim.keymap.del("x", mapping, { buffer = bufnr })
end
end
end