nvim-treesitter / nvim-treesitter-textobjects Goto Github PK
View Code? Open in Web Editor NEWLicense: Apache License 2.0
License: Apache License 2.0
I assume this is a bug in this extension rather than vim-commentary
, but I don't know that. Please close if it is not.
Commenting in and out code is a PERFECT use of this extension, I hope it can be made to work.
Describe the bug
Using https://github.com/tpope/vim-commentary I can comment out a class or a function with gcac gcaf
but when I repeat the command it does not uncomment it. This is the expected behaviour of vim-commentary
.
To Reproduce
Try it with vim-commentary on any TypeScript file.
Output of :checkhealth nvim_treesitter
tree-sitter
executable not found (parser generator, only needed for :TSInstallFromGrammar, not required for :TSInstall)node
found v14.16.0 (only needed for :TSInstallFromGrammar)git
executable found.cc
executable found. Selected from { vim.NIL, "cc", "gcc", "clang", "cl" }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}
Paste the output here
Output of nvim --version
NVIM v0.5.0
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3
Compilation: /usr/bin/gcc-11 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DNVIM_TS_HAS_SET_MATCH_LIMIT -O2 -g -Og -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=always -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/home/runner/work/neovim/neovim/build/config -I/home/runner/work/neovim/neovim/src -I/home/runner/work/neovim/neovim/.deps/usr/include -I/usr/include -I/home/runner/work/neovim/neovim/build/src/nvim/auto -I/home/runner/work/neovim/neovim/build/include
Compiled by runner@fv-az242-526
Features: +acl +iconv +tui
See ":help feature-compile"
system vimrc file: "$VIM/sysinit.vim"
fall-back for $VIM: "
/home/runner/work/neovim/neovim/build/nvim.AppDir/usr/share/nvim"
Run :checkhealth for more info
I want to create a custom textobject for c
and cpp
which will select all the statements inside function body excluding function parenthesis. I have added the below query search to textobjects.scm
, but nvim-treesitter query seach does not work as expected. I am facing similar issue with nvim-treesitter/playground
as well.
(function_definition
body: (compound_statement
("{" (_)* @function.inner . "}"))?) @function.outer
Steps to reproduce the behavior:
foo.c
foo.c
int foo(int x) {
int a = 3;
int b = 4;
return x + 1;
}
nvim-treesitter/playground
(function_definition
body: (compound_statement
("{" (_)* @function.inner . "}"))?) @function.outer
@function.inner
incorrectly highlights only the last statement inside function parenthesis.
whereas @function.inner
should highlight all the statements inside parenthesis.
Output of :checkhealth nvim_treesitter
health#nvim_treesitter#check
Installation
- OK:
tree-sitter
found 0.20.0 (parser generator, only needed for :TSInstallFromGrammar)
- OK:
node
found v16.6.1 (only needed for :TSInstallFromGrammar)
- OK:
git
executable found.
- OK:
cc
executable found. Selected from { vim.NIL, "cc", "gcc", "clang", "cl" }
- OK: Neovim was compiled with tree-sitter runtime ABI version 13 (required >=13). Parsers must be compatible with runtime ABI.
Parser/Features H L F I J
- ocaml_interface✓ ✓ ✓ . ✓
- beancount ✓ . ✓ . .
- python ✓ ✓ ✓ ✓ ✓
- sparql ✓ ✓ ✓ ✓ ✓
- comment ✓ . . . .
- lua ✓ ✓ ✓ ✓ ✓
- ocaml ✓ ✓ ✓ . ✓
- go ✓ ✓ ✓ ✓ ✓
- ql ✓ ✓ . ✓ ✓
- json ✓ ✓ ✓ ✓ .
- jsdoc ✓ . . . .
- ledger ✓ . ✓ ✓ ✓
- php ✓ ✓ ✓ ✓ ✓
- clojure ✓ ✓ ✓ . ✓
- supercollider ✓ ✓ ✓ ✓ ✓
- heex ✓ . ✓ ✓ ✓
- typescript ✓ ✓ ✓ ✓ ✓
- fennel ✓ ✓ . . ✓
- query ✓ ✓ ✓ ✓ ✓
- cpp ✓ ✓ ✓ ✓ ✓
- vue ✓ . ✓ . ✓
- latex ✓ . ✓ . ✓
- rst ✓ ✓ . . ✓
- css ✓ . ✓ ✓ ✓
- glimmer ✓ . . . .
- erlang . . . . .
- regex ✓ . . . .
- svelte ✓ . ✓ ✓ ✓
- c ✓ ✓ ✓ ✓ ✓
- fortran ✓ . ✓ ✓ .
- teal ✓ ✓ ✓ ✓ ✓
- java ✓ ✓ . ✓ ✓
- gomod ✓ . . . .
- dart ✓ ✓ . ✓ ✓
- verilog ✓ ✓ ✓ . ✓
- bash ✓ ✓ ✓ . ✓
- yaml ✓ ✓ ✓ ✓ ✓
- julia ✓ ✓ ✓ ✓ ✓
- vim ✓ . . . ✓
- cmake ✓ . ✓ . .
- turtle ✓ ✓ ✓ ✓ ✓
- zig ✓ . ✓ ✓ ✓
- html ✓ ✓ ✓ ✓ ✓
- bibtex ✓ . ✓ ✓ .
- r ✓ ✓ . . .
- tsx ✓ ✓ ✓ ✓ ✓
- yang ✓ . ✓ . .
- javascript ✓ ✓ ✓ ✓ ✓
- surface ✓ . ✓ ✓ ✓
- godotResource ✓ ✓ ✓ . .
- c_sharp ✓ ✓ ✓ . ✓
- commonlisp ✓ ✓ ✓ . .
- gdscript ✓ ✓ . . ✓
- elixir ✓ ✓ ✓ ✓ ✓
- cuda ✓ ✓ ✓ ✓ ✓
- haskell ✓ . . . ✓
- ocamllex ✓ . . . ✓
- kotlin ✓ . . . ✓
- ruby ✓ ✓ ✓ ✓ ✓
- fish ✓ ✓ ✓ ✓ ✓
- devicetree ✓ ✓ ✓ ✓ ✓
- scala . . . . .
- dockerfile ✓ . . . ✓
- rust ✓ ✓ ✓ ✓ ✓
- swift . . . . .
- toml ✓ ✓ ✓ ✓ ✓
- tlaplus ✓ . ✓ . ✓
- elm . . . . .
- jsonc ✓ ✓ ✓ ✓ ✓
- graphql ✓ . . ✓ ✓
- nix ✓ ✓ ✓ . ✓
- scss ✓ . . ✓ .
- hcl ✓ . ✓ ✓ ✓
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
NVIM v0.5.0
Build type: Release
LuaJIT 2.0.5
Compilation: /usr/bin/cc -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -fexceptions -Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -fstack-clash-protection -fcf-protection -Wp,-U_FORTIFY_SOURCE -Wp,-D_FORTIFY_SOURCE=1
-DNVIM_TS_HAS_SET_MATCH_LIMIT -O2 -DNDEBUG -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=always -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/build/neovim/src/neovim-0.5.0/build/config -I/build/neovim/src/neovim-0.5.0/src -I/usr/include -I/build/neovim/src/neovim-0.5.0/build/src/nvim/auto -I/build/neovim/src/neovim-0.5.0/build/include
Compiled by builduser
Features: +acl +iconv +tui
See ":help feature-compile"
system vimrc file: "$VIM/sysinit.vim"
fall-back for $VIM: "/usr/share/nvim"
Run :checkhealth for more info
I have also tested this on neovim nightly 0.6.0+dev+43+g02bf251bb-1
. I am facing the same issue.
Currently we have normal mappings only. ts_utils.goto_node
needs to be adapted to support visual mode also.
Describe the bug
If the first or last element of a Python class or function is a comment, then targeting it as a text object (with @class.outer
, @function.inner
, etc.) won't include the comment.
This isn't a real problem for me, just a curious edge case I noticed. If fixing this over-complicates other parts of the code or parser, feel free to disregard this and close, but on the off-chance there is a simple fix I'm missing, I thought I would be reporting it.
To Reproduce
With
treesitter.setup {
textobjects = {
select = {
enable = true,
keymaps = {
["ac"] = "@class.outer",
},
},
},
}
and the Python snippet
class A:
x = 1
y = 2 # some comment
with the cursor anywhere on or before the character 2
, then typing vac
will select everything except the comment. If the cursor is on the comment, then typing vac
won't do anything.
Expected behavior
With the cursor anywhere in the class, typing vac
selects the whole class.
Output of :checkhealth nvim_treesitter
health#nvim_treesitter#check
Installation
- OK:
git
executable found.
- OK:
cc
executable found.
elm parser healthcheck
- OK: elm parser found.
- WARNING: No
highlights.scm
query found for elm
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
- WARNING: No
locals.scm
query found for elm
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
- WARNING: No
textobjects.scm
query found for elm
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
- WARNING: No
folds.scm
query found for elm
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
c parser healthcheck
- OK: c parser found.
- OK:
highlights.scm
found.
- OK:
locals.scm
found.
- OK:
textobjects.scm
found.
- OK:
folds.scm
found.
java parser healthcheck
- OK: java parser found.
- OK:
highlights.scm
found.
- OK:
locals.scm
found.
- WARNING: No
textobjects.scm
query found for java
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
- WARNING: No
folds.scm
query found for java
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
python parser healthcheck
- OK: python parser found.
- OK:
highlights.scm
found.
- OK:
locals.scm
found.
- OK:
textobjects.scm
found.
- OK:
folds.scm
found.
dart parser healthcheck
- OK: dart parser found.
- OK:
highlights.scm
found.
- OK:
locals.scm
found.
- WARNING: No
textobjects.scm
query found for dart
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
- WARNING: No
folds.scm
query found for dart
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
lua parser healthcheck
- OK: lua parser found.
- OK:
highlights.scm
found.
- OK:
locals.scm
found.
- OK:
textobjects.scm
found.
- OK:
folds.scm
found.
ocaml parser healthcheck
- OK: ocaml parser found.
- OK:
highlights.scm
found.
- OK:
locals.scm
found.
- WARNING: No
textobjects.scm
query found for ocaml
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
- OK:
folds.scm
found.
go parser healthcheck
- OK: go parser found.
- OK:
highlights.scm
found.
- OK:
locals.scm
found.
- OK:
textobjects.scm
found.
- WARNING: No
folds.scm
query found for go
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
nix parser healthcheck
- OK: nix parser found.
- WARNING: No
highlights.scm
query found for nix
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
- WARNING: No
locals.scm
query found for nix
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
- WARNING: No
textobjects.scm
query found for nix
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
- WARNING: No
folds.scm
query found for nix
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
yaml parser healthcheck
- OK: yaml parser found.
- WARNING: No
highlights.scm
query found for yaml
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
- WARNING: No
locals.scm
query found for yaml
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
- WARNING: No
textobjects.scm
query found for yaml
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
- WARNING: No
folds.scm
query found for yaml
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
json parser healthcheck
- OK: json parser found.
- OK:
highlights.scm
found.
- WARNING: No
locals.scm
query found for json
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
- WARNING: No
textobjects.scm
query found for json
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
- WARNING: No
folds.scm
query found for json
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
jsdoc parser healthcheck
- OK: jsdoc parser found.
- WARNING: No
highlights.scm
query found for jsdoc
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
- WARNING: No
locals.scm
query found for jsdoc
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
- WARNING: No
textobjects.scm
query found for jsdoc
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
- WARNING: No
folds.scm
query found for jsdoc
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
markdown parser healthcheck
- OK: markdown parser found.
- WARNING: No
highlights.scm
query found for markdown
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
- WARNING: No
locals.scm
query found for markdown
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
- WARNING: No
textobjects.scm
query found for markdown
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
- WARNING: No
folds.scm
query found for markdown
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
julia parser healthcheck
- OK: julia parser found.
- WARNING: No
highlights.scm
query found for julia
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
- WARNING: No
locals.scm
query found for julia
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
- WARNING: No
textobjects.scm
query found for julia
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
- WARNING: No
folds.scm
query found for julia
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
html parser healthcheck
- OK: html parser found.
- OK:
highlights.scm
found.
- OK:
locals.scm
found.
- WARNING: No
textobjects.scm
query found for html
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
- WARNING: No
folds.scm
query found for html
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
typescript parser healthcheck
- OK: typescript parser found.
- OK:
highlights.scm
found.
- OK:
locals.scm
found.
- OK:
textobjects.scm
found.
- OK:
folds.scm
found.
fennel parser healthcheck
- OK: fennel parser found.
- OK:
highlights.scm
found.
- OK:
locals.scm
found.
- WARNING: No
textobjects.scm
query found for fennel
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
- WARNING: No
folds.scm
query found for fennel
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
swift parser healthcheck
- OK: swift parser found.
- WARNING: No
highlights.scm
query found for swift
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
- WARNING: No
locals.scm
query found for swift
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
- WARNING: No
textobjects.scm
query found for swift
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
- WARNING: No
folds.scm
query found for swift
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
query parser healthcheck
- OK: query parser found.
- OK:
highlights.scm
found.
- OK:
locals.scm
found.
- WARNING: No
textobjects.scm
query found for query
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
- WARNING: No
folds.scm
query found for query
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
cpp parser healthcheck
- OK: cpp parser found.
- OK:
highlights.scm
found.
- OK:
locals.scm
found.
- OK:
textobjects.scm
found.
- OK:
folds.scm
found.
regex parser healthcheck
- OK: regex parser found.
- OK:
highlights.scm
found.
- WARNING: No
locals.scm
query found for regex
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
- WARNING: No
textobjects.scm
query found for regex
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
- WARNING: No
folds.scm
query found for regex
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
ruby parser healthcheck
- OK: ruby parser found.
- OK:
highlights.scm
found.
- OK:
locals.scm
found.
- WARNING: No
textobjects.scm
query found for ruby
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
- WARNING: No
folds.scm
query found for ruby
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
vue parser healthcheck
- OK: vue parser found.
- WARNING: No
highlights.scm
query found for vue
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
- WARNING: No
locals.scm
query found for vue
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
- WARNING: No
textobjects.scm
query found for vue
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
- WARNING: No
folds.scm
query found for vue
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
ql parser healthcheck
- OK: ql parser found.
- OK:
highlights.scm
found.
- OK:
locals.scm
found.
- WARNING: No
textobjects.scm
query found for ql
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
- WARNING: No
folds.scm
query found for ql
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
scala parser healthcheck
- OK: scala parser found.
- WARNING: No
highlights.scm
query found for scala
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
- WARNING: No
locals.scm
query found for scala
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
- WARNING: No
textobjects.scm
query found for scala
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
- WARNING: No
folds.scm
query found for scala
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
toml parser healthcheck
- OK: toml parser found.
- OK:
highlights.scm
found.
- OK:
locals.scm
found.
- WARNING: No
textobjects.scm
query found for toml
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
- WARNING: No
folds.scm
query found for toml
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
rust parser healthcheck
- OK: rust parser found.
- OK:
highlights.scm
found.
- OK:
locals.scm
found.
- OK:
textobjects.scm
found.
- WARNING: No
folds.scm
query found for rust
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
bash parser healthcheck
- OK: bash parser found.
- OK:
highlights.scm
found.
- OK:
locals.scm
found.
- WARNING: No
textobjects.scm
query found for bash
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
- WARNING: No
folds.scm
query found for bash
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
ocaml_interface parser healthcheck
- OK: ocaml_interface parser found.
- OK:
highlights.scm
found.
- OK:
locals.scm
found.
- WARNING: No
textobjects.scm
query found for ocaml_interface
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
- OK:
folds.scm
found.
rst parser healthcheck
- OK: rst parser found.
- OK:
highlights.scm
found.
- OK:
locals.scm
found.
- OK:
textobjects.scm
found.
- WARNING: No
folds.scm
query found for rst
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
css parser healthcheck
- OK: css parser found.
- OK:
highlights.scm
found.
- WARNING: No
locals.scm
query found for css
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
- WARNING: No
textobjects.scm
query found for css
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
- WARNING: No
folds.scm
query found for css
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
c_sharp parser healthcheck
- OK: c_sharp parser found.
- OK:
highlights.scm
found.
- WARNING: No
locals.scm
query found for c_sharp
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
- OK:
textobjects.scm
found.
- WARNING: No
folds.scm
query found for c_sharp
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
javascript parser healthcheck
- OK: javascript parser found.
- OK:
highlights.scm
found.
- OK:
locals.scm
found.
- OK:
textobjects.scm
found.
- OK:
folds.scm
found.
php parser healthcheck
- OK: php parser found.
- OK:
highlights.scm
found.
- OK:
locals.scm
found.
- WARNING: No
textobjects.scm
query found for php
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
- OK:
folds.scm
found.
haskell parser healthcheck
- OK: haskell parser found.
- WARNING: No
highlights.scm
query found for haskell
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
- WARNING: No
locals.scm
query found for haskell
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
- WARNING: No
textobjects.scm
query found for haskell
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
- WARNING: No
folds.scm
query found for haskell
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
tsx parser healthcheck
- OK: tsx parser found.
- OK:
highlights.scm
found.
- OK:
locals.scm
found.
- OK:
textobjects.scm
found.
- OK:
folds.scm
found.
Output of nvim --version
NVIM v0.5.0-721-g3c5141d2c
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3
Compilation: /usr/bin/gcc-5 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -O2 -g -Og -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/home/travis/build/neovim/bot-ci/build/neovim/build/config -I/home/travis/build/neovim/bot-ci/build/neovim/src -I/home/travis/build/neovim/bot-ci/build/neovim/.deps/usr/include -I/usr/include -I/home/travis/build/neovim/bot-ci/build/neovim/build/src/nvim/auto -I/home/travis/build/neovim/bot-ci/build/neovim/build/include
Compiled by travis@travis-job-5482189d-7ef7-4d79-892c-6d7ec9adbd1f
Features: +acl +iconv +tui
See ":help feature-compile"
system vimrc file: "$VIM/sysinit.vim"
fall-back for $VIM: "
/home/travis/build/neovim/bot-ci/build/neovim/build/nvim.AppDir/usr/share/nvim
"
Run :checkhealth for more info
Like this but with treesitter support.
Is your feature request related to a problem? Please describe.
A lot of the time when defining selections and movements, I run into conflicts with default vim bindings or other plugins. Debugging such situations is pretty tough, since the current way of configuring bindings (via the map) is opaque.
Describe the solution you'd like
Instead of creating bindings via the map, perhaps there's a way to expose the motions as commands, or some other format, where the user can assign them to bindings through a more standard mechanism, like nvim_set_keymap
. For example, https://github.com/neovim/nvim-lspconfig defines a bunch of functions and asks users to create bindings via something like:
buf_set_keymap("n", "<leader>t", [[<Cmd>lua vim.lsp.buf.hover()<CR>]], opts)
I think this is pretty straightforward for things like "move" commands, but I'm not sure whether it will work for things like "select".
In ruby you have blocks that can look like the following:
foo.each do |item|
item
end
foo.each { |item| item }
@block.outer
in the first case would cover do..end
including the do
and end
and would cover the brackets and everything inside the brackets in the second. (Note in the second example the brackets dont have to be on the same line)
If you were to do a visual selection of the outer and then cancel, your cursor would be moved to the very end of the block(makes sense since this is how other text objects work like word). Your cursor would be on the d
in end
in the first example and }
in the second.
If you then went to select @block.inner
you jump to the next instance rather than doing the inner of the outer your cursor is on
If this isnt possible, feel free to close. Appreciate your work on this project!
.
Features like #150 and #125 would benefit from being per-mapping/objects instead of global options.
Our current settings look like this
keymaps = {
["af"] = "@function.outer",
["if"] = "@function.inner",
["ac"] = "@class.outer",
["ic"] = "@class.inner",
}
We could extend them to something like
-- Global options are defined here
-- lookahead = true,
keymaps = {
["af"] = {
textobject = "@function.outer",
-- If these options aren't given the global/default ones
-- are used.
lookahead = true,
auto_expand = true,
},
-- This form is valid, and it uses the global options.
["if"] = "@function.inner"
}
Describe the bug
When trying to navigate a Python file using the goto_next_start
action, @function.outer
jumps to the next class definition rather than to the next method within a class
To Reproduce
require'nvim-treesitter.configs'.setup {
ensure_installed = "maintained",
textobjects = {
move = {
enable = true,
keymaps = {
goto_next_start = {
["]]"] = "@function.outer"
},
},
},
},
}
# my_module.py
import os
class MyModuleClass:
"""My module"""
def method_1(self):
...
def method_2(self):
...
class MySecondModuleClass:
...
import
in normal mode, enter the keymap ]]
class MyModuleClass
]]
againclass MySecondModuleClass
]]
againclass MySecondModuleClass
definition (...
)If the cursor is anywhere within MyModuleClass
, entering ]]
also moves the cursor to MySecondModuleClass
Expected behavior
Given 1-3 from above remain the same:
4. Cursor lands on the 'd' in def method_1(self)
5. Enter keymap ]]
again
6. Cursor lands on the 'd' in def method_2(self)
Output of :checkhealth nvim_treesitter
health#nvim_treesitter#check
Installation
- OK:
tree-sitter
found 0.20.0 (parser generator, only needed for :TSInstallFromGrammar)
- OK:
node
found v12.22.3 (only needed for :TSInstallFromGrammar)
- OK:
git
executable found.
- OK:
cc
executable found. Selected from { vim.NIL, "cc", "gcc", "clang", "cl" }
- OK: Neovim was compiled with tree-sitter runtime ABI version 13 (required >=13). Parsers must be compatible with runtime ABI.
Parser/Features H L F I J
- javascript ✓ ✓ ✓ ✓ ✓
- ocaml ✓ ✓ ✓ . ✓
- ocaml_interface✓ ✓ ✓ . ✓
- ocamllex ✓ . . . ✓
- c_sharp ✓ . ✓ . ✓
- vue ✓ . ✓ . ✓
- yaml ✓ ✓ ✓ ✓ ✓
- html ✓ ✓ ✓ ✓ ✓
- lua ✓ ✓ ✓ ✓ ✓
- tsx ✓ ✓ ✓ ✓ ✓
- css ✓ . ✓ ✓ ✓
- supercollider ✓ ✓ ✓ ✓ ✓
- hcl ✓ . ✓ . ✓
- c ✓ ✓ ✓ ✓ ✓
- toml ✓ ✓ ✓ ✓ ✓
- glimmer ✓ . . . .
- jsonc ✓ ✓ ✓ ✓ ✓
- yang ✓ . ✓ . .
- nix ✓ ✓ ✓ . ✓
- dart ✓ ✓ . ✓ ✓
- rst ✓ ✓ . . ✓
- fennel ✓ ✓ . . ✓
- teal ✓ ✓ ✓ ✓ ✓
- typescript ✓ ✓ ✓ ✓ ✓
- clojure ✓ ✓ ✓ . ✓
- regex ✓ . . . .
- commonlisp ✓ ✓ ✓ . .
- cpp ✓ ✓ ✓ ✓ ✓
- comment ✓ . . . .
- cuda ✓ ✓ ✓ ✓ ✓
- dockerfile ✓ . . . ✓
- sparql ✓ ✓ ✓ ✓ ✓
- rust ✓ ✓ ✓ ✓ ✓
- ledger ✓ . ✓ ✓ ✓
- r ✓ ✓ . . .
- python ✓ ✓ ✓ ✓ ✓
- devicetree ✓ ✓ ✓ ✓ ✓
- gomod ✓ . . . .
- svelte ✓ . ✓ ✓ ✓
- ruby ✓ ✓ ✓ ✓ ✓
- beancount ✓ . ✓ . .
- bash ✓ ✓ ✓ . ✓
- latex ✓ . ✓ . ✓
- fish ✓ ✓ ✓ ✓ ✓
- php ✓ ✓ ✓ ✓ ✓
- java ✓ ✓ . ✓ ✓
- kotlin ✓ . . . ✓
- cmake ✓ . ✓ . .
- zig ✓ ✓ ✓ ✓ ✓
- bibtex ✓ . ✓ ✓ .
- julia ✓ ✓ ✓ ✓ ✓
- json ✓ ✓ ✓ ✓ .
- turtle ✓ ✓ ✓ ✓ ✓
- go ✓ ✓ ✓ ✓ ✓
- jsdoc ✓ . . . .
- scss ✓ . . ✓ .
- ql ✓ ✓ . ✓ ✓
- verilog ✓ ✓ ✓ . ✓
- erlang . . . . .
- query ✓ ✓ ✓ ✓ ✓
- gdscript ✓ ✓ . . ✓
- elixir ✓ ✓ ✓ ✓ ✓
- graphql ✓ . . ✓ ✓
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
NVIM v0.5.0
Build type: Release
LuaJIT 2.1.0-beta3
Compilation: gcc-5 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DNVIM_TS_HAS_SET_MATCH_LIMIT -O2 -DNDEBUG -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/tmp/neovim-20210704-5099-1dv0lhc/neovim-0.5.0/build/config -I/tmp/neovim-20210704-5099-1dv0lhc/neovim-0.5.0/src -I/home/linuxbrew/.linuxbrew/include -I/usr/include -I/tmp/neovim-20210704-5099-1dv0lhc/neovim-0.5.0/build/src/nvim/auto -I/tmp/neovim-20210704-5099-1dv0lhc/neovim-0.5.0/build/include
Compiled by linuxbrew@e4b9819dd4f3
Features: +acl +iconv +tui
See ":help feature-compile"
system vimrc file: "$VIM/sysinit.vim"
fall-back for $VIM: "home/linuxbrew/.linuxbrew/Cellar/neovim/0.5.0/share/nvim"
Run :checkhealth for more info
For example, in jsx, the each attribute of element are split by <space>
.
But Treesitter doesn't include the separator(space).
When I delete this textobj(test={true}
), the `' before is still there.
This is correct, but it is inconvenient.
Then I need to delete that space manually.
So, is there any to target the attribute
, but also include the space(one or more) before?
and here's my config now.
; jsx attributes
(jsx_self_closing_element attribute: (_) @attribute.outer)
(jsx_element open_tag: (_ attribute: (_) @attribute.outer))
(Thanks for the plugin: it is a snap to set up and easy to work with so far.)
I was surprised to see that by default, an inner function object in, for example, Go and Javascript includes the braces. I'm guessing that this is expected behavior and probably a result of how treesitter itself works. But I wanted to confirm that before going further.
I ask because my most common use for inner function objects is that I want to change, delete, or yank all the code in the function body, but in those cases I don't normally want to include the braces. So, I'll need to consider whether it's possible to tweak treesitter's results.
I think it would be so useful to use something like this:
require'nvim-treesitter.configs'.setup {
textobjects = {
select = {
enable = true,
keymaps = {
["ap"] = "@parameter.outer",
}
}
}
}
nmap <leader>P :TSPasteParameterBefore<CR>
nmap <leader>p :TSPasteParameterAfter<CR>
Then if I could take a function call like:
blah(arg1, arg2, arg3);
and hover arg2
and use dap
to delete arg2
.
Then hover arg1
and use a keybinding to paste the parameter I just copied before arg1
or use a different keybinding to paste the parameter after arg1
(in this case <leader>P
for "before" and <leader>p
for "after").
When I do dap
it copies the preceding ,
(or sometimes the trailing ,
). When pasting the code would first need to remove the preceding/trailing ,
and then enter a new ,
after the pasted parameter when pasting before the final parameter, or enter a preceding ,
when pasting into the final parameter position. If there are no parameters then no trailing/preceding ,
would be added (for languages that support trailing ,
after the last parameter, could leave it up to the user's code formatter to handle this but in cases where a trailing ,
already exists then pasting into the final parameter position should not enter the preceding ,
). I'm aware there are languages that don't use ,
between parameters such as Haskell, for such languages it would be easier.
This might not be the direction you see nvim-treesitter-textobjects
going, and if not, I'm happy to provide this support in a new plugin, but I'd be really grateful for any advice you could give me on how I might implement this.
In scss syntax, the property's value could be multiple.
In treesitter, these values are same level.
For example below, the animation property has 5 value,
But in fact they all belong to one value.
Is there a way to select all the children below declaration
, like plain_value
, integer_value
but except property_name
First of all, thanks for this plugin! I'm trying it out and the results are impressive!
One thing I'm missing from targets.vim is the "an argument" text object:
Select an argument in a list of arguments. Includes a separator if preset, but excludes surrounding braces. This leaves a proper argument list after deletion. Accepts a count.
........... a , b ( cccccccc , d ) e └─── aa ──┘
As I understand the analogue could be @parameter.outer
. Unfortunately I wasn't able to see how that could be defined with queries at the moment as the most grammars I've checked do not keep punctuation in the AST. Maybe some out of band solution might work where there's some post processing on the query result to find the matching comma...
Describe the bug
Does not work with tsx files, only ts
To Reproduce
Use the following configuration:
require'nvim-treesitter.configs'.setup {
ensure_installed = {"typescript", "tsx", "javascript"},
highlight = { enable = true },
textobjects = {
select = {
enable = true,
lookahead = true,
keymaps = {
["af"] = "@function.outer",
["if"] = "@function.inner",
["ac"] = "@class.outer",
["ic"] = "@class.inner",
["ap"] = "@parameter.outer",
["ip"] = "@parameter.inner",
},
},
},
}
Open tsx file with a function definition like:
function blah(arg: string, arg2: string): string {
return arg + arg2;
}
Put the cursor over the first a
in arg:
and then use dip
to delete the parameter.
This will work fine in a ts file, but not at all in a tsx file.
Output of :checkhealth nvim_treesitter
health#nvim_treesitter#check
======================================================================== ## Installation
- OK:
tree-sitter
found 0.20.0 (parser generator, only needed for :TSInstallFromGrammar)
- OK:
node
found v14.15.4 (only needed for :TSInstallFromGrammar)
- OK:
git
executable found. - OK: cc
executable found. Selected from { vim.NIL, "cc", "gcc", "clang", "cl" }
- OK: Neovim was compiled with tree-sitter runtime ABI version 13 (required >=13). Parsers must be compatible with runtime ABI.
Parser/Features H L F I J
- tsx ✓ ✓ ✓ ✓ ✓
- c_sharp ✓ ✓ ✓ . ✓
- c ✓ ✓ ✓ ✓ ✓
- javascript ✓ ✓ ✓ ✓ ✓
- typescript ✓ ✓ ✓ ✓ ✓
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
NVIM v0.6.0-dev+43-g02bf251bb
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3
Compilation: /usr/bin/gcc-11 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DNVIM_TS_HAS_SET_MATCH_LIMIT -O2 -g -Og -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=always -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/home/runner/work/neovim/neovim/build/config -I/home/runner/work/neovim/neovim/src -I/home/runner/work/neovim/neovim/.deps/usr/include -I/usr/include -I/home/runner/work/neovim/neovim/build/src/nvim/auto -I/home/runner/work/neovim/neovim/build/include
Compiled by runner@fv-az87-55
Features: +acl +iconv +tui
See ":help feature-compile"
system vimrc file: "$VIM/sysinit.vim"
fall-back for $VIM: "/share/nvim"
Run :checkhealth for more info
Describe the bug
Text objects don't work inside of injected languages.
Pressing daa
here doesn't do anything.
Related to #27
To Reproduce
Steps to reproduce the behavior using the following textobjects config:
textobjects = {
select = {
enable = true,
lookahead = true,
keymaps = {
["aa"] = "@parameter.outer",
["ia"] = "@parameter.inner",
},
},
},
:set ft=vim
lua <<EOF
test(1, 2)
EOF
daa
(nothing happens)Output of :checkhealth nvim_treesitter
nvim_treesitter: health#nvim_treesitter#check
========================================================================
## Installation
- WARNING: `tree-sitter` executable not found (parser generator, only needed for :TSInstallFromGrammar, not required for :TSInstall)
- OK: `node` found v16.10.0 (only needed for :TSInstallFromGrammar)
- OK: `git` executable found.
- OK: `cc` executable found. Selected from { vim.NIL, "cc", "gcc", "clang", "cl", "zig" }
Version: cc (Debian 8.3.0-6) 8.3.0
- OK: Neovim was compiled with tree-sitter runtime ABI version 13 (required >=13). Parsers must be compatible with runtime ABI.
## Parser/Features H L F I J
- dart ✓ ✓ . ✓ ✓
- ruby ✓ ✓ ✓ ✓ ✓
- ocaml_interface✓ ✓ ✓ . ✓
- c_sharp ✓ ✓ ✓ . ✓
- dockerfile ✓ . . . ✓
- svelte ✓ . ✓ ✓ ✓
- typescript ✓ ✓ ✓ ✓ ✓
- regex ✓ . . . .
- zig ✓ . ✓ ✓ ✓
- supercollider ✓ ✓ ✓ ✓ ✓
- r ✓ ✓ . . .
- haskell ✓ . . . ✓
- hcl ✓ . ✓ ✓ ✓
- tlaplus ✓ . ✓ . ✓
- pioasm ✓ . . . ✓
- glimmer ✓ . . . .
- json ✓ ✓ ✓ ✓ .
- fish ✓ ✓ ✓ ✓ ✓
- llvm ✓ . . . .
- jsonc ✓ ✓ ✓ ✓ ✓
- query ✓ ✓ ✓ ✓ ✓
- yang ✓ . ✓ . .
- scala ✓ . ✓ . ✓
- scss ✓ . . ✓ .
- rst ✓ ✓ . . ✓
- fennel ✓ ✓ . . ✓
- ql ✓ ✓ . ✓ ✓
- heex ✓ . ✓ ✓ ✓
- verilog ✓ ✓ ✓ . ✓
- c ✓ ✓ ✓ ✓ ✓
- jsdoc ✓ . . . .
- sparql ✓ ✓ ✓ ✓ ✓
- html ✓ ✓ ✓ ✓ ✓
- toml ✓ ✓ ✓ ✓ ✓
- javascript ✓ ✓ ✓ ✓ ✓
- tsx ✓ ✓ ✓ ✓ ✓
- java ✓ ✓ . ✓ ✓
- turtle ✓ ✓ ✓ ✓ ✓
- vue ✓ . ✓ . ✓
- hjson ✓ ✓ ✓ ✓ ✓
- python ✓ ✓ ✓ ✓ ✓
- lua ✓ ✓ ✓ ✓ ✓
- clojure ✓ ✓ ✓ . ✓
- perl ✓ . . . .
- vim ✓ ✓ . . ✓
- commonlisp ✓ ✓ ✓ . .
- cmake ✓ . ✓ . .
- latex ✓ . ✓ . ✓
- yaml ✓ ✓ ✓ ✓ ✓
- cuda ✓ ✓ ✓ ✓ ✓
- beancount ✓ . ✓ . .
- bibtex ✓ . ✓ ✓ .
- kotlin ✓ . . . ✓
- comment ✓ . . . .
- glsl ✓ ✓ ✓ ✓ ✓
- fortran ✓ . ✓ ✓ .
- julia ✓ ✓ ✓ ✓ ✓
- graphql ✓ . . ✓ ✓
- elm . . . . .
- dot ✓ . . . ✓
- json5 ✓ . . . ✓
- nix ✓ ✓ ✓ . ✓
- rust ✓ ✓ ✓ ✓ ✓
- erlang . . . . .
- ledger ✓ . ✓ ✓ ✓
- css ✓ . ✓ ✓ ✓
- elixir ✓ ✓ ✓ ✓ ✓
- go ✓ ✓ ✓ ✓ ✓
- php ✓ ✓ ✓ ✓ ✓
- surface ✓ . ✓ ✓ ✓
- bash ✓ ✓ ✓ . ✓
- gomod ✓ . . . .
- cpp ✓ ✓ ✓ ✓ ✓
- ocaml ✓ ✓ ✓ . ✓
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
NVIM v0.6.0-dev+479-g9086938f7
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3
Compilation: /usr/bin/gcc-11 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DNVIM_TS_HAS_SET_MATCH_LIMIT -O2 -g -Og -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=always -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/home/runner/work/neovim/neovim/build/config -I/home/runner/work/neovim/neovim/src -I/home/runner/work/neovim/neovim/.deps/usr/include -I/usr/include -I/home/runner/work/neovim/neovim/build/src/nvim/auto -I/home/runner/work/neovim/neovim/build/include
Compiled by runner@fv-az50-41
Features: +acl +iconv +tui
See ":help feature-compile"
system vimrc file: "$VIM/sysinit.vim"
fall-back for $VIM: "
/home/runner/work/neovim/neovim/build/nvim.AppDir/usr/share/nvim"
Run :checkhealth for more info
Describe the bug
The text objects I set are non-existent. When I try the bindings within the configuration (at the bottom), nothing happens. There's no error messages or anything like that. It is as if they weren't set. Thanks for any help
Expected behavior
I was expecting the text objects to be selected, cleared, etc when I acted upon them
Output of :checkhealth nvim_treesitter
health#nvim_treesitter#check
========================================================================
## Installation
- WARNING: `tree-sitter` executable not found (parser generator, only needed for :TSInstallFromGrammar, not required for :TSInstall)
- OK: `node` found v16.4.1 (only needed for :TSInstallFromGrammar)
- OK: `git` executable found.
- OK: `gcc` executable found. Selected from { vim.NIL, "cc", "gcc", "clang", "cl" }
- OK: Neovim was compiled with tree-sitter runtime ABI version 13 (required >=13). Parsers must be compatible with runtime ABI.
Parser/Features H L F I J
- python ✓ ✓ ✓ ✓ ✓
- haskell ✓ . . . ✓
- yaml ✓ ✓ ✓ ✓ ✓
- javascript ✓ ✓ ✓ ✓ ✓
- commonlisp ✓ ✓ ✓ . .
- json ✓ ✓ ✓ ✓ .
- rust ✓ ✓ ✓ ✓ ✓
- c ✓ ✓ ✓ ✓ ✓
- html ✓ ✓ ✓ ✓ ✓
- css ✓ . ✓ ✓ ✓
- lua ✓ ✓ ✓ ✓ ✓
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
NVIM v0.6.0-dev+98-ga5c25e4f3
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3
Compilation: C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x64/cl.exe /DWIN32 /D_WINDOWS /W3 -DNVIM_TS_HAS_SET_MATCH_LIMIT /MD /Zi /O2 /Ob1 /DNDEBUG /W3 -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE -DWIN32 -D_WIN32_WINNT=0x0600 -DINCLUDE_GENERATED_DECLARATIONS -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -ID:/a/neovim/neovim/build/config -ID:/a/neovim/neovim/src -ID:/a/neovim/neovim/nvim-deps/usr/include -ID:/a/neovim/neovim/build/src/nvim/auto -ID:/a/neovim/neovim/build/include
Compiled by runneradmin@fv-az152-272
Features: -acl +iconv +tui
See ":help feature-compile"
system vimrc file: "$VIM\sysinit.vim"
fall-back for $VIM: "C:/Program Files/nvim/share/nvim"
Run :checkhealth for more info
Additional context
My Text Objects Configuration
-- ...
textobjects = {
lsp_interop = { enable = true },
select = {
enable = true,
keymaps = {
["al"] = "@loop.outer",
["il"] = "@loop.inner",
["ab"] = "@block.outer",
["ib"] = "@block.inner",
["ac"] = "@class.outer",
["ic"] = "@class.inner",
["af"] = "@function.outer",
["if"] = "@function.inner",
["ap"] = "@parameter.outer",
["ip"] = "@parameter.inner",
["ak"] = "@comment.outer"
},
},
swap = {
enable = true,
swap_next = {
["<Leader>cs"] = "@parameter.inner",
},
swap_previous = {
["<Leader>cs"] = "@parameter.inner",
},
},
move = {
enable = true,
set_jumps = true,
goto_next_start = { ["]]"] = "@function.outer" },
goto_next_end = { ["]}"] = "@function.outer" },
goto_previous_start = { ["[["] = "@function.outer" },
goto_previous_end = { ["[{"] = "@function.outer" },
}
}
-- ...
Describe the bug
It will over map my fallback textobject keymap.
Expected behavior
If the module has not supported textobject, stop mapping.
Is your feature request related to a problem? Please describe.
Given an argument list A, B, C, D
the parameter.outer objects would be A,
; B,
; C,
and D
. This means that daa
(delete around argument) would leave a trailing comma that has to be manually deleted
Describe the solution you'd like
It would be great if it could detect the last argument in the list specially and extend it backward to get the preceding comma
Describe the bug
Hotkey for query does not capture block.
I have this query set to fold docstrings for Python
in my own little plugin so I can be certain the query captures correctly.
(function_definition body: (block (expression_statement (string) @docstring)))
I have also tested this with my plugin enabled/disabled.
I have tried this with capture groups @docstring
, @comment
, @comment.inner
, @comment.outer
I have tried with multi line and single line string.
To Reproduce
# Python file with docstring to yank
def f():
""" Some text
With more to follow
"""
return 3 + 3
# My configuration
require('nvim-treesitter.configs') .setup({
...,
textobjects = {
select = {
keymaps = {
...,
["c"] = {
python = "(function_definition body: (block (expression_statement (string) @comment.outer)))"
}
}
}
}
...,
})
Expected behavior
Using yid
, the documentation block should be yanked
Output of :checkhealth nvim_treesitter
nvim_treesitter: health#nvim_treesitter#check
Installation
- OK:
tree-sitter
found 0.20.0 (parser generator, only needed for :TSInstallFromGrammar)
- 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 (GCC) 11.1.0
- OK: Neovim was compiled with tree-sitter runtime ABI version 13 (required >=13). Parsers must be compatible with runtime ABI.
Parser/Features H L F I J
- python ✓ ✓ ✓ ✓ ✓
- c ✓ ✓ ✓ ✓ ✓
- lua ✓ ✓ ✓ ✓ ✓
- query ✓ ✓ ✓ ✓ ✓
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
NVIM v0.7.0-dev+734-g51306f98b
Build type: Release
LuaJIT 2.1.0-beta3
Compiled by root@skantify
Features: +acl +iconv +tui
See ":help feature-compile"
system vimrc file: "$VIM/sysinit.vim"
fall-back for $VIM: "/usr/local/share/nvim"
Run :checkhealth for more info
Additional context
Using nvim-treesitter-playground
I can be certain this query highlights the documentation block.
Would be nice if the move commands could accept counts. And also the select commands could accept counts to select an outer textobject in a nested structure.
Describe the bug
I used python, but can't select or yank the function with keybinding such as v
or y
.
when put the cursor in a function, :lua print(vim.inspect(require'nvim-treesitter.query'.collect_group_results(0, 'textobject')))
return {}
, but use command like :TSTextobjectSelect @function.outer
visually select all function
To Reproduce
Steps to reproduce the behavior:
vif
(which i binded if
for "@function.inner"
) doesn't visually select inner functionvif
select inner functionOutput of :checkhealth nvim_treesitter
Parser/Features H L F I
- python ✓ ✓ ✓ ✓
Output of nvim --version
NVIM v0.5.0-dev+1186-g8665a96b9
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3
Compilation: /usr/bin/cc -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -O2 -g -Og -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=always -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/home/runner/work/neovim/neovim/build/config -I/home/runner/work/neovim/neovim/src -I/home/runner/work/neovim/neovim/.deps/usr/include -I/usr/include -I/home/runner/work/neovim/neovim/build/src/nvim/auto -I/home/runner/work/neovim/neovim/build/include
Compiled by runner@fv-az67-513
Features: +acl +iconv +tui
See ":help feature-compile"
system vimrc file: "$VIM/sysinit.vim"
fall-back for $VIM: "
/home/runner/work/neovim/neovim/build/nvim.AppDir/usr/share/nvim"
Run :checkhealth for more info
Additional context
Add any other context about the problem here.
nvim-treesitter-textobjects has the the ability to swap function arguments. I have previously been using vim-argumentative, which also does this (without the use of tree-sitter). However, vim-argumentative is also able to swap the positions of items in lists. For instance, with the cursor on item foo
in the following example, pressing >,
moves foo
from the first index to the second one like so: [foo, bar, baz]
--> [bar, foo, baz]
.
Would this be possible to impement using tree-sitter?
I personally use the following config for swap:
swap = {
enable = true,
swap_next = {
['>,'] = '@parameter.inner',
},
swap_previous = {
['<,'] = '@parameter.inner',
}
}
What I would want is for >,
to swap both parameters and list items like in my previous example.
Edit: I realized after posting that #86 is a very similar question.
Hey guys,
thank you very much for your great work on all the treesitter features! I highly appreciate it! 🙏
Is your feature request related to a problem? Please describe.
I must admit that I was never a friend of letting a plugin doing the key mappings for me. Also if it allows me to define a configuration option to define the key-combo to use. I feel like having less control, it becomes unstructured and ugly. At least that is my view. Unfortunately it seems to become a pattern for the more recent Lua'ish plugins to push for this kind of mappings.
So I denied to use the map definitions within the initialization step of this plugin. I'm adding them manually by myself where they belong to (from my perspective). Unfortunately this results in incredible long lines which look like this for example:
vnoremap <silent> af :<C-u>lua require'nvim-treesitter.textobjects.select'.select_textobject('@function.outer')<CR>
Talking about code quality this results into a fail that is hard to read, because 80% is equal boilerplate code. It is hard to see what is the actual relevant configuration here.
Describe the solution you'd like
I wanted to ask if you guys are willed to add a simple command for each of those exposed functions. Just something as simple as api.nvim_command('command! TSTextObjectSelect lua require....
. This would make it slightly easier to add such mappings by hand, removing a lot of the boilerplate.
I'm also open to get suggestions how I could improve my mappings else.
Thank you very much in advanced!
Consider a python snippet like the following with the cursor placed at the caret:
print( "a" , "b" , "c" )
^
If you try to select parameter.inner
or parameter.outer
, nothing will happen.
If the cursor is in a different location:
print( "a" , "b" , "c" )
^
Now parameter.outer
will select something (the "b"
parameter up to its comma, but not its leading space),
but parameter.inner
still does nothing.
This is probably technically correct according to the way the syntax tree maps to tokens, but it's not very convenient for editing. You'll get similar behavior if you happen to be in whitespace for other text objects, e.g.:
def foo(bar):
print(bar)
^
Here function.outer
will select the entire function and body as expected, but function.inner
selects nothing.
When the cursor is on whitespace, it should probably "snap" to the next non-whitespace token before looking for the surrounding text object.
Describe the bug
Current search for textobjects is too slow and could be more flexible (counts, textobjects in same line).
Solution
Avoid iter_prepared_matches
in find_best_match
. Use find_best_matches
to allow the use of v:count
Describe the bug
I am trying to set up lazy loading of treesitter with packer.nvim
and there is a race condition with doing so.
As a result keymapping for textobjects
are not loaded.
To Reproduce
A piece of packer
config:
use {
"nvim-treesitter/nvim-treesitter",
run = ":TSUpdate",
requires = {
{
"nvim-treesitter/playground",
after = "nvim-treesitter",
cmd = { "TSPlaygroundToggle", "TSHighlightCapturesUnderCursor" },
},
{
"nvim-treesitter/nvim-treesitter-textobjects",
module = "nvim-treesitter-textobjects",
after = "nvim-treesitter",
},
},
event = "BufRead",
config = function()
require "config.treesitter"
end,
}
config.treesitter
file:
local swap_next, swap_prev = (function()
local swap_objects = {
c = "@class.outer",
f = "@function.outer",
b = "@block.outer",
s = "@statement.outer",
p = "@parameter.inner",
m = "@call.outer",
}
local n, p = {}, {}
for key, obj in pairs(swap_objects) do
n[string.format("<leader>s%s", key)] = obj
p[string.format("<leader>S%s", key)] = obj
end
return n, p
end)()
require("nvim-treesitter.configs").setup {
ensure_installed = "maintained",
highlight = {
enable = true,
},
indent = {
enable = true,
disable = { "yaml" },
},
incremental_selection = {
enable = true,
keymaps = {
init_selection = "<enter>",
node_incremental = "<enter>",
node_decremental = "<bs>",
},
},
textobjects = {
select = {
enable = true,
-- Automatically jump forward to textobj, similar to targets.vim
lookahead = true,
keymaps = {
-- You can use the capture groups defined in textobjects.scm
["oc"] = "@class.outer",
["ic"] = "@class.inner",
["of"] = "@function.outer",
["if"] = "@function.inner",
["ob"] = "@block.outer",
["ib"] = "@block.inner",
["ol"] = "@loop.outer",
["il"] = "@loop.inner",
["os"] = "@statement.outer",
["is"] = "@statement.inner",
["oC"] = "@comment.outer",
["iC"] = "@comment.inner",
["om"] = "@call.outer",
["im"] = "@call.inner",
},
},
swap = {
enable = true,
swap_next = swap_next,
swap_previous = swap_prev,
},
move = {
enable = true,
set_jumps = true, -- whether to set jumps in the jumplist
goto_next_start = {
["]m"] = "@function.outer",
["]]"] = "@class.outer",
},
goto_next_end = {
["]M"] = "@function.outer",
["]["] = "@class.outer",
},
goto_previous_start = {
["[m"] = "@function.outer",
["[["] = "@class.outer",
},
goto_previous_end = {
["[M"] = "@function.outer",
["[]"] = "@class.outer",
},
},
},
playground = {
enable = true,
disable = {},
updatetime = 25,
persist_queries = false,
},
}
As far as I understand what is going on is:
treesitter
is loaded (on BufRead
) with the keymappings.playground
and textobjects
are loaded AFTER keymappings were set up and as a result no keymapping are actually appied to the plugin.Expected behavior
Keymapping from config.treesitter
must be applied to the plugin.
Output of :checkhealth nvim_treesitter
health#nvim_treesitter#check
Installation
- WARNING:
tree-sitter
executable not found (parser generator, only needed for :TSInstallFromGrammar, not required for :TSInstall)
- OK:
node
found v14.17.1 (only needed for :TSInstallFromGrammar)
- OK:
git
executable found.
- OK:
cc
executable found. Selected from { vim.NIL, "cc", "gcc", "clang", "cl" }
- OK: Neovim was compiled with tree-sitter runtime ABI version 13 (required >=13). Parsers must be compatible with runtime ABI.
Output of nvim --version
NVIM v0.6.0-dev+116-g35041432b
Is there a way to lazy load the plugin with packer.nvim
?
Describe the bug
Error when trying to navigate markdown file using text objects
To Reproduce
markdown file like this
# Heading
Text
configuration like this:
...
goto_previous_end = {
['[]'] = '@class.outer',
},
Hit []
, error out:
E5108: Error executing lua ...r/start/nvim-treesitter/lua/nvim-treesitter/ts_utils.lua:389: Column value outside range
stack traceback:
[C]: in function 'nvim_win_set_cursor'
...r/start/nvim-treesitter/lua/nvim-treesitter/ts_utils.lua:389: in function 'goto_node'
...ter-textobjects/lua/nvim-treesitter/textobjects/move.lua:47: in function 'move'
...ter-textobjects/lua/nvim-treesitter/textobjects/move.lua:60: in function 'goto_previous_end'
[string ":lua"]:1: in main chunk
Expected behavior
Cursor is moved, no error.
Output of :checkhealth nvim_treesitter
nvim_treesitter: health#nvim_treesitter#check
========================================================================
## Installation
- OK: `tree-sitter` found 0.20.1 (062421dece3315bd6f228ad6d468cba083d0a2d5) (parser generator, only needed for :TSInstallFromGrammar)
- OK: `node` found v15.14.0 (only needed for :TSInstallFromGrammar)
- OK: `git` executable found.
- OK: `cc` executable found. Selected from { vim.NIL, "cc", "gcc", "clang", "cl", "zig" }
Version: cc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0
- OK: Neovim was compiled with tree-sitter runtime ABI version 13 (required >=13). Parsers must be compatible with runtime ABI.
Parser/Features H L F I J
- json ✓ ✓ ✓ ✓ .-
- vim ✓ ✓ . . ✓-
- haskell ✓ . . . ✓-
- supercollider ✓ ✓ ✓ ✓ ✓-
- scala ✓ . ✓ . ✓-
- go ✓ ✓ ✓ ✓ ✓-
- prisma ✓ . . . .-
- tsx ✓ ✓ ✓ ✓ ✓-
- typescript ✓ ✓ ✓ ✓ ✓-
- r ✓ ✓ . . .-
- c_sharp ✓ ✓ ✓ . ✓-
- swift . . . . .-
- cmake ✓ . ✓ . .-
- ocamllex ✓ . . . ✓-
- zig ✓ . ✓ ✓ ✓-
- ocaml_interface✓ ✓ ✓ . ✓-
- ocaml ✓ ✓ ✓ . ✓-
- bibtex ✓ . ✓ ✓ .-
- heex ✓ . ✓ ✓ ✓-
- make ✓ . . . ✓-
- surface ✓ . ✓ ✓ ✓-
- elixir ✓ ✓ ✓ ✓ ✓-
- erlang . . . . .-
- svelte ✓ . ✓ ✓ ✓-
- scss ✓ . . ✓ .-
- dockerfile ✓ . . . ✓-
- devicetree ✓ ✓ ✓ ✓ ✓-
- glsl ✓ ✓ ✓ ✓ ✓-
- julia ✓ ✓ ✓ ✓ ✓-
- d ✓ . ✓ ✓ ✓-
- cuda ✓ ✓ ✓ ✓ ✓-
- kotlin ✓ . . . ✓-
- cpp ✓ ✓ ✓ ✓ ✓-
- commonlisp ✓ ✓ ✓ . .-
- php ✓ ✓ ✓ ✓ ✓-
- clojure ✓ ✓ ✓ . ✓-
- sparql ✓ ✓ ✓ ✓ ✓-
- fish ✓ ✓ ✓ ✓ ✓-
- bash ✓ ✓ ✓ . ✓-
- jsdoc ✓ . . . .-
- javascript ✓ ✓ ✓ ✓ ✓-
- perl ✓ . . . .-
- comment ✓ . . . .-
- ruby ✓ ✓ ✓ ✓ ✓-
- graphql ✓ . . ✓ ✓-
- verilog ✓ ✓ ✓ . ✓-
- ql ✓ ✓ . ✓ ✓-
- teal ✓ ✓ ✓ ✓ ✓-
- python ✓ ✓ ✓ ✓ ✓-
- fennel ✓ ✓ . . ✓-
- rst ✓ ✓ . . ✓-
- regex ✓ . . . .-
- dart ✓ ✓ . ✓ ✓-
- fusion ✓ ✓ . . .-
- nix ✓ ✓ ✓ . ✓-
- rust ✓ ✓ ✓ ✓ ✓-
- yang ✓ . ✓ . .-
- http ✓ . . . ✓-
- llvm ✓ . . . .-
- yaml ✓ ✓ ✓ ✓ ✓-
- hjson ✓ ✓ ✓ ✓ ✓-
- elm ✓ . . . ✓-
- pioasm ✓ . . . ✓-
- json5 ✓ . . . ✓-
- fortran ✓ . ✓ ✓ .-
- jsonc ✓ ✓ ✓ ✓ ✓-
- latex ✓ . ✓ . ✓-
- vue ✓ . ✓ ✓ ✓-
- beancount ✓ . ✓ . .-
- pug ✓ . . . ✓-
- turtle ✓ ✓ ✓ ✓ ✓-
- godot_resource ✓ ✓ ✓ . .-
- gdscript ✓ ✓ . . ✓-
- query ✓ ✓ ✓ ✓ ✓-
- ledger ✓ . ✓ ✓ ✓-
- java ✓ ✓ . ✓ ✓-
- glimmer ✓ . . . .-
- lua ✓ ✓ ✓ ✓ ✓-
- c ✓ ✓ ✓ ✓ ✓-
- toml ✓ ✓ ✓ ✓ ✓-
- html ✓ ✓ ✓ ✓ ✓-
- dot ✓ . . . ✓-
- css ✓ . ✓ ✓ ✓-
- tlaplus ✓ . ✓ . ✓-
- hcl ✓ . ✓ ✓ ✓-
- markdown ✓ . . . ✓-
- gomod ✓ . . . ✓-
- gowork ✓ . . . ✓-
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
NVIM v0.7.0-dev+751-g67bb01ae2
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3
Compilation: /usr/bin/cc -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DNVIM_TS_HAS_SET_MATCH_LIMIT -O2 -g -Og -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/home/dch/neovim/build/config -I/home/dch/neovim/src -I/home/dch/neovim/.deps/usr/include -I/usr/include -I/home/dch/neovim/build/src/nvim/auto -I/home/dch/neovim/build/include
Compiled by dch@DESKTOP-NA4O3IV
Features: +acl +iconv +tui
See ":help feature-compile"
system vimrc file: "$VIM/sysinit.vim"
fall-back for $VIM: "/home/dch/.local/nvim/share/nvim"
Run :checkhealth for more info
Describe the bug
I used python, go etc, but can't select or yank the function
To Reproduce
Steps to reproduce the behavior:
Expected behavior
select or yank the function
Output of :checkhealth nvim_treesitter
git
executable found.cc
executable found.highlights.scm
found.locals.scm
found.folds.scm
found.indents.scm
found.highlights.scm
found.locals.scm
found.folds.scm
found.indents.scm
found.highlights.scm
found.locals.scm
found.folds.scm
query found for clojure
indents.scm
query found for clojure
highlights.scm
found.locals.scm
found.folds.scm
found.indents.scm
found.highlights.scm
found.locals.scm
found.folds.scm
found.indents.scm
found.highlights.scm
found.locals.scm
found.folds.scm
query found for ql
indents.scm
query found for ql
highlights.scm
found.locals.scm
query found for graphql
folds.scm
query found for graphql
indents.scm
found.highlights.scm
found.locals.scm
found.folds.scm
found.indents.scm
found.highlights.scm
found.locals.scm
found.folds.scm
found.indents.scm
found.highlights.scm
found.locals.scm
found.folds.scm
found.indents.scm
found.highlights.scm
found.locals.scm
query found for kotlin
folds.scm
query found for kotlin
indents.scm
query found for kotlin
highlights.scm
found.locals.scm
found.folds.scm
found.indents.scm
found.highlights.scm
found.locals.scm
found.folds.scm
found.indents.scm
found.highlights.scm
found.locals.scm
found.folds.scm
query found for gdscript
indents.scm
query found for gdscript
highlights.scm
found.locals.scm
found.folds.scm
found.indents.scm
found.highlights.scm
found.locals.scm
query found for jsdoc
folds.scm
query found for jsdoc
indents.scm
query found for jsdoc
highlights.scm
found.locals.scm
query found for regex
folds.scm
query found for regex
indents.scm
query found for regex
highlights.scm
found.locals.scm
found.folds.scm
query found for fennel
indents.scm
query found for fennel
Paste the output here
In Vim, when you type a motion outside a textobj, it will auto jump forward then do the motion.
This is super usefull, mean you don't need to move the cursor to the textobj
part.
In treesitter-textobjects
, it only do the motion when cursor in right position.
For example below, the @inner
is inside @outer
.
When do the motion like ca
, da
, ya
. It works good.
Cause cursor always in @outer
But the @inner
part, have to move cursor it, then do the motion right.
And here's the config, but I think has nothing to do with the config.
; import
(import_statement
(import_clause
[(named_imports) (identifier)] @import.inner)) @import.outer
Describe the bug
Error detected while processing FileType Autocommands for "*":
E5108: Error executing lua /usr/local/share/nvim/runtime/lua/vim/treesitter/query.lua:119: query: error at position 440
To Reproduce
Steps to reproduce the behavior:
Expected behavior
no error
Output of :checkhealth nvim_treesitter
health#nvim_treesitter#check
Installation
- OK:
git
executable found.
- OK:
cc
executable found.
elm parser healthcheck
- OK: elm parser found.
- WARNING: No
highlights.scm
query found for elm
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
- WARNING: No
locals.scm
query found for elm
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
- WARNING: No
folds.scm
query found for elm
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
- WARNING: No
indents.scm
query found for elm
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
c parser healthcheck
- OK: c parser found.
- OK:
highlights.scm
found.
- OK:
locals.scm
found.
- OK:
folds.scm
found.
- WARNING: No
indents.scm
query found for c
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
teal parser healthcheck
- OK: teal parser found.
- OK:
highlights.scm
found.
- OK:
locals.scm
found.
- OK:
folds.scm
found.
- WARNING: No
indents.scm
query found for teal
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
java parser healthcheck
- OK: java parser found.
- OK:
highlights.scm
found.
- OK:
locals.scm
found.
- WARNING: No
folds.scm
query found for java
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
- WARNING: No
indents.scm
query found for java
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
python parser healthcheck
- OK: python parser found.
- OK:
highlights.scm
found.
- OK:
locals.scm
found.
- OK:
folds.scm
found.
- WARNING: No
indents.scm
query found for python
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
dart parser healthcheck
- OK: dart parser found.
- OK:
highlights.scm
found.
- OK:
locals.scm
found.
- WARNING: No
folds.scm
query found for dart
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
- WARNING: No
indents.scm
query found for dart
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
lua parser healthcheck
- OK: lua parser found.
- OK:
highlights.scm
found.
- OK:
locals.scm
found.
- OK:
folds.scm
found.
- OK:
indents.scm
found.
ocaml parser healthcheck
- OK: ocaml parser found.
- OK:
highlights.scm
found.
- OK:
locals.scm
found.
- OK:
folds.scm
found.
- WARNING: No
indents.scm
query found for ocaml
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
go parser healthcheck
- OK: go parser found.
- OK:
highlights.scm
found.
- OK:
locals.scm
found.
- OK:
folds.scm
found.
- WARNING: No
indents.scm
query found for go
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
nix parser healthcheck
- OK: nix parser found.
- OK:
highlights.scm
found.
- OK:
locals.scm
found.
- OK:
folds.scm
found.
- WARNING: No
indents.scm
query found for nix
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
yaml parser healthcheck
- OK: yaml parser found.
- WARNING: No
highlights.scm
query found for yaml
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
- WARNING: No
locals.scm
query found for yaml
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
- WARNING: No
folds.scm
query found for yaml
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
- WARNING: No
indents.scm
query found for yaml
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
json parser healthcheck
- OK: json parser found.
- OK:
highlights.scm
found.
- WARNING: No
locals.scm
query found for json
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
- WARNING: No
folds.scm
query found for json
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
- WARNING: No
indents.scm
query found for json
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
jsdoc parser healthcheck
- OK: jsdoc parser found.
- OK:
highlights.scm
found.
- WARNING: No
locals.scm
query found for jsdoc
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
- WARNING: No
folds.scm
query found for jsdoc
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
- WARNING: No
indents.scm
query found for jsdoc
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
php parser healthcheck
- OK: php parser found.
- OK:
highlights.scm
found.
- OK:
locals.scm
found.
- OK:
folds.scm
found.
- WARNING: No
indents.scm
query found for php
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
clojure parser healthcheck
- OK: clojure parser found.
- OK:
highlights.scm
found.
- OK:
locals.scm
found.
- WARNING: No
folds.scm
query found for clojure
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
- WARNING: No
indents.scm
query found for clojure
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
html parser healthcheck
- OK: html parser found.
- OK:
highlights.scm
found.
- OK:
locals.scm
found.
- WARNING: No
folds.scm
query found for html
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
- WARNING: No
indents.scm
query found for html
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
typescript parser healthcheck
- OK: typescript parser found.
- OK:
highlights.scm
found.
- OK:
locals.scm
found.
- OK:
folds.scm
found.
- WARNING: No
indents.scm
query found for typescript
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
fennel parser healthcheck
- OK: fennel parser found.
- OK:
highlights.scm
found.
- OK:
locals.scm
found.
- WARNING: No
folds.scm
query found for fennel
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
- WARNING: No
indents.scm
query found for fennel
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
swift parser healthcheck
- OK: swift parser found.
- WARNING: No
highlights.scm
query found for swift
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
- WARNING: No
locals.scm
query found for swift
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
- WARNING: No
folds.scm
query found for swift
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
- WARNING: No
indents.scm
query found for swift
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
regex parser healthcheck
- OK: regex parser found.
- OK:
highlights.scm
found.
- WARNING: No
locals.scm
query found for regex
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
- WARNING: No
folds.scm
query found for regex
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
- WARNING: No
indents.scm
query found for regex
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
query parser healthcheck
- OK: query parser found.
- OK:
highlights.scm
found.
- OK:
locals.scm
found.
- WARNING: No
folds.scm
query found for query
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
- WARNING: No
indents.scm
query found for query
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
verilog parser healthcheck
- OK: verilog parser found.
- OK:
highlights.scm
found.
- OK:
locals.scm
found.
- OK:
folds.scm
found.
- WARNING: No
indents.scm
query found for verilog
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
cpp parser healthcheck
- OK: cpp parser found.
- OK:
highlights.scm
found.
- OK:
locals.scm
found.
- OK:
folds.scm
found.
- WARNING: No
indents.scm
query found for cpp
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
ql parser healthcheck
- OK: ql parser found.
- OK:
highlights.scm
found.
- OK:
locals.scm
found.
- WARNING: No
folds.scm
query found for ql
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
- WARNING: No
indents.scm
query found for ql
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
rst parser healthcheck
- OK: rst parser found.
- OK:
highlights.scm
found.
- OK:
locals.scm
found.
- WARNING: No
folds.scm
query found for rst
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
- WARNING: No
indents.scm
query found for rst
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
ruby parser healthcheck
- OK: ruby parser found.
- OK:
highlights.scm
found.
- OK:
locals.scm
found.
- WARNING: No
folds.scm
query found for ruby
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
- WARNING: No
indents.scm
query found for ruby
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
vue parser healthcheck
- OK: vue parser found.
- WARNING: No
highlights.scm
query found for vue
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
- WARNING: No
locals.scm
query found for vue
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
- WARNING: No
folds.scm
query found for vue
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
- WARNING: No
indents.scm
query found for vue
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
ocamllex parser healthcheck
- OK: ocamllex parser found.
- OK:
highlights.scm
found.
- WARNING: No
locals.scm
query found for ocamllex
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
- WARNING: No
folds.scm
query found for ocamllex
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
- WARNING: No
indents.scm
query found for ocamllex
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
scala parser healthcheck
- OK: scala parser found.
- WARNING: No
highlights.scm
query found for scala
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
- WARNING: No
locals.scm
query found for scala
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
- WARNING: No
folds.scm
query found for scala
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
- WARNING: No
indents.scm
query found for scala
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
toml parser healthcheck
- OK: toml parser found.
- OK:
highlights.scm
found.
- OK:
locals.scm
found.
- WARNING: No
folds.scm
query found for toml
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
- WARNING: No
indents.scm
query found for toml
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
rust parser healthcheck
- OK: rust parser found.
- OK:
highlights.scm
found.
- OK:
locals.scm
found.
- WARNING: No
folds.scm
query found for rust
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
- WARNING: No
indents.scm
query found for rust
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
bash parser healthcheck
- OK: bash parser found.
- OK:
highlights.scm
found.
- OK:
locals.scm
found.
- WARNING: No
folds.scm
query found for bash
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
- WARNING: No
indents.scm
query found for bash
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
ocaml_interface parser healthcheck
- OK: ocaml_interface parser found.
- OK:
highlights.scm
found.
- OK:
locals.scm
found.
- OK:
folds.scm
found.
- WARNING: No
indents.scm
query found for ocaml_interface
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
javascript parser healthcheck
- OK: javascript parser found.
- OK:
highlights.scm
found.
- OK:
locals.scm
found.
- OK:
folds.scm
found.
- WARNING: No
indents.scm
query found for javascript
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
css parser healthcheck
- OK: css parser found.
- OK:
highlights.scm
found.
- WARNING: No
locals.scm
query found for css
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
- WARNING: No
folds.scm
query found for css
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
- OK:
indents.scm
found.
julia parser healthcheck
- OK: julia parser found.
- WARNING: No
highlights.scm
query found for julia
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
- WARNING: No
locals.scm
query found for julia
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
- WARNING: No
folds.scm
query found for julia
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
- WARNING: No
indents.scm
query found for julia
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
graphql parser healthcheck
- OK: graphql parser found.
- OK:
highlights.scm
found.
- WARNING: No
locals.scm
query found for graphql
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
- WARNING: No
folds.scm
query found for graphql
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
- WARNING: No
indents.scm
query found for graphql
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
haskell parser healthcheck
- OK: haskell parser found.
- WARNING: No
highlights.scm
query found for haskell
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
- WARNING: No
locals.scm
query found for haskell
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
- WARNING: No
folds.scm
query found for haskell
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
- WARNING: No
indents.scm
query found for haskell
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
c_sharp parser healthcheck
- OK: c_sharp parser found.
- OK:
highlights.scm
found.
- WARNING: No
locals.scm
query found for c_sharp
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
- WARNING: No
folds.scm
query found for c_sharp
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
- WARNING: No
indents.scm
query found for c_sharp
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
tsx parser healthcheck
- OK: tsx parser found.
- OK:
highlights.scm
found.
- OK:
locals.scm
found.
- OK:
folds.scm
found.
- WARNING: No
indents.scm
query found for tsx
- ADVICE:
- Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
Output of nvim --version
NVIM v0.5.0-901-gf5e0f1796
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3
Compilation: /usr/bin/cc -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -O2 -g -Og -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/home/sharks/source/neovim/build/config -I/home/sharks/source/neovim/src -I/home/sharks/source/neovim/.deps/usr/include -I/usr/include -I/home/sharks/source/neovim/build/src/nvim/auto -I/home/sharks/source/neovim/build/include
Additional context
Add any other context about the problem here.
Is your feature request related to a problem? Please describe.
Code comments are usually hard-wrapped, so I use gw
/ gq
to reflow long multiline comments when editing them. Unfortunately, when these are not separated by an empty line from preceding and following code, then the ip
(inner paragraph) text object includes that as well, so gwip
/ gqip
reflows even the code (which is unwanted and very probably wrong). So you have to resort to first visually selecting the comment and then gw
/ gq
.
Describe the solution you'd like
I'd love to use treesitter + @comment.outer
to invoke gw
/ gq
over the appropriate range of text. However, @comment.outer
currently doesn't span multiline comments, it only extends to the current line. Would it be realistic to redefine it, so that e.g. gwac
(if ac
is configured as the @comment.outer
text object) reflows the entire multiline comment?
Describe alternatives you've considered
If redefining @comment.outer
is doable but not desirable for backwards compatibility reasons, then maybe a new textobject could be provided, something like @multiline_comment.outer
?
Additional context
I'm specifically interesting in Python, but once a solution exists for one language, it should be fairly easy to extend it to other ones with similar syntax?
Is your feature request related to a problem? Please describe.
I want a way to distinguish between methods and functions in JavaScript and other languages.
Describe the solution you'd like
I'd like:
goto_next_start = {
["]k"] = "@class.outer",
["]m"] = "(method_definition) @function",
["]f"] = "@function.outer",
["]b"] = "@block.outer",
}
to work (I realize I'm not specifying javascript
for ]m
but I was just testing it out before cleaning it up.
Describe alternatives you've considered
None
Additional context
I'd like to do something like this eventually:
goto_next_start = {
["]k"] = "@class.outer",
["]m"] = {
javascript: "(method_definition) @function",
java = "(method_declaration) @function",
"@function.outer"
}
["]f"] = "@function.outer",
["]b"] = "@block.outer",
}
So that I can correctly move from method to method in the languages I most often work with and fall back to the more generic solution when an override isn't defined.
Describe the bug
I use Neovim nightly (0.6.0)
I can't install the plugin with packer.
To Reproduce
inside my startup function from packer I have:
local use = require('packer').use
require('packer').startup(function()
-- Package manager
use 'wbthomason/packer.nvim'
-- Libs lua
use({
'nvim-lua/plenary.nvim',
'nvim-lua/popup.nvim',
})
-- Treesitter
use({
'nvim-treesitter/nvim-treesitter',
config = [[ require('modules.plugins.treesitter') ]],
requires = {
'nvim-treesitter/nvim-treesitter-textobjects'
},
run = ':TSUpdate',
})
-- Lsp
use({
'neovim/nvim-lspconfig',
-- 'ray-x/lsp_signature.nvim',
'jose-elias-alvarez/nvim-lsp-ts-utils',
'jose-elias-alvarez/null-ls.nvim',
requires = {
'nvim-lua/plenary.nvim',
'neovim/nvim-lspconfig',
},
})
-- Completion
use({
'hrsh7th/nvim-cmp',
'hrsh7th/cmp-nvim-lsp',
'hrsh7th/cmp-buffer',
'hrsh7th/cmp-path',
'hrsh7th/cmp-nvim-lua',
'lukas-reineke/cmp-rg',
})
-- File explorer
use({
'kyazdani42/nvim-tree.lua',
requires = 'kyazdani42/nvim-web-devicons',
config = [[ require('modules.plugins.nvimtree') ]],
})
-- Dev tools
use({
'editorconfig/editorconfig-vim',
})
use 'windwp/nvim-autopairs'
use({
'norcalli/nvim-colorizer.lua',
config = [[require('modules.plugins.colorizer')]],
})
use 'tpope/vim-commentary' -- "gc" to comment visual regions/lines
-- Telescope
use { 'nvim-telescope/telescope.nvim', requires = { 'nvim-lua/plenary.nvim', 'nvim-lua/popup.nvim' } }
use 'nvim-telescope/telescope-fzf-native.nvim'
-- Theme
use({
'Mofiqul/dracula.nvim',
'marko-cerovac/material.nvim',
'kyazdani42/nvim-web-devicons',
})
-- Statusline
use({
'nvim-lualine/lualine.nvim',
requires = {
'nvim-web-devicons',
},
})
use 'arkav/lualine-lsp-progress' -- Integration with progress notifications
-- i3 support
use({
'mboughaba/i3config.vim',
config = function() require('i3config').setup() end
})
end)
I have the following error when I try to install it with packer:
nvim-treesitter/nvim-treesitter-textobjects: failed to install
Expected behavior
nvim-treesitter-textobjects should be installed.
Output of nvim --version
NVIM v0.6.0-dev+600-gf71be1f87
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3
Compilation: /usr/bin/gcc-11 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DNVIM_TS_HAS_SET_MATCH_LIMIT -O2 -g -Og -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=always -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/home/runner/work/neovim/neovim/build/config -I/home/runner/work/neovim/neovim/src -I/home/runner/work/neovim/neovim/.deps/usr/include -I/usr/include -I/home/runner/work/neovim/neovim/build/src/nvim/auto -I/home/runner/work/neovim/neovim/build/include
Compilé par runner@fv-az121-63
Features: +acl +iconv +tui
See ":help feature-compile"
fichier vimrc système : "$VIM/sysinit.vim"
$VIM par défaut : "/share/nvim"
Run :checkhealth for more info
Is your feature request related to a problem? Please describe.
When attempting to make linewise selection of a textobject (for example, with Vaf
for function.outer
) I expect it to become linewise selection. Instead it is forced to be a regular selection (like an outcome of vaf
). This is a consequence of how nvim-treesitter.ts_utils.update_selection()
operates: it selects exactly the textobject forcing regular visual selection.
Linewise selection is useful, for example, when you want to delete lines with indented function definition.
Describe the solution you'd like
Making explicit linewise visual selection possible.
Describe alternatives you've considered
Technically, adding extra V
keystroke solves the issue: vafV
forces linewise selection. However, it seems to present a little unnecessary cognitive load compared to regular vim experience.
Additional context
I will make a PR which utilizes the equivalence of expected Vaf
and vafV
.
For example, cursor is under if
condition, I can navigate to the end or start of current if
condition
In our CI the zig queries are currently failing (probably due to new parser). @maxxnino could you update the queries or remove them entirely?
Is your feature request related to a problem? Please describe.
I would like to be able to have string textobjects so I can e.g. replace the content of a string with my clipboard
Describe the solution you'd like
@string.outer
that includes the quotes and @string.inner
that doesn't include the quotes
Describe alternatives you've considered
N/A
Additional context
N/A
There is https://github.com/whatyouhide/vim-textobj-xmlattr plugin, and it' not maintained unfortunately. It doesn't work with jsx files, it doesn't handle cases where there is a space between an attribute key and a value. Is it possible to replicated it with the help of treesitter?
Probably related to the new switch statements
https://github.com/nvim-treesitter/nvim-treesitter-textobjects/runs/2372061753?check_suite_focus=true
Although the original incremental selection is good, it can be improved. It goes from the very bottom to the top, which can be tedious sometimes. Leveraging text objects, we can ensure that what we select are always that text object we specified earlier.
Refined incremental selection work this way:
User type some command that specify a text object and enter visual mode.
When user increase or decrease the node in the syntax tree, he can only reach a new text object (or syntax structure) that can match the query.
I have some time and I'm happy to contribute this feature. XD
Due to branch protection rules it can not directly push to master anymore.
Possible solutions:
If I have a piece of code f(a, b, c, d)
and I put my cursor on a
and perform swap_next for @parameter.inner
, it does not compose with .
; after the initial swap I have f(b, a, c, d)
with the cursor still on a
, and I would expect that .
would once more do another swap (leaving f(b, c, a, d)
). Instead .
ignores the swap does whatever happened before that (eg an insertion).
Thanks for this plugin, by the way; enabling this kind of thing is to me one of the most exciting outcomes of treesitter.
Describe the bug
Help tags are duplicated from nvim-treesitter:
Error generating helptags:
Vim(helptags):E154: Duplicate tag "nvim-treesitter-text-objects-move-submod" in file ...
$ rg nvim-treesitter-text-objects-move-submod
nvim-treesitter/nvim-treesitter/doc/nvim-treesitter.txt
356: *nvim-treesitter-text-objects-move-submod*
nvim-treesitter/nvim-treesitter-textobjects/doc/nvim-treesitter-textobjects.txt
77: *nvim-treesitter-text-objects-move-submod*
Hey guys,
I prefer to use <cmd>
for my mappings in general for all the documented benefits (always clean commands, no silent required, performance, clean command history, ...). Unfortunately this does not work for the TSTextobjectSelect
command in visual mode.
This mapping does not work. The result is that the visual selections gets quit and and cursor jumps to the end of the textobject (here the function).
vnoremap af <cmd>TSTextobjectSelect @function.outer<CR>
But it works if I write the mapping like this:
vnoremap af :<C-u>TSTextobjectSelect @function.outer<CR>
Is it possible to patch the command to work with the <cmd>
mapping syntax?
Describe the bug
I am unable to define custom textobjects for the select submodule.
To Reproduce
Config:
require'nvim-treesitter.configs'.setup {
textobjects = {
select = {
enable = true,
keymaps = {
-- Or you can define your own textobjects like this
["iF"] = {
python = "(function_definition) @function",
cpp = "(function_definition) @function",
c = "(function_definition) @function",
java = "(method_declaration) @function",
},
},
},
},
}
C file:
int foo() {
}
Doing viF
results in E5108: Error executing lua ...ckpack/opt/nvim-treesitter/lua/nvim-treesitter/query.lua:144: attempt to index local 'query' (a nil value)
.
Expected behavior
I expect the function to be selected.
Output of :checkhealth nvim_treesitter
health#nvim_treesitter#check
Installation
- OK:
tree-sitter
found 0.19.4 (4e321f34a0688f2ad0ce6ec32d0700b039e8436c) (parser generator, only needed for :TSInstallFromGrammar)
- OK:
node
found v12.16.3 (only needed for :TSInstallFromGrammar)
- OK:
git
executable found.
- OK:
cc
executable found. Selected from { vim.NIL, "cc", "gcc", "clang", "cl" }
- OK: Neovim was compiled with tree-sitter runtime ABI version 13 (required >=13). Parsers must be compatible with runtime ABI.
Parser/Features H L F I
- swift . . . .
- fortran ✓ . ✓ .
- c_sharp ✓ . . .
- rust ✓ ✓ ✓ ✓
- go ✓ ✓ ✓ ✓
- ledger ✓ . ✓ ✓
- ruby ✓ ✓ ✓ ✓
- zig ✓ ✓ ✓ ✓
- rst ✓ ✓ . .
- bibtex ✓ . ✓ ✓
- fennel ✓ ✓ . .
- latex ✓ . ✓ .
- teal ✓ ✓ ✓ ✓
- gomod ✓ . . .
- beancount ✓ . ✓ .
- graphql ✓ . . ✓
- r ✓ ✓ . .
- glimmer ✓ . . .
- verilog ✓ ✓ ✓ .
- jsonc ✓ ✓ ✓ ✓
- bash ✓ ✓ ✓ .
- elm . . . .
- c ✓ ✓ ✓ ✓
- comment ✓ . . .
- dart ✓ ✓ . ✓
- fish ✓ ✓ ✓ ✓
- sparql ✓ ✓ ✓ ✓
- query ✓ ✓ ✓ ✓
- jsdoc ✓ . . .
- php x x ✓ ✓
- regex ✓ . . .
- ql ✓ ✓ . ✓
- gdscript x x . .
- nix x x x .
- typescript ✓ ✓ ✓ ✓
- yaml x x ✓ ✓
- turtle ✓ ✓ ✓ ✓
- html ✓ ✓ ✓ ✓
- devicetree x x x x
- julia ✓ ✓ ✓ .
- json ✓ ✓ ✓ ✓
- javascript ✓ ✓ ✓ ✓
- svelte x . ✓ ✓
- css ✓ . ✓ ✓
- supercollider x x x x
- scss ✓ . . ✓
- haskell . . . .
- erlang . . . .
- toml ✓ ✓ ✓ ✓
- scala . . . .
- elixir ✓ ✓ . ✓
- tsx ✓ ✓ ✓ ✓
- clojure ✓ ✓ ✓ .
- kotlin ✓ . . .
- ocaml x ✓ ✓ .
- commonlisp ✓ ✓ ✓ .
- vue ✓ . ✓ .
- python ✓ ✓ ✓ ✓
- lua ✓ ✓ ✓ ✓
- ocaml_interfacex ✓ ✓ .
- java x ✓ . ✓
- cpp ✓ ✓ ✓ ✓
- ocamllex x . . .
- dockerfile ✓ . . .
Legend: H[ighlight], L[ocals], F[olds], I[ndents]
+) multiple parsers found, only one will be used
x) errors found in the query, try to run :TSUpdate {lang}
The following errors have been detected:
- ERROR: php(highlights): /usr/local/share/nvim/runtime/lua/vim/treesitter/query.lua:161: query: invalid node type at position 100
- ERROR: php(locals): /usr/local/share/nvim/runtime/lua/vim/treesitter/query.lua:161: query: invalid node type at position 987
- ERROR: gdscript(highlights): ...local/share/nvim/runtime/lua/vim/treesitter/language.lua:33: ABI version mismatch for /Users/rethy/.local/share/nvim/site/pack/backpack/opt/nvim-treesitter/parser/gdscript.so: supported between 13 and 13, found 12
- ERROR: gdscript(locals): ...local/share/nvim/runtime/lua/vim/treesitter/language.lua:33: ABI version mismatch for /Users/rethy/.local/share/nvim/site/pack/backpack/opt/nvim-treesitter/parser/gdscript.so: supported between 13 and 13, found 12
- ERROR: nix(highlights): ...local/share/nvim/runtime/lua/vim/treesitter/language.lua:33: ABI version mismatch for /Users/rethy/.local/share/nvim/site/pack/backpack/opt/nvim-treesitter/parser/nix.so: supported between 13 and 13, found 12
- ERROR: nix(locals): ...local/share/nvim/runtime/lua/vim/treesitter/language.lua:33: ABI version mismatch for /Users/rethy/.local/share/nvim/site/pack/backpack/opt/nvim-treesitter/parser/nix.so: supported between 13 and 13, found 12
- ERROR: nix(folds): ...local/share/nvim/runtime/lua/vim/treesitter/language.lua:33: ABI version mismatch for /Users/rethy/.local/share/nvim/site/pack/backpack/opt/nvim-treesitter/parser/nix.so: supported between 13 and 13, found 12
- ERROR: yaml(highlights): /usr/local/share/nvim/runtime/lua/vim/treesitter/query.lua:161: query: invalid node type at position 291
- ERROR: yaml(locals): /usr/local/share/nvim/runtime/lua/vim/treesitter/query.lua:161: query: invalid node type at position 20
- ERROR: devicetree(highlights): ...local/share/nvim/runtime/lua/vim/treesitter/language.lua:33: ABI version mismatch for /Users/rethy/.local/share/nvim/site/pack/backpack/opt/nvim-treesitter/parser/devicetree.so: supported between 13 and 13, found 12
- ERROR: devicetree(locals): ...local/share/nvim/runtime/lua/vim/treesitter/language.lua:33: ABI version mismatch for /Users/rethy/.local/share/nvim/site/pack/backpack/opt/nvim-treesitter/parser/devicetree.so: supported between 13 and 13, found 12
- ERROR: devicetree(folds): ...local/share/nvim/runtime/lua/vim/treesitter/language.lua:33: ABI version mismatch for /Users/rethy/.local/share/nvim/site/pack/backpack/opt/nvim-treesitter/parser/devicetree.so: supported between 13 and 13, found 12
- ERROR: devicetree(indents): ...local/share/nvim/runtime/lua/vim/treesitter/language.lua:33: ABI version mismatch for /Users/rethy/.local/share/nvim/site/pack/backpack/opt/nvim-treesitter/parser/devicetree.so: supported between 13 and 13, found 12
- ERROR: svelte(highlights): /usr/local/share/nvim/runtime/lua/vim/treesitter/query.lua:161: query: invalid node type at position 17
- ERROR: supercollider(highlights): ...local/share/nvim/runtime/lua/vim/treesitter/language.lua:33: ABI version mismatch for /Users/rethy/.local/share/nvim/site/pack/backpack/opt/nvim-treesitter/parser/supercollider.so: supported between 13 and 13, found 12
- ERROR: supercollider(locals): ...local/share/nvim/runtime/lua/vim/treesitter/language.lua:33: ABI version mismatch for /Users/rethy/.local/share/nvim/site/pack/backpack/opt/nvim-treesitter/parser/supercollider.so: supported between 13 and 13, found 12
- ERROR: supercollider(folds): ...local/share/nvim/runtime/lua/vim/treesitter/language.lua:33: ABI version mismatch for /Users/rethy/.local/share/nvim/site/pack/backpack/opt/nvim-treesitter/parser/supercollider.so: supported between 13 and 13, found 12
- ERROR: supercollider(indents): ...local/share/nvim/runtime/lua/vim/treesitter/language.lua:33: ABI version mismatch for /Users/rethy/.local/share/nvim/site/pack/backpack/opt/nvim-treesitter/parser/supercollider.so: supported between 13 and 13, found 12
- ERROR: ocaml(highlights): /usr/local/share/nvim/runtime/lua/vim/treesitter/query.lua:161: query: invalid node type at position 2729
- ERROR: ocaml_interface(highlights): /usr/local/share/nvim/runtime/lua/vim/treesitter/query.lua:161: query: invalid node type at position 2729
- ERROR: java(highlights): /usr/local/share/nvim/runtime/lua/vim/treesitter/query.lua:161: query: invalid node type at position 2209
- ERROR: ocamllex(highlights): ...local/share/nvim/runtime/lua/vim/treesitter/language.lua:33: ABI version mismatch for /Users/rethy/.local/share/nvim/site/pack/backpack/opt/nvim-treesitter/parser/ocamllex.so: supported between 13 and 13, found 11
Output of nvim --version
NVIM v0.5.0-dev+1311-gf8173df4d
Build type: Debug
LuaJIT 2.1.0-beta3
Compilation: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=always -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=1 -I/Users/rethy/neovim/build/config -I/Users/rethy/neovim/src -I/Users/rethy/neovim/.deps/usr/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include -I/Library/Frameworks/Mono.framework/Headers -I/Users/rethy/neovim/build/src/nvim/auto -I/Users/rethy/neovim/build/include
Compiled by [email protected]
Features: +acl +iconv +tui
See ":help feature-compile"
system vimrc file: "$VIM/sysinit.vim"
fall-back for $VIM: "/usr/local/share/nvim"
Run :checkhealth for more info
Additional context
I looked at the code and I don't think it should work unless I misunderstand the following snippet:
shared.lua
local parser = parsers.get_parser(bufnr, lang)
parser:for_each_tree(function(tree, lang_tree)
local lang = lang_tree:lang()
local start_row, _, end_row, _ = tree:root():range()
local query = queries.get_query(lang, 'textobjects')
for m in queries.iter_prepared_matches(query, tree:root(), bufnr, start_row, end_row) do
for _, n in pairs(m) do
if n.node then
table.insert(matches, n)
end
end
end
end)
Is your feature request related to a problem? Please describe.
I'm always frustrated when [not a problem exactly, but when textobject/move adds to jumplist.]
Describe the solution you'd like
I would like to just move away to my hearts content around the code and not worry about populating the jumplist with [email protected], etc..
Additional context
Textobjects/move is a great feature. it makes navigating through code so much more intuitive, especially in large pages. But I would like to keep the jumplist separate so I can navigate back only to places where I have some edits instead of revisiting random "inspection" jumps from the past. It would make the move module even more necessary and good to use.
Goes without saying, thanks for this plugin, for me personally this and playground are the most important tree-sitter modules to be!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.