Open aktau opened 6 months ago
Try this
["]s"] = { query = "@local.scope", query_group = "locals", desc = "Next scope" },
That actually does something, which is much better than before!
It's not exactly what I want, for example with this C code I first move to the first letter of the if
, then to the first brace {
when I use ]s
. I would prefer just moving to the first brace:
int c = 3;
if (ptr == MAP_FAILED) {
/* 1 2 */
perror("mmap");
return 0;
}
But it's already a lot better than before. Thanks.
This happens because for statement, if statement, while statement, function definition, etc are also defined to make their own scope in https://github.com/nvim-treesitter/nvim-treesitter/blob/4770d9a1a77b0cc2b723c646c3dbe43a9133e5db/queries/c/locals.scm#L58-L67
The work around is to copy that file to ~/.config/nvim/queries/c/locals.scm
and then comment out the blocks you don't want to jump to.
So the query names in nvim-treesitter
seem to have been changed. I guess we need to update the README.
Describe the bug
Simply put, the ]s, [s, ]S, [S mappings do nothing for me (no movement), when attempting to navigate around simple C and Go files (haven't tried others yet). Mappings like ]m, [m, ]M, [M do work.
I'm not sure if this problem is PEBKAC or not, but having seen
locals.scm
for Go/C/..., I suspect it isn't. The README gives this example:But there is no movement (see below). I've verified that
nmap ]s
shows me an anonymous Lua function is bound.To Reproduce
Expected behavior
I expected some movement to happen.v
Output of
:checkhealth nvim-treesitter
Installation ~ - WARNING `tree-sitter` executable not found (parser generator, only needed for :TSInstallFromGrammar, not required for :TSInstall) - WARNING `node` executable not found (only needed for :TSInstallFromGrammar, not required for :TSInstall) - OK `git` executable found. - OK `cc` executable found. Selected from { vim.NIL, "cc", "gcc", "clang", "cl", "zig" } Version: cc (Debian 13.2.0-10) 13.2.0 - OK Neovim was compiled with tree-sitter runtime ABI version 14 (required >=13). Parsers must be compatible with runtime ABI. OS Info: { machine = "x86_64", release = "6.6.13-amd64", sysname = "Linux", version = "#1 SMP PREEMPT_DYNAMIC Debian 6.6.13" } ~ Parser/Features H L F I J - bash ✓ ✓ ✓ . ✓ - c ✓ ✓ ✓ ✓ ✓ - cpp ✓ ✓ ✓ ✓ ✓ - go ✓ ✓ ✓ ✓ ✓ - lua ✓ ✓ ✓ ✓ ✓ - markdown ✓ . ✓ ✓ ✓ - markdown_inline ✓ . . . ✓ - python ✓ ✓ ✓ ✓ ✓ - query ✓ ✓ ✓ ✓ ✓ - sql ✓ . . ✓ ✓ - starlark ✓ ✓ ✓ ✓ ✓ - 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