Open tmbdev opened 2 weeks ago
You need to set the keymaps manually I believe, I use this:
-- Globally map Tree-sitter text object binds
local function textobj_map(key, query)
local outer = '@' .. query .. '.outer'
local inner = '@' .. query .. '.inner'
local opts = {
desc = 'Selection for ' .. query .. ' text objects',
silent = true,
}
map('x', 'i' .. key, function()
vim.cmd.TSTextobjectSelect(inner)
end, opts)
map('x', 'a' .. key, function()
vim.cmd.TSTextobjectSelect(outer)
end, opts)
map('o', 'i' .. key, function()
vim.cmd.TSTextobjectSelect(inner)
end, opts)
map('o', 'a' .. key, function()
vim.cmd.TSTextobjectSelect(outer)
end, opts)
end
textobj_map('f', 'call')
textobj_map('F', 'function')
-- ... etc.
Also I think the config should be of the form textobjects = { select = { enable = true} } -- Enable textobjects
Describe the bug vaf/vif not working in Lua code
To Reproduce
Expected behavior I expect the lines comprising the function to be selected. Instead, it just changes into visual mode
The following work, however:
Output of
:checkhealth nvim-treesitter
============================================================================== nvim-treesitter: require("nvim-treesitter.health").check() Installation ~ - OK `tree-sitter` found 0.23.0 (parser generator, only needed for :TSInstallFromGrammar) - OK `node` found v18.20.4 (only needed for :TSInstallFromGrammar) - OK `git` executable found. - OK `cc` executable found. Selected from { vim.NIL, "cc", "gcc", "clang", "cl", "zig" } Version: Apple clang version 15.0.0 (clang-1500.3.9.4) - OK Neovim was compiled with tree-sitter runtime ABI version 14 (required >=13). Parsers must be compatible with runtime ABI. OS Info: { machine = "arm64", release = "23.5.0", sysname = "Darwin", version = "Darwin Kernel Version 23.5.0: Wed May 1 20:12:58 PDT 2024; root:xnu-10063.121.3~5/RELEASE_ARM64_T6000" } ~ Parser/Features H L F I J - c ✓ ✓ ✓ ✓ ✓ - cpp ✓ ✓ ✓ ✓ ✓ - fortran ✓ . ✓ ✓ ✓ - go ✓ ✓ ✓ ✓ ✓ - haskell ✓ ✓ ✓ . ✓ - lua ✓ ✓ ✓ ✓ ✓ - markdown ✓ . ✓ ✓ ✓ - markdown_inline ✓ . . . ✓ - python ✓ ✓ ✓ ✓ ✓ - query ✓ ✓ ✓ ✓ ✓ - vim ✓ ✓ ✓ . ✓ - vimdoc ✓ . . . ✓ Legend: H[ighlight], L[ocals], F[olds], I[ndents], In[j]ections +) multiple parsers found, only one will be used x) errors found in the query, try to run :TSUpdate {lang} ~
Output of
nvim --version
Additional context I'm using this init.lua file with -u to isolate the problem, but I get the same problem with my full .lua file: