mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-15 09:50:04 -04:00
docs: add descriptions to incremental_selection keymaps
This commit is contained in:
parent
4e934673d8
commit
2282461416
1 changed files with 15 additions and 4 deletions
|
|
@ -120,6 +120,13 @@ function M.node_decremental()
|
||||||
ts_utils.update_selection(buf, node)
|
ts_utils.update_selection(buf, node)
|
||||||
end
|
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)
|
function M.attach(bufnr)
|
||||||
local config = configs.get_module "incremental_selection"
|
local config = configs.get_module "incremental_selection"
|
||||||
for funcname, mapping in pairs(config.keymaps) do
|
for funcname, mapping in pairs(config.keymaps) do
|
||||||
|
|
@ -129,8 +136,12 @@ function M.attach(bufnr)
|
||||||
else
|
else
|
||||||
mode = "x"
|
mode = "x"
|
||||||
end
|
end
|
||||||
local cmd = string.format(":lua require'nvim-treesitter.incremental_selection'.%s()<CR>", funcname)
|
vim.keymap.set(
|
||||||
api.nvim_buf_set_keymap(bufnr, mode, mapping, cmd, { silent = true, noremap = true })
|
mode,
|
||||||
|
mapping,
|
||||||
|
M[funcname],
|
||||||
|
{ buffer = bufnr, silent = true, noremap = true, desc = FUNCTION_DESCRIPTIONS[funcname] }
|
||||||
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -138,9 +149,9 @@ function M.detach(bufnr)
|
||||||
local config = configs.get_module "incremental_selection"
|
local config = configs.get_module "incremental_selection"
|
||||||
for f, mapping in pairs(config.keymaps) do
|
for f, mapping in pairs(config.keymaps) do
|
||||||
if f == "init_selection" then
|
if f == "init_selection" then
|
||||||
api.nvim_buf_del_keymap(bufnr, "n", mapping)
|
vim.keymap.del("n", mapping, { buffer = bufnr })
|
||||||
else
|
else
|
||||||
api.nvim_buf_del_keymap(bufnr, "x", mapping)
|
vim.keymap.del("x", mapping, { buffer = bufnr })
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue