-
I have Tree-sitter incremental selection mapped to I want to initialize selection on Here's where I'm at: hydra({
name = "Tree-sitter incremental selection",
mode = { "n", "v", "x" },
body = "<Leader>",
heads = {
{ "j", "<M-8>", { desc = "Decrease selection", mode = "x", } },
{ "k", "<M-9>", { desc = "Increase selection", mode = "x", } },
{ "k", "<M-9>", { desc = "Initiate selection", mode = "n", } },
},
config = {
desc = "Tree-sitter incremental selection",
}
}) It doesn't do anything, when I press If I change Any idea how to make this work? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
After perusing the source code of nvim-treesitter, I found the underlying functions for my local ts_select = require("nvim-treesitter.incremental_selection")
local ts_select_hydra = hydra({
name = "Tree-sitter incremental selection",
mode = "x",
heads = {
{ "j", ts_select.node_decremental, { desc = "Decrease selection", mode = "x", } },
{ "k", ts_select.node_incremental, { desc = "Increase selection", mode = "x", } },
{ "<Esc>", "<Esc>", { desc = "Exit", mode = "x", exit_before = true } },
},
config = {
desc = "Tree-sitter incremental selection",
}
})
vim.keymap.set({ "n", "x" }, "<Leader>k", function()
ts_select.init_selection()
ts_select_hydra:activate()
end, { desc = "Tree-sitter incremental selection" }) Maybe this is possible to achieve without a separate keybind for activating the hydra, but I couldn't figure that out. |
Beta Was this translation helpful? Give feedback.
After perusing the source code of nvim-treesitter, I found the underlying functions for my
<M-8>
/<M-9>
keybinds. After a bit of experimentation I got it working: