Skip to content

Any way to make a hydra for Tree-sitter incremental selection? #59

Closed Answered by Hubro
Hubro asked this question in Q&A
Discussion options

You must be logged in to vote

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:

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

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Hubro
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant