diff options
| author | Christian Clason <c.clason@uni-graz.at> | 2023-05-20 17:29:03 +0200 |
|---|---|---|
| committer | Christian Clason <c.clason@uni-graz.at> | 2025-05-12 18:43:40 +0200 |
| commit | 5817ff01b523a0dce5e7a42374ac137cb6490577 (patch) | |
| tree | bf2bcb2d3add6285bb0b6a4c72065d6ce20d0718 | |
| parent | feat!: drop modules, general refactor and cleanup (diff) | |
| download | nvim-treesitter-5817ff01b523a0dce5e7a42374ac137cb6490577.tar nvim-treesitter-5817ff01b523a0dce5e7a42374ac137cb6490577.tar.gz nvim-treesitter-5817ff01b523a0dce5e7a42374ac137cb6490577.tar.bz2 nvim-treesitter-5817ff01b523a0dce5e7a42374ac137cb6490577.tar.lz nvim-treesitter-5817ff01b523a0dce5e7a42374ac137cb6490577.tar.xz nvim-treesitter-5817ff01b523a0dce5e7a42374ac137cb6490577.tar.zst nvim-treesitter-5817ff01b523a0dce5e7a42374ac137cb6490577.zip | |
feat(locals)!: refactor `locals.lua` into standalone
Co-authored-by: TheLeoP <eugenio2305@hotmail.com>
| -rw-r--r-- | README.md | 4 | ||||
| -rw-r--r-- | SUPPORTED_LANGUAGES.md | 554 | ||||
| -rw-r--r-- | TODO.md | 4 | ||||
| -rw-r--r-- | lua/nvim-treesitter/locals.lua | 218 | ||||
| -rw-r--r-- | lua/nvim-treesitter/query.lua | 165 | ||||
| -rwxr-xr-x | scripts/update-readme.lua | 1 |
6 files changed, 418 insertions, 528 deletions
@@ -119,6 +119,10 @@ vim.bo.indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()" Injections are used for multi-language documents, see `:h treesitter-language-injections`. No setup is needed. +## Locals + +These queries can be used to look up definitions and references to identifiers in a given scope. They are used, e.g., by the `nvim-treesitter-refactor` plugin. + # Advanced setup ## Adding parsers diff --git a/SUPPORTED_LANGUAGES.md b/SUPPORTED_LANGUAGES.md index a388c9c9a..aef22b34d 100644 --- a/SUPPORTED_LANGUAGES.md +++ b/SUPPORTED_LANGUAGES.md @@ -6,288 +6,288 @@ Legend: - **Tier:** _core_, _stable_, _community_, or _unstable_ - **CLI:** `:TSInstall` requires `tree-sitter` CLI installed - **NPM:** `:TSInstallFromGrammar` requires `node` installed -- **Queries** available for **H**ighlights, **I**ndents, **F**olds, In**J**ections +- **Queries** available for **H**ighlights, **I**ndents, **F**olds, In**J**ections, **L**ocals <!--This section of the README is automatically updated by a CI job--> <!--parserinfo--> Language | Tier | Queries | CLI | NPM | Maintainer -------- |:----:|:-------:|:---:|:---:| ---------- -[ada](https://github.com/briot/tree-sitter-ada) | | `HF ` | | | @briot -[agda](https://github.com/tree-sitter/tree-sitter-agda) | | `HF ` | | | @Decodetalkers -[angular](https://github.com/dlvandenberg/tree-sitter-angular) | unstable | `HFIJ` | | ✓ | @dlvandenberg -[apex](https://github.com/aheber/tree-sitter-sfapex) | community | `HF ` | | | @aheber -[arduino](https://github.com/ObserverOfTime/tree-sitter-arduino) | | `HFIJ` | | | @ObserverOfTime -[asm](https://github.com/RubixDev/tree-sitter-asm) | community | `H J` | | | @RubixDev -[astro](https://github.com/virchau13/tree-sitter-astro) | | `HFIJ` | | | @virchau13 -[authzed](https://github.com/mleonidas/tree-sitter-authzed) | community | `H J` | | | @mattpolzin -[awk](https://github.com/Beaglefoot/tree-sitter-awk) | | `H J` | | | -[bash](https://github.com/tree-sitter/tree-sitter-bash) | | `HF J` | | | @TravonteD -[bass](https://github.com/vito/tree-sitter-bass) | | `HFIJ` | | | @amaanq -[beancount](https://github.com/polarmutex/tree-sitter-beancount) | | `HF J` | | | @polarmutex -[bibtex](https://github.com/latex-lsp/tree-sitter-bibtex) | community | `HFI ` | | | @theHamsta, @clason -[bicep](https://github.com/amaanq/tree-sitter-bicep) | | `HFIJ` | | | @amaanq -[bitbake](https://github.com/amaanq/tree-sitter-bitbake) | stable | `HFIJ` | | | @amaanq -[blueprint](https://gitlab.com/gabmus/tree-sitter-blueprint.git) | unstable | `H ` | | | @gabmus -[c](https://github.com/tree-sitter/tree-sitter-c) | core | `HFIJ` | | | @amaanq -[c_sharp](https://github.com/tree-sitter/tree-sitter-c-sharp) | | `HF J` | | | @Luxed -[cairo](https://github.com/amaanq/tree-sitter-cairo) | stable | `HFIJ` | | | @amaanq -[capnp](https://github.com/amaanq/tree-sitter-capnp) | | `HFIJ` | | | @amaanq -[chatito](https://github.com/ObserverOfTime/tree-sitter-chatito) | | `HFIJ` | | | @ObserverOfTime -[clojure](https://github.com/sogaiu/tree-sitter-clojure) | | `HF J` | | | @NoahTheDuke -[cmake](https://github.com/uyha/tree-sitter-cmake) | | `HFI ` | | | @uyha -[comment](https://github.com/stsewd/tree-sitter-comment) | stable | `H ` | | | @stsewd -[commonlisp](https://github.com/theHamsta/tree-sitter-commonlisp) | | `HF ` | | ✓ | @theHamsta -[cooklang](https://github.com/addcninblue/tree-sitter-cooklang) | community | `H ` | | | @addcninblue -[corn](https://github.com/jakestanger/tree-sitter-corn) | community | `HFI ` | | | @jakestanger -[cpon](https://github.com/amaanq/tree-sitter-cpon) | | `HFIJ` | | | @amaanq -[cpp](https://github.com/tree-sitter/tree-sitter-cpp) | | `HFIJ` | | ✓ | @theHamsta -[css](https://github.com/tree-sitter/tree-sitter-css) | | `HFIJ` | | | @TravonteD -[csv](https://github.com/amaanq/tree-sitter-csv) | stable | `H ` | | | @amaanq -[cuda](https://github.com/theHamsta/tree-sitter-cuda) | | `HFIJ` | | ✓ | @theHamsta -[cue](https://github.com/eonpatapon/tree-sitter-cue) | | `HFIJ` | | | @amaanq -[d](https://github.com/gdamore/tree-sitter-d) | stable | `HFIJ` | | | @amaanq -[dart](https://github.com/UserNobody14/tree-sitter-dart) | | `HFIJ` | | | @akinsho -[devicetree](https://github.com/joelspadin/tree-sitter-devicetree) | | `HFIJ` | | | @jedrzejboczar -[dhall](https://github.com/jbellerb/tree-sitter-dhall) | | `HF J` | | | @amaanq -[diff](https://github.com/the-mikedavis/tree-sitter-diff) | | `H ` | | | @gbprod -[disassembly](https://github.com/ColinKennedy/tree-sitter-disassembly) | community | `H J` | | | @ColinKennedy -[djot](https://github.com/treeman/tree-sitter-djot) | community | `HFIJ` | | | @NoahTheDuke -[dockerfile](https://github.com/camdencheek/tree-sitter-dockerfile) | | `H J` | | | @camdencheek -[dot](https://github.com/rydesun/tree-sitter-dot) | | `H IJ` | | | @rydesun -[doxygen](https://github.com/amaanq/tree-sitter-doxygen) | stable | `H IJ` | | | @amaanq -[dtd](https://github.com/tree-sitter-grammars/tree-sitter-xml) | stable | `HF J` | | | @ObserverOfTime -[earthfile](https://github.com/glehmann/tree-sitter-earthfile) | community | `H J` | | | @glehmann -[ebnf](https://github.com/RubixDev/ebnf) | unstable | `H ` | | | @RubixDev -[eds](https://github.com/uyha/tree-sitter-eds) | community | `HF ` | | | @uyha -[eex](https://github.com/connorlay/tree-sitter-eex) | | `H J` | | | @connorlay -[elixir](https://github.com/elixir-lang/tree-sitter-elixir) | | `HFIJ` | | | @connorlay -[elm](https://github.com/elm-tooling/tree-sitter-elm) | | `H J` | | | @zweimach -[elsa](https://github.com/glapa-grossklag/tree-sitter-elsa) | | `HFIJ` | | | @glapa-grossklag, @amaanq -[elvish](https://github.com/elves/tree-sitter-elvish) | | `H J` | | | @elves -[embedded_template](https://github.com/tree-sitter/tree-sitter-embedded-template) | | `H J` | | | -[erlang](https://github.com/WhatsApp/tree-sitter-erlang) | | `HF ` | | | @filmor -[facility](https://github.com/FacilityApi/tree-sitter-facility) | community | `HFIJ` | | | @bryankenote -[faust](https://github.com/khiner/tree-sitter-faust) | community | `H J` | | | @khiner -[fennel](https://github.com/alexmozaidze/tree-sitter-fennel) | | `HF J` | | ✓ | @alexmozaidze -[fidl](https://github.com/google/tree-sitter-fidl) | community | `HF J` | | | @chaopeng -[firrtl](https://github.com/amaanq/tree-sitter-firrtl) | | `HFIJ` | | | @amaanq -[fish](https://github.com/ram02z/tree-sitter-fish) | | `HFIJ` | | | @ram02z -[foam](https://github.com/FoamScience/tree-sitter-foam) | unstable | `HFIJ` | | | @FoamScience -[forth](https://github.com/AlexanderBrevig/tree-sitter-forth) | stable | `HFIJ` | | | @amaanq -[fortran](https://github.com/stadelmanma/tree-sitter-fortran) | | `HFI ` | | | @amaanq -[fsh](https://github.com/mgramigna/tree-sitter-fsh) | | `H ` | | | @mgramigna -[func](https://github.com/amaanq/tree-sitter-func) | | `H ` | | | @amaanq -[fusion](https://gitlab.com/jirgn/tree-sitter-fusion.git) | | `HFI ` | | | @jirgn -[gdscript](https://github.com/PrestonKnopp/tree-sitter-gdscript)[^gdscript] | | `HFIJ` | | | @PrestonKnopp -[gdshader](https://github.com/GodOfAvacyn/tree-sitter-gdshader) | community | `H J` | | | @godofavacyn -[git_config](https://github.com/the-mikedavis/tree-sitter-git-config)[^git_config] | | `HF J` | | | @amaanq -[git_rebase](https://github.com/the-mikedavis/tree-sitter-git-rebase) | | `H J` | | | @gbprod -[gitattributes](https://github.com/ObserverOfTime/tree-sitter-gitattributes) | | `H J` | | | @ObserverOfTime -[gitcommit](https://github.com/gbprod/tree-sitter-gitcommit) | | `H J` | | | @gbprod -[gitignore](https://github.com/shunsambongi/tree-sitter-gitignore) | | `H ` | | | @theHamsta -[gleam](https://github.com/gleam-lang/tree-sitter-gleam) | | `HFIJ` | | | @amaanq -[glimmer](https://github.com/alexlafroscia/tree-sitter-glimmer)[^glimmer] | | `HFI ` | | | @NullVoxPopuli -[glsl](https://github.com/theHamsta/tree-sitter-glsl) | | `HFIJ` | | ✓ | @theHamsta -[gn](https://github.com/amaanq/tree-sitter-gn) | stable | `HFIJ` | | | @amaanq -[gnuplot](https://github.com/dpezto/tree-sitter-gnuplot) | community | `H J` | | | @dpezto -[go](https://github.com/tree-sitter/tree-sitter-go) | | `HFIJ` | | | @theHamsta, @WinWisely268 -[godot_resource](https://github.com/PrestonKnopp/tree-sitter-godot-resource)[^godot_resource] | | `HF J` | | | @pierpo -[gomod](https://github.com/camdencheek/tree-sitter-go-mod) | | `H J` | | | @camdencheek -[gosum](https://github.com/amaanq/tree-sitter-go-sum) | | `H ` | | | @amaanq -[gotmpl](https://github.com/ngalaiko/tree-sitter-go-template) | community | `H J` | | | @qvalentin -[gowork](https://github.com/omertuc/tree-sitter-go-work) | | `H J` | | | @omertuc -[gpg](https://github.com/ObserverOfTime/tree-sitter-gpg-config) | stable | `H J` | | | @ObserverOfTime -[graphql](https://github.com/bkegley/tree-sitter-graphql) | | `H IJ` | | | @bkegley -[groovy](https://github.com/murtaza64/tree-sitter-groovy) | community | `HFIJ` | | | @murtaza64 -[gstlaunch](https://github.com/theHamsta/tree-sitter-gstlaunch) | stable | `H ` | | | @theHamsta -[hack](https://github.com/slackhq/tree-sitter-hack) | | `H ` | | | -[hare](https://github.com/amaanq/tree-sitter-hare) | | `HFIJ` | | | @amaanq -[haskell](https://github.com/tree-sitter/tree-sitter-haskell) | | `HF J` | | | @mrcjkb -[haskell_persistent](https://github.com/MercuryTechnologies/tree-sitter-haskell-persistent) | | `HF ` | | | @lykahb -[hcl](https://github.com/MichaHoffmann/tree-sitter-hcl) | | `HFIJ` | | | @MichaHoffmann -[heex](https://github.com/connorlay/tree-sitter-heex) | | `HFIJ` | | | @connorlay -[helm](https://github.com/ngalaiko/tree-sitter-go-template) | community | `H J` | | | @qvalentin -[hjson](https://github.com/winston0410/tree-sitter-hjson) | | `HFIJ` | | ✓ | @winston0410 -[hlsl](https://github.com/theHamsta/tree-sitter-hlsl) | | `HFIJ` | | ✓ | @theHamsta -[hlsplaylist](https://github.com/Freed-Wu/tree-sitter-hlsplaylist) | community | `H J` | | | @Freed-Wu -[hocon](https://github.com/antosha417/tree-sitter-hocon) | | `HF J` | | ✓ | @antosha417 -[hoon](https://github.com/urbit-pilled/tree-sitter-hoon) | unstable | `HF ` | | | @urbit-pilled -[html](https://github.com/tree-sitter/tree-sitter-html) | | `HFIJ` | | | @TravonteD -[htmldjango](https://github.com/interdependence/tree-sitter-htmldjango) | unstable | `HFIJ` | | | @ObserverOfTime -[http](https://github.com/rest-nvim/tree-sitter-http) | | `H J` | | | @amaanq, @NTBBloodbath -[hurl](https://github.com/pfeiferj/tree-sitter-hurl) | community | `HFIJ` | | | @pfeiferj -[hyprlang](https://github.com/luckasRanarison/tree-sitter-hyprlang) | community | `HFIJ` | | | @luckasRanarison -[idl](https://github.com/cathaysia/tree-sitter-idl) | community | `H J` | | | @cathaysa -[ini](https://github.com/justinmk/tree-sitter-ini) | unstable | `HF ` | | | @theHamsta -[inko](https://github.com/inko-lang/tree-sitter-inko) | community | `HFIJ` | | | @yorickpeterse -[ispc](https://github.com/fab4100/tree-sitter-ispc) | | `HFIJ` | | ✓ | @fab4100 -[janet_simple](https://github.com/sogaiu/tree-sitter-janet-simple) | | `HF J` | | | @sogaiu -[java](https://github.com/tree-sitter/tree-sitter-java) | | `HFIJ` | | | @p00f -[javascript](https://github.com/tree-sitter/tree-sitter-javascript) | | `HFIJ` | | | @steelsojka -[jq](https://github.com/flurie/tree-sitter-jq) | | `H J` | | | @ObserverOfTime -[jsdoc](https://github.com/tree-sitter/tree-sitter-jsdoc) | | `H ` | | | @steelsojka -[json](https://github.com/tree-sitter/tree-sitter-json) | | `HFI ` | | | @steelsojka -[json5](https://github.com/Joakker/tree-sitter-json5) | | `H J` | | | @Joakker -[jsonc](https://gitlab.com/WhyNotHugo/tree-sitter-jsonc.git)[^jsonc] | | `HFIJ` | | ✓ | @WhyNotHugo -[jsonnet](https://github.com/sourcegraph/tree-sitter-jsonnet) | | `HF ` | | | @nawordar -[julia](https://github.com/tree-sitter/tree-sitter-julia) | community | `HFIJ` | | | @theHamsta -[just](https://github.com/IndianBoy42/tree-sitter-just) | community | `HFIJ` | | | @Hubro -[kconfig](https://github.com/amaanq/tree-sitter-kconfig) | stable | `HFIJ` | | | @amaanq -[kdl](https://github.com/amaanq/tree-sitter-kdl) | | `HFIJ` | | | @amaanq -[kotlin](https://github.com/fwcd/tree-sitter-kotlin) | | `HF J` | | | @SalBakraa -[koto](https://github.com/koto-lang/tree-sitter-koto) | community | `HF J` | | | @irh -[kusto](https://github.com/Willem-J-an/tree-sitter-kusto) | community | `H J` | | | @Willem-J-an -[lalrpop](https://github.com/traxys/tree-sitter-lalrpop) | | `H J` | | | @traxys -[latex](https://github.com/latex-lsp/tree-sitter-latex) | community | `HF J` | ✓ | | @theHamsta, @clason -[ledger](https://github.com/cbarrete/tree-sitter-ledger) | | `HFIJ` | | | @cbarrete -[leo](https://github.com/r001/tree-sitter-leo) | community | `H IJ` | | | @r001 -[linkerscript](https://github.com/amaanq/tree-sitter-linkerscript) | stable | `HFIJ` | | | @amaanq -[liquid](https://github.com/hankthetank27/tree-sitter-liquid) | community | `H J` | | | @hankthetank27 -[liquidsoap](https://github.com/savonet/tree-sitter-liquidsoap) | community | `HFI ` | | | @toots -[llvm](https://github.com/benwilliamgraham/tree-sitter-llvm) | | `H ` | | | @benwilliamgraham -[lua](https://github.com/MunifTanjim/tree-sitter-lua) | core | `HFIJ` | | | @muniftanjim -[luadoc](https://github.com/amaanq/tree-sitter-luadoc) | | `H ` | | | @amaanq -[luap](https://github.com/amaanq/tree-sitter-luap)[^luap] | | `H ` | | | @amaanq -[luau](https://github.com/amaanq/tree-sitter-luau) | | `HFIJ` | | | @amaanq -[m68k](https://github.com/grahambates/tree-sitter-m68k) | | `HF J` | | | @grahambates -[make](https://github.com/alemuller/tree-sitter-make) | | `HF J` | | | @lewis6991 -[markdown](https://github.com/MDeiml/tree-sitter-markdown)[^markdown] | core | `HFIJ` | | | @MDeiml -[markdown_inline](https://github.com/MDeiml/tree-sitter-markdown)[^markdown_inline] | core | `H J` | | | @MDeiml -[matlab](https://github.com/acristoffers/tree-sitter-matlab) | | `HFIJ` | | | @acristoffers -[menhir](https://github.com/Kerl13/tree-sitter-menhir) | | `H J` | | | @Kerl13 -[mermaid](https://github.com/monaqa/tree-sitter-mermaid) | unstable | `H ` | | | -[meson](https://github.com/Decodetalkers/tree-sitter-meson) | | `HFIJ` | | | @Decodetalkers -[mlir](https://github.com/artagnon/tree-sitter-mlir) | unstable | `H ` | ✓ | | @artagnon -[muttrc](https://github.com/neomutt/tree-sitter-muttrc) | community | `H J` | | | @Freed-Wu -[nasm](https://github.com/naclsn/tree-sitter-nasm) | stable | `H J` | | | @ObserverOfTime -[nickel](https://github.com/nickel-lang/tree-sitter-nickel) | | `H I ` | | | -[nim](https://github.com/alaviss/tree-sitter-nim) | community | `HF J` | | | @aMOPel -[nim_format_string](https://github.com/aMOPel/tree-sitter-nim-format-string) | community | `H J` | | | @aMOPel -[ninja](https://github.com/alemuller/tree-sitter-ninja) | | `HFI ` | | | @alemuller -[nix](https://github.com/cstrahan/tree-sitter-nix) | | `HF J` | | | @leo60228 -[norg](https://github.com/nvim-neorg/tree-sitter-norg) | unstable | ` ` | | | @JoeyGrajciar, @vhyrro -[nqc](https://github.com/amaanq/tree-sitter-nqc) | stable | `HFIJ` | | | @amaanq -[objc](https://github.com/amaanq/tree-sitter-objc) | | `HFIJ` | | | @amaanq -[objdump](https://github.com/ColinKennedy/tree-sitter-objdump) | community | `H J` | | | @ColinKennedy -[ocaml](https://github.com/tree-sitter/tree-sitter-ocaml) | | `HFIJ` | | | @undu -[ocaml_interface](https://github.com/tree-sitter/tree-sitter-ocaml) | | `HFIJ` | | | @undu -[ocamllex](https://github.com/atom-ocaml/tree-sitter-ocamllex) | | `H J` | ✓ | | @undu -[odin](https://github.com/amaanq/tree-sitter-odin) | | `HFIJ` | | | @amaanq -[org](https://github.com/milisims/tree-sitter-org) | | ` ` | | | -[pascal](https://github.com/Isopod/tree-sitter-pascal.git) | | `HFIJ` | | | @Isopod -[passwd](https://github.com/ath3/tree-sitter-passwd) | | `H ` | | | @amaanq -[pem](https://github.com/ObserverOfTime/tree-sitter-pem) | stable | `HF J` | | | @ObserverOfTime -[perl](https://github.com/tree-sitter-perl/tree-sitter-perl) | | `HF J` | | | @RabbiVeesh, @LeoNerd -[php](https://github.com/tree-sitter/tree-sitter-php)[^php] | | `HFIJ` | | | @tk-shirasaka -[php_only](https://github.com/tree-sitter/tree-sitter-php)[^php_only] | | `HFIJ` | | | @tk-shirasaka -[phpdoc](https://github.com/claytonrcarter/tree-sitter-phpdoc) | unstable | `H ` | | ✓ | @mikehaertl -[pioasm](https://github.com/leo60228/tree-sitter-pioasm) | | `H J` | | | @leo60228 -[po](https://github.com/erasin/tree-sitter-po) | | `HF J` | | | @amaanq -[pod](https://github.com/tree-sitter-perl/tree-sitter-pod) | community | `H ` | | | @RabbiVeesh, @LeoNerd -[poe_filter](https://github.com/ObserverOfTime/tree-sitter-poe-filter)[^poe_filter] | unstable | `HFIJ` | | | @ObserverOfTime -[pony](https://github.com/amaanq/tree-sitter-pony) | | `HFIJ` | | | @amaanq, @mfelsche -[printf](https://github.com/ObserverOfTime/tree-sitter-printf) | stable | `H ` | | | @ObserverOfTime -[prisma](https://github.com/victorhqc/tree-sitter-prisma) | | `HF ` | | | @elianiva -[promql](https://github.com/MichaHoffmann/tree-sitter-promql) | unstable | `H J` | | | @MichaHoffmann -[properties](https://github.com/ObserverOfTime/tree-sitter-properties)[^properties] | stable | `H J` | | | @ObserverOfTime -[proto](https://github.com/treywood/tree-sitter-proto) | | `HF ` | | | @treywood -[prql](https://github.com/PRQL/tree-sitter-prql) | | `H J` | | | @matthias-Q -[psv](https://github.com/amaanq/tree-sitter-csv) | stable | `H ` | | | @amaanq -[pug](https://github.com/zealot128/tree-sitter-pug) | unstable | `H J` | | | @zealot128 -[puppet](https://github.com/amaanq/tree-sitter-puppet) | | `HFIJ` | | | @amaanq -[purescript](https://github.com/postsolar/tree-sitter-purescript) | community | `H J` | | | @postsolar -[pymanifest](https://github.com/ObserverOfTime/tree-sitter-pymanifest) | stable | `H J` | | | @ObserverOfTime -[python](https://github.com/tree-sitter/tree-sitter-python) | | `HFIJ` | | | @stsewd, @theHamsta -[ql](https://github.com/tree-sitter/tree-sitter-ql) | | `HFIJ` | | | @pwntester -[qmldir](https://github.com/Decodetalkers/tree-sitter-qmldir) | | `H J` | | | @amaanq -[qmljs](https://github.com/yuja/tree-sitter-qmljs) | | `HF J` | | | @Decodetalkers -[query](https://github.com/nvim-treesitter/tree-sitter-query)[^query] | core | `HFIJ` | | | @steelsojka -[r](https://github.com/r-lib/tree-sitter-r) | | `H IJ` | | | @echasnovski -[racket](https://github.com/6cdh/tree-sitter-racket) | unstable | `HF J` | | | -[rasi](https://github.com/Fymyte/tree-sitter-rasi) | | `HFIJ` | | | @Fymyte -[rbs](https://github.com/joker1007/tree-sitter-rbs) | community | `HFIJ` | | | @joker1007 -[re2c](https://github.com/amaanq/tree-sitter-re2c) | stable | `HFIJ` | | | @amaanq -[readline](https://github.com/ribru17/tree-sitter-readline) | community | `HFIJ` | | | @ribru17 -[regex](https://github.com/tree-sitter/tree-sitter-regex) | | `H ` | | | @theHamsta -[rego](https://github.com/FallenAngel97/tree-sitter-rego) | | `H J` | | | @FallenAngel97 -[requirements](https://github.com/ObserverOfTime/tree-sitter-requirements) | stable | `H J` | | | @ObserverOfTime -[rnoweb](https://github.com/bamonroe/tree-sitter-rnoweb) | | `HF J` | | | @bamonroe -[robot](https://github.com/Hubro/tree-sitter-robot) | community | `HFI ` | | | @Hubro -[roc](https://github.com/nat-418/tree-sitter-roc) | community | `H J` | | | @nat-418 -[ron](https://github.com/amaanq/tree-sitter-ron) | | `HFIJ` | | | @amaanq -[rst](https://github.com/stsewd/tree-sitter-rst) | | `H J` | | | @stsewd -[ruby](https://github.com/tree-sitter/tree-sitter-ruby) | | `HFIJ` | | | @TravonteD -[rust](https://github.com/tree-sitter/tree-sitter-rust) | | `HFIJ` | | | @amaanq -[scala](https://github.com/tree-sitter/tree-sitter-scala) | | `HF J` | | | @stevanmilic -[scfg](https://git.sr.ht/~rockorager/tree-sitter-scfg) | community | `H J` | ✓ | | @WhyNotHugo -[scheme](https://github.com/6cdh/tree-sitter-scheme) | unstable | `HF J` | | | -[scss](https://github.com/serenadeai/tree-sitter-scss) | | `HFI ` | | | @elianiva -[slang](https://github.com/theHamsta/tree-sitter-slang)[^slang] | unstable | `HFIJ` | | ✓ | @theHamsta -[slint](https://github.com/slint-ui/tree-sitter-slint) | community | `HFIJ` | | | @hunger -[smali](https://github.com/tree-sitter-grammars/tree-sitter-smali) | community | `HFIJ` | | | @amaanq -[smithy](https://github.com/indoorvivants/tree-sitter-smithy) | | `H ` | | | @amaanq, @keynmol -[snakemake](https://github.com/osthomas/tree-sitter-snakemake) | unstable | `HFIJ` | | | -[solidity](https://github.com/JoranHonig/tree-sitter-solidity) | | `HF ` | | | @amaanq -[soql](https://github.com/aheber/tree-sitter-sfapex) | community | `H ` | | | @aheber -[sosl](https://github.com/aheber/tree-sitter-sfapex) | | `H ` | | | @aheber -[sourcepawn](https://github.com/nilshelmig/tree-sitter-sourcepawn) | community | `H J` | | | @Sarrus1 -[sparql](https://github.com/BonaBeavis/tree-sitter-sparql) | | `HFIJ` | | | @BonaBeavis -[sql](https://github.com/derekstride/tree-sitter-sql) | | `H IJ` | | | @derekstride -[squirrel](https://github.com/amaanq/tree-sitter-squirrel) | | `HFIJ` | | | @amaanq -[ssh_config](https://github.com/ObserverOfTime/tree-sitter-ssh-config) | stable | `HFIJ` | | | @ObserverOfTime -[starlark](https://github.com/amaanq/tree-sitter-starlark) | | `HFIJ` | | | @amaanq -[strace](https://github.com/sigmaSd/tree-sitter-strace) | stable | `H J` | | | @amaanq -[styled](https://github.com/mskelton/tree-sitter-styled) | community | `HFIJ` | | | @mskelton -[supercollider](https://github.com/madskjeldgaard/tree-sitter-supercollider) | | `HFIJ` | | | @madskjeldgaard -[surface](https://github.com/connorlay/tree-sitter-surface) | | `HFIJ` | | | @connorlay -[svelte](https://github.com/tree-sitter-grammars/tree-sitter-svelte) | stable | `HFIJ` | | | @amaanq -[swift](https://github.com/alex-pinkus/tree-sitter-swift) | | `H I ` | ✓ | | @alex-pinkus -[sxhkdrc](https://github.com/RaafatTurki/tree-sitter-sxhkdrc) | | `HF J` | | | @RaafatTurki -[systemtap](https://github.com/ok-ryoko/tree-sitter-systemtap) | community | `HF J` | | | @ok-ryoko -[t32](https://gitlab.com/xasc/tree-sitter-t32.git) | community | `HFIJ` | | | @xasc -[tablegen](https://github.com/amaanq/tree-sitter-tablegen) | | `HFIJ` | | | @amaanq -[tcl](https://github.com/tree-sitter-grammars/tree-sitter-tcl) | stable | `HFI ` | | | @lewis6991 -[teal](https://github.com/euclidianAce/tree-sitter-teal) | | `HFIJ` | ✓ | | @euclidianAce -[templ](https://github.com/vrischmann/tree-sitter-templ) | community | `H J` | | | @vrischmann -[terraform](https://github.com/MichaHoffmann/tree-sitter-hcl) | | `HFIJ` | | | @MichaHoffmann -[textproto](https://github.com/PorterAtGoogle/tree-sitter-textproto) | community | `HFI ` | | | @Porter -[thrift](https://github.com/duskmoon314/tree-sitter-thrift) | | `HFIJ` | | | @amaanq, @duskmoon314 -[tiger](https://github.com/ambroisie/tree-sitter-tiger) | | `HFIJ` | | | @ambroisie -[tlaplus](https://github.com/tlaplus-community/tree-sitter-tlaplus) | | `HF J` | | | @ahelwer, @susliko -[tmux](https://github.com/Freed-Wu/tree-sitter-tmux) | community | `H J` | | | @Freed-Wu -[todotxt](https://github.com/arnarg/tree-sitter-todotxt.git) | unstable | `H ` | | | @arnarg -[toml](https://github.com/tree-sitter-grammars/tree-sitter-toml) | | `HFIJ` | | ✓ | @tk-shirasaka -[tsv](https://github.com/amaanq/tree-sitter-csv) | stable | `H ` | | | @amaanq -[tsx](https://github.com/tree-sitter/tree-sitter-typescript) | | `HFIJ` | | ✓ | @steelsojka -[turtle](https://github.com/BonaBeavis/tree-sitter-turtle) | | `HFIJ` | | | @BonaBeavis -[twig](https://github.com/gbprod/tree-sitter-twig) | | `H J` | | | @gbprod -[typescript](https://github.com/tree-sitter/tree-sitter-typescript) | | `HFIJ` | | ✓ | @steelsojka -[typoscript](https://github.com/Teddytrombone/tree-sitter-typoscript) | community | `HFIJ` | | | @Teddytrombone -[typst](https://github.com/uben0/tree-sitter-typst) | community | `HFIJ` | | | @uben0, @RaafatTurki -[udev](https://github.com/ObserverOfTime/tree-sitter-udev) | stable | `H J` | | | @ObserverOfTime -[ungrammar](https://github.com/Philipp-M/tree-sitter-ungrammar) | | `HFIJ` | | | @Philipp-M, @amaanq -[unison](https://github.com/kylegoetz/tree-sitter-unison) | unstable | `H J` | ✓ | | @tapegram -[usd](https://github.com/ColinKennedy/tree-sitter-usd) | | `HFI ` | | | @ColinKennedy -[uxntal](https://github.com/amaanq/tree-sitter-uxntal) | | `HFIJ` | | | @amaanq -[v](https://github.com/vlang/v-analyzer) | | `HFIJ` | | | @kkharji, @amaanq -[vala](https://github.com/vala-lang/tree-sitter-vala) | | `HF ` | | | @Prince781 -[vento](https://github.com/ventojs/tree-sitter-vento) | community | `H J` | | | @wrapperup, @oscarotero -[verilog](https://github.com/tree-sitter/tree-sitter-verilog) | | `HF J` | | | @zegervdv -[vhs](https://github.com/charmbracelet/tree-sitter-vhs) | | `H ` | | | @caarlos0 -[vim](https://github.com/neovim/tree-sitter-vim) | core | `HF J` | | | @clason -[vimdoc](https://github.com/neovim/tree-sitter-vimdoc) | core | `H J` | | | @clason -[vue](https://github.com/tree-sitter-grammars/tree-sitter-vue) | stable | `HFIJ` | | | @WhyNotHugo, @lucario387 -[wgsl](https://github.com/szebniok/tree-sitter-wgsl) | | `HFI ` | | | @szebniok -[wgsl_bevy](https://github.com/theHamsta/tree-sitter-wgsl-bevy) | | `HFI ` | | ✓ | @theHamsta -[wing](https://github.com/winglang/tree-sitter-wing) | community | `HF ` | | | @gshpychka, @MarkMcCulloh -[wit](https://github.com/liamwh/tree-sitter-wit) | community | `H J` | | | @liamwh -[xcompose](https://github.com/ObserverOfTime/tree-sitter-xcompose) | stable | `H J` | | | @ObserverOfTime -[xml](https://github.com/tree-sitter-grammars/tree-sitter-xml) | stable | `HFIJ` | | | @ObserverOfTime -[yaml](https://github.com/tree-sitter-grammars/tree-sitter-yaml) | stable | `HFIJ` | | | @amaanq -[yang](https://github.com/Hubro/tree-sitter-yang) | | `HFIJ` | | | @Hubro -[yuck](https://github.com/Philipp-M/tree-sitter-yuck) | | `HFIJ` | | | @Philipp-M, @amaanq -[zathurarc](https://github.com/Freed-Wu/tree-sitter-zathurarc) | community | `H J` | | | @Freed-Wu -[zig](https://github.com/maxxnino/tree-sitter-zig) | | `HFIJ` | | | @maxxnino +[ada](https://github.com/briot/tree-sitter-ada) | | `HF L` | | | @briot +[agda](https://github.com/tree-sitter/tree-sitter-agda) | | `HF ` | | | @Decodetalkers +[angular](https://github.com/dlvandenberg/tree-sitter-angular) | unstable | `HFIJL` | | ✓ | @dlvandenberg +[apex](https://github.com/aheber/tree-sitter-sfapex) | community | `HF L` | | | @aheber +[arduino](https://github.com/ObserverOfTime/tree-sitter-arduino) | | `HFIJL` | | | @ObserverOfTime +[asm](https://github.com/RubixDev/tree-sitter-asm) | community | `H J ` | | | @RubixDev +[astro](https://github.com/virchau13/tree-sitter-astro) | | `HFIJL` | | | @virchau13 +[authzed](https://github.com/mleonidas/tree-sitter-authzed) | community | `H J ` | | | @mattpolzin +[awk](https://github.com/Beaglefoot/tree-sitter-awk) | | `H J ` | | | +[bash](https://github.com/tree-sitter/tree-sitter-bash) | | `HF JL` | | | @TravonteD +[bass](https://github.com/vito/tree-sitter-bass) | | `HFIJL` | | | @amaanq +[beancount](https://github.com/polarmutex/tree-sitter-beancount) | | `HF J ` | | | @polarmutex +[bibtex](https://github.com/latex-lsp/tree-sitter-bibtex) | community | `HFI ` | | | @theHamsta, @clason +[bicep](https://github.com/amaanq/tree-sitter-bicep) | | `HFIJL` | | | @amaanq +[bitbake](https://github.com/amaanq/tree-sitter-bitbake) | stable | `HFIJL` | | | @amaanq +[blueprint](https://gitlab.com/gabmus/tree-sitter-blueprint.git) | unstable | `H ` | | | @gabmus +[c](https://github.com/tree-sitter/tree-sitter-c) | core | `HFIJL` | | | @amaanq +[c_sharp](https://github.com/tree-sitter/tree-sitter-c-sharp) | | `HF JL` | | | @Luxed +[cairo](https://github.com/amaanq/tree-sitter-cairo) | stable | `HFIJL` | | | @amaanq +[capnp](https://github.com/amaanq/tree-sitter-capnp) | | `HFIJL` | | | @amaanq +[chatito](https://github.com/ObserverOfTime/tree-sitter-chatito) | | `HFIJL` | | | @ObserverOfTime +[clojure](https://github.com/sogaiu/tree-sitter-clojure) | | `HF JL` | | | @NoahTheDuke +[cmake](https://github.com/uyha/tree-sitter-cmake) | | `HFI ` | | | @uyha +[comment](https://github.com/stsewd/tree-sitter-comment) | stable | `H ` | | | @stsewd +[commonlisp](https://github.com/theHamsta/tree-sitter-commonlisp) | | `HF L` | | ✓ | @theHamsta +[cooklang](https://github.com/addcninblue/tree-sitter-cooklang) | community | `H ` | | | @addcninblue +[corn](https://github.com/jakestanger/tree-sitter-corn) | community | `HFI L` | | | @jakestanger +[cpon](https://github.com/amaanq/tree-sitter-cpon) | | `HFIJL` | | | @amaanq +[cpp](https://github.com/tree-sitter/tree-sitter-cpp) | | `HFIJL` | | ✓ | @theHamsta +[css](https://github.com/tree-sitter/tree-sitter-css) | | `HFIJ ` | | | @TravonteD +[csv](https://github.com/amaanq/tree-sitter-csv) | stable | `H ` | | | @amaanq +[cuda](https://github.com/theHamsta/tree-sitter-cuda) | | `HFIJL` | | ✓ | @theHamsta +[cue](https://github.com/eonpatapon/tree-sitter-cue) | | `HFIJL` | | | @amaanq +[d](https://github.com/gdamore/tree-sitter-d) | stable | `HFIJL` | | | @amaanq +[dart](https://github.com/UserNobody14/tree-sitter-dart) | | `HFIJL` | | | @akinsho +[devicetree](https://github.com/joelspadin/tree-sitter-devicetree) | | `HFIJL` | | | @jedrzejboczar +[dhall](https://github.com/jbellerb/tree-sitter-dhall) | | `HF J ` | | | @amaanq +[diff](https://github.com/the-mikedavis/tree-sitter-diff) | | `H ` | | | @gbprod +[disassembly](https://github.com/ColinKennedy/tree-sitter-disassembly) | community | `H J ` | | | @ColinKennedy +[djot](https://github.com/treeman/tree-sitter-djot) | community | `HFIJL` | | | @NoahTheDuke +[dockerfile](https://github.com/camdencheek/tree-sitter-dockerfile) | | `H J ` | | | @camdencheek +[dot](https://github.com/rydesun/tree-sitter-dot) | | `H IJ ` | | | @rydesun +[doxygen](https://github.com/amaanq/tree-sitter-doxygen) | stable | `H IJ ` | | | @amaanq +[dtd](https://github.com/tree-sitter-grammars/tree-sitter-xml) | stable | `HF JL` | | | @ObserverOfTime +[earthfile](https://github.com/glehmann/tree-sitter-earthfile) | community | `H J ` | | | @glehmann +[ebnf](https://github.com/RubixDev/ebnf) | unstable | `H ` | | | @RubixDev +[eds](https://github.com/uyha/tree-sitter-eds) | community | `HF ` | | | @uyha +[eex](https://github.com/connorlay/tree-sitter-eex) | | `H J ` | | | @connorlay +[elixir](https://github.com/elixir-lang/tree-sitter-elixir) | | `HFIJL` | | | @connorlay +[elm](https://github.com/elm-tooling/tree-sitter-elm) | | `H J ` | | | @zweimach +[elsa](https://github.com/glapa-grossklag/tree-sitter-elsa) | | `HFIJL` | | | @glapa-grossklag, @amaanq +[elvish](https://github.com/elves/tree-sitter-elvish) | | `H J ` | | | @elves +[embedded_template](https://github.com/tree-sitter/tree-sitter-embedded-template) | | `H J ` | | | +[erlang](https://github.com/WhatsApp/tree-sitter-erlang) | | `HF ` | | | @filmor +[facility](https://github.com/FacilityApi/tree-sitter-facility) | community | `HFIJ ` | | | @bryankenote +[faust](https://github.com/khiner/tree-sitter-faust) | community | `H J ` | | | @khiner +[fennel](https://github.com/alexmozaidze/tree-sitter-fennel) | | `HF JL` | | ✓ | @alexmozaidze +[fidl](https://github.com/google/tree-sitter-fidl) | community | `HF J ` | | | @chaopeng +[firrtl](https://github.com/amaanq/tree-sitter-firrtl) | | `HFIJL` | | | @amaanq +[fish](https://github.com/ram02z/tree-sitter-fish) | | `HFIJL` | | | @ram02z +[foam](https://github.com/FoamScience/tree-sitter-foam) | unstable | `HFIJL` | | | @FoamScience +[forth](https://github.com/AlexanderBrevig/tree-sitter-forth) | stable | `HFIJL` | | | @amaanq +[fortran](https://github.com/stadelmanma/tree-sitter-fortran) | | `HFI ` | | | @amaanq +[fsh](https://github.com/mgramigna/tree-sitter-fsh) | | `H ` | | | @mgramigna +[func](https://github.com/amaanq/tree-sitter-func) | | `H ` | | | @amaanq +[fusion](https://gitlab.com/jirgn/tree-sitter-fusion.git) | | `HFI L` | | | @jirgn +[gdscript](https://github.com/PrestonKnopp/tree-sitter-gdscript)[^gdscript] | | `HFIJL` | | | @PrestonKnopp +[gdshader](https://github.com/GodOfAvacyn/tree-sitter-gdshader) | community | `H J ` | | | @godofavacyn +[git_config](https://github.com/the-mikedavis/tree-sitter-git-config)[^git_config] | | `HF J ` | | | @amaanq +[git_rebase](https://github.com/the-mikedavis/tree-sitter-git-rebase) | | `H J ` | | | @gbprod +[gitattributes](https://github.com/ObserverOfTime/tree-sitter-gitattributes) | | `H JL` | | | @ObserverOfTime +[gitcommit](https://github.com/gbprod/tree-sitter-gitcommit) | | `H J ` | | | @gbprod +[gitignore](https://github.com/shunsambongi/tree-sitter-gitignore) | | `H ` | | | @theHamsta +[gleam](https://github.com/gleam-lang/tree-sitter-gleam) | | `HFIJL` | | | @amaanq +[glimmer](https://github.com/alexlafroscia/tree-sitter-glimmer)[^glimmer] | | `HFI L` | | | @NullVoxPopuli +[glsl](https://github.com/theHamsta/tree-sitter-glsl) | | `HFIJL` | | ✓ | @theHamsta +[gn](https://github.com/amaanq/tree-sitter-gn) | stable | `HFIJL` | | | @amaanq +[gnuplot](https://github.com/dpezto/tree-sitter-gnuplot) | community | `H J ` | | | @dpezto +[go](https://github.com/tree-sitter/tree-sitter-go) | | `HFIJL` | | | @theHamsta, @WinWisely268 +[godot_resource](https://github.com/PrestonKnopp/tree-sitter-godot-resource)[^godot_resource] | | `HF JL` | | | @pierpo +[gomod](https://github.com/camdencheek/tree-sitter-go-mod) | | `H J ` | | | @camdencheek +[gosum](https://github.com/amaanq/tree-sitter-go-sum) | | `H ` | | | @amaanq +[gotmpl](https://github.com/ngalaiko/tree-sitter-go-template) | community | `H J ` | | | @qvalentin +[gowork](https://github.com/omertuc/tree-sitter-go-work) | | `H J ` | | | @omertuc +[gpg](https://github.com/ObserverOfTime/tree-sitter-gpg-config) | stable | `H J ` | | | @ObserverOfTime +[graphql](https://github.com/bkegley/tree-sitter-graphql) | | `H IJ ` | | | @bkegley +[groovy](https://github.com/murtaza64/tree-sitter-groovy) | community | `HFIJL` | | | @murtaza64 +[gstlaunch](https://github.com/theHamsta/tree-sitter-gstlaunch) | stable | `H ` | | | @theHamsta +[hack](https://github.com/slackhq/tree-sitter-hack) | | `H ` | | | +[hare](https://github.com/amaanq/tree-sitter-hare) | | `HFIJL` | | | @amaanq +[haskell](https://github.com/tree-sitter/tree-sitter-haskell) | | `HF J ` | | | @mrcjkb +[haskell_persistent](https://github.com/MercuryTechnologies/tree-sitter-haskell-persistent) | | `HF ` | | | @lykahb +[hcl](https://github.com/MichaHoffmann/tree-sitter-hcl) | | `HFIJ ` | | | @MichaHoffmann +[heex](https://github.com/connorlay/tree-sitter-heex) | | `HFIJL` | | | @connorlay +[helm](https://github.com/ngalaiko/tree-sitter-go-template) | community | `H J ` | | | @qvalentin +[hjson](https://github.com/winston0410/tree-sitter-hjson) | | `HFIJL` | | ✓ | @winston0410 +[hlsl](https://github.com/theHamsta/tree-sitter-hlsl) | | `HFIJL` | | ✓ | @theHamsta +[hlsplaylist](https://github.com/Freed-Wu/tree-sitter-hlsplaylist) | community | `H J ` | | | @Freed-Wu +[hocon](https://github.com/antosha417/tree-sitter-hocon) | | `HF J ` | | ✓ | @antosha417 +[hoon](https://github.com/urbit-pilled/tree-sitter-hoon) | unstable | `HF L` | | | @urbit-pilled +[html](https://github.com/tree-sitter/tree-sitter-html) | | `HFIJL` | | | @TravonteD +[htmldjango](https://github.com/interdependence/tree-sitter-htmldjango) | unstable | `HFIJ ` | | | @ObserverOfTime +[http](https://github.com/rest-nvim/tree-sitter-http) | | `H J ` | | | @amaanq, @NTBBloodbath +[hurl](https://github.com/pfeiferj/tree-sitter-hurl) | community | `HFIJ ` | | | @pfeiferj +[hyprlang](https://github.com/luckasRanarison/tree-sitter-hyprlang) | community | `HFIJ ` | | | @luckasRanarison +[idl](https://github.com/cathaysia/tree-sitter-idl) | community | `H J ` | | | @cathaysa +[ini](https://github.com/justinmk/tree-sitter-ini) | unstable | `HF ` | | | @theHamsta +[inko](https://github.com/inko-lang/tree-sitter-inko) | community | `HFIJL` | | | @yorickpeterse +[ispc](https://github.com/fab4100/tree-sitter-ispc) | | `HFIJL` | | ✓ | @fab4100 +[janet_simple](https://github.com/sogaiu/tree-sitter-janet-simple) | | `HF JL` | | | @sogaiu +[java](https://github.com/tree-sitter/tree-sitter-java) | | `HFIJL` | | | @p00f +[javascript](https://github.com/tree-sitter/tree-sitter-javascript) | | `HFIJL` | | | @steelsojka +[jq](https://github.com/flurie/tree-sitter-jq) | | `H JL` | | | @ObserverOfTime +[jsdoc](https://github.com/tree-sitter/tree-sitter-jsdoc) | | `H ` | | | @steelsojka +[json](https://github.com/tree-sitter/tree-sitter-json) | | `HFI L` | | | @steelsojka +[json5](https://github.com/Joakker/tree-sitter-json5) | | `H J ` | | | @Joakker +[jsonc](https://gitlab.com/WhyNotHugo/tree-sitter-jsonc.git)[^jsonc] | | `HFIJL` | | ✓ | @WhyNotHugo +[jsonnet](https://github.com/sourcegraph/tree-sitter-jsonnet) | | `HF L` | | | @nawordar +[julia](https://github.com/tree-sitter/tree-sitter-julia) | community | `HFIJL` | | | @theHamsta +[just](https://github.com/IndianBoy42/tree-sitter-just) | community | `HFIJL` | | | @Hubro +[kconfig](https://github.com/amaanq/tree-sitter-kconfig) | stable | `HFIJL` | | | @amaanq +[kdl](https://github.com/amaanq/tree-sitter-kdl) | | `HFIJL` | | | @amaanq +[kotlin](https://github.com/fwcd/tree-sitter-kotlin) | | `HF JL` | | | @SalBakraa +[koto](https://github.com/koto-lang/tree-sitter-koto) | community | `HF JL` | | | @irh +[kusto](https://github.com/Willem-J-an/tree-sitter-kusto) | community | `H J ` | | | @Willem-J-an +[lalrpop](https://github.com/traxys/tree-sitter-lalrpop) | | `H JL` | | | @traxys +[latex](https://github.com/latex-lsp/tree-sitter-latex) | community | `HF J ` | ✓ | | @theHamsta, @clason +[ledger](https://github.com/cbarrete/tree-sitter-ledger) | | `HFIJ ` | | | @cbarrete +[leo](https://github.com/r001/tree-sitter-leo) | community | `H IJ ` | | | @r001 +[linkerscript](https://github.com/amaanq/tree-sitter-linkerscript) | stable | `HFIJL` | | | @amaanq +[liquid](https://github.com/hankthetank27/tree-sitter-liquid) | community | `H J ` | | | @hankthetank27 +[liquidsoap](https://github.com/savonet/tree-sitter-liquidsoap) | community | `HFI L` | | | @toots +[llvm](https://github.com/benwilliamgraham/tree-sitter-llvm) | | `H ` | | | @benwilliamgraham +[lua](https://github.com/MunifTanjim/tree-sitter-lua) | core | `HFIJL` | | | @muniftanjim +[luadoc](https://github.com/amaanq/tree-sitter-luadoc) | | `H ` | | | @amaanq +[luap](https://github.com/amaanq/tree-sitter-luap)[^luap] | | `H ` | | | @amaanq +[luau](https://github.com/amaanq/tree-sitter-luau) | | `HFIJL` | | | @amaanq +[m68k](https://github.com/grahambates/tree-sitter-m68k) | | `HF JL` | | | @grahambates +[make](https://github.com/alemuller/tree-sitter-make) | | `HF J ` | | | @lewis6991 +[markdown](https://github.com/MDeiml/tree-sitter-markdown)[^markdown] | core | `HFIJ ` | | | @MDeiml +[markdown_inline](https://github.com/MDeiml/tree-sitter-markdown)[^markdown_inline] | core | `H J ` | | | @MDeiml +[matlab](https://github.com/acristoffers/tree-sitter-matlab) | | `HFIJL` | | | @acristoffers +[menhir](https://github.com/Kerl13/tree-sitter-menhir) | | `H J ` | | | @Kerl13 +[mermaid](https://github.com/monaqa/tree-sitter-mermaid) | unstable | `H ` | | | +[meson](https://github.com/Decodetalkers/tree-sitter-meson) | | `HFIJ ` | | | @Decodetalkers +[mlir](https://github.com/artagnon/tree-sitter-mlir) | unstable | `H L` | ✓ | | @artagnon +[muttrc](https://github.com/neomutt/tree-sitter-muttrc) | community | `H J ` | | | @Freed-Wu +[nasm](https://github.com/naclsn/tree-sitter-nasm) | stable | `H J ` | | | @ObserverOfTime +[nickel](https://github.com/nickel-lang/tree-sitter-nickel) | | `H I ` | | | +[nim](https://github.com/alaviss/tree-sitter-nim) | community | `HF JL` | | | @aMOPel +[nim_format_string](https://github.com/aMOPel/tree-sitter-nim-format-string) | community | `H J ` | | | @aMOPel +[ninja](https://github.com/alemuller/tree-sitter-ninja) | | `HFI ` | | | @alemuller +[nix](https://github.com/cstrahan/tree-sitter-nix) | | `HF JL` | | | @leo60228 +[norg](https://github.com/nvim-neorg/tree-sitter-norg) | unstable | ` ` | | | @JoeyGrajciar, @vhyrro +[nqc](https://github.com/amaanq/tree-sitter-nqc) | stable | `HFIJL` | | | @amaanq +[objc](https://github.com/amaanq/tree-sitter-objc) | | `HFIJL` | | | @amaanq +[objdump](https://github.com/ColinKennedy/tree-sitter-objdump) | community | `H J ` | | | @ColinKennedy +[ocaml](https://github.com/tree-sitter/tree-sitter-ocaml) | | `HFIJL` | | | @undu +[ocaml_interface](https://github.com/tree-sitter/tree-sitter-ocaml) | | `HFIJL` | | | @undu +[ocamllex](https://github.com/atom-ocaml/tree-sitter-ocamllex) | | `H J ` | ✓ | | @undu +[odin](https://github.com/amaanq/tree-sitter-odin) | | `HFIJL` | | | @amaanq +[org](https://github.com/milisims/tree-sitter-org) | | ` ` | | | +[pascal](https://github.com/Isopod/tree-sitter-pascal.git) | | `HFIJL` | | | @Isopod +[passwd](https://github.com/ath3/tree-sitter-passwd) | | `H ` | | | @amaanq +[pem](https://github.com/ObserverOfTime/tree-sitter-pem) | stable | `HF J ` | | | @ObserverOfTime +[perl](https://github.com/tree-sitter-perl/tree-sitter-perl) | | `HF J ` | | | @RabbiVeesh, @LeoNerd +[php](https://github.com/tree-sitter/tree-sitter-php)[^php] | | `HFIJL` | | | @tk-shirasaka +[php_only](https://github.com/tree-sitter/tree-sitter-php)[^php_only] | | `HFIJL` | | | @tk-shirasaka +[phpdoc](https://github.com/claytonrcarter/tree-sitter-phpdoc) | unstable | `H ` | | ✓ | @mikehaertl +[pioasm](https://github.com/leo60228/tree-sitter-pioasm) | | `H J ` | | | @leo60228 +[po](https://github.com/erasin/tree-sitter-po) | | `HF J ` | | | @amaanq +[pod](https://github.com/tree-sitter-perl/tree-sitter-pod) | community | `H ` | | | @RabbiVeesh, @LeoNerd +[poe_filter](https://github.com/ObserverOfTime/tree-sitter-poe-filter)[^poe_filter] | unstable | `HFIJ ` | | | @ObserverOfTime +[pony](https://github.com/amaanq/tree-sitter-pony) | | `HFIJL` | | | @amaanq, @mfelsche +[printf](https://github.com/ObserverOfTime/tree-sitter-printf) | stable | `H ` | | | @ObserverOfTime +[prisma](https://github.com/victorhqc/tree-sitter-prisma) | | `HF ` | | | @elianiva +[promql](https://github.com/MichaHoffmann/tree-sitter-promql) | unstable | `H J ` | | | @MichaHoffmann +[properties](https://github.com/ObserverOfTime/tree-sitter-properties)[^properties] | stable | `H JL` | | | @ObserverOfTime +[proto](https://github.com/treywood/tree-sitter-proto) | | `HF ` | | | @treywood +[prql](https://github.com/PRQL/tree-sitter-prql) | | `H J ` | | | @matthias-Q +[psv](https://github.com/amaanq/tree-sitter-csv) | stable | `H ` | | | @amaanq +[pug](https://github.com/zealot128/tree-sitter-pug) | unstable | `H J ` | | | @zealot128 +[puppet](https://github.com/amaanq/tree-sitter-puppet) | | `HFIJL` | | | @amaanq +[purescript](https://github.com/postsolar/tree-sitter-purescript) | community | `H JL` | | | @postsolar +[pymanifest](https://github.com/ObserverOfTime/tree-sitter-pymanifest) | stable | `H J ` | | | @ObserverOfTime +[python](https://github.com/tree-sitter/tree-sitter-python) | | `HFIJL` | | | @stsewd, @theHamsta +[ql](https://github.com/tree-sitter/tree-sitter-ql) | | `HFIJL` | | | @pwntester +[qmldir](https://github.com/Decodetalkers/tree-sitter-qmldir) | | `H J ` | | | @amaanq +[qmljs](https://github.com/yuja/tree-sitter-qmljs) | | `HF J ` | | | @Decodetalkers +[query](https://github.com/nvim-treesitter/tree-sitter-query)[^query] | core | `HFIJL` | | | @steelsojka +[r](https://github.com/r-lib/tree-sitter-r) | | `H IJL` | | | @echasnovski +[racket](https://github.com/6cdh/tree-sitter-racket) | unstable | `HF J ` | | | +[rasi](https://github.com/Fymyte/tree-sitter-rasi) | | `HFIJL` | | | @Fymyte +[rbs](https://github.com/joker1007/tree-sitter-rbs) | community | `HFIJ ` | | | @joker1007 +[re2c](https://github.com/amaanq/tree-sitter-re2c) | stable | `HFIJL` | | | @amaanq +[readline](https://github.com/ribru17/tree-sitter-readline) | community | `HFIJ ` | | | @ribru17 +[regex](https://github.com/tree-sitter/tree-sitter-regex) | | `H ` | | | @theHamsta +[rego](https://github.com/FallenAngel97/tree-sitter-rego) | | `H J ` | | | @FallenAngel97 +[requirements](https://github.com/ObserverOfTime/tree-sitter-requirements) | stable | `H J ` | | | @ObserverOfTime +[rnoweb](https://github.com/bamonroe/tree-sitter-rnoweb) | | `HF J ` | | | @bamonroe +[robot](https://github.com/Hubro/tree-sitter-robot) | community | `HFI ` | | | @Hubro +[roc](https://github.com/nat-418/tree-sitter-roc) | community | `H JL` | | | @nat-418 +[ron](https://github.com/amaanq/tree-sitter-ron) | | `HFIJL` | | | @amaanq +[rst](https://github.com/stsewd/tree-sitter-rst) | | `H JL` | | | @stsewd +[ruby](https://github.com/tree-sitter/tree-sitter-ruby) | | `HFIJL` | | | @TravonteD +[rust](https://github.com/tree-sitter/tree-sitter-rust) | | `HFIJL` | | | @amaanq +[scala](https://github.com/tree-sitter/tree-sitter-scala) | | `HF JL` | | | @stevanmilic +[scfg](https://git.sr.ht/~rockorager/tree-sitter-scfg) | community | `H J ` | ✓ | | @WhyNotHugo +[scheme](https://github.com/6cdh/tree-sitter-scheme) | unstable | `HF J ` | | | +[scss](https://github.com/serenadeai/tree-sitter-scss) | | `HFI ` | | | @elianiva +[slang](https://github.com/theHamsta/tree-sitter-slang)[^slang] | unstable | `HFIJL` | | ✓ | @theHamsta +[slint](https://github.com/slint-ui/tree-sitter-slint) | community | `HFIJL` | | | @hunger +[smali](https://github.com/tree-sitter-grammars/tree-sitter-smali) | community | `HFIJL` | | | @amaanq +[smithy](https://github.com/indoorvivants/tree-sitter-smithy) | | `H ` | | | @amaanq, @keynmol +[snakemake](https://github.com/osthomas/tree-sitter-snakemake) | unstable | `HFIJL` | | | +[solidity](https://github.com/JoranHonig/tree-sitter-solidity) | | `HF ` | | | @amaanq +[soql](https://github.com/aheber/tree-sitter-sfapex) | community | `H ` | | | @aheber +[sosl](https://github.com/aheber/tree-sitter-sfapex) | | `H ` | | | @aheber +[sourcepawn](https://github.com/nilshelmig/tree-sitter-sourcepawn) | community | `H JL` | | | @Sarrus1 +[sparql](https://github.com/BonaBeavis/tree-sitter-sparql) | | `HFIJL` | | | @BonaBeavis +[sql](https://github.com/derekstride/tree-sitter-sql) | | `H IJ ` | | | @derekstride +[squirrel](https://github.com/amaanq/tree-sitter-squirrel) | | `HFIJL` | | | @amaanq +[ssh_config](https://github.com/ObserverOfTime/tree-sitter-ssh-config) | stable | `HFIJL` | | | @ObserverOfTime +[starlark](https://github.com/amaanq/tree-sitter-starlark) | | `HFIJL` | | | @amaanq +[strace](https://github.com/sigmaSd/tree-sitter-strace) | stable | `H J ` | | | @amaanq +[styled](https://github.com/mskelton/tree-sitter-styled) | community | `HFIJ ` | | | @mskelton +[supercollider](https://github.com/madskjeldgaard/tree-sitter-supercollider) | | `HFIJL` | | | @madskjeldgaard +[surface](https://github.com/connorlay/tree-sitter-surface) | | `HFIJ ` | | | @connorlay +[svelte](https://github.com/tree-sitter-grammars/tree-sitter-svelte) | stable | `HFIJL` | | | @amaanq +[swift](https://github.com/alex-pinkus/tree-sitter-swift) | | `H I L` | ✓ | | @alex-pinkus +[sxhkdrc](https://github.com/RaafatTurki/tree-sitter-sxhkdrc) | | `HF J ` | | | @RaafatTurki +[systemtap](https://github.com/ok-ryoko/tree-sitter-systemtap) | community | `HF JL` | | | @ok-ryoko +[t32](https://gitlab.com/xasc/tree-sitter-t32.git) | community | `HFIJL` | | | @xasc +[tablegen](https://github.com/amaanq/tree-sitter-tablegen) | | `HFIJL` | | | @amaanq +[tcl](https://github.com/tree-sitter-grammars/tree-sitter-tcl) | stable | `HFI ` | | | @lewis6991 +[teal](https://github.com/euclidianAce/tree-sitter-teal) | | `HFIJL` | ✓ | | @euclidianAce +[templ](https://github.com/vrischmann/tree-sitter-templ) | community | `H J ` | | | @vrischmann +[terraform](https://github.com/MichaHoffmann/tree-sitter-hcl) | | `HFIJ ` | | | @MichaHoffmann +[textproto](https://github.com/PorterAtGoogle/tree-sitter-textproto) | community | `HFI ` | | | @Porter +[thrift](https://github.com/duskmoon314/tree-sitter-thrift) | | `HFIJL` | | | @amaanq, @duskmoon314 +[tiger](https://github.com/ambroisie/tree-sitter-tiger) | | `HFIJL` | | | @ambroisie +[tlaplus](https://github.com/tlaplus-community/tree-sitter-tlaplus) | | `HF JL` | | | @ahelwer, @susliko +[tmux](https://github.com/Freed-Wu/tree-sitter-tmux) | community | `H J ` | | | @Freed-Wu +[todotxt](https://github.com/arnarg/tree-sitter-todotxt.git) | unstable | `H ` | | | @arnarg +[toml](https://github.com/tree-sitter-grammars/tree-sitter-toml) | | `HFIJL` | | ✓ | @tk-shirasaka +[tsv](https://github.com/amaanq/tree-sitter-csv) | stable | `H ` | | | @amaanq +[tsx](https://github.com/tree-sitter/tree-sitter-typescript) | | `HFIJL` | | ✓ | @steelsojka +[turtle](https://github.com/BonaBeavis/tree-sitter-turtle) | | `HFIJL` | | | @BonaBeavis +[twig](https://github.com/gbprod/tree-sitter-twig) | | `H J ` | | | @gbprod +[typescript](https://github.com/tree-sitter/tree-sitter-typescript) | | `HFIJL` | | ✓ | @steelsojka +[typoscript](https://github.com/Teddytrombone/tree-sitter-typoscript) | community | `HFIJ ` | | | @Teddytrombone +[typst](https://github.com/uben0/tree-sitter-typst) | community | `HFIJ ` | | | @uben0, @RaafatTurki +[udev](https://github.com/ObserverOfTime/tree-sitter-udev) | stable | `H JL` | | | @ObserverOfTime +[ungrammar](https://github.com/Philipp-M/tree-sitter-ungrammar) | | `HFIJL` | | | @Philipp-M, @amaanq +[unison](https://github.com/kylegoetz/tree-sitter-unison) | unstable | `H J ` | ✓ | | @tapegram +[usd](https://github.com/ColinKennedy/tree-sitter-usd) | | `HFI L` | | | @ColinKennedy +[uxntal](https://github.com/amaanq/tree-sitter-uxntal) | | `HFIJL` | | | @amaanq +[v](https://github.com/vlang/v-analyzer) | | `HFIJL` | | | @kkharji, @amaanq +[vala](https://github.com/vala-lang/tree-sitter-vala) | | `HF ` | | | @Prince781 +[vento](https://github.com/ventojs/tree-sitter-vento) | community | `H J ` | | | @wrapperup, @oscarotero +[verilog](https://github.com/tree-sitter/tree-sitter-verilog) | | `HF JL` | | | @zegervdv +[vhs](https://github.com/charmbracelet/tree-sitter-vhs) | | `H ` | | | @caarlos0 +[vim](https://github.com/neovim/tree-sitter-vim) | core | `HF JL` | | | @clason +[vimdoc](https://github.com/neovim/tree-sitter-vimdoc) | core | `H J ` | | | @clason +[vue](https://github.com/tree-sitter-grammars/tree-sitter-vue) | stable | `HFIJ ` | | | @WhyNotHugo, @lucario387 +[wgsl](https://github.com/szebniok/tree-sitter-wgsl) | | `HFI ` | | | @szebniok +[wgsl_bevy](https://github.com/theHamsta/tree-sitter-wgsl-bevy) | | `HFI ` | | ✓ | @theHamsta +[wing](https://github.com/winglang/tree-sitter-wing) | community | `HF L` | | | @gshpychka, @MarkMcCulloh +[wit](https://github.com/liamwh/tree-sitter-wit) | community | `H J ` | | | @liamwh +[xcompose](https://github.com/ObserverOfTime/tree-sitter-xcompose) | stable | `H JL` | | | @ObserverOfTime +[xml](https://github.com/tree-sitter-grammars/tree-sitter-xml) | stable | `HFIJL` | | | @ObserverOfTime +[yaml](https://github.com/tree-sitter-grammars/tree-sitter-yaml) | stable | `HFIJL` | | | @amaanq +[yang](https://github.com/Hubro/tree-sitter-yang) | | `HFIJ ` | | | @Hubro +[yuck](https://github.com/Philipp-M/tree-sitter-yuck) | | `HFIJL` | | | @Philipp-M, @amaanq +[zathurarc](https://github.com/Freed-Wu/tree-sitter-zathurarc) | community | `H J ` | | | @Freed-Wu +[zig](https://github.com/maxxnino/tree-sitter-zig) | | `HFIJL` | | | @maxxnino [^gdscript]: Godot [^git_config]: git_config [^glimmer]: Glimmer and Ember @@ -13,7 +13,7 @@ This document lists the planned and finished changes in this rewrite towards [Nv - provide `install.compile_command` for overriding (function that takes files, ...?) - allow using repo makefile (norg!)? - ...or switch to makefile completely? -- [ ] **`locals.lua`:** refactor, move to `nvim-treesitter-refactor` +- [ ] **`locals.lua`:** move to `nvim-treesitter-refactor`? - [ ] **update-lockfile:** allow specifying version in addition to commit hash (for Tier 1) - [ ] **update-lockfile:** one commit per parser/tier? - [ ] **documentation:** consolidate, autogenerate? @@ -26,9 +26,11 @@ This document lists the planned and finished changes in this rewrite towards [Nv - [X] remove module framework - [X] remove extra utilities - [X] refactor `indent.lua` into standalone +- [X] refactor `locals.lua` into standalone - [X] refactor commands, predicates, filetypes registration to plugin/ - [X] support installing tiers of parsers - [X] install parsers to standard directory by default - [X] remove bundled queries from runtimepath; copy on parser install - [X] general refactor and cleanup +- [X] switch to upstream injection format - [X] remove locals from highlighting (cf. https://github.com/nvim-treesitter/nvim-treesitter/issues/3944#issuecomment-1458782497) diff --git a/lua/nvim-treesitter/locals.lua b/lua/nvim-treesitter/locals.lua index fa8496469..c8ebe0b0d 100644 --- a/lua/nvim-treesitter/locals.lua +++ b/lua/nvim-treesitter/locals.lua @@ -2,7 +2,6 @@ -- Locals are a generalization of definition and scopes -- it's the way nvim-treesitter uses to "understand" the code -local query = require('nvim-treesitter.query') local api = vim.api local ts = vim.treesitter @@ -30,19 +29,6 @@ local function get_root_for_node(node) return result end --- Iterates matches from a locals query file. --- @param bufnr the buffer --- @param root the root node -function M.iter_locals(bufnr, root) - return query.iter_group_results(bufnr, 'locals', root) -end - ----@param bufnr integer ----@return any -function M.collect_locals(bufnr) - return query.collect_group_results(bufnr, 'locals') -end - -- Creates unique id for a node based on text and range ---@param scope TSNode: the scope node of the definition ---@param node_text string: the node text to use @@ -52,48 +38,6 @@ function M.get_definition_id(scope, node_text) return table.concat({ 'k', node_text or '', scope:range() }, '_') end -function M.get_definitions(bufnr) - local locals = M.collect_locals(bufnr) - - local defs = {} - - for _, loc in ipairs(locals) do - if loc['local.definition'] then - table.insert(defs, loc['local.definition']) - end - end - - return defs -end - -function M.get_scopes(bufnr) - local locals = M.collect_locals(bufnr) - - local scopes = {} - - for _, loc in ipairs(locals) do - if loc['local.scope'] and loc['local.scope'].node then - table.insert(scopes, loc['local.scope'].node) - end - end - - return scopes -end - -function M.get_references(bufnr) - local locals = M.collect_locals(bufnr) - - local refs = {} - - for _, loc in ipairs(locals) do - if loc['local.reference'] and loc['local.reference'].node then - table.insert(refs, loc['local.reference'].node) - end - end - - return refs -end - -- Gets a table with all the scopes containing a node -- The order is from most specific to least (bottom up) ---@param node TSNode @@ -129,8 +73,8 @@ function M.iter_scope_tree(node, bufnr) end -- Gets a table of all nodes and their 'kinds' from a locals list ----@param local_def any: the local list result ----@return table: a list of node entries +---@param local_def TSLocal[] the local list result +---@return TSLocal[] a list of node entries function M.get_local_nodes(local_def) local result = {} @@ -145,9 +89,9 @@ end -- The accumulator function is given -- * The table of the node -- * The node --- * The full definition match `@definition.var.something` -> 'var.something' --- * The last definition match `@definition.var.something` -> 'something' ----@param local_def any The locals result +-- * The full definition match `@local.definition.var.something` -> 'var.something' +-- * The last definition match `@local.definition.var.something` -> 'something' +---@param local_def TSLocal The locals result ---@param accumulator function The accumulator function ---@param full_match? string The full match path to append to ---@param last_match? string The last match @@ -181,14 +125,108 @@ local function memoize(fn, hash_fn) return function(...) local key = hash_fn(...) if cache[key] == nil then - local v = fn(...) ---@type any - cache[key] = v ~= nil and v or vim.NIL + local v = { fn(...) } ---@type any + + for k, value in pairs(v) do + if value == nil then + value[k] = vim.NIL + end + end + + cache[key] = v end local v = cache[key] - return v ~= vim.NIL and v or nil + + for k, value in pairs(v) do + if value == vim.NIL then + value[k] = nil + end + end + + return unpack(v) end end +---@param bufnr integer: the buffer +---@return TSNode|nil root: root node of the buffer +local function get_root(bufnr) + local parser = ts.get_parser(bufnr) + if not parser then + return + end + parser:parse() + return parser:trees()[1]:root() +end + +---@param bufnr integer: the buffer +---@return Query|nil query: `locals` query +---@return TSNode|nil root: root node of the bufferocal function get_query(bufnr) +local function get_query(bufnr) + local root = get_root(bufnr) + + local ft = vim.bo[bufnr].filetype + local lang = ts.language.get_lang(ft) or ft + + local query = (ts.query.get(lang, 'locals')) + + return query, root +end + +---@alias TSScope "parent"|"local"|"global" + +---@class TSLocal +---@field kind string +---@field node TSNode +---@field scope TSScope + +-- Return all locals for the buffer +-- +-- memoized by buffer tick +-- +---@param bufnr integer buffer +---@return TSLocal[] definitions +---@return TSLocal[] references +---@return TSNode[] scopes +M.get = memoize(function(bufnr) + local query, root = get_query(bufnr) + if not query or not root then + return {}, {}, {} + end + + local definitions = {} + local scopes = {} + local references = {} + for id, node, metadata in query:iter_captures(root, bufnr) do + local kind = query.captures[id] + + local scope = 'local' ---@type string + for k, v in pairs(metadata) do + if type(k) == 'string' and vim.endswith(k, 'local.scope') then + scope = v + end + end + + if node and vim.startswith(kind, 'local.definition') then + table.insert(definitions, { kind = kind, node = node, scope = scope }) + end + + if node and kind == 'local.scope' then + table.insert(scopes, node) + end + + if node and kind == 'local.reference' then + table.insert(references, { kind = kind, node = node, scope = scope }) + end + end + + return definitions, references, scopes +end, function(bufnr) + local root = get_root(bufnr) + if not root then + return tostring(bufnr) + end + return tostring(root:id()) +end) -- Get a single dimension table to look definition nodes. -- Keys are generated by using the range of the containing scope and the text of the definition node. @@ -202,11 +240,14 @@ end -- is called very frequently, which is why this lookup must be fast as possible. -- ---@param bufnr integer: the buffer ----@return table result: a table for looking up definitions +---@return TSLocal[] result: a table for looking up definitions M.get_definitions_lookup_table = memoize(function(bufnr) - local definitions = M.get_definitions(bufnr) - local result = {} + local definitions, _, _ = M.get(bufnr) + if not definitions then + return {} + end + local result = {} for _, definition in ipairs(definitions) do for _, node_entry in ipairs(M.get_local_nodes(definition)) do local scopes = M.get_definition_scopes(node_entry.node, bufnr, node_entry.scope) @@ -221,7 +262,11 @@ M.get_definitions_lookup_table = memoize(function(bufnr) return result end, function(bufnr) - return tostring(bufnr) + local root = get_root(bufnr) + if not root then + return tostring(bufnr) + end + return tostring(root:id()) end) -- Gets all the scopes of a definition based on the scope type @@ -233,7 +278,7 @@ end) -- ---@param node TSNode: the definition node ---@param bufnr integer: the buffer ----@param scope_type string: the scope type +---@param scope_type TSScope: the scope type function M.get_definition_scopes(node, bufnr, scope_type) local scopes = {} local scope_count = 1 ---@type integer|nil @@ -248,8 +293,8 @@ function M.get_definition_scopes(node, bufnr, scope_type) end local i = 0 - for scope in M.iter_scope_tree(node, bufnr) do - table.insert(scopes, scope) + for scope_node in M.iter_scope_tree(node, bufnr) do + table.insert(scopes, scope_node) i = i + 1 if scope_count and i >= scope_count then @@ -284,7 +329,8 @@ end -- Finds usages of a node in a given scope. ---@param node TSNode the node to find usages for ----@param scope_node TSNode the node to look within +---@param scope_node TSNode|nil the node to look within +---@param bufnr integer|nil the bufnr to look into ---@return TSNode[]: a list of nodes function M.find_usages(node, scope_node, bufnr) bufnr = bufnr or api.nvim_get_current_buf() @@ -297,17 +343,19 @@ function M.find_usages(node, scope_node, bufnr) scope_node = scope_node or get_root_for_node(node) local usages = {} - for match in M.iter_locals(bufnr, scope_node) do + local query, _ = get_query(bufnr) + if not query then + return {} + end + + for id, node_capture in query:iter_captures(scope_node, bufnr) do + local kind = query.captures[id] if - match.reference - and match.reference.node - and ts.get_node_text(match.reference.node, bufnr) == node_text + node_capture + and kind == 'local.reference' + and ts.get_node_text(node_capture, bufnr) == node_text then - local def_node, _, kind = M.find_definition(match.reference.node, bufnr) - - if kind == nil or def_node == node then - table.insert(usages, match.reference.node) - end + table.insert(usages, node_capture) end end @@ -322,7 +370,7 @@ function M.containing_scope(node, bufnr, allow_scope) bufnr = bufnr or api.nvim_get_current_buf() allow_scope = allow_scope == nil or allow_scope == true - local scopes = M.get_scopes(bufnr) + local _, _, scopes = M.get(bufnr) if not node or not scopes then return end @@ -339,7 +387,7 @@ end function M.nested_scope(node, cursor_pos) local bufnr = api.nvim_get_current_buf() - local scopes = M.get_scopes(bufnr) + local _, _, scopes = M.get(bufnr) if not node or not scopes then return end @@ -359,7 +407,7 @@ end function M.next_scope(node) local bufnr = api.nvim_get_current_buf() - local scopes = M.get_scopes(bufnr) + local _, _, scopes = M.get(bufnr) if not node or not scopes then return end @@ -389,7 +437,7 @@ end function M.previous_scope(node) local bufnr = api.nvim_get_current_buf() - local scopes = M.get_scopes(bufnr) + local _, _, scopes = M.get(bufnr) if not node or not scopes then return end diff --git a/lua/nvim-treesitter/query.lua b/lua/nvim-treesitter/query.lua deleted file mode 100644 index f7e5205f7..000000000 --- a/lua/nvim-treesitter/query.lua +++ /dev/null @@ -1,165 +0,0 @@ -local M = {} - -local EMPTY_ITER = function() end - ----@class QueryInfo ----@field root TSNode ----@field source integer ----@field start integer ----@field stop integer - ----@param bufnr integer ----@param query_name string ----@param root TSNode ----@param root_lang string|nil ----@return Query|nil, QueryInfo|nil -local function prepare_query(bufnr, query_name, root, root_lang) - local ft = vim.bo[bufnr].filetype - local buf_lang = vim.treesitter.language.get_lang(ft) or ft - if not buf_lang then - return - end - - local parser = vim.treesitter.get_parser(bufnr, buf_lang) - if not parser then - return - end - - if not root then - local first_tree = parser:trees()[1] - - if first_tree then - root = first_tree:root() - end - end - - if not root then - return - end - - local range = { root:range() } - - if not root_lang then - local lang_tree = parser:language_for_range(range) - - if lang_tree then - root_lang = lang_tree:lang() - end - end - - if not root_lang then - return - end - - local query = vim.treesitter.query.get(root_lang, query_name) - if not query then - return - end - - return query, - { - root = root, - source = bufnr, - start = range[1], - -- The end row is exclusive so we need to add 1 to it. - stop = range[3] + 1, - } -end - --- Given a path (i.e. a List(String)) this functions inserts value at path ----@param object any ----@param path string[] ----@param value any -function M.insert_to_path(object, path, value) - local curr_obj = object - - for index = 1, (#path - 1) do - if curr_obj[path[index]] == nil then - curr_obj[path[index]] = {} - end - - curr_obj = curr_obj[path[index]] - end - - curr_obj[path[#path]] = value -end - ----@param query Query ----@param bufnr integer ----@param start_row integer ----@param end_row integer -function M.iter_prepared_matches(query, qnode, bufnr, start_row, end_row) - -- A function that splits a string on '.' - ---@param to_split string - ---@return string[] - local function split(to_split) - local t = {} - for str in string.gmatch(to_split, '([^.]+)') do - table.insert(t, str) - end - - return t - end - - local matches = query:iter_matches(qnode, bufnr, start_row, end_row, { all = false }) - - local function iterator() - local pattern, match, metadata = matches() - if pattern ~= nil then - local prepared_match = {} - - -- Extract capture names from each match - for id, node in pairs(match) do - local name = query.captures[id] -- name of the capture in the query - if name ~= nil then - local path = split(name .. '.node') - M.insert_to_path(prepared_match, path, node) - local metadata_path = split(name .. '.metadata') - M.insert_to_path(prepared_match, metadata_path, metadata[id]) - end - end - - -- Add some predicates for testing - ---@type string[][] ( TODO: make pred type so this can be pred[]) - local preds = query.info.patterns[pattern] - if preds then - for _, pred in pairs(preds) do - -- functions - if pred[1] == 'set!' and type(pred[2]) == 'string' then - M.insert_to_path(prepared_match, split(pred[2]), pred[3]) - end - end - end - - return prepared_match - end - end - return iterator -end - ----Iterates matches from a query file. ----@param bufnr integer the buffer ----@param query_group string the query file to use ----@param root TSNode the root node ----@param root_lang? string the root node lang, if known -function M.iter_group_results(bufnr, query_group, root, root_lang) - local query, params = prepare_query(bufnr, query_group, root, root_lang) - if not query then - return EMPTY_ITER - end - assert(params) - - return M.iter_prepared_matches(query, params.root, params.source, params.start, params.stop) -end - -function M.collect_group_results(bufnr, query_group, root, lang) - local matches = {} - - for prepared_match in M.iter_group_results(bufnr, query_group, root, lang) do - table.insert(matches, prepared_match) - end - - return matches -end - -return M diff --git a/scripts/update-readme.lua b/scripts/update-readme.lua index 825d84037..6c23c1af6 100755 --- a/scripts/update-readme.lua +++ b/scripts/update-readme.lua @@ -47,6 +47,7 @@ for _, v in ipairs(sorted_parsers) do .. (vim.loop.fs_stat('runtime/queries/' .. v.name .. '/folds.scm') and 'F' or ' ') .. (vim.loop.fs_stat('runtime/queries/' .. v.name .. '/indents.scm') and 'I' or ' ') .. (vim.loop.fs_stat('runtime/queries/' .. v.name .. '/injections.scm') and 'J' or ' ') + .. (vim.loop.fs_stat('runtime/queries/' .. v.name .. '/locals.scm') and 'L' or ' ') .. '` | ' -- CLI |
