1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-02-02 22:20:06 +08:00

revert(treesitter)!: revert treesitter

This commit is contained in:
wsdjeg 2022-11-14 00:10:02 +08:00
parent 09a5ffee35
commit aced222602
268 changed files with 2020 additions and 6161 deletions

View File

@ -1,2 +1 @@
open_collective: "nvim-treesitter" open_collective: "nvim-treesitter"
github: "nvim-treesitter"

View File

@ -66,7 +66,7 @@ body:
description: | description: |
Please provide a screenshot of the current highlighting. Please also tell us the `:h colorscheme` you are using Please provide a screenshot of the current highlighting. Please also tell us the `:h colorscheme` you are using
and how to install it. If applicable, you can also upload a screenshot with the contents of and how to install it. If applicable, you can also upload a screenshot with the contents of
`:TSHighlightCapturesUnderCursor`. `:TSHighlightCapturesUnderCursor'.
validations: validations:
required: true required: true

View File

@ -27,7 +27,7 @@ jobs:
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- name: Lint with stylua - name: Lint with stylua
uses: JohnnyMorganz/stylua-action@v1 uses: JohnnyMorganz/stylua-action@1.0.0
with: with:
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
args: --check . args: --check .

View File

@ -52,8 +52,7 @@ jobs:
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
env: env:
CC: ${{ matrix.cc }} CC: ${{ matrix.cc }}
NVIM: ${{ matrix.os == 'windows-2022' && 'nvim-win64\\bin\\nvim.exe' || 'nvim' }} NVIM: ${{ matrix.os == 'windows-2022' && 'Neovim\\bin\\nvim.exe' || 'nvim' }}
ALLOWED_INSTALLATION_FAILURES: ${{ matrix.os == 'windows-2022' && 'rnoweb' }}
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- uses: ilammy/msvc-dev-cmd@v1 - uses: ilammy/msvc-dev-cmd@v1
@ -62,7 +61,7 @@ jobs:
- name: Install and prepare Neovim - name: Install and prepare Neovim
env: env:
NVIM_TAG: ${{ matrix.nvim_tag }} NVIM_TAG: ${{ matrix.nvim_tag }}
TREE_SITTER_CLI_TAG: v0.20.6 TREE_SITTER_CLI_TAG: v0.20.4
run: | run: |
bash ./scripts/ci-install-${{ matrix.os }}.sh bash ./scripts/ci-install-${{ matrix.os }}.sh
@ -82,5 +81,12 @@ jobs:
if: matrix.os == 'windows-2022' if: matrix.os == 'windows-2022'
run: cp -r ~/AppData/Local/nvim/pack/nvim-treesitter/start/nvim-treesitter/parser/* parser run: cp -r ~/AppData/Local/nvim/pack/nvim-treesitter/start/nvim-treesitter/parser/* parser
# NOTE: this is a temporary workaround to skip swift tests on ubuntu
# stable and should be removed once neovim 0.7 is released.
- if: matrix.os == 'ubuntu-latest' && matrix.nvim_tag == 'stable'
run: echo "SKIP_SWIFT_CHECK=TRUE" >> $GITHUB_ENV
- name: Check query files - name: Check query files
env:
SKIP_SWIFT_CHECK: ${{ env.SKIP_SWIFT_CHECK }}
run: $NVIM --headless -c "luafile ./scripts/check-queries.lua" -c "q" run: $NVIM --headless -c "luafile ./scripts/check-queries.lua" -c "q"

View File

@ -41,7 +41,7 @@ jobs:
- name: Install and prepare Neovim - name: Install and prepare Neovim
env: env:
NVIM_TAG: stable NVIM_TAG: stable
TREE_SITTER_CLI_TAG: v0.20.6 TREE_SITTER_CLI_TAG: v0.20.4
run: | run: |
bash ./scripts/ci-install-${{ matrix.os }}.sh bash ./scripts/ci-install-${{ matrix.os }}.sh

View File

@ -6,7 +6,6 @@ on:
push: push:
branches: branches:
- master - master
workflow_dispatch:
jobs: jobs:
update-lockfile: update-lockfile:

View File

@ -4,7 +4,6 @@ on:
push: push:
branches: branches:
- master - master
workflow_dispatch:
jobs: jobs:
update-readme: update-readme:

View File

@ -89,179 +89,143 @@ effect on highlighting. We will work on improving highlighting in the near futur
#### Misc #### Misc
```scheme ```
@comment ; line and block comments @comment
@error ; syntax/parser errors @debug
@none ; completely disable the highlight @error for error `ERROR` nodes.
@preproc ; various preprocessor directives & shebangs @none to disable completely the highlight
@define ; preprocessor definition directives @preproc
@operator ; symbolic operators (e.g. `+` / `*`) @punctuation.delimiter for `;` `.` `,`
@punctuation.bracket for `()` or `{}`
@punctuation.special for symbols with special meaning like `{}` in string interpolation.
``` ```
#### Punctuation #### Constants
```scheme
@punctuation.delimiter ; delimiters (e.g. `;` / `.` / `,`)
@punctuation.bracket ; brackets (e.g. `()` / `{}` / `[]`)
@punctuation.special ; special symbols (e.g. `{}` in string interpolation)
``` ```
@constant
#### Literals @constant.builtin
@constant.macro
```scheme @string
@string ; string literals @string.regex
@string.regex ; regular expressions @string.escape
@string.escape ; escape sequences @string.special
@string.special ; other special strings (e.g. dates) @character
@character.special
@character ; character literals @number
@character.special ; special characters (e.g. wildcards) @boolean
@float
@boolean ; boolean literals
@number ; numeric literals
@float ; floating-point number literals
``` ```
#### Functions #### Functions
```scheme ```
@function ; function definitions @function
@function.builtin ; built-in functions @function.builtin
@function.call ; function calls @function.macro
@function.macro ; preprocessor macros @parameter
@method ; method definitions @method
@method.call ; method calls @field
@property
@constructor ; constructor calls and definitions @constructor
@parameter ; parameters of a function
``` ```
#### Keywords #### Keywords
```scheme ```
@keyword ; various keywords @conditional (e.g. `if`, `else`)
@keyword.function ; keywords that define a function (e.g. `func` in Go, `def` in Python) @repeat (e.g. `for`, `while`)
@keyword.operator ; operators that are English words (e.g. `and` / `or`) @label for C/Lua-like labels
@keyword.return ; keywords like `return` and `yield` @keyword
@keyword.function (keyword to define a function, e.g. `func` in Go, `def` in Python)
@keyword.operator (for operators that are English words, e.g. `and`, `or`)
@keyword.return
@operator (for symbolic operators, e.g. `+`, `*`)
@exception (e.g. `throw`, `catch`)
@include keywords for including modules (e.g. import/from in Python)
@storageclass
@conditional ; keywords related to conditionals (e.g. `if` / `else`) @type
@repeat ; keywords related to loops (e.g. `for` / `while`) @type.builtin
@debug ; keywords related to debugging @type.definition
@label ; GOTO and other labels (e.g. `label:` in C) @type.qualifier
@include ; keywords for including modules (e.g. `import` / `from` in Python) @namespace for identifiers referring to namespaces
@exception ; keywords related to exceptions (e.g. `throw` / `catch`) @symbol for identifiers referring to symbols
@attribute for e.g. Python decorators
``` ```
#### Types @conceal followed by `(#set! conceal "")` for captures that are not used for highlights but only for concealing.
```scheme #### Variables
@type ; type or class definitions and annotations
@type.builtin ; built-in types
@type.definition ; type definitions (e.g. `typedef` in C)
@type.qualifier ; type qualifiers (e.g. `const`)
@storageclass ; visibility/life-time modifiers
@storageclass.lifetime ; life-time modifiers (e.g. `static`)
@attribute ; attribute annotations (e.g. Python decorators)
@field ; object and struct fields
@property ; similar to `@field`
``` ```
@variable
#### Identifiers @variable.builtin
```scheme
@variable ; various variable names
@variable.builtin ; built-in variable names (e.g. `this`)
@constant ; constant identifiers
@constant.builtin ; built-in constant values
@constant.macro ; constants defined by the preprocessor
@namespace ; modules or namespaces
@symbol ; symbols or atoms
``` ```
#### Text #### Text
Mainly for markup languages. Mainly for markup languages.
```scheme ```
@text ; non-structured text @text
@text.strong ; bold text @text.strong
@text.emphasis ; text with emphasis @text.emphasis
@text.underline ; underlined text @text.underline
@text.strike ; strikethrough text @text.strike
@text.title ; text that is part of a title @text.title
@text.literal ; literal or verbatim text @text.literal
@text.uri ; URIs (e.g. hyperlinks) @text.uri
@text.math ; math environments (e.g. `$ ... $` in LaTeX) @text.math (e.g. for LaTeX math environments)
@text.environment ; text environments of markup languages @text.environment (e.g. for text environments of markup languages)
@text.environment.name ; text indicating the type of an environment @text.environment.name (e.g. for the name/the string indicating the type of text environment)
@text.reference ; text references, footnotes, citations, etc. @text.reference (for footnotes, text references, citations)
@text.todo ; todo notes @text.note
@text.note ; info notes @text.warning
@text.warning ; warning notes @text.danger
@text.danger ; danger/error notes
@text.diff.add ; added text (for diff files) @todo
@text.diff.delete ; deleted text (for diff files)
``` ```
#### Tags #### Tags
Used for XML-like tags. Used for xml-like tags
```scheme ```
@tag ; XML tag names @tag
@tag.attribute ; XML tag attributes @tag.attribute
@tag.delimiter ; XML tag delimiters @tag.delimiter
``` ```
#### Conceal #### Conceal
@conceal followed by `(#set! conceal "")` for captures that are not used for highlights but only for concealing.
```scheme
@conceal ; for captures that are only used for concealing
```
`@conceal` must be followed by `(#set! conceal "")`.
#### Spell
```scheme
@spell ; for defining regions to be spellchecked
```
#### Non-standard
These captures are used by some languages but don't have any default highlights.
They fall back to the parent capture if they are not manually defined.
```scheme
@variable.global
```
### Locals ### Locals
```scheme ```
@definition ; various definitions @definition for various definitions
@definition.constant ; constants @definition.constant
@definition.function ; functions @definition.function
@definition.method ; methods @definition.method
@definition.var ; variables @definition.var
@definition.parameter ; parameters @definition.parameter
@definition.macro ; preprocessor macros @definition.macro
@definition.type ; types or classes @definition.type
@definition.field ; fields or properties @definition.field
@definition.enum ; enumerations @definition.enum
@definition.namespace ; modules or namespaces @definition.namespace for modules or C++ namespaces
@definition.import ; imported names @definition.import for imported names
@definition.associated ; the associated type of a variable
@scope ; scope block @definition.associated to determine the type of a variable
@reference ; identifier reference @definition.doc for documentation adjacent to a definition. E.g.
@scope
@reference
@constructor
``` ```
@ -295,8 +259,8 @@ Possible scope values are:
You can define folds for a given language by adding a `folds.scm` query : You can define folds for a given language by adding a `folds.scm` query :
```scheme ```
@fold ; fold this node @fold
``` ```
If the `fold.scm` query is not present, this will fallback to the `@scope` captures in the `locals` If the `fold.scm` query is not present, this will fallback to the `@scope` captures in the `locals`
@ -310,25 +274,25 @@ You can directly use the name of the language that you want to inject (e.g. `@ht
If you want to dynamically detect the language (e.g. for Markdown blocks) use the `@language` to capture If you want to dynamically detect the language (e.g. for Markdown blocks) use the `@language` to capture
the node describing the language and `@content` to describe the injection region. the node describing the language and `@content` to describe the injection region.
```scheme ```
@{lang} ; e.g. @html to describe a html region @{language} ; e.g. @html to describe a html region
@language ; dynamic detection of the injection language (i.e. the text of the captured node describes the language) @language ; dynamic detection of the injection language (i.e. the text of the captured node describes the language).
@content ; region for the dynamically detected language @content ; region for the dynamically detected language.
@combined ; combine all matches of a pattern as one single block of content @combined ; This will combine all matches of a pattern as one single block of content.
``` ```
### Indents ### Indents
```scheme ```
@indent ; indent children when matching this node @indent ; Indent children when matching this node
@indent_end ; marks the end of indented block @indent_end ; Marks the end of indented block
@aligned_indent ; behaves like python aligned/hanging indent @aligned_indent ; Behaves like python aligned/hanging indent
@dedent ; dedent children when matching this node @dedent ; Dedent children when matching this node
@branch ; dedent itself when matching this node @branch ; Dedent itself when matching this node
@ignore ; do not indent in this node @ignore ; Do not indent in this node
@auto ; behaves like 'autoindent' buffer option @auto ; Behaves like 'autoindent' buffer option
@zero_indent ; sets this node at position 0 (no indent) @zero_indent ; Sets this node at position 0 (no indent)
``` ```
[Zulip]: https://nvim-treesitter.zulipchat.com [Zulip]: https://nvim-treesitter.zulipchat.com

View File

@ -63,7 +63,7 @@ For more detailed information on setting these up, see ["Advanced setup"](#advan
## Requirements ## Requirements
- **Neovim 0.8.0 or later** built with **tree-sitter 0.20.3+** (latest [nightly](https://github.com/neovim/neovim#install-from-source) recommended) - Neovim latest stable version or [nightly](https://github.com/neovim/neovim#install-from-source)
- `tar` and `curl` in your path (or alternatively `git`) - `tar` and `curl` in your path (or alternatively `git`)
- A C compiler in your path and libstdc++ installed ([Windows users please read this!](https://github.com/nvim-treesitter/nvim-treesitter/wiki/Windows-support)). - A C compiler in your path and libstdc++ installed ([Windows users please read this!](https://github.com/nvim-treesitter/nvim-treesitter/wiki/Windows-support)).
@ -109,33 +109,18 @@ require'nvim-treesitter.configs'.setup {
-- Install parsers synchronously (only applied to `ensure_installed`) -- Install parsers synchronously (only applied to `ensure_installed`)
sync_install = false, sync_install = false,
-- Automatically install missing parsers when entering buffer
-- Recommendation: set to false if you don't have `tree-sitter` CLI installed locally
auto_install = true,
-- List of parsers to ignore installing (for "all") -- List of parsers to ignore installing (for "all")
ignore_install = { "javascript" }, ignore_install = { "javascript" },
---- If you need to change the installation directory of the parsers (see -> Advanced Setup)
-- parser_install_dir = "/some/path/to/store/parsers", -- Remember to run vim.opt.runtimepath:append("/some/path/to/store/parsers")!
highlight = { highlight = {
-- `false` will disable the whole extension -- `false` will disable the whole extension
enable = true, enable = true,
-- NOTE: these are the names of the parsers and not the filetype. (for example if you want to -- NOTE: these are the names of the parsers and not the filetype. (for example if you want to
-- disable highlighting for the `tex` filetype, you need to include `latex` in this list as this is disable highlighting for the `tex` filetype, you need to include `latex` in this list as this is
-- the name of the parser) the name of the parser)
-- list of language that will be disabled -- list of language that will be disabled
disable = { "c", "rust" }, disable = { "c", "rust" },
-- Or use a function for more flexibility, e.g. to disable slow treesitter highlight for large files
disable = function(lang, buf)
local max_filesize = 100 * 1024 -- 100 KB
local ok, stats = pcall(vim.loop.fs_stat, vim.api.nvim_buf_get_name(buf))
if ok and stats and stats.size > max_filesize then
return true
end
end,
-- Setting this to true will run `:h syntax` and tree-sitter at the same time. -- Setting this to true will run `:h syntax` and tree-sitter at the same time.
-- Set this to `true` if you depend on 'syntax' being enabled (like for indentation). -- Set this to `true` if you depend on 'syntax' being enabled (like for indentation).
@ -172,12 +157,10 @@ We are looking for maintainers to add more parsers and to write query files for
<!--This section of the README is automatically updated by a CI job--> <!--This section of the README is automatically updated by a CI job-->
<!--parserinfo--> <!--parserinfo-->
- [x] [agda](https://github.com/AusCyberman/tree-sitter-agda) (maintained by @Decodetalkers)
- [x] [astro](https://github.com/virchau13/tree-sitter-astro) (maintained by @virchau13) - [x] [astro](https://github.com/virchau13/tree-sitter-astro) (maintained by @virchau13)
- [x] [bash](https://github.com/tree-sitter/tree-sitter-bash) (maintained by @TravonteD) - [x] [bash](https://github.com/tree-sitter/tree-sitter-bash) (maintained by @TravonteD)
- [x] [beancount](https://github.com/polarmutex/tree-sitter-beancount) (maintained by @polarmutex) - [x] [beancount](https://github.com/polarmutex/tree-sitter-beancount) (maintained by @polarmutex)
- [x] [bibtex](https://github.com/latex-lsp/tree-sitter-bibtex) (maintained by @theHamsta, @clason) - [x] [bibtex](https://github.com/latex-lsp/tree-sitter-bibtex) (maintained by @theHamsta, @clason)
- [x] [blueprint](https://gitlab.com/gabmus/tree-sitter-blueprint.git) (experimental, maintained by @gabmus)
- [x] [c](https://github.com/tree-sitter/tree-sitter-c) (maintained by @vigoux) - [x] [c](https://github.com/tree-sitter/tree-sitter-c) (maintained by @vigoux)
- [x] [c_sharp](https://github.com/tree-sitter/tree-sitter-c-sharp) (maintained by @Luxed) - [x] [c_sharp](https://github.com/tree-sitter/tree-sitter-c-sharp) (maintained by @Luxed)
- [x] [clojure](https://github.com/sogaiu/tree-sitter-clojure) (maintained by @sogaiu) - [x] [clojure](https://github.com/sogaiu/tree-sitter-clojure) (maintained by @sogaiu)
@ -191,14 +174,12 @@ We are looking for maintainers to add more parsers and to write query files for
- [x] [d](https://github.com/CyberShadow/tree-sitter-d) (experimental, maintained by @nawordar) - [x] [d](https://github.com/CyberShadow/tree-sitter-d) (experimental, maintained by @nawordar)
- [x] [dart](https://github.com/UserNobody14/tree-sitter-dart) (maintained by @Akin909) - [x] [dart](https://github.com/UserNobody14/tree-sitter-dart) (maintained by @Akin909)
- [x] [devicetree](https://github.com/joelspadin/tree-sitter-devicetree) (maintained by @jedrzejboczar) - [x] [devicetree](https://github.com/joelspadin/tree-sitter-devicetree) (maintained by @jedrzejboczar)
- [x] [diff](https://github.com/the-mikedavis/tree-sitter-diff) (maintained by @gbprod)
- [x] [dockerfile](https://github.com/camdencheek/tree-sitter-dockerfile) (maintained by @camdencheek) - [x] [dockerfile](https://github.com/camdencheek/tree-sitter-dockerfile) (maintained by @camdencheek)
- [x] [dot](https://github.com/rydesun/tree-sitter-dot) (maintained by @rydesun) - [x] [dot](https://github.com/rydesun/tree-sitter-dot) (maintained by @rydesun)
- [x] [eex](https://github.com/connorlay/tree-sitter-eex) (maintained by @connorlay) - [x] [eex](https://github.com/connorlay/tree-sitter-eex) (maintained by @connorlay)
- [x] [elixir](https://github.com/elixir-lang/tree-sitter-elixir) (maintained by @jonatanklosko, @connorlay) - [x] [elixir](https://github.com/elixir-lang/tree-sitter-elixir) (maintained by @jonatanklosko, @connorlay)
- [ ] [elm](https://github.com/elm-tooling/tree-sitter-elm) - [ ] [elm](https://github.com/elm-tooling/tree-sitter-elm)
- [x] [elvish](https://github.com/ckafi/tree-sitter-elvish) (maintained by @ckafi) - [x] [elvish](https://github.com/ckafi/tree-sitter-elvish) (maintained by @ckafi)
- [ ] [embedded_template](https://github.com/tree-sitter/tree-sitter-embedded-template)
- [x] [erlang](https://github.com/AbstractMachinesLab/tree-sitter-erlang) (maintained by @ostera) - [x] [erlang](https://github.com/AbstractMachinesLab/tree-sitter-erlang) (maintained by @ostera)
- [x] [fennel](https://github.com/travonted/tree-sitter-fennel) (maintained by @TravonteD) - [x] [fennel](https://github.com/travonted/tree-sitter-fennel) (maintained by @TravonteD)
- [x] [fish](https://github.com/ram02z/tree-sitter-fish) (maintained by @ram02z) - [x] [fish](https://github.com/ram02z/tree-sitter-fish) (maintained by @ram02z)
@ -206,9 +187,6 @@ We are looking for maintainers to add more parsers and to write query files for
- [ ] [fortran](https://github.com/stadelmanma/tree-sitter-fortran) - [ ] [fortran](https://github.com/stadelmanma/tree-sitter-fortran)
- [x] [fusion](https://gitlab.com/jirgn/tree-sitter-fusion.git) (maintained by @jirgn) - [x] [fusion](https://gitlab.com/jirgn/tree-sitter-fusion.git) (maintained by @jirgn)
- [x] [Godot (gdscript)](https://github.com/PrestonKnopp/tree-sitter-gdscript) (maintained by @Shatur95) - [x] [Godot (gdscript)](https://github.com/PrestonKnopp/tree-sitter-gdscript) (maintained by @Shatur95)
- [x] [git_rebase](https://github.com/the-mikedavis/tree-sitter-git-rebase) (maintained by @gbprod)
- [x] [gitattributes](https://github.com/ObserverOfTime/tree-sitter-gitattributes) (maintained by @ObserverOfTime)
- [x] [gitignore](https://github.com/shunsambongi/tree-sitter-gitignore) (maintained by @theHamsta)
- [x] [gleam](https://github.com/J3RN/tree-sitter-gleam) (maintained by @connorlay) - [x] [gleam](https://github.com/J3RN/tree-sitter-gleam) (maintained by @connorlay)
- [x] [Glimmer and Ember](https://github.com/alexlafroscia/tree-sitter-glimmer) (maintained by @alexlafroscia) - [x] [Glimmer and Ember](https://github.com/alexlafroscia/tree-sitter-glimmer) (maintained by @alexlafroscia)
- [x] [glsl](https://github.com/theHamsta/tree-sitter-glsl) (maintained by @theHamsta) - [x] [glsl](https://github.com/theHamsta/tree-sitter-glsl) (maintained by @theHamsta)
@ -221,19 +199,17 @@ We are looking for maintainers to add more parsers and to write query files for
- [ ] [haskell](https://github.com/tree-sitter/tree-sitter-haskell) - [ ] [haskell](https://github.com/tree-sitter/tree-sitter-haskell)
- [x] [hcl](https://github.com/MichaHoffmann/tree-sitter-hcl) (maintained by @MichaHoffmann) - [x] [hcl](https://github.com/MichaHoffmann/tree-sitter-hcl) (maintained by @MichaHoffmann)
- [x] [heex](https://github.com/connorlay/tree-sitter-heex) (maintained by @connorlay) - [x] [heex](https://github.com/connorlay/tree-sitter-heex) (maintained by @connorlay)
- [x] [help](https://github.com/neovim/tree-sitter-vimdoc) (maintained by @vigoux) - [x] [help](https://github.com/vigoux/tree-sitter-vimdoc) (experimental, maintained by @vigoux)
- [x] [hjson](https://github.com/winston0410/tree-sitter-hjson) (maintained by @winston0410) - [x] [hjson](https://github.com/winston0410/tree-sitter-hjson) (maintained by @winston0410)
- [x] [hlsl](https://github.com/theHamsta/tree-sitter-hlsl) (maintained by @theHamsta)
- [x] [hocon](https://github.com/antosha417/tree-sitter-hocon) (maintained by @antosha417) - [x] [hocon](https://github.com/antosha417/tree-sitter-hocon) (maintained by @antosha417)
- [x] [html](https://github.com/tree-sitter/tree-sitter-html) (maintained by @TravonteD) - [x] [html](https://github.com/tree-sitter/tree-sitter-html) (maintained by @TravonteD)
- [x] [http](https://github.com/rest-nvim/tree-sitter-http) (maintained by @NTBBloodbath) - [x] [http](https://github.com/NTBBloodbath/tree-sitter-http) (maintained by @NTBBloodbath)
- [x] [java](https://github.com/tree-sitter/tree-sitter-java) (maintained by @p00f) - [x] [java](https://github.com/tree-sitter/tree-sitter-java) (maintained by @p00f)
- [x] [javascript](https://github.com/tree-sitter/tree-sitter-javascript) (maintained by @steelsojka) - [x] [javascript](https://github.com/tree-sitter/tree-sitter-javascript) (maintained by @steelsojka)
- [x] [jsdoc](https://github.com/tree-sitter/tree-sitter-jsdoc) (maintained by @steelsojka) - [x] [jsdoc](https://github.com/tree-sitter/tree-sitter-jsdoc) (maintained by @steelsojka)
- [x] [json](https://github.com/tree-sitter/tree-sitter-json) (maintained by @steelsojka) - [x] [json](https://github.com/tree-sitter/tree-sitter-json) (maintained by @steelsojka)
- [x] [json5](https://github.com/Joakker/tree-sitter-json5) (maintained by @Joakker) - [x] [json5](https://github.com/Joakker/tree-sitter-json5) (maintained by @Joakker)
- [x] [JSON with comments](https://gitlab.com/WhyNotHugo/tree-sitter-jsonc.git) (maintained by @WhyNotHugo) - [x] [JSON with comments](https://gitlab.com/WhyNotHugo/tree-sitter-jsonc.git) (maintained by @WhyNotHugo)
- [x] [jsonnet](https://github.com/sourcegraph/tree-sitter-jsonnet) (maintained by @nawordar)
- [x] [julia](https://github.com/tree-sitter/tree-sitter-julia) (maintained by @mroavi, @theHamsta) - [x] [julia](https://github.com/tree-sitter/tree-sitter-julia) (maintained by @mroavi, @theHamsta)
- [x] [kotlin](https://github.com/fwcd/tree-sitter-kotlin) (maintained by @SalBakraa) - [x] [kotlin](https://github.com/fwcd/tree-sitter-kotlin) (maintained by @SalBakraa)
- [x] [lalrpop](https://github.com/traxys/tree-sitter-lalrpop) (maintained by @traxys) - [x] [lalrpop](https://github.com/traxys/tree-sitter-lalrpop) (maintained by @traxys)
@ -241,38 +217,28 @@ We are looking for maintainers to add more parsers and to write query files for
- [x] [ledger](https://github.com/cbarrete/tree-sitter-ledger) (maintained by @cbarrete) - [x] [ledger](https://github.com/cbarrete/tree-sitter-ledger) (maintained by @cbarrete)
- [x] [llvm](https://github.com/benwilliamgraham/tree-sitter-llvm) (maintained by @benwilliamgraham) - [x] [llvm](https://github.com/benwilliamgraham/tree-sitter-llvm) (maintained by @benwilliamgraham)
- [x] [lua](https://github.com/MunifTanjim/tree-sitter-lua) (maintained by @muniftanjim) - [x] [lua](https://github.com/MunifTanjim/tree-sitter-lua) (maintained by @muniftanjim)
- [x] [m68k](https://github.com/grahambates/tree-sitter-m68k) (maintained by @grahambates)
- [x] [make](https://github.com/alemuller/tree-sitter-make) (maintained by @lewis6991) - [x] [make](https://github.com/alemuller/tree-sitter-make) (maintained by @lewis6991)
- [x] [markdown](https://github.com/MDeiml/tree-sitter-markdown) (experimental, maintained by @MDeiml) - [ ] [markdown](https://github.com/MDeiml/tree-sitter-markdown)
- [x] [markdown_inline](https://github.com/MDeiml/tree-sitter-markdown) (experimental, maintained by @MDeiml)
- [x] [menhir](https://github.com/Kerl13/tree-sitter-menhir) (maintained by @Kerl13)
- [x] [meson](https://github.com/Decodetalkers/tree-sitter-meson) (maintained by @Decodetalkers)
- [ ] [nickel](https://github.com/nickel-lang/tree-sitter-nickel)
- [x] [ninja](https://github.com/alemuller/tree-sitter-ninja) (maintained by @alemuller) - [x] [ninja](https://github.com/alemuller/tree-sitter-ninja) (maintained by @alemuller)
- [x] [nix](https://github.com/cstrahan/tree-sitter-nix) (maintained by @leo60228) - [x] [nix](https://github.com/cstrahan/tree-sitter-nix) (maintained by @leo60228)
- [x] [norg](https://github.com/nvim-neorg/tree-sitter-norg) (maintained by @JoeyGrajciar, @vhyrro, @mrossinek) - [x] [norg](https://github.com/nvim-neorg/tree-sitter-norg) (maintained by @JoeyGrajciar, @vhyrro, @mrossinek)
- [x] [ocaml](https://github.com/tree-sitter/tree-sitter-ocaml) (maintained by @undu) - [x] [ocaml](https://github.com/tree-sitter/tree-sitter-ocaml) (maintained by @undu)
- [x] [ocaml_interface](https://github.com/tree-sitter/tree-sitter-ocaml) (maintained by @undu) - [x] [ocaml_interface](https://github.com/tree-sitter/tree-sitter-ocaml) (maintained by @undu)
- [x] [ocamllex](https://github.com/atom-ocaml/tree-sitter-ocamllex) (maintained by @undu) - [x] [ocamllex](https://github.com/atom-ocaml/tree-sitter-ocamllex) (maintained by @undu)
- [ ] [org](https://github.com/milisims/tree-sitter-org)
- [x] [pascal](https://github.com/Isopod/tree-sitter-pascal.git) (maintained by @isopod) - [x] [pascal](https://github.com/Isopod/tree-sitter-pascal.git) (maintained by @isopod)
- [x] [perl](https://github.com/ganezdragon/tree-sitter-perl) (maintained by @ganezdragon) - [x] [perl](https://github.com/ganezdragon/tree-sitter-perl) (maintained by @ganezdragon)
- [x] [php](https://github.com/tree-sitter/tree-sitter-php) (maintained by @tk-shirasaka) - [x] [php](https://github.com/tree-sitter/tree-sitter-php) (maintained by @tk-shirasaka)
- [x] [phpdoc](https://github.com/claytonrcarter/tree-sitter-phpdoc) (experimental, maintained by @mikehaertl) - [x] [phpdoc](https://github.com/claytonrcarter/tree-sitter-phpdoc) (experimental, maintained by @mikehaertl)
- [x] [pioasm](https://github.com/leo60228/tree-sitter-pioasm) (maintained by @leo60228) - [x] [pioasm](https://github.com/leo60228/tree-sitter-pioasm) (maintained by @leo60228)
- [x] [prisma](https://github.com/victorhqc/tree-sitter-prisma) (maintained by @elianiva) - [x] [prisma](https://github.com/victorhqc/tree-sitter-prisma) (maintained by @elianiva)
- [x] [proto](https://github.com/mitchellh/tree-sitter-proto) (maintained by @fsouza) - [x] [pug](https://github.com/zealot128/tree-sitter-pug) (maintained by @zealot128)
- [x] [pug](https://github.com/zealot128/tree-sitter-pug) (experimental, maintained by @zealot128)
- [x] [python](https://github.com/tree-sitter/tree-sitter-python) (maintained by @stsewd, @theHamsta) - [x] [python](https://github.com/tree-sitter/tree-sitter-python) (maintained by @stsewd, @theHamsta)
- [x] [ql](https://github.com/tree-sitter/tree-sitter-ql) (maintained by @pwntester) - [x] [ql](https://github.com/tree-sitter/tree-sitter-ql) (maintained by @pwntester)
- [x] [qmljs](https://github.com/yuja/tree-sitter-qmljs) (maintained by @yuja)
- [x] [Tree-sitter query language](https://github.com/nvim-treesitter/tree-sitter-query) (maintained by @steelsojka) - [x] [Tree-sitter query language](https://github.com/nvim-treesitter/tree-sitter-query) (maintained by @steelsojka)
- [x] [r](https://github.com/r-lib/tree-sitter-r) (maintained by @jimhester) - [x] [r](https://github.com/r-lib/tree-sitter-r) (maintained by @jimhester)
- [x] [racket](https://github.com/6cdh/tree-sitter-racket) (maintained by @6cdh)
- [x] [rasi](https://github.com/Fymyte/tree-sitter-rasi) (maintained by @Fymyte) - [x] [rasi](https://github.com/Fymyte/tree-sitter-rasi) (maintained by @Fymyte)
- [x] [regex](https://github.com/tree-sitter/tree-sitter-regex) (maintained by @theHamsta) - [x] [regex](https://github.com/tree-sitter/tree-sitter-regex) (maintained by @theHamsta)
- [x] [rego](https://github.com/FallenAngel97/tree-sitter-rego) (maintained by @FallenAngel97) - [x] [rego](https://github.com/FallenAngel97/tree-sitter-rego) (maintained by @FallenAngel97)
- [x] [rnoweb](https://github.com/bamonroe/tree-sitter-rnoweb) (maintained by @bamonroe)
- [x] [rst](https://github.com/stsewd/tree-sitter-rst) (maintained by @stsewd) - [x] [rst](https://github.com/stsewd/tree-sitter-rst) (maintained by @stsewd)
- [x] [ruby](https://github.com/tree-sitter/tree-sitter-ruby) (maintained by @TravonteD) - [x] [ruby](https://github.com/tree-sitter/tree-sitter-ruby) (maintained by @TravonteD)
- [x] [rust](https://github.com/tree-sitter/tree-sitter-rust) (maintained by @vigoux) - [x] [rust](https://github.com/tree-sitter/tree-sitter-rust) (maintained by @vigoux)
@ -282,25 +248,19 @@ We are looking for maintainers to add more parsers and to write query files for
- [x] [slint](https://github.com/jrmoulton/tree-sitter-slint) (experimental, maintained by @jrmoulton) - [x] [slint](https://github.com/jrmoulton/tree-sitter-slint) (experimental, maintained by @jrmoulton)
- [x] [solidity](https://github.com/YongJieYongJie/tree-sitter-solidity) (maintained by @YongJieYongJie) - [x] [solidity](https://github.com/YongJieYongJie/tree-sitter-solidity) (maintained by @YongJieYongJie)
- [x] [sparql](https://github.com/BonaBeavis/tree-sitter-sparql) (maintained by @bonabeavis) - [x] [sparql](https://github.com/BonaBeavis/tree-sitter-sparql) (maintained by @bonabeavis)
- [x] [sql](https://github.com/derekstride/tree-sitter-sql) (maintained by @derekstride)
- [x] [supercollider](https://github.com/madskjeldgaard/tree-sitter-supercollider) (maintained by @madskjeldgaard) - [x] [supercollider](https://github.com/madskjeldgaard/tree-sitter-supercollider) (maintained by @madskjeldgaard)
- [x] [surface](https://github.com/connorlay/tree-sitter-surface) (maintained by @connorlay) - [x] [surface](https://github.com/connorlay/tree-sitter-surface) (maintained by @connorlay)
- [x] [svelte](https://github.com/Himujjal/tree-sitter-svelte) (maintained by @elianiva) - [x] [svelte](https://github.com/Himujjal/tree-sitter-svelte) (maintained by @elianiva)
- [x] [swift](https://github.com/alex-pinkus/tree-sitter-swift) (maintained by @alex-pinkus) - [ ] [swift](https://github.com/alex-pinkus/tree-sitter-swift)
- [x] [sxhkdrc](https://github.com/RaafatTurki/tree-sitter-sxhkdrc) (maintained by @RaafatTurki)
- [x] [teal](https://github.com/euclidianAce/tree-sitter-teal) (maintained by @euclidianAce) - [x] [teal](https://github.com/euclidianAce/tree-sitter-teal) (maintained by @euclidianAce)
- [x] [tiger](https://github.com/ambroisie/tree-sitter-tiger) (maintained by @ambroisie)
- [x] [tlaplus](https://github.com/tlaplus-community/tree-sitter-tlaplus) (maintained by @ahelwer, @susliko) - [x] [tlaplus](https://github.com/tlaplus-community/tree-sitter-tlaplus) (maintained by @ahelwer, @susliko)
- [x] [todotxt](https://github.com/arnarg/tree-sitter-todotxt.git) (experimental, maintained by @arnarg) - [x] [todotxt](https://github.com/arnarg/tree-sitter-todotxt.git) (experimental, maintained by @arnarg)
- [x] [toml](https://github.com/ikatyang/tree-sitter-toml) (maintained by @tk-shirasaka) - [x] [toml](https://github.com/ikatyang/tree-sitter-toml) (maintained by @tk-shirasaka)
- [x] [tsx](https://github.com/tree-sitter/tree-sitter-typescript) (maintained by @steelsojka) - [x] [tsx](https://github.com/tree-sitter/tree-sitter-typescript) (maintained by @steelsojka)
- [x] [turtle](https://github.com/BonaBeavis/tree-sitter-turtle) (maintained by @bonabeavis) - [x] [turtle](https://github.com/BonaBeavis/tree-sitter-turtle) (maintained by @bonabeavis)
- [x] [twig](https://github.com/gbprod/tree-sitter-twig) (maintained by @gbprod)
- [x] [typescript](https://github.com/tree-sitter/tree-sitter-typescript) (maintained by @steelsojka) - [x] [typescript](https://github.com/tree-sitter/tree-sitter-typescript) (maintained by @steelsojka)
- [x] [v](https://github.com/vlang/vls) (maintained by @tami5) - [x] [vala](https://github.com/matbme/tree-sitter-vala) (maintained by @matbme)
- [x] [vala](https://github.com/vala-lang/tree-sitter-vala) (maintained by @Prince781, @vala-lang) - [x] [verilog](https://github.com/tree-sitter/tree-sitter-verilog) (experimental, maintained by @zegervdv)
- [x] [verilog](https://github.com/tree-sitter/tree-sitter-verilog) (maintained by @zegervdv)
- [x] [vhs](https://github.com/charmbracelet/tree-sitter-vhs) (maintained by @caarlos0, @maaslalani)
- [x] [vim](https://github.com/vigoux/tree-sitter-viml) (maintained by @vigoux) - [x] [vim](https://github.com/vigoux/tree-sitter-viml) (maintained by @vigoux)
- [x] [vue](https://github.com/ikatyang/tree-sitter-vue) (maintained by @WhyNotHugo) - [x] [vue](https://github.com/ikatyang/tree-sitter-vue) (maintained by @WhyNotHugo)
- [x] [wgsl](https://github.com/szebniok/tree-sitter-wgsl) (maintained by @szebniok) - [x] [wgsl](https://github.com/szebniok/tree-sitter-wgsl) (maintained by @szebniok)
@ -309,7 +269,6 @@ We are looking for maintainers to add more parsers and to write query files for
- [x] [zig](https://github.com/maxxnino/tree-sitter-zig) (maintained by @maxxnino) - [x] [zig](https://github.com/maxxnino/tree-sitter-zig) (maintained by @maxxnino)
<!--parserinfo--> <!--parserinfo-->
For related information on the supported languages, including related plugins, see [this wiki page](https://github.com/nvim-treesitter/nvim-treesitter/wiki/Supported-Languages-Information).
# Available modules # Available modules
@ -335,22 +294,17 @@ require'nvim-treesitter.configs'.setup {
} }
``` ```
To customize the syntax highlighting of a capture, simply define or link a highlight group of the same name: You can add custom highlight captures with:
```lua ```vim
-- Highlight the @foo.bar capture group with the "Identifier" highlight group lua <<EOF
vim.api.nvim_set_hl(0, "@foo.bar", { link = "Identifier" }) require"nvim-treesitter.highlight".set_custom_captures {
-- Highlight the @foo.bar capture group with the "Identifier" highlight group.
["foo.bar"] = "Identifier",
}
EOF
``` ```
For a language-specific highlight, append the name of the language:
```lua
-- Highlight @foo.bar as "Identifier" only in Lua files
vim.api.nvim_set_hl(0, "@foo.bar.lua", { link = "Identifier" })
```
See `:h treesitter-highlight-groups` for details.
#### Incremental selection #### Incremental selection
Incremental selection based on the named nodes from the grammar. Incremental selection based on the named nodes from the grammar.
@ -389,45 +343,12 @@ Tree-sitter based folding. *(Technically not a module because it's per windows a
```vim ```vim
set foldmethod=expr set foldmethod=expr
set foldexpr=nvim_treesitter#foldexpr() set foldexpr=nvim_treesitter#foldexpr()
set nofoldenable " Disable folding at startup.
``` ```
This will respect your `foldminlines` and `foldnestmax` settings. This will respect your `foldminlines` and `foldnestmax` settings.
# Advanced setup # Advanced setup
## Changing the parser install directory
If you want to install the parsers to a custom directory you can specify this
directory with `parser_install_dir` option in that is passed to `setup`.
`nvim-treesitter` will then install the parser files into this directory.
This directory must be writeable and must be explicitly added to the
`runtimepath`. For example:
``` lua
require'nvim-treesitter.configs'.setup {
parser_install_dir = "/some/path/to/store/parsers",
...
}
vim.opt.runtimepath:append("/some/path/to/store/parsers")
```
If this option is not included in the setup options, or is explicitly set to
`nil` then the default install directories will be used. If this value is set
the default directories will be ignored.
Bear in mind that any parser installed into a parser folder on the runtime path
will still be considered installed. (For example if
"~/.local/share/nvim/site/parser/c.so" exists then the "c" parser will be
considered installed, even though it is not in `parser_install_dir`)
The default paths are:
1. first the package folder. Where `nvim-treesitter` is installed.
2. second the site directory. This is the "site" subdirectory of `stdpath("data")`.
## Adding parsers ## Adding parsers
If you have a parser that is not on the list of supported languages (either as a repository on Github or in a local directory), you can add it manually for use by `nvim-treesitter` as follows: If you have a parser that is not on the list of supported languages (either as a repository on Github or in a local directory), you can add it manually for use by `nvim-treesitter` as follows:
@ -466,7 +387,7 @@ Once the parser is installed, you can update it (from the latest revision of the
Note that neither `:TSInstall` nor `:TSInstallFromGrammar` copy query files from the grammar repository. Note that neither `:TSInstall` nor `:TSInstallFromGrammar` copy query files from the grammar repository.
If you want your installed grammar to be useful, you must manually [add query files](#adding-queries) to your local nvim-treesitter installation. If you want your installed grammar to be useful, you must manually [add query files](#adding-queries) to your local nvim-treesitter installation.
Note also that module functionality is only triggered if your language's filetype is correctly identified. Note also that module functionality is only triggered if your language's filetype is correctly identified.
If Neovim does not detect your language's filetype by default, you can use [Neovim's `vim.filetype.add()`](https://neovim.io/doc/user/lua.html#vim.filetype.add()) to add a custom detection rule. If Neovim does not detect your language's filetype by default, you can use [Neovim's `vim.filetype.add()`](https://neovim.io/doc/user/lua.html#vim.filetype.add()) (0.7.0 and above) to add a custom detection rule.
If you use a git repository for your parser and want to use a specific version, you can set the `revision` key If you use a git repository for your parser and want to use a specific version, you can set the `revision` key
in the `install_info` table for you parser config. in the `install_info` table for you parser config.
@ -476,7 +397,7 @@ in the `install_info` table for you parser config.
Queries are what `nvim-treesitter` uses to extract information from the syntax tree; Queries are what `nvim-treesitter` uses to extract information from the syntax tree;
they are located in the `queries/{language}/*` runtime directories (see `:h rtp`), they are located in the `queries/{language}/*` runtime directories (see `:h rtp`),
like the `queries` folder of this plugin, e.g. `queries/{language}/{locals,highlights,textobjects}.scm`. like the `queries` folder of this plugin, e.g. `queries/{language}/{locals,highlights,textobjects}.scm`.
Other modules may require additional queries such as `folding.scm`. You can find a Other modules may require additional queries such as `folding.scm`. You can find a
list of all supported capture names in [CONTRIBUTING.md](https://github.com/nvim-treesitter/nvim-treesitter/blob/master/CONTRIBUTING.md#parser-configurations). list of all supported capture names in [CONTRIBUTING.md](https://github.com/nvim-treesitter/nvim-treesitter/blob/master/CONTRIBUTING.md#parser-configurations).
All queries found in the runtime directories will be combined. All queries found in the runtime directories will be combined.
@ -548,7 +469,7 @@ Check [`:h nvim-treesitter-utils`](doc/nvim-treesitter.txt) for more information
# Troubleshooting # Troubleshooting
Before doing anything, make sure you have the latest version of this plugin and run `:checkhealth nvim-treesitter`. Before doing anything, make sure you have the latest version of this plugin and run `:checkhealth nvim_treesitter`.
It can also help to update the parsers via `:TSUpdate`. It can also help to update the parsers via `:TSUpdate`.
#### Feature `X` does not work for `{language}`... #### Feature `X` does not work for `{language}`...

View File

@ -1,5 +1,5 @@
function! nvim_treesitter#statusline(...) abort function! nvim_treesitter#statusline(...) abort
return luaeval("require'nvim-treesitter.statusline'.statusline(_A)", get(a:, 1, {})) return luaeval("require'nvim-treesitter'.statusline(_A)", get(a:, 1, {}))
endfunction endfunction
function! nvim_treesitter#foldexpr() abort function! nvim_treesitter#foldexpr() abort
@ -7,11 +7,11 @@ function! nvim_treesitter#foldexpr() abort
endfunction endfunction
function! nvim_treesitter#installable_parsers(arglead, cmdline, cursorpos) abort function! nvim_treesitter#installable_parsers(arglead, cmdline, cursorpos) abort
return join(luaeval("require'nvim-treesitter.parsers'.available_parsers()") + ['all'], "\n") return join(luaeval("require'nvim-treesitter.parsers'.available_parsers()") + ['all', 'maintained'], "\n")
endfunction endfunction
function! nvim_treesitter#installed_parsers(arglead, cmdline, cursorpos) abort function! nvim_treesitter#installed_parsers(arglead, cmdline, cursorpos) abort
return join(luaeval("require'nvim-treesitter.info'.installed_parsers()") + ['all'], "\n") return join(luaeval("require'nvim-treesitter.info'.installed_parsers()") + ['all', 'maintained'], "\n")
endfunction endfunction
function! nvim_treesitter#available_modules(arglead, cmdline, cursorpos) abort function! nvim_treesitter#available_modules(arglead, cmdline, cursorpos) abort

View File

@ -1,32 +0,0 @@
local MODREV, SPECREV = "scm", "-1"
rockspec_format = "3.0"
package = "nvim-treesitter"
version = MODREV .. SPECREV
description = {
summary = "Nvim Treesitter configurations and abstraction layer",
labels = { "neovim"},
homepage = "https://github.com/nvim-treesitter/nvim-treesitter",
license = "Apache-2.0",
}
dependencies = {
"lua >= 5.1, < 5.4",
}
source = {
url = "http://github.com/nvim-treesitter/nvim-treesitter/archive/v" .. MODREV .. ".zip",
}
if MODREV == 'scm' then
source = {
url = 'git://github.com/nvim-treesitter/nvim-treesitter',
}
end
build = {
type = "builtin",
copy_directories = {
'plugin'
}
}

View File

@ -39,21 +39,12 @@ To enable supported features, put this in your `init.lua` file:
> >
require'nvim-treesitter.configs'.setup { require'nvim-treesitter.configs'.setup {
-- A directory to install the parsers into.
-- If this is excluded or nil parsers are installed
-- to either the package dir, or the "site" dir.
-- If a custom path is used (not nil) it must be added to the runtimepath.
parser_install_dir = "/some/path/to/store/parsers",
-- A list of parser names, or "all" -- A list of parser names, or "all"
ensure_installed = { "c", "lua", "rust" }, ensure_installed = { "c", "lua", "rust" },
-- Install parsers synchronously (only applied to `ensure_installed`) -- Install parsers synchronously (only applied to `ensure_installed`)
sync_install = false, sync_install = false,
-- Automatically install missing parsers when entering buffer
auto_install = false,
-- List of parsers to ignore installing (for "all") -- List of parsers to ignore installing (for "all")
ignore_install = { "javascript" }, ignore_install = { "javascript" },
@ -71,7 +62,6 @@ To enable supported features, put this in your `init.lua` file:
additional_vim_regex_highlighting = false, additional_vim_regex_highlighting = false,
}, },
} }
vim.opt.runtimepath:append("/some/path/to/store/parsers")
< <
See |nvim-treesitter-modules| for a list of all available modules and its options. See |nvim-treesitter-modules| for a list of all available modules and its options.
@ -351,6 +341,11 @@ get_node_at_cursor(winnr)~
`winnr` will be 0 if nil. `winnr` will be 0 if nil.
Returns the node under the cursor. Returns the node under the cursor.
*ts_utils.get_node_text*
get_node_text(node, bufnr)~
Returns the text content of a `node`.
*ts_utils.is_parent* *ts_utils.is_parent*
is_parent(dest, source)~ is_parent(dest, source)~
@ -476,6 +471,299 @@ Note: This is highly experimental, and folding can break on some types of
edits. If you encounter such breakage, hiting `zx` should fix folding. edits. If you encounter such breakage, hiting `zx` should fix folding.
In any case, feel free to open an issue with the reproducing steps. In any case, feel free to open an issue with the reproducing steps.
==============================================================================
HIGHLIGHTS *nvim-treesitter-highlights*
The following is a list of highlights groups, the syntactic elements they
apply to, and some examples.
*hl-TSAttribute*
`TSAttribute`
Annotations that can be attached to the code to denote some kind of meta
information. e.g. C++/Dart attributes.
*hl-TSBoolean*
`TSBoolean`
Boolean literals: `True` and `False` in Python.
*hl-TSCharacter*
`TSCharacter`
Character literals: `'a'` in C.
*hl-TSCharacterSpecial*
`TSCharacterSpecial`
Special characters.
*hl-TSComment*
`TSComment`
Line comments and block comments.
*hl-TSConditional*
`TSConditional`
Keywords related to conditionals: `if`, `when`, `cond`, etc.
*hl-TSConstant*
`TSConstant`
Constants identifiers. These might not be semantically constant.
E.g. uppercase variables in Python.
*hl-TSConstBuiltin*
`TSConstBuiltin`
Built-in constant values: `nil` in Lua.
*hl-TSConstMacro*
`TSConstMacro`
Constants defined by macros: `NULL` in C.
*hl-TSConstructor*
`TSConstructor`
Constructor calls and definitions: `{}` in Lua, and Java constructors.
*hl-TSDebug*
`TSDebug`
Debugging statements.
*hl-TSDefine*
`TSDefine`
Preprocessor #define statements.
*hl-TSError*
`TSError`
Syntax/parser errors. This might highlight large sections of code while the
user is typing still incomplete code, use a sensible highlight.
*hl-TSException*
`TSException`
Exception related keywords: `try`, `except`, `finally` in Python.
*hl-TSField*
`TSField`
Object and struct fields.
*hl-TSFloat*
`TSFloat`
Floating-point number literals.
*hl-TSFunction*
`TSFunction`
Function calls and definitions.
*hl-TSFuncBuiltin*
`TSFuncBuiltin`
Built-in functions: `print` in Lua.
*hl-TSFuncMacro*
`TSFuncMacro`
Macro defined functions (calls and definitions): each `macro_rules` in
Rust.
*hl-TSInclude*
`TSInclude`
File or module inclusion keywords: `#include` in C, `use` or `extern crate` in
Rust.
*hl-TSKeyword*
`TSKeyword`
Keywords that don't fit into other categories.
*hl-TSKeywordFunction*
`TSKeywordFunction`
Keywords used to define a function: `function` in Lua, `def` and `lambda` in
Python.
*hl-TSKeywordOperator*
`TSKeywordOperator`
Unary and binary operators that are English words: `and`, `or` in Python;
`sizeof` in C.
*hl-TSKeywordReturn*
`TSKeywordReturn`
Keywords like `return` and `yield`.
*hl-TSLabel*
`TSLabel`
GOTO labels: `label:` in C, and `::label::` in Lua.
*hl-TSMethod*
`TSMethod`
Method calls and definitions.
*hl-TSNamespace*
`TSNamespace`
Identifiers referring to modules and namespaces.
*hl-None*
`TSNone`
No highlighting (sets all highlight arguments to `NONE`). this group is used
to clear certain ranges, for example, string interpolations. Don't change the
values of this highlight group.
*hl-TSNumber*
`TSNumber`
Numeric literals that don't fit into other categories.
*hl-TSOperator*
`TSOperator`
Binary or unary operators: `+`, and also `->` and `*` in C.
*hl-TSParameter*
`TSParameter`
Parameters of a function.
*hl-TSParameterReference*
`TSParameterReference`
References to parameters of a function.
*hl-TSPreProc*
`TSPreProc`
Preprocessor #if, #else, #endif, etc.
*hl-TSProperty*
`TSProperty`
Same as `TSField`.
*hl-TSPunctDelimiter*
`TSPunctDelimiter`
Punctuation delimiters: Periods, commas, semicolons, etc.
*hl-TSPunctBracket*
`TSPunctBracket`
Brackets, braces, parentheses, etc.
*hl-TSPunctSpecial*
`TSPunctSpecial`
Special punctuation that doesn't fit into the previous categories.
*hl-TSRepeat*
`TSRepeat`
Keywords related to loops: `for`, `while`, etc.
*hl-StorageClass*
`TSStorageClass`
Keywords that affect how a variable is stored: `static`, `comptime`, `extern`,
etc.
*hl-TSString*
`TSString`
String literals.
*hl-TSStringRegex*
`TSStringRegex`
Regular expression literals.
*hl-TSStringEscape*
`TSStringEscape`
Escape characters within a string: `\n`, `\t`, etc.
*hl-TSStringSpecial*
`TSStringSpecial`
Strings with special meaning that don't fit into the previous categories.
*hl-TSSymbol*
`TSSymbol`
Identifiers referring to symbols or atoms.
*hl-TSTag*
`TSTag`
Tags like HTML tag names.
*hl-TSTagAttribute*
`TSTagAttribute`
HTML tag attributes.
*hl-TSTagDelimiter*
`TSTagDelimiter`
Tag delimiters like `<` `>` `/`.
*hl-TSText*
`TSText`
Non-structured text. Like text in a markup language.
*hl-TSSTrong*
`TSStrong`
Text to be represented in bold.
*hl-TSEmphasis*
`TSEmphasis`
Text to be represented with emphasis.
*hl-TSUnderline*
`TSUnderline`
Text to be represented with an underline.
*hl-TSStrike*
`TSStrike`
Strikethrough text.
*hl-TSTitle*
`TSTitle`
Text that is part of a title.
*hl-TSLiteral*
`TSLiteral`
Literal or verbatim text.
*hl-TSURI*
`TSURI`
URIs like hyperlinks or email addresses.
*hl-TSMath*
`TSMath`
Math environments like LaTeX's `$ ... $`
*hl-TSTextReference*
`TSTextReference`
Footnotes, text references, citations, etc.
*hl-TSEnvironment*
`TSEnvironment`
Text environments of markup languages.
*hl-TSEnvironmentName*
`TSEnvironmentName`
Text/string indicating the type of text environment. Like the name of a
`\begin` block in LaTeX.
*hl-TSNote*
`TSNote`
Text representation of an informational note.
*TSWarning*
`TSWarning`
Text representation of a warning note.
*TSDanger*
`TSDanger`
Text representation of a danger note.
*hl-TSTodo*
`TSTodo`
Anything that needs extra attention, such as keywords like TODO or FIXME.
*hl-TSType*
`TSType`
Type (and class) definitions and annotations.
*hl-TSTypeBuiltin*
`TSTypeBuiltin`
Built-in types: `i32` in Rust.
*hl-TSTypeQualifier*
`TSTypeQualifier`
Qualifiers on types, e.g. `const` or `volatile` in C or `mut` in Rust.
*hl-TSTypeDefinition*
`TSTypeDefinition`
Type definitions, e.g. `typedef` in C.
*hl-TSVariable*
`TSVariable`
Variable names that don't fit into other categories.
*hl-TSVariableBuiltin*
`TSVariableBuiltin`
Variable names defined by the language: `this` or `self` in Javascript.
============================================================================== ==============================================================================
PERFORMANCE *nvim-treesitter-performance* PERFORMANCE *nvim-treesitter-performance*

View File

@ -1,33 +1,27 @@
{ {
"agda": {
"revision": "80ea622cf952a0059e168e5c92a798b2f1925652"
},
"astro": { "astro": {
"revision": "947e93089e60c66e681eba22283f4037841451e7" "revision": "6602ccbf9a5f79845dad62f1e118e07f97e3533c"
}, },
"bash": { "bash": {
"revision": "77cf8a7cab8904baf1a721762e012644ac1d4c7b" "revision": "275effdfc0edce774acf7d481f9ea195c6c403cd"
}, },
"beancount": { "beancount": {
"revision": "4cbd1f09cd07c1f1fabf867c2cf354f9da53cc4c" "revision": "78b8ddca3ab774573a4e3bf64eabd79e9452cea9"
}, },
"bibtex": { "bibtex": {
"revision": "ccfd77db0ed799b6c22c214fe9d2937f47bc8b34" "revision": "ccfd77db0ed799b6c22c214fe9d2937f47bc8b34"
}, },
"blueprint": {
"revision": "6ef91ca8270f0112b9c6d27ecb9966c741a5d103"
},
"c": { "c": {
"revision": "7175a6dd5fc1cee660dce6fe23f6043d75af424a" "revision": "e348e8ec5efd3aac020020e4af53d2ff18f393a9"
}, },
"c_sharp": { "c_sharp": {
"revision": "3ef3f7f99e16e528e6689eae44dff35150993307" "revision": "5b6ae1f88e741b9ed738891ad1362fb9f2041671"
}, },
"clojure": { "clojure": {
"revision": "087bac78c53fe1387756cd5b8e68a69b3f6d7244" "revision": "879f0e726295807d917d576fcf9e1e432c4c20fc"
}, },
"cmake": { "cmake": {
"revision": "6e51463ef3052dd3b328322c22172eda093727ad" "revision": "5020572408a386d5d2dfac3516584f5edda7a49b"
}, },
"comment": { "comment": {
"revision": "a37ca370310ac6f89b6e0ebf2b86b2219780494e" "revision": "a37ca370310ac6f89b6e0ebf2b86b2219780494e"
@ -39,55 +33,49 @@
"revision": "5e113412aadb78955c27010daa4dbe1d202013cf" "revision": "5e113412aadb78955c27010daa4dbe1d202013cf"
}, },
"cpp": { "cpp": {
"revision": "5ead1e26c6ab71919db0f1880c46a278a93bc5ea" "revision": "a832195eb3685a279856bb480ce19cff19554b6d"
}, },
"css": { "css": {
"revision": "769203d0f9abe1a9a691ac2b9fe4bb4397a73c51" "revision": "a03f1d2d1dfbf6f8e0fdca5f9ff030228241eb57"
}, },
"cuda": { "cuda": {
"revision": "7f1a79e612160aa02be87f1a24469ae3655fe818" "revision": "5178a7a5b25dc7ee4a69bf72f31bd6d3ff0a0795"
}, },
"d": { "d": {
"revision": "c2fbf21bd3aa45495fe13247e040ad5815250032" "revision": "c2fbf21bd3aa45495fe13247e040ad5815250032"
}, },
"dart": { "dart": {
"revision": "53485a8f301254e19c518aa20c80f1bcf7cf5c62" "revision": "6a25376685d1d47968c2cef06d4db8d84a70025e"
}, },
"devicetree": { "devicetree": {
"revision": "ea30a05d0f0446a96d8b096ad11828ad4f8ad849" "revision": "877adbfa0174d25894c40fa75ad52d4515a36368"
},
"diff": {
"revision": "330eb648bbc257b4e91621e82a85372be7dde27a"
}, },
"dockerfile": { "dockerfile": {
"revision": "f913be9bb8689af22114605012693146fbe9ddaa" "revision": "25c71d6a24cdba8f0c74ef40d4d2d93defd7e196"
}, },
"dot": { "dot": {
"revision": "9ab85550c896d8b294d9b9ca1e30698736f08cea" "revision": "917230743aa10f45a408fea2ddb54bbbf5fbe7b7"
}, },
"eex": { "eex": {
"revision": "f742f2fe327463335e8671a87c0b9b396905d1d1" "revision": "f742f2fe327463335e8671a87c0b9b396905d1d1"
}, },
"elixir": { "elixir": {
"revision": "b20eaa75565243c50be5e35e253d8beb58f45d56" "revision": "1dabc1c790e07115175057863808085ea60dd08a"
}, },
"elm": { "elm": {
"revision": "28bb193640d916dfaf947912c1413cebb0484841" "revision": "9835f900e4df40277f0701d1bc0b6cee0853f81b"
}, },
"elvish": { "elvish": {
"revision": "f32711e31e987fd5c2c002f3daba02f25c68672f" "revision": "e50787cadd3bc54f6d9c0704493a79078bb8a4e5"
},
"embedded_template": {
"revision": "91fc5ae1140d5c9d922312431f7d251a48d7b8ce"
}, },
"erlang": { "erlang": {
"revision": "3a9c769444f08bbccce03845270efac0c641c5e7" "revision": "fab680273af1a8f5cc0c3a0c62cbf5b1bea71f39"
}, },
"fennel": { "fennel": {
"revision": "517195970428aacca60891b050aa53eabf4ba78d" "revision": "d37fd84a702b78ff0282f223ece83c61ab062a6e"
}, },
"fish": { "fish": {
"revision": "84436cf24c2b3176bfbb220922a0fdbd0141e406" "revision": "d482d70ea8e191c05b2c1b613ed6fdff30a14da0"
}, },
"foam": { "foam": {
"revision": "fdb7f14b885abfc4df57728c9b2a2f2ad24d3cb7" "revision": "fdb7f14b885abfc4df57728c9b2a2f2ad24d3cb7"
@ -101,80 +89,68 @@
"gdscript": { "gdscript": {
"revision": "2a6abdaa47fcb91397e09a97c7433fd995ea46c6" "revision": "2a6abdaa47fcb91397e09a97c7433fd995ea46c6"
}, },
"git_rebase": {
"revision": "127f5b56c1ad3e8a449a7d6e0c7412ead7f7724c"
},
"gitattributes": {
"revision": "cee9f8865694b29bb9e85e0b90805f92ad3fc47e"
},
"gitignore": {
"revision": "f4685bf11ac466dd278449bcfe5fd014e94aa504"
},
"gleam": { "gleam": {
"revision": "cfcbca3f8f734773878e00d7bfcedea98eb10be2" "revision": "cfcbca3f8f734773878e00d7bfcedea98eb10be2"
}, },
"glimmer": { "glimmer": {
"revision": "abcc9970da0ed0645741bf52ea70232374bc9e52" "revision": "5caf63ac0e3c549b90c9aeb042871206b4b7bc16"
}, },
"glsl": { "glsl": {
"revision": "a743ada24fa17da9acc5665133f07d56e03530be" "revision": "ffb93961426926554a0ba4a389ea6e9d6fafdea9"
}, },
"go": { "go": {
"revision": "05900faa3cdb5d2d8c8bd5e77ee698487e0a8611" "revision": "c8fed1f0847a65a04a4b8cb7655f5f416e0742ca"
}, },
"godot_resource": { "godot_resource": {
"revision": "b6ef0768711086a86b3297056f9ffb5cc1d77b4a" "revision": "b6ef0768711086a86b3297056f9ffb5cc1d77b4a"
}, },
"gomod": { "gomod": {
"revision": "4a65743dbc2bb3094114dd2b43da03c820aa5234" "revision": "e8f51f8e4363a3d9a427e8f63f4c1bbc5ef5d8d0"
}, },
"gowork": { "gowork": {
"revision": "949a8a470559543857a62102c84700d291fc984c" "revision": "6dd9dd79fb51e9f2abc829d5e97b15015b6a8ae2"
}, },
"graphql": { "graphql": {
"revision": "5e66e961eee421786bdda8495ed1db045e06b5fe" "revision": "5e66e961eee421786bdda8495ed1db045e06b5fe"
}, },
"hack": { "hack": {
"revision": "b7bd6928532ada34dddb1dece4a158ab62c6e783" "revision": "d434b4e6c9af0524b163d7a912c8ce79d2b1f778"
}, },
"haskell": { "haskell": {
"revision": "bee6b49543e34c2967c6294a4b05e8bd2bf2da59" "revision": "ed976b81b00ce7b72b99bca75e7a616cc526220c"
}, },
"hcl": { "hcl": {
"revision": "45ce22c16ec924e34517cf785e23c07952e45893" "revision": "d559c46ba170808b23a73da0cf49f315d221d095"
}, },
"heex": { "heex": {
"revision": "52b804b1cb2d57e58d90090326d3ef9bd19cf16c" "revision": "592e22292a367312c35e13de7fdb888f029981d6"
}, },
"help": { "help": {
"revision": "49cdef52ded4a886bf34bc474876b09f9270d48f" "revision": "41ac50500e68fadc139737bbee2a0618628b822b"
}, },
"hjson": { "hjson": {
"revision": "02fa3b79b3ff9a296066da6277adfc3f26cbc9e0" "revision": "02fa3b79b3ff9a296066da6277adfc3f26cbc9e0"
}, },
"hlsl": {
"revision": "384b26ec65e10f26cf147bfcde772c50ca5ef0d0"
},
"hocon": { "hocon": {
"revision": "c390f10519ae69fdb03b3e5764f5592fb6924bcc" "revision": "bb412e2633f4a3611a4e16efe58d917093bb4782"
}, },
"html": { "html": {
"revision": "29f53d8f4f2335e61bf6418ab8958dac3282077a" "revision": "161a92474a7bb2e9e830e48e76426f38299d99d1"
}, },
"http": { "http": {
"revision": "30a9c1789d64429a830802cde5b1760ff1064312" "revision": "bfddd16b1cf78e0042fd1f6846a179f76a254e20"
}, },
"java": { "java": {
"revision": "09d650def6cdf7f479f4b78f595e9ef5b58ce31e" "revision": "881b84fe7078651af5077cc4cea4c85f9fddde3b"
}, },
"javascript": { "javascript": {
"revision": "936d976a782e75395d9b1c8c7c7bf4ba6fe0d86b" "revision": "fdeb68ac8d2bd5a78b943528bb68ceda3aade2eb"
}, },
"jsdoc": { "jsdoc": {
"revision": "189a6a4829beb9cdbe837260653b4a3dfb0cc3db" "revision": "189a6a4829beb9cdbe837260653b4a3dfb0cc3db"
}, },
"json": { "json": {
"revision": "73076754005a460947cafe8e03a8cf5fa4fa2938" "revision": "203e239408d642be83edde8988d6e7b20a19f0e8"
}, },
"json5": { "json5": {
"revision": "5dd5cdc418d9659682556b6adca2dd9ace0ac6d2" "revision": "5dd5cdc418d9659682556b6adca2dd9ace0ac6d2"
@ -182,146 +158,113 @@
"jsonc": { "jsonc": {
"revision": "02b01653c8a1c198ae7287d566efa86a135b30d5" "revision": "02b01653c8a1c198ae7287d566efa86a135b30d5"
}, },
"jsonnet": {
"revision": "0475a5017ad7dc84845d1d33187f2321abcb261d"
},
"julia": { "julia": {
"revision": "58d0701550b4cce02acf433eedada03b634cc524" "revision": "12ea597262125fc22fd2e91aa953ac69b19c26ca"
}, },
"kotlin": { "kotlin": {
"revision": "b953dbdd05257fcb2b64bc4d9c1578fac12e3c28" "revision": "a4f71eb9b8c9b19ded3e0e9470be4b1b77c2b569"
}, },
"lalrpop": { "lalrpop": {
"revision": "7744b56f03ac1e5643fad23c9dd90837fe97291e" "revision": "7744b56f03ac1e5643fad23c9dd90837fe97291e"
}, },
"latex": { "latex": {
"revision": "8c75e93cd08ccb7ce1ccab22c1fbd6360e3bcea6" "revision": "ab9c1c59de5da1a8d8c629c81d856a6378b6f116"
}, },
"ledger": { "ledger": {
"revision": "47b8971448ce5e9abac865f450c1b14fb3b6eee9" "revision": "1050a25df55a62878102d10e524b5184b316b7ad"
}, },
"llvm": { "llvm": {
"revision": "e9948edc41e9e5869af99dddb2b5ff5cc5581af6" "revision": "e9948edc41e9e5869af99dddb2b5ff5cc5581af6"
}, },
"lua": { "lua": {
"revision": "fb30e8cb605e2ebd6c643e6981325a63fbbde320" "revision": "2b4ffd5a5ffd0c6b4c84f0d9e003050a70db2a37"
},
"m68k": {
"revision": "d097b123f19c6eaba2bf181c05420d88b9fc489d"
}, },
"make": { "make": {
"revision": "a4b9187417d6be349ee5fd4b6e77b4172c6827dd" "revision": "a4b9187417d6be349ee5fd4b6e77b4172c6827dd"
}, },
"markdown": { "markdown": {
"revision": "272e080bca0efd19a06a7f4252d746417224959e" "revision": "d24196f9b3e5af6fcb2ec2a0b6cbc5c06f58b85e"
},
"markdown_inline": {
"revision": "272e080bca0efd19a06a7f4252d746417224959e"
},
"menhir": {
"revision": "db7953acb0d5551f207373c81fa07a57d7b085cb"
},
"meson": {
"revision": "153d22588fb5c1eee16a165a084f9ea30f29d941"
},
"nickel": {
"revision": "9d83db400b6c11260b9106f131f93ddda8131933"
}, },
"ninja": { "ninja": {
"revision": "0a95cfdc0745b6ae82f60d3a339b37f19b7b9267" "revision": "0a95cfdc0745b6ae82f60d3a339b37f19b7b9267"
}, },
"nix": { "nix": {
"revision": "6b71a810c0acd49b980c50fc79092561f7cee307" "revision": "6d6aaa50793b8265b6a8b6628577a0083d3b923d"
}, },
"norg": { "norg": {
"revision": "dfac5ad2740a79b18ae849590a924e7bad3f1b23" "revision": "17d61df817c1e0a9cdef8d915d4e4c556b7cf68c"
}, },
"ocaml": { "ocaml": {
"revision": "cc26b1ef111100f26a137bcbcd39fd4e35be9a59" "revision": "23d419ba45789c5a47d31448061557716b02750a"
}, },
"ocaml_interface": { "ocaml_interface": {
"revision": "cc26b1ef111100f26a137bcbcd39fd4e35be9a59" "revision": "23d419ba45789c5a47d31448061557716b02750a"
}, },
"ocamllex": { "ocamllex": {
"revision": "ac1d5957e719d49bd6acd27439b79843e4daf8ed" "revision": "ac1d5957e719d49bd6acd27439b79843e4daf8ed"
}, },
"org": {
"revision": "081179c52b3e8175af62b9b91dc099d010c38770"
},
"pascal": { "pascal": {
"revision": "2fd40f477d3e2794af152618ccfac8d92eb72a66" "revision": "2fd40f477d3e2794af152618ccfac8d92eb72a66"
}, },
"perl": { "perl": {
"revision": "749d26fe13fb131b92e6515416096e572575b981" "revision": "bbf86084d9b7eb4768f3fb9fe094b3e0600057b1"
}, },
"php": { "php": {
"revision": "ab2e72179ceb8bb0b249c8ac9162a148e911b3dc" "revision": "3c17a28da38afac41332d3ce79bbd8951867f346"
}, },
"phpdoc": { "phpdoc": {
"revision": "2f4d16c861b5a454b577d057f247f9902d7b47f5" "revision": "d9150d4cb5941f6ff10adba89bfa1f11f4b05b37"
}, },
"pioasm": { "pioasm": {
"revision": "924aadaf5dea2a6074d72027b064f939acf32e20" "revision": "924aadaf5dea2a6074d72027b064f939acf32e20"
}, },
"prisma": { "prisma": {
"revision": "17a59236ac25413b81b1613ea6ba5d8d52d7cd6c" "revision": "bf0833cbedb2c5b39250f5ba900f1239a16c6749"
},
"proto": {
"revision": "42d82fa18f8afe59b5fc0b16c207ee4f84cb185f"
}, },
"pug": { "pug": {
"revision": "63e214905970e75f065688b1e8aa90823c3aacdc" "revision": "5875f9a7d94836708119b0a1102bb5792e8bf673"
}, },
"python": { "python": {
"revision": "b14614e2144b8f9ee54deed5a24f3c6f51f9ffa8" "revision": "78c4e9b6b2f08e1be23b541ffced47b15e2972ad"
}, },
"ql": { "ql": {
"revision": "bd087020f0d8c183080ca615d38de0ec827aeeaf" "revision": "8e7fd7e638d4a0ec7a792ee16b19dbc6407aa810"
},
"qmljs": {
"revision": "0b2b25bcaa7d4925d5f0dda16f6a99c588a437f1"
}, },
"query": { "query": {
"revision": "0695cd0760532de7b54f23c667d459b5d1332b44" "revision": "5217c6805c09f8fc00ed13d17d5fcb791437aee6"
}, },
"r": { "r": {
"revision": "80efda55672d1293aa738f956c7ae384ecdc31b4" "revision": "cc04302e1bff76fa02e129f332f44636813b0c3c"
},
"racket": {
"revision": "09cb27a06415bce529a26774a842f5a80d50d362"
}, },
"rasi": { "rasi": {
"revision": "12391343979463a2484e6353e5afb6dcb8c31e8b" "revision": "e2961f02244c068a67549adf896b0779e4a29516"
}, },
"regex": { "regex": {
"revision": "e1cfca3c79896ff79842f057ea13e529b66af636" "revision": "e1cfca3c79896ff79842f057ea13e529b66af636"
}, },
"rego": { "rego": {
"revision": "6d70da3a998fd0081efc5d1019c71e74cc1568e9" "revision": "858ca3013da4d50ea1bdb32162a2bfb43641b422"
},
"rnoweb": {
"revision": "502c1126dc6777f09af5bef16e72a42f75bd081e"
}, },
"rst": { "rst": {
"revision": "25e6328872ac3a764ba8b926aea12719741103f1" "revision": "b74770c0166f28c1a0ab293513a78712ca1c338b"
}, },
"ruby": { "ruby": {
"revision": "c91960320d0f337bdd48308a8ad5500bd2616979" "revision": "0b107de5415e7470a30ef1a390d9db3306432bdb"
}, },
"rust": { "rust": {
"revision": "0431a2c60828731f27491ee9fdefe25e250ce9c9" "revision": "0509e440ae042db6483984b3a56b3c5f24b5d9b9"
}, },
"scala": { "scala": {
"revision": "140c96cf398693189d4e50f76d19ddfcd8a018f8" "revision": "ec6047f531e7d4c13787d4ff208b94a84de34165"
}, },
"scheme": { "scheme": {
"revision": "bdcd2c8496701153506a9e3e1b76dfed852873ba" "revision": "a1d2233f4e5498bb305858323c93525e1dd165c0"
}, },
"scss": { "scss": {
"revision": "c478c6868648eff49eb04a4df90d703dc45b312a" "revision": "c478c6868648eff49eb04a4df90d703dc45b312a"
}, },
"slint": { "slint": {
"revision": "d422300f5d6ccce8f9a617dfed57aafb636fadb2" "revision": "0d4dda94f96623302dfc234e06be62a5717f47da"
}, },
"solidity": { "solidity": {
"revision": "52ed0880c0126df2f2c7693f215fe6f38e4a2e0a" "revision": "52ed0880c0126df2f2c7693f215fe6f38e4a2e0a"
@ -329,32 +272,23 @@
"sparql": { "sparql": {
"revision": "05f949d3c1c15e3261473a244d3ce87777374dec" "revision": "05f949d3c1c15e3261473a244d3ce87777374dec"
}, },
"sql": {
"revision": "70c50264ae022193adb364ffa7a767d765ed9857"
},
"supercollider": { "supercollider": {
"revision": "90c6d9f777d2b8c4ce497c48b5f270a44bcf3ea0" "revision": "0f0e5b5a96dd3e048a9c3db648ed969c44068bff"
}, },
"surface": { "surface": {
"revision": "f4586b35ac8548667a9aaa4eae44456c1f43d032" "revision": "f4586b35ac8548667a9aaa4eae44456c1f43d032"
}, },
"svelte": { "svelte": {
"revision": "52e122ae68b316d3aa960a0a422d3645ba717f42" "revision": "84c90ee15f851e1541c25c86e8a4338f5b4d5af2"
}, },
"swift": { "swift": {
"revision": "25f8de356e3c33099ed691bd3b8b5c0fe3a11e15" "revision": "897df54ad1b2d103dcab3df94f335fceefa230dc"
},
"sxhkdrc": {
"revision": "440d5f913d9465c9c776a1bd92334d32febcf065"
}, },
"teal": { "teal": {
"revision": "1ae8c68e90523b26b93af56feb7868fe4214e2b2" "revision": "fcc5f6f4d194dede4e676834ff28a506e39e17b4"
},
"tiger": {
"revision": "eb1d3714998977ae76ca7c6a102b10ee37efc2b5"
}, },
"tlaplus": { "tlaplus": {
"revision": "deaf0e5c573ad4e2bbfc9a29abb7b6dcb572556e" "revision": "dde405e5128c3c47ab8aa014d21b6e5296ca450f"
}, },
"todotxt": { "todotxt": {
"revision": "0207f6a4ab6aeafc4b091914d31d8235049a2578" "revision": "0207f6a4ab6aeafc4b091914d31d8235049a2578"
@ -363,37 +297,28 @@
"revision": "8bd2056818b21860e3d756b5a58c4f6e05fb744e" "revision": "8bd2056818b21860e3d756b5a58c4f6e05fb744e"
}, },
"tsx": { "tsx": {
"revision": "0ab9d99867435a7667c5548a6617a6bf73dbd830" "revision": "8e9dba7bd7cf089838a036a98be94db53ba2d0a9"
}, },
"turtle": { "turtle": {
"revision": "085437f5cb117703b7f520dd92161140a684f092" "revision": "085437f5cb117703b7f520dd92161140a684f092"
}, },
"twig": {
"revision": "035f549ec8c043e734f04341d7ccdc669bb2ba91"
},
"typescript": { "typescript": {
"revision": "0ab9d99867435a7667c5548a6617a6bf73dbd830" "revision": "8e9dba7bd7cf089838a036a98be94db53ba2d0a9"
},
"v": {
"revision": "66b92a89ef1e149300df79c0b2a934ad959c8eec"
}, },
"vala": { "vala": {
"revision": "8f690bfa639f2b83d1fb938ed3dd98a7ba453e8b" "revision": "31a08784cc74b61cb10c5d8314cf8a8aa98aa9a8"
}, },
"verilog": { "verilog": {
"revision": "4457145e795b363f072463e697dfe2f6973c9a52" "revision": "8f6b1f357d1231c420404b5f7a368a73c25adfa2"
},
"vhs": {
"revision": "2f87b9d973597e69552ecf6a4fe16470fbd8c44e"
}, },
"vim": { "vim": {
"revision": "4ae7bd67706d7e10afed827ce2ded884ab41650f" "revision": "68f7cacfd9ae4698181511c9fdd6641bc25a260b"
}, },
"vue": { "vue": {
"revision": "91fe2754796cd8fba5f229505a23fa08f3546c06" "revision": "91fe2754796cd8fba5f229505a23fa08f3546c06"
}, },
"wgsl": { "wgsl": {
"revision": "af16e7d9e230004888fb52d33599ad38b4cf6052" "revision": "5ca98b174f7dddf69fb7a80c54d49badd1f1f8c4"
}, },
"yaml": { "yaml": {
"revision": "0e36bed171768908f331ff7dff9d956bae016efb" "revision": "0e36bed171768908f331ff7dff9d956bae016efb"
@ -402,6 +327,6 @@
"revision": "8e9d175982afcefa3dac8ca20d40d1643accd2bd" "revision": "8e9d175982afcefa3dac8ca20d40d1643accd2bd"
}, },
"zig": { "zig": {
"revision": "d90d38d28ce8cc27bfea8b4e0c75211e9e2398ca" "revision": "4cff36421dae9c05388b86cd64d2bab4b9ed6676"
} }
} }

View File

@ -1,8 +1,13 @@
if not pcall(require, "vim.treesitter.languagetree") then
error "nvim-treesitter requires a more recent Neovim nightly version!"
end
local install = require "nvim-treesitter.install" local install = require "nvim-treesitter.install"
local utils = require "nvim-treesitter.utils" local utils = require "nvim-treesitter.utils"
local ts_utils = require "nvim-treesitter.ts_utils"
local info = require "nvim-treesitter.info" local info = require "nvim-treesitter.info"
local configs = require "nvim-treesitter.configs" local configs = require "nvim-treesitter.configs"
local statusline = require "nvim-treesitter.statusline" local parsers = require "nvim-treesitter.parsers"
-- Registers all query predicates -- Registers all query predicates
require "nvim-treesitter.query_predicates" require "nvim-treesitter.query_predicates"
@ -16,7 +21,68 @@ function M.setup()
configs.init() configs.init()
end end
M.define_modules = configs.define_modules function M.define_modules(...)
M.statusline = statusline.statusline configs.define_modules(...)
end
local get_line_for_node = function(node, type_patterns, transform_fn)
local node_type = node:type()
local is_valid = false
for _, rgx in ipairs(type_patterns) do
if node_type:find(rgx) then
is_valid = true
break
end
end
if not is_valid then
return ""
end
local line = transform_fn(vim.trim(ts_utils.get_node_text(node)[1] or ""))
-- Escape % to avoid statusline to evaluate content as expression
return line:gsub("%%", "%%%%")
end
-- Trim spaces and opening brackets from end
local transform_line = function(line)
return line:gsub("%s*[%[%(%{]*%s*$", "")
end
function M.statusline(opts)
if not parsers.has_parser() then
return
end
local options = opts or {}
if type(opts) == "number" then
options = { indicator_size = opts }
end
local indicator_size = options.indicator_size or 100
local type_patterns = options.type_patterns or { "class", "function", "method" }
local transform_fn = options.transform_fn or transform_line
local separator = options.separator or " -> "
local current_node = ts_utils.get_node_at_cursor()
if not current_node then
return ""
end
local lines = {}
local expr = current_node
while expr do
local line = get_line_for_node(expr, type_patterns, transform_fn)
if line ~= "" and not vim.tbl_contains(lines, line) then
table.insert(lines, 1, line)
end
expr = expr:parent()
end
local text = table.concat(lines, separator)
local text_len = #text
if text_len > indicator_size then
return "..." .. text:sub(text_len - indicator_size, text_len)
end
return text
end
return M return M

View File

@ -8,40 +8,17 @@ local caching = require "nvim-treesitter.caching"
local M = {} local M = {}
---@class TSConfig
---@field modules {[string]:TSModule}
---@field sync_install boolean
---@field ensure_installed string[]|string
---@field ignore_install string[]
---@field auto_install boolean
---@field update_strategy string
---@field parser_install_dir string|nil
---@type TSConfig
local config = { local config = {
modules = {}, modules = {},
sync_install = false, sync_install = false,
ensure_installed = {}, ensure_installed = {},
auto_install = false,
ignore_install = {}, ignore_install = {},
update_strategy = "lockfile", update_strategy = "lockfile",
parser_install_dir = nil,
} }
-- List of modules that need to be setup on initialization. -- List of modules that need to be setup on initialization.
local queued_modules_defs = {} local queued_modules_defs = {}
-- Whether we've initialized the plugin yet. -- Whether we've initialized the plugin yet.
local is_initialized = false local is_initialized = false
---@class TSModule
---@field module_path string
---@field enable boolean|string[]|function(string): boolean
---@field disable boolean|string[]|function(string): boolean
---@field is_supported function(string): boolean
---@field attach function(string)
---@field detach function(string)
---@field enabled_buffers table<integer, boolean>
---@type {[string]: TSModule}
local builtin_modules = { local builtin_modules = {
highlight = { highlight = {
module_path = "nvim-treesitter.highlight", module_path = "nvim-treesitter.highlight",
@ -75,9 +52,7 @@ local builtin_modules = {
local attached_buffers_by_module = caching.create_buffer_cache() local attached_buffers_by_module = caching.create_buffer_cache()
---Resolves a module by requiring the `module_path` or using the module definition. -- Resolves a module by requiring the `module_path` or using the module definition.
---@param mod_name string
---@return TSModule|nil
local function resolve_module(mod_name) local function resolve_module(mod_name)
local config_mod = M.get_module(mod_name) local config_mod = M.get_module(mod_name)
@ -92,10 +67,10 @@ local function resolve_module(mod_name)
end end
end end
---Enables and attaches the module to a buffer for lang. -- Enables and attaches the module to a buffer for lang.
---@param mod string path to module -- @param mod path to module
---@param bufnr integer|nil buffer number, defaults to current buffer -- @param bufnr buffer number, defaults to current buffer
---@param lang string|nil language, defaults to current language -- @param lang language, defaults to current language
local function enable_module(mod, bufnr, lang) local function enable_module(mod, bufnr, lang)
local module = M.get_module(mod) local module = M.get_module(mod)
if not module then if not module then
@ -116,29 +91,24 @@ local function enable_module(mod, bufnr, lang)
M.attach_module(mod, bufnr, lang) M.attach_module(mod, bufnr, lang)
end end
---Enables autocomands for the module. -- Enables autocomands for the module.
---After the module is loaded `loaded` will be set to true for the module. -- After the module is loaded `loaded` will be set to true for the module.
---@param mod string path to module -- @param mod path to module
local function enable_mod_conf_autocmd(mod) local function enable_mod_conf_autocmd(mod)
local config_mod = M.get_module(mod) local config_mod = M.get_module(mod)
if not config_mod or config_mod.loaded then if not config_mod or config_mod.loaded then
return return
end end
api.nvim_create_autocmd("FileType", { local cmd = string.format("lua require'nvim-treesitter.configs'.reattach_module('%s')", mod)
group = api.nvim_create_augroup("NvimTreesitter-" .. mod, {}), api.nvim_command(string.format("autocmd NvimTreesitter FileType * %s", cmd))
callback = function()
require("nvim-treesitter.configs").reattach_module(mod)
end,
desc = "Reattach module",
})
config_mod.loaded = true config_mod.loaded = true
end end
---Enables the module globally and for all current buffers. -- Enables the module globally and for all current buffers.
---After enabled, `enable` will be set to true for the module. -- After enabled, `enable` will be set to true for the module.
---@param mod string path to module -- @param mod path to module
local function enable_all(mod) local function enable_all(mod)
local config_mod = M.get_module(mod) local config_mod = M.get_module(mod)
if not config_mod then if not config_mod then
@ -154,9 +124,9 @@ local function enable_all(mod)
end end
end end
---Disables and detaches the module for a buffer. -- Disables and detaches the module for a buffer.
---@param mod string path to module -- @param mod path to module
---@param bufnr integer buffer number, defaults to current buffer -- @param bufnr buffer number, defaults to current buffer
local function disable_module(mod, bufnr) local function disable_module(mod, bufnr)
local module = M.get_module(mod) local module = M.get_module(mod)
if not module then if not module then
@ -170,21 +140,23 @@ local function disable_module(mod, bufnr)
M.detach_module(mod, bufnr) M.detach_module(mod, bufnr)
end end
---Disables autocomands for the module. -- Disables autocomands for the module.
---After the module is unloaded `loaded` will be set to false for the module. -- After the module is unloaded `loaded` will be set to false for the module.
---@param mod string path to module -- @param mod path to module
local function disable_mod_conf_autocmd(mod) local function disable_mod_conf_autocmd(mod)
local config_mod = M.get_module(mod) local config_mod = M.get_module(mod)
if not config_mod or not config_mod.loaded then if not config_mod or not config_mod.loaded then
return return
end end
api.nvim_clear_autocmds { event = "FileType", group = "NvimTreesitter-" .. mod } -- TODO(kyazdani): detach the correct autocmd... doesn't work when using %s, cmd.
-- This will remove all autocomands!
api.nvim_command "autocmd! NvimTreesitter FileType *"
config_mod.loaded = false config_mod.loaded = false
end end
---Disables the module globally and for all current buffers. -- Disables the module globally and for all current buffers.
---After disabled, `enable` will be set to false for the module. -- After disabled, `enable` will be set to false for the module.
---@param mod string path to module -- @param mod path to module
local function disable_all(mod) local function disable_all(mod)
local config_mod = M.get_module(mod) local config_mod = M.get_module(mod)
if not config_mod then if not config_mod then
@ -200,10 +172,10 @@ local function disable_all(mod)
end end
end end
---Toggles a module for a buffer -- Toggles a module for a buffer
---@param mod string path to module -- @param mod path to module
---@param bufnr integer buffer number, defaults to current buffer -- @param bufnr buffer number, defaults to current buffer
---@param lang string language, defaults to current language -- @param lang language, defaults to current language
local function toggle_module(mod, bufnr, lang) local function toggle_module(mod, bufnr, lang)
bufnr = bufnr or api.nvim_get_current_buf() bufnr = bufnr or api.nvim_get_current_buf()
lang = lang or parsers.get_buf_lang(bufnr) lang = lang or parsers.get_buf_lang(bufnr)
@ -230,10 +202,10 @@ local function toggle_all(mod)
end end
end end
---Recurses through all modules including submodules -- Recurses through all modules including submodules
---@param accumulator function called for each module -- @param accumulator function called for each module
---@param root {[string]: TSModule} root configuration table to start at -- @param root root configuration table to start at
---@param path string|nil prefix path -- @param path prefix path
local function recurse_modules(accumulator, root, path) local function recurse_modules(accumulator, root, path)
root = root or config.modules root = root or config.modules
@ -248,9 +220,9 @@ local function recurse_modules(accumulator, root, path)
end end
end end
---Shows current configuration of all nvim-treesitter modules -- Shows current configuration of all nvim-treesitter modules
---@param process_function function used as the `process` parameter -- @param process_function function used as the `process` parameter
--- for vim.inspect (https://github.com/kikito/inspect.lua#optionsprocess) -- for vim.inspect (https://github.com/kikito/inspect.lua#optionsprocess)
local function config_info(process_function) local function config_info(process_function)
process_function = process_function process_function = process_function
or function(item, path) or function(item, path)
@ -265,8 +237,29 @@ local function config_info(process_function)
print(vim.inspect(config, { process = process_function })) print(vim.inspect(config, { process = process_function }))
end end
---@param query_group string if not vim.ui then
---@param lang string vim.ui = {
select = function(items, opts, on_choice)
vim.validate {
items = { items, "table", false },
on_choice = { on_choice, "function", false },
}
opts = opts or {}
local choices = { opts.prompt or "Select one of:" }
local format_item = opts.format_item or tostring
for i, item in pairs(items) do
table.insert(choices, string.format("%d: %s", i, format_item(item)))
end
local choice = vim.fn.inputlist(choices)
if choice < 1 or choice > #items then
on_choice(nil, nil)
else
on_choice(items[choice], choice)
end
end,
}
end
function M.edit_query_file(query_group, lang) function M.edit_query_file(query_group, lang)
lang = lang or parsers.get_buf_lang() lang = lang or parsers.get_buf_lang()
local files = ts_query.get_query_files(lang, query_group, true) local files = ts_query.get_query_files(lang, query_group, true)
@ -284,8 +277,6 @@ function M.edit_query_file(query_group, lang)
end end
end end
---@param query_group string
---@param lang string
function M.edit_query_file_user_after(query_group, lang) function M.edit_query_file_user_after(query_group, lang)
lang = lang or parsers.get_buf_lang() lang = lang or parsers.get_buf_lang()
local folder = utils.join_path(vim.fn.stdpath "config", "after", "queries", lang) local folder = utils.join_path(vim.fn.stdpath "config", "after", "queries", lang)
@ -367,11 +358,11 @@ M.commands = {
}, },
} }
---@param mod string module -- @param mod: module (string)
---@param lang string the language of the buffer -- @param lang: the language of the buffer (string)
---@param bufnr integer the bufnr -- @param bufnr: the bufnr (number)
function M.is_enabled(mod, lang, bufnr) function M.is_enabled(mod, lang, bufnr)
if not parsers.has_parser(lang) then if not parsers.list[lang] or not parsers.has_parser(lang) then
return false return false
end end
@ -403,20 +394,11 @@ function M.is_enabled(mod, lang, bufnr)
return true return true
end end
---Setup call for users to override module configurations. -- Setup call for users to override module configurations.
---@param user_data TSConfig module overrides -- @param user_data module overrides
function M.setup(user_data) function M.setup(user_data)
config.modules = vim.tbl_deep_extend("force", config.modules, user_data) config.modules = vim.tbl_deep_extend("force", config.modules, user_data)
config.ignore_install = user_data.ignore_install or {} config.ignore_install = user_data.ignore_install or {}
config.parser_install_dir = user_data.parser_install_dir or nil
if config.parser_install_dir then
config.parser_install_dir = vim.fn.expand(config.parser_install_dir, ":p")
end
config.auto_install = user_data.auto_install or false
if config.auto_install then
require("nvim-treesitter.install").setup_auto_install()
end
local ensure_installed = user_data.ensure_installed or {} local ensure_installed = user_data.ensure_installed or {}
if #ensure_installed > 0 then if #ensure_installed > 0 then
@ -428,7 +410,6 @@ function M.setup(user_data)
end end
config.modules.ensure_installed = nil config.modules.ensure_installed = nil
config.ensure_installed = ensure_installed
recurse_modules(function(_, _, new_path) recurse_modules(function(_, _, new_path)
local data = utils.get_at_path(config.modules, new_path) local data = utils.get_at_path(config.modules, new_path)
@ -438,33 +419,32 @@ function M.setup(user_data)
end, config.modules) end, config.modules)
end end
---Defines a table of modules that can be attached/detached to buffers -- Defines a table of modules that can be attached/detached to buffers
---based on language support. A module consist of the following properties: -- based on language support. A module consist of the following properties:
---* @enable Whether the modules is enabled. Can be true or false. -- * @enable Whether the modules is enabled. Can be true or false.
---* @disable A list of languages to disable the module for. Only relevant if enable is true. -- * @disable A list of languages to disable the module for. Only relevant if enable is true.
---* @keymaps A list of user mappings for a given module if relevant. -- * @keymaps A list of user mappings for a given module if relevant.
---* @is_supported A function which, given a ft, will return true if the ft works on the module. -- * @is_supported A function which, given a ft, will return true if the ft works on the module.
---* @module_path A string path to a module file using `require`. The exported module must contain -- * @module_path A string path to a module file using `require`. The exported module must contain
--- an `attach` and `detach` function. This path is not required if `attach` and `detach` -- an `attach` and `detach` function. This path is not required if `attach` and `detach`
--- functions are provided directly on the module definition. -- functions are provided directly on the module definition.
---* @attach An attach function that is called for each buffer that the module is enabled for. This is required -- * @attach An attach function that is called for each buffer that the module is enabled for. This is required
--- if a `module_path` is not specified. -- if a `module_path` is not specified.
---* @detach A detach function that is called for each buffer that the module is enabled for. This is required -- * @detach A detach function that is called for each buffer that the module is enabled for. This is required
--- if a `module_path` is not specified. -- if a `module_path` is not specified.
---Modules are not setup until `init` is invoked by the plugin. This allows modules to be defined in any order -- Modules are not setup until `init` is invoked by the plugin. This allows modules to be defined in any order
---and can be loaded lazily. -- and can be loaded lazily.
---@example -- @example
---require"nvim-treesitter".define_modules { -- require"nvim-treesitter".define_modules {
--- my_cool_module = { -- my_cool_module = {
--- attach = function() -- attach = function()
--- do_some_cool_setup() -- do_some_cool_setup()
--- end, -- end,
--- detach = function() -- detach = function()
--- do_some_cool_teardown() -- do_some_cool_teardown()
--- end -- end
--- } -- }
---} -- }
---@param mod_defs TSModule[]
function M.define_modules(mod_defs) function M.define_modules(mod_defs)
if not is_initialized then if not is_initialized then
table.insert(queued_modules_defs, mod_defs) table.insert(queued_modules_defs, mod_defs)
@ -491,10 +471,10 @@ function M.define_modules(mod_defs)
end end
end end
---Attaches a module to a buffer -- Attaches a module to a buffer
---@param mod_name string the module name -- @param mod_name the module name
---@param bufnr integer the bufnr -- @param bufnr the bufnr
---@param lang string the language of the buffer -- @param lang the language of the buffer
function M.attach_module(mod_name, bufnr, lang) function M.attach_module(mod_name, bufnr, lang)
bufnr = bufnr or api.nvim_get_current_buf() bufnr = bufnr or api.nvim_get_current_buf()
lang = lang or parsers.get_buf_lang(bufnr) lang = lang or parsers.get_buf_lang(bufnr)
@ -506,9 +486,9 @@ function M.attach_module(mod_name, bufnr, lang)
end end
end end
---Detaches a module to a buffer -- Detaches a module to a buffer
---@param mod_name string the module name -- @param mod_name the module name
---@param bufnr integer the bufnr -- @param bufnr the bufnr
function M.detach_module(mod_name, bufnr) function M.detach_module(mod_name, bufnr)
local resolved_mod = resolve_module(mod_name) local resolved_mod = resolve_module(mod_name)
bufnr = bufnr or api.nvim_get_current_buf() bufnr = bufnr or api.nvim_get_current_buf()
@ -519,17 +499,17 @@ function M.detach_module(mod_name, bufnr)
end end
end end
---Same as attach_module, but if the module is already attached, detach it first. -- Same as attach_module, but if the module is already attached, detach it first.
---@param mod_name string the module name -- @param mod_name the module name
---@param bufnr integer the bufnr -- @param bufnr the bufnr
---@param lang string the language of the buffer -- @param lang the language of the buffer
function M.reattach_module(mod_name, bufnr, lang) function M.reattach_module(mod_name, bufnr, lang)
M.detach_module(mod_name, bufnr) M.detach_module(mod_name, bufnr)
M.attach_module(mod_name, bufnr, lang) M.attach_module(mod_name, bufnr, lang)
end end
---Gets available modules -- Gets available modules
---@param root {[string]:TSModule} table to find modules -- @param root root table to find modules
function M.available_modules(root) function M.available_modules(root)
local modules = {} local modules = {}
@ -540,26 +520,25 @@ function M.available_modules(root)
return modules return modules
end end
---Gets a module config by path -- Gets a module config by path
---@param mod_path string path to the module -- @param mod_path path to the module
---@return TSModule|nil the module or nil -- @returns the module or nil
function M.get_module(mod_path) function M.get_module(mod_path)
local mod = utils.get_at_path(config.modules, mod_path) local mod = utils.get_at_path(config.modules, mod_path)
return M.is_module(mod) and mod or nil return M.is_module(mod) and mod or nil
end end
---Determines whether the provided table is a module. -- Determines whether the provided table is a module.
---A module should contain an attach and detach function. -- A module should contain an attach and detach function.
---@param mod table the module table -- @param mod the module table
---@return boolean
function M.is_module(mod) function M.is_module(mod)
return type(mod) == "table" return type(mod) == "table"
and ((type(mod.attach) == "function" and type(mod.detach) == "function") or type(mod.module_path) == "string") and ((type(mod.attach) == "function" and type(mod.detach) == "function") or type(mod.module_path) == "string")
end end
---Initializes built-in modules and any queued modules -- Initializes built-in modules and any queued modules
---registered by plugins or the user. -- registered by plugins or the user.
function M.init() function M.init()
is_initialized = true is_initialized = true
M.define_modules(builtin_modules) M.define_modules(builtin_modules)
@ -569,39 +548,6 @@ function M.init()
end end
end end
---If parser_install_dir is not nil is used or created.
---If parser_install_dir is nil try the package dir of the nvim-treesitter
---plugin first, followed by the "site" dir from "runtimepath". "site" dir will
---be created if it doesn't exist. Using only the package dir won't work when
---the plugin is installed with Nix, since the "/nix/store" is read-only.
---@param folder_name string
---@return string|nil, string|nil
function M.get_parser_install_dir(folder_name)
folder_name = folder_name or "parser"
local install_dir
if config.parser_install_dir then
install_dir = config.parser_install_dir
else
install_dir = utils.get_package_path()
end
local parser_dir = utils.join_path(install_dir, folder_name)
return utils.create_or_reuse_writable_dir(
parser_dir,
utils.join_space("Could not create parser dir '", parser_dir, "': "),
utils.join_space(
"Parser dir '",
parser_dir,
"' should be read/write (see README on how to configure an alternative install location)"
)
)
end
function M.get_parser_info_dir()
return M.get_parser_install_dir "parser-info"
end
function M.get_update_strategy() function M.get_update_strategy()
return config.update_strategy return config.update_strategy
end end
@ -610,8 +556,4 @@ function M.get_ignored_parser_installs()
return config.ignore_install or {} return config.ignore_install or {}
end end
function M.get_ensure_installed_parsers()
return config.ensure_installed or {}
end
return M return M

View File

@ -39,13 +39,8 @@ local folds_levels = tsutils.memoize_by_buf_tick(function(bufnr)
local min_fold_lines = api.nvim_win_get_option(0, "foldminlines") local min_fold_lines = api.nvim_win_get_option(0, "foldminlines")
for _, match in ipairs(matches) do for _, node in ipairs(matches) do
local start, stop, stop_col local start, _, stop, stop_col = node.node:range()
if match.metadata and match.metadata.range then
start, _, stop, stop_col = unpack(match.metadata.range)
else
start, _, stop, stop_col = match.node:range()
end
if stop_col == 0 then if stop_col == 0 then
stop = stop - 1 stop = stop - 1
@ -102,8 +97,6 @@ local folds_levels = tsutils.memoize_by_buf_tick(function(bufnr)
return levels return levels
end) end)
---@param lnum integer
---@return string
function M.get_fold_indic(lnum) function M.get_fold_indic(lnum)
if not parsers.has_parser() or not lnum then if not parsers.has_parser() or not lnum then
return "0" return "0"

View File

@ -7,26 +7,25 @@ local shell = require "nvim-treesitter.shell_command_selectors"
local install = require "nvim-treesitter.install" local install = require "nvim-treesitter.install"
local utils = require "nvim-treesitter.utils" local utils = require "nvim-treesitter.utils"
local health = vim.health or require "health" local health_start = vim.fn["health#report_start"]
local health_ok = vim.fn["health#report_ok"]
local health_error = vim.fn["health#report_error"]
local health_warn = vim.fn["health#report_warn"]
local M = {} local M = {}
local NVIM_TREESITTER_MINIMUM_ABI = 13 local NVIM_TREESITTER_MINIMUM_ABI = 13
local function install_health() local function install_health()
health.report_start "Installation" health_start "Installation"
if fn.has "nvim-0.7" == 0 then
health.report_error "Nvim-treesitter requires Neovim 0.7.0+"
end
if fn.executable "tree-sitter" == 0 then if fn.executable "tree-sitter" == 0 then
health.report_warn( health_warn(
"`tree-sitter` executable not found (parser generator, only needed for :TSInstallFromGrammar," "`tree-sitter` executable not found (parser generator, only needed for :TSInstallFromGrammar,"
.. " not required for :TSInstall)" .. " not required for :TSInstall)"
) )
else else
health.report_ok( health_ok(
"`tree-sitter` found " "`tree-sitter` found "
.. (utils.ts_cli_version() or "(unknown version)") .. (utils.ts_cli_version() or "(unknown version)")
.. " (parser generator, only needed for :TSInstallFromGrammar)" .. " (parser generator, only needed for :TSInstallFromGrammar)"
@ -34,7 +33,7 @@ local function install_health()
end end
if fn.executable "node" == 0 then if fn.executable "node" == 0 then
health.report_warn( health_warn(
"`node` executable not found (only needed for :TSInstallFromGrammar," .. " not required for :TSInstall)" "`node` executable not found (only needed for :TSInstallFromGrammar," .. " not required for :TSInstall)"
) )
else else
@ -42,21 +41,21 @@ local function install_health()
local result = handle:read "*a" local result = handle:read "*a"
handle:close() handle:close()
local version = vim.split(result, "\n")[1] local version = vim.split(result, "\n")[1]
health.report_ok("`node` found " .. version .. " (only needed for :TSInstallFromGrammar)") health_ok("`node` found " .. version .. " (only needed for :TSInstallFromGrammar)")
end end
if fn.executable "git" == 0 then if fn.executable "git" == 0 then
health.report_error("`git` executable not found.", { health_error("`git` executable not found.", {
"Install it with your package manager.", "Install it with your package manager.",
"Check that your `$PATH` is set correctly.", "Check that your `$PATH` is set correctly.",
}) })
else else
health.report_ok "`git` executable found." health_ok "`git` executable found."
end end
local cc = shell.select_executable(install.compilers) local cc = shell.select_executable(install.compilers)
if not cc then if not cc then
health.report_error("`cc` executable not found.", { health_error("`cc` executable not found.", {
"Check that any of " "Check that any of "
.. vim.inspect(install.compilers) .. vim.inspect(install.compilers)
.. " is in your $PATH" .. " is in your $PATH"
@ -64,7 +63,7 @@ local function install_health()
}) })
else else
local version = vim.fn.systemlist(cc .. (cc == "cl" and "" or " --version"))[1] local version = vim.fn.systemlist(cc .. (cc == "cl" and "" or " --version"))[1]
health.report_ok( health_ok(
"`" "`"
.. cc .. cc
.. "` executable found. Selected from " .. "` executable found. Selected from "
@ -74,7 +73,7 @@ local function install_health()
end end
if vim.treesitter.language_version then if vim.treesitter.language_version then
if vim.treesitter.language_version >= NVIM_TREESITTER_MINIMUM_ABI then if vim.treesitter.language_version >= NVIM_TREESITTER_MINIMUM_ABI then
health.report_ok( health_ok(
"Neovim was compiled with tree-sitter runtime ABI version " "Neovim was compiled with tree-sitter runtime ABI version "
.. vim.treesitter.language_version .. vim.treesitter.language_version
.. " (required >=" .. " (required >="
@ -82,7 +81,7 @@ local function install_health()
.. "). Parsers must be compatible with runtime ABI." .. "). Parsers must be compatible with runtime ABI."
) )
else else
health.report_error( health_error(
"Neovim was compiled with tree-sitter runtime ABI version " "Neovim was compiled with tree-sitter runtime ABI version "
.. vim.treesitter.language_version .. vim.treesitter.language_version
.. ".\n" .. ".\n"
@ -128,7 +127,7 @@ function M.check()
table.insert(error_collection, { parser_name, query_group, err }) table.insert(error_collection, { parser_name, query_group, err })
end end
end end
table.insert(parser_installation, vim.fn.trim(out, " ", 2)) table.insert(parser_installation, out)
end end
end end
local legend = [[ local legend = [[
@ -138,9 +137,9 @@ function M.check()
x) errors found in the query, try to run :TSUpdate {lang}]] x) errors found in the query, try to run :TSUpdate {lang}]]
table.insert(parser_installation, legend) table.insert(parser_installation, legend)
-- Finally call the report function -- Finally call the report function
health.report_start(table.concat(parser_installation, "\n")) health_start(table.concat(parser_installation, "\n"))
if #error_collection > 0 then if #error_collection > 0 then
health.report_start "The following errors have been detected:" health_start "The following errors have been detected:"
for _, p in ipairs(error_collection) do for _, p in ipairs(error_collection) do
local lang, type, err = unpack(p) local lang, type, err = unpack(p)
local lines = {} local lines = {}
@ -161,7 +160,7 @@ function M.check()
end end
end end
end end
health.report_error(table.concat(lines, "\n")) health_error(table.concat(lines, "\n"))
end end
end end
end end

View File

@ -6,9 +6,115 @@ local configs = require "nvim-treesitter.configs"
local M = {} local M = {}
---@param config table local hlmap = vim.treesitter.highlighter.hl_map
---@param lang string
---@return boolean -- nvim-treesitter Highlight Group Mappings
-- Note: Some highlight groups may not be applied upstream, some may be experimental
hlmap["annotation"] = "TSAnnotation"
hlmap["attribute"] = "TSAttribute"
hlmap["boolean"] = "TSBoolean"
hlmap["character"] = "TSCharacter"
hlmap["character.special"] = "TSCharacterSpecial"
hlmap["comment"] = "TSComment"
hlmap["conditional"] = "TSConditional"
hlmap["constant"] = "TSConstant"
hlmap["constant.builtin"] = "TSConstBuiltin"
hlmap["constant.macro"] = "TSConstMacro"
hlmap["constructor"] = "TSConstructor"
hlmap["debug"] = "TSDebug"
hlmap["define"] = "TSDefine"
hlmap["error"] = "TSError"
hlmap["exception"] = "TSException"
hlmap["field"] = "TSField"
hlmap["float"] = "TSFloat"
hlmap["function"] = "TSFunction"
hlmap["function.builtin"] = "TSFuncBuiltin"
hlmap["function.macro"] = "TSFuncMacro"
hlmap["include"] = "TSInclude"
hlmap["keyword"] = "TSKeyword"
hlmap["keyword.function"] = "TSKeywordFunction"
hlmap["keyword.operator"] = "TSKeywordOperator"
hlmap["keyword.return"] = "TSKeywordReturn"
hlmap["label"] = "TSLabel"
hlmap["method"] = "TSMethod"
hlmap["namespace"] = "TSNamespace"
hlmap["none"] = "TSNone"
hlmap["number"] = "TSNumber"
hlmap["operator"] = "TSOperator"
hlmap["parameter"] = "TSParameter"
hlmap["parameter.reference"] = "TSParameterReference"
hlmap["preproc"] = "TSPreProc"
hlmap["property"] = "TSProperty"
hlmap["punctuation.delimiter"] = "TSPunctDelimiter"
hlmap["punctuation.bracket"] = "TSPunctBracket"
hlmap["punctuation.special"] = "TSPunctSpecial"
hlmap["repeat"] = "TSRepeat"
hlmap["storageclass"] = "TSStorageClass"
hlmap["string"] = "TSString"
hlmap["string.regex"] = "TSStringRegex"
hlmap["string.escape"] = "TSStringEscape"
hlmap["string.special"] = "TSStringSpecial"
hlmap["symbol"] = "TSSymbol"
hlmap["tag"] = "TSTag"
hlmap["tag.attribute"] = "TSTagAttribute"
hlmap["tag.delimiter"] = "TSTagDelimiter"
hlmap["text"] = "TSText"
hlmap["text.strong"] = "TSStrong"
hlmap["text.emphasis"] = "TSEmphasis"
hlmap["text.underline"] = "TSUnderline"
hlmap["text.strike"] = "TSStrike"
hlmap["text.title"] = "TSTitle"
hlmap["text.literal"] = "TSLiteral"
hlmap["text.uri"] = "TSURI"
hlmap["text.math"] = "TSMath"
hlmap["text.reference"] = "TSTextReference"
hlmap["text.environment"] = "TSEnvironment"
hlmap["text.environment.name"] = "TSEnvironmentName"
hlmap["text.note"] = "TSNote"
hlmap["text.warning"] = "TSWarning"
hlmap["text.danger"] = "TSDanger"
hlmap["todo"] = "TSTodo"
hlmap["type"] = "TSType"
hlmap["type.builtin"] = "TSTypeBuiltin"
hlmap["type.qualifier"] = "TSTypeQualifier"
hlmap["type.definition"] = "TSTypeDefinition"
hlmap["variable"] = "TSVariable"
hlmap["variable.builtin"] = "TSVariableBuiltin"
local function should_enable_vim_regex(config, lang) local function should_enable_vim_regex(config, lang)
local additional_hl = config.additional_vim_regex_highlighting local additional_hl = config.additional_vim_regex_highlighting
local is_table = type(additional_hl) == "table" local is_table = type(additional_hl) == "table"
@ -16,39 +122,38 @@ local function should_enable_vim_regex(config, lang)
return additional_hl and (not is_table or vim.tbl_contains(additional_hl, lang)) return additional_hl and (not is_table or vim.tbl_contains(additional_hl, lang))
end end
---@param bufnr integer
local function enable_syntax(bufnr) local function enable_syntax(bufnr)
api.nvim_buf_set_option(bufnr, "syntax", "ON") api.nvim_buf_set_option(bufnr, "syntax", "ON")
end end
---@param bufnr integer
function M.stop(bufnr) function M.stop(bufnr)
if ts.highlighter.active[bufnr] then if ts.highlighter.active[bufnr] then
ts.highlighter.active[bufnr]:destroy() ts.highlighter.active[bufnr]:destroy()
end end
end end
---@param bufnr integer
---@param lang string
function M.start(bufnr, lang) function M.start(bufnr, lang)
local parser = parsers.get_parser(bufnr, lang) local parser = parsers.get_parser(bufnr, lang)
ts.highlighter.new(parser, {}) ts.highlighter.new(parser, {})
end end
---@param bufnr integer
---@param lang string
function M.attach(bufnr, lang) function M.attach(bufnr, lang)
local config = configs.get_module "highlight" local config = configs.get_module "highlight"
M.start(bufnr, lang) M.start(bufnr, lang)
if config and should_enable_vim_regex(config, lang) then if should_enable_vim_regex(config, lang) then
enable_syntax(bufnr) enable_syntax(bufnr)
end end
end end
---@param bufnr integer
function M.detach(bufnr) function M.detach(bufnr)
M.stop(bufnr) M.stop(bufnr)
enable_syntax(bufnr) enable_syntax(bufnr)
end end
function M.set_custom_captures(captures)
for k, v in pairs(captures) do
hlmap[k] = v
end
end
return M return M

View File

@ -120,33 +120,17 @@ function M.node_decremental()
ts_utils.update_selection(buf, node) ts_utils.update_selection(buf, node)
end end
local FUNCTION_DESCRIPTIONS = {
init_selection = "Start selecting nodes with nvim-treesitter",
node_incremental = "Increment selection to named node",
scope_incremental = "Increment selection to surrounding scope",
node_decremental = "Shrink selection to previous named node",
}
function M.attach(bufnr) function M.attach(bufnr)
local config = configs.get_module "incremental_selection" local config = configs.get_module "incremental_selection"
for funcname, mapping in pairs(config.keymaps) do for funcname, mapping in pairs(config.keymaps) do
local mode local mode
local rhs
if funcname == "init_selection" then if funcname == "init_selection" then
mode = "n" mode = "n"
rhs = M[funcname]
else else
mode = "x" mode = "x"
-- We need to move to command mode to access marks '< (visual area start) and '> (visual area end) which are not
-- properly accessible in visual mode.
rhs = string.format(":lua require'nvim-treesitter.incremental_selection'.%s()<CR>", funcname)
end end
vim.keymap.set( local cmd = string.format(":lua require'nvim-treesitter.incremental_selection'.%s()<CR>", funcname)
mode, api.nvim_buf_set_keymap(bufnr, mode, mapping, cmd, { silent = true, noremap = true })
mapping,
rhs,
{ buffer = bufnr, silent = true, noremap = true, desc = FUNCTION_DESCRIPTIONS[funcname] }
)
end end
end end
@ -154,9 +138,9 @@ function M.detach(bufnr)
local config = configs.get_module "incremental_selection" local config = configs.get_module "incremental_selection"
for f, mapping in pairs(config.keymaps) do for f, mapping in pairs(config.keymaps) do
if f == "init_selection" then if f == "init_selection" then
vim.keymap.del("n", mapping, { buffer = bufnr }) api.nvim_buf_del_keymap(bufnr, "n", mapping)
else else
vim.keymap.del("x", mapping, { buffer = bufnr }) api.nvim_buf_del_keymap(bufnr, "x", mapping)
end end
end end
end end

View File

@ -149,19 +149,12 @@ function M.get_indent(lnum)
end end
-- do not indent for nodes that starts-and-ends on same line and starts on target line (lnum) -- do not indent for nodes that starts-and-ends on same line and starts on target line (lnum)
local should_process = not is_processed_by_row[srow]
local is_in_err = false
if should_process then
local parent = node:parent()
is_in_err = parent and parent:has_error()
end
if if
should_process not is_processed_by_row[srow]
and ( -- Dear stylua, please don't change the semantics of this statement!
q.indent[node:id()] -- stylua: ignore start
and (srow ~= erow or is_in_err) and (q.indent[node:id()] and srow ~= erow and ((srow ~= lnum - 1) or q.indent[node:id()].start_at_same_line))
and (srow ~= lnum - 1 or q.indent[node:id()].start_at_same_line) -- stylua: ignore end
)
then then
indent = indent + indent_size indent = indent + indent_size
is_processed = true is_processed = true
@ -202,6 +195,7 @@ local indent_funcs = {}
function M.attach(bufnr) function M.attach(bufnr)
indent_funcs[bufnr] = vim.bo.indentexpr indent_funcs[bufnr] = vim.bo.indentexpr
vim.bo.indentexpr = "nvim_treesitter#indent()" vim.bo.indentexpr = "nvim_treesitter#indent()"
vim.api.nvim_command("au Filetype " .. vim.bo.filetype .. " setlocal indentexpr=nvim_treesitter#indent()")
end end
function M.detach(bufnr) function M.detach(bufnr)

View File

@ -14,13 +14,11 @@ local function install_info()
local parser_list = parsers.available_parsers() local parser_list = parsers.available_parsers()
table.sort(parser_list) table.sort(parser_list)
for _, lang in pairs(parser_list) do for _, ft in pairs(parser_list) do
local is_installed = #api.nvim_get_runtime_file("parser/" .. lang .. ".so", false) > 0 local is_installed = #api.nvim_get_runtime_file("parser/" .. ft .. ".so", false) > 0
api.nvim_out_write(lang .. string.rep(" ", max_len - #lang + 1)) api.nvim_out_write(ft .. string.rep(" ", max_len - #ft + 1))
if is_installed then if is_installed then
api.nvim_out_write "[✓] installed\n" api.nvim_out_write "[✓] installed\n"
elseif pcall(vim.treesitter.inspect_lang, lang) then
api.nvim_out_write "[✗] not installed (but still loaded. Restart Neovim!)\n"
else else
api.nvim_out_write "[✗] not installed\n" api.nvim_out_write "[✗] not installed\n"
end end
@ -117,24 +115,21 @@ local function print_info_modules(parserlist, module)
api.nvim_buf_set_option(curbuf, "modified", false) api.nvim_buf_set_option(curbuf, "modified", false)
api.nvim_buf_set_option(curbuf, "buftype", "nofile") api.nvim_buf_set_option(curbuf, "buftype", "nofile")
vim.cmd [[ api.nvim_exec(
syntax match TSModuleInfoGood // [[
syntax match TSModuleInfoBad // syntax match TSModuleInfoGood //
syntax match TSModuleInfoHeader /^>>.*$/ contains=TSModuleInfoNamespace syntax match TSModuleInfoBad //
syntax match TSModuleInfoNamespace /^>> \w*/ contained syntax match TSModuleInfoHeader /^>>.*$/ contains=TSModuleInfoNamespace
syntax match TSModuleInfoParser /^[^> ]*\ze / syntax match TSModuleInfoNamespace /^>> \w*/ contained
]] syntax match TSModuleInfoParser /^[^> ]*\ze /
highlight default TSModuleInfoGood guifg=LightGreen gui=bold
local highlights = { highlight default TSModuleInfoBad guifg=Crimson
TSModuleInfoGood = { fg = "LightGreen", bold = true, default = true }, highlight default link TSModuleInfoHeader Type
TSModuleInfoBad = { fg = "Crimson", default = true }, highlight default link TSModuleInfoNamespace Statement
TSModuleInfoHeader = { link = "Type", default = true }, highlight default link TSModuleInfoParser Identifier
TSModuleInfoNamespace = { link = "Statement", default = true }, ]],
TSModuleInfoParser = { link = "Identifier", default = true }, false
} )
for k, v in pairs(highlights) do
api.nvim_set_hl(0, k, v)
end
end end
local function module_info(module) local function module_info(module)

View File

@ -42,14 +42,11 @@ local function get_job_status()
.. "]" .. "]"
end end
---@param lang string
---@param validate boolean|nil
---@return InstallInfo
local function get_parser_install_info(lang, validate) local function get_parser_install_info(lang, validate)
local parser_config = parsers.get_parser_configs()[lang] local parser_config = parsers.get_parser_configs()[lang]
if not parser_config then if not parser_config then
error('Parser not available for language "' .. lang .. '"') return error("Parser not available for language " .. lang)
end end
local install_info = parser_config.install_info local install_info = parser_config.install_info
@ -82,39 +79,30 @@ local function get_revision(lang)
return (lockfile[lang] and lockfile[lang].revision) return (lockfile[lang] and lockfile[lang].revision)
end end
---@param lang string
---@return string|nil
local function get_installed_revision(lang) local function get_installed_revision(lang)
local lang_file = utils.join_path(configs.get_parser_info_dir(), lang .. ".revision") local lang_file = utils.join_path(utils.get_parser_info_dir(), lang .. ".revision")
if vim.fn.filereadable(lang_file) == 1 then if vim.fn.filereadable(lang_file) == 1 then
return vim.fn.readfile(lang_file)[1] return vim.fn.readfile(lang_file)[1]
end end
end end
---@param lang string
---@return boolean
local function is_installed(lang) local function is_installed(lang)
return #api.nvim_get_runtime_file("parser/" .. lang .. ".so", false) > 0 return #api.nvim_get_runtime_file("parser/" .. lang .. ".so", false) > 0
end end
---@param lang string
---@return boolean
local function needs_update(lang) local function needs_update(lang)
local revision = get_revision(lang) local revision = get_revision(lang)
return not revision or revision ~= get_installed_revision(lang) return not revision or revision ~= get_installed_revision(lang)
end end
---@return table
local function outdated_parsers() local function outdated_parsers()
return vim.tbl_filter(function(lang) return vim.tbl_filter(function(lang)
return needs_update(lang) return needs_update(lang)
end, info.installed_parsers()) end, info.installed_parsers())
end end
---@param handle userdata
---@param is_stderr boolean
local function onread(handle, is_stderr) local function onread(handle, is_stderr)
return function(_, data) return function(err, data)
if data then if data then
if is_stderr then if is_stderr then
complete_error_output[handle] = (complete_error_output[handle] or "") .. data complete_error_output[handle] = (complete_error_output[handle] or "") .. data
@ -159,7 +147,6 @@ function M.iter_cmd(cmd_list, i, lang, success_message)
local stdout = luv.new_pipe(false) local stdout = luv.new_pipe(false)
local stderr = luv.new_pipe(false) local stderr = luv.new_pipe(false)
attr.opts.stdio = { nil, stdout, stderr } attr.opts.stdio = { nil, stdout, stderr }
---@type userdata
handle = luv.spawn( handle = luv.spawn(
attr.cmd, attr.cmd,
attr.opts, attr.opts,
@ -238,12 +225,6 @@ local function iter_cmd_sync(cmd_list)
return true return true
end end
---@param cache_folder string
---@param install_folder string
---@param lang string
---@param repo InstallInfo
---@param with_sync boolean
---@param generate_from_grammar boolean
local function run_install(cache_folder, install_folder, lang, repo, with_sync, generate_from_grammar) local function run_install(cache_folder, install_folder, lang, repo, with_sync, generate_from_grammar)
parsers.reset_cache() parsers.reset_cache()
@ -261,14 +242,10 @@ local function run_install(cache_folder, install_folder, lang, repo, with_sync,
if from_local_path then if from_local_path then
compile_location = repo.url compile_location = repo.url
else else
local repo_location = project_name local repo_location = string.gsub(repo.location or project_name, "/", path_sep)
if repo.location then compile_location = cache_folder .. path_sep .. repo_location
repo_location = repo_location .. "/" .. repo.location
end
repo_location = repo_location:gsub("/", path_sep)
compile_location = utils.join_path(cache_folder, repo_location)
end end
local parser_lib_name = utils.join_path(install_folder, lang) .. ".so" local parser_lib_name = install_folder .. path_sep .. lang .. ".so"
generate_from_grammar = repo.requires_generate_from_grammar or generate_from_grammar generate_from_grammar = repo.requires_generate_from_grammar or generate_from_grammar
@ -352,7 +329,7 @@ local function run_install(cache_folder, install_folder, lang, repo, with_sync,
shell.select_mv_cmd("parser.so", parser_lib_name, compile_location), shell.select_mv_cmd("parser.so", parser_lib_name, compile_location),
{ {
cmd = function() cmd = function()
vim.fn.writefile({ revision or "" }, utils.join_path(configs.get_parser_info_dir(), lang .. ".revision")) vim.fn.writefile({ revision or "" }, utils.join_path(utils.get_parser_info_dir(), lang .. ".revision"))
end, end,
}, },
{ -- auto-attach modules after installation { -- auto-attach modules after installation
@ -380,12 +357,6 @@ local function run_install(cache_folder, install_folder, lang, repo, with_sync,
end end
end end
---@param lang string
---@param ask_reinstall boolean
---@param cache_folder string
---@param install_folder string
---@param with_sync boolean
---@param generate_from_grammar boolean
local function install_lang(lang, ask_reinstall, cache_folder, install_folder, with_sync, generate_from_grammar) local function install_lang(lang, ask_reinstall, cache_folder, install_folder, with_sync, generate_from_grammar)
if is_installed(lang) and ask_reinstall ~= "force" then if is_installed(lang) and ask_reinstall ~= "force" then
if not ask_reinstall then if not ask_reinstall then
@ -399,22 +370,11 @@ local function install_lang(lang, ask_reinstall, cache_folder, install_folder, w
end end
end end
local ok, install_info = pcall(get_parser_install_info, lang, true) local install_info = get_parser_install_info(lang, true)
if not ok then
vim.notify("Installation not possible: " .. install_info, vim.log.levels.ERROR)
if not parsers.get_parser_configs()[lang] then
vim.notify(
"See https://github.com/nvim-treesitter/nvim-treesitter/#adding-parsers on how to add a new parser!",
vim.log.levels.INFO
)
end
return
end
run_install(cache_folder, install_folder, lang, install_info, with_sync, generate_from_grammar) run_install(cache_folder, install_folder, lang, install_info, with_sync, generate_from_grammar)
end end
---@return function
local function install(options) local function install(options)
options = options or {} options = options or {}
local with_sync = options.with_sync local with_sync = options.with_sync
@ -431,20 +391,20 @@ local function install(options)
if err then if err then
return api.nvim_err_writeln(err) return api.nvim_err_writeln(err)
end end
assert(cache_folder)
local install_folder local install_folder, err = utils.get_parser_install_dir()
install_folder, err = configs.get_parser_install_dir()
if err then if err then
return api.nvim_err_writeln(err) return api.nvim_err_writeln(err)
end end
assert(install_folder)
local languages local languages
local ask local ask
if ... == "all" then if ... == "all" then
languages = parsers.available_parsers() languages = parsers.available_parsers()
ask = false ask = false
elseif ... == "maintained" then
languages = parsers.maintained_parsers()
ask = false
else else
languages = vim.tbl_flatten { ... } languages = vim.tbl_flatten { ... }
ask = ask_reinstall ask = ask_reinstall
@ -464,18 +424,6 @@ local function install(options)
end end
end end
function M.setup_auto_install()
vim.api.nvim_create_autocmd("FileType", {
pattern = { "*" },
callback = function()
local lang = parsers.get_buf_lang()
if parsers.get_parser_configs()[lang] and not is_installed(lang) then
install() { lang }
end
end,
})
end
function M.update(options) function M.update(options)
options = options or {} options = options or {}
return function(...) return function(...)
@ -514,67 +462,37 @@ function M.update(options)
end end
function M.uninstall(...) function M.uninstall(...)
if vim.tbl_contains({ "all" }, ...) then local path_sep = "/"
if fn.has "win32" == 1 then
path_sep = "\\"
end
if vim.tbl_contains({ "all", "maintained" }, ...) then
reset_progress_counter() reset_progress_counter()
local installed = info.installed_parsers() local installed = info.installed_parsers()
if ... == "maintained" then
local maintained = parsers.maintained_parsers()
installed = vim.tbl_filter(function(l)
return vim.tbl_contains(maintained, l)
end, installed)
end
for _, langitem in pairs(installed) do for _, langitem in pairs(installed) do
M.uninstall(langitem) M.uninstall(langitem)
end end
elseif ... then elseif ... then
local ensure_installed_parsers = configs.get_ensure_installed_parsers()
if ensure_installed_parsers == "all" then
ensure_installed_parsers = parsers.available_parsers()
end
ensure_installed_parsers = utils.difference(ensure_installed_parsers, configs.get_ignored_parser_installs())
local languages = vim.tbl_flatten { ... } local languages = vim.tbl_flatten { ... }
for _, lang in ipairs(languages) do for _, lang in ipairs(languages) do
local install_dir, err = configs.get_parser_install_dir() local install_dir, err = utils.get_parser_install_dir()
if err then if err then
return api.nvim_err_writeln(err) return api.nvim_err_writeln(err)
end end
if vim.tbl_contains(ensure_installed_parsers, lang) then local parser_lib = install_dir .. path_sep .. lang .. ".so"
vim.notify(
"Uninstalling "
.. lang
.. '. But the parser is still configured in "ensure_installed" setting of nvim-treesitter.'
.. " Please consider updating your config!",
vim.log.levels.ERROR
)
end
local parser_lib = utils.join_path(install_dir, lang) .. ".so" local command_list = {
local all_parsers = vim.api.nvim_get_runtime_file("parser/" .. lang .. ".so", true) shell.select_rm_file_cmd(parser_lib, "Uninstalling parser for " .. lang),
if vim.fn.filereadable(parser_lib) == 1 then }
local command_list = { M.iter_cmd(command_list, 1, lang, "Treesitter parser for " .. lang .. " has been uninstalled")
shell.select_rm_file_cmd(parser_lib, "Uninstalling parser for " .. lang),
{
cmd = function()
local all_parsers_after_deletion = vim.api.nvim_get_runtime_file("parser/" .. lang .. ".so", true)
if #all_parsers_after_deletion > 0 then
vim.notify(
"Tried to uninstall parser for "
.. lang
.. "! But the parser is still installed (not by nvim-treesitter)."
.. " Please delete the following files manually: "
.. table.concat(all_parsers_after_deletion, ", "),
vim.log.levels.ERROR
)
end
end,
},
}
M.iter_cmd(command_list, 1, lang, "Treesitter parser for " .. lang .. " has been uninstalled")
elseif #all_parsers > 0 then
vim.notify(
"Parser for "
.. lang
.. " is installed! But not by nvim-treesitter! Please manually remove the following files: "
.. table.concat(all_parsers, ", "),
vim.log.levels.ERROR
)
end
end end
end end
end end

View File

@ -4,7 +4,6 @@
local queries = require "nvim-treesitter.query" local queries = require "nvim-treesitter.query"
local ts_utils = require "nvim-treesitter.ts_utils" local ts_utils = require "nvim-treesitter.ts_utils"
local ts_query = vim.treesitter.query
local api = vim.api local api = vim.api
local M = {} local M = {}
@ -163,7 +162,7 @@ M.get_definitions_lookup_table = ts_utils.memoize_by_buf_tick(function(bufnr)
local scopes = M.get_definition_scopes(node_entry.node, bufnr, node_entry.scope) local scopes = M.get_definition_scopes(node_entry.node, bufnr, node_entry.scope)
-- Always use the highest valid scope -- Always use the highest valid scope
local scope = scopes[#scopes] local scope = scopes[#scopes]
local node_text = ts_query.get_node_text(node_entry.node, bufnr) local node_text = ts_utils.get_node_text(node_entry.node, bufnr)[1]
local id = M.get_definition_id(scope, node_text) local id = M.get_definition_id(scope, node_text)
result[id] = node_entry result[id] = node_entry
@ -211,7 +210,7 @@ end
function M.find_definition(node, bufnr) function M.find_definition(node, bufnr)
local def_lookup = M.get_definitions_lookup_table(bufnr) local def_lookup = M.get_definitions_lookup_table(bufnr)
local node_text = ts_query.get_node_text(node, bufnr) local node_text = ts_utils.get_node_text(node, bufnr)[1]
for scope in M.iter_scope_tree(node, bufnr) do for scope in M.iter_scope_tree(node, bufnr) do
local id = M.get_definition_id(scope, node_text) local id = M.get_definition_id(scope, node_text)
@ -232,7 +231,7 @@ end
-- @returns a list of nodes -- @returns a list of nodes
function M.find_usages(node, scope_node, bufnr) function M.find_usages(node, scope_node, bufnr)
local bufnr = bufnr or api.nvim_get_current_buf() local bufnr = bufnr or api.nvim_get_current_buf()
local node_text = ts_query.get_node_text(node, bufnr) local node_text = ts_utils.get_node_text(node, bufnr)[1]
if not node_text or #node_text < 1 then if not node_text or #node_text < 1 then
return {} return {}
@ -245,7 +244,7 @@ function M.find_usages(node, scope_node, bufnr)
if if
match.reference match.reference
and match.reference.node and match.reference.node
and ts_query.get_node_text(match.reference.node, bufnr) == node_text and ts_utils.get_node_text(match.reference.node, bufnr)[1] == node_text
then then
local def_node, _, kind = M.find_definition(match.reference.node, bufnr) local def_node, _, kind = M.find_definition(match.reference.node, bufnr)

View File

@ -17,26 +17,8 @@ local filetype_to_parsername = {
OpenFOAM = "foam", OpenFOAM = "foam",
pandoc = "markdown", pandoc = "markdown",
rmd = "markdown", rmd = "markdown",
cs = "c_sharp",
tape = "vhs",
} }
---@class InstallInfo
---@field url string
---@field branch string|nil
---@field revision string|nil
---@field files string[]
---@field generate_requires_npm boolean|nil
---@field requires_generate_from_grammar boolean|nil
---@field location string|nil
---@class ParserInfo
---@field install_info InstallInfo
---@field filetype string
---@field maintainers string[]
---@field experimental boolean|nil
---@type ParserInfo[]
local list = setmetatable({}, { local list = setmetatable({}, {
__newindex = function(table, parsername, parserconfig) __newindex = function(table, parsername, parserconfig)
rawset( rawset(
@ -61,46 +43,6 @@ local list = setmetatable({}, {
end, end,
}) })
list.agda = {
install_info = {
url = "https://github.com/AusCyberman/tree-sitter-agda",
branch = "master",
files = { "src/parser.c", "src/scanner.cc" },
generate_requires_npm = true,
},
filetype = "agda",
maintainers = { "@Decodetalkers" },
}
list.meson = {
install_info = {
url = "https://github.com/Decodetalkers/tree-sitter-meson",
branch = "master",
files = { "src/parser.c" },
},
filetype = "meson",
maintainers = { "@Decodetalkers" },
}
list.qmljs = {
install_info = {
url = "https://github.com/yuja/tree-sitter-qmljs",
branch = "master",
files = { "src/parser.c", "src/scanner.c" },
},
filetype = "qmljs",
maintainers = { "@yuja" },
}
list.racket = {
install_info = {
url = "https://github.com/6cdh/tree-sitter-racket",
branch = "main",
files = { "src/parser.c", "src/scanner.cc" },
},
maintainers = { "@6cdh" },
}
list.scheme = { list.scheme = {
install_info = { install_info = {
url = "https://github.com/6cdh/tree-sitter-scheme", url = "https://github.com/6cdh/tree-sitter-scheme",
@ -135,14 +77,6 @@ list.c = {
maintainers = { "@vigoux" }, maintainers = { "@vigoux" },
} }
list.embedded_template = {
install_info = {
url = "https://github.com/tree-sitter/tree-sitter-embedded-template",
files = { "src/parser.c" },
},
filetype = "eruby",
}
list.clojure = { list.clojure = {
install_info = { install_info = {
url = "https://github.com/sogaiu/tree-sitter-clojure", url = "https://github.com/sogaiu/tree-sitter-clojure",
@ -199,15 +133,6 @@ list.glsl = {
maintainers = { "@theHamsta" }, maintainers = { "@theHamsta" },
} }
list.hlsl = {
install_info = {
url = "https://github.com/theHamsta/tree-sitter-hlsl",
files = { "src/parser.c", "src/scanner.cc" },
generate_requires_npm = true,
},
maintainers = { "@theHamsta" },
}
list.dockerfile = { list.dockerfile = {
install_info = { install_info = {
url = "https://github.com/camdencheek/tree-sitter-dockerfile", url = "https://github.com/camdencheek/tree-sitter-dockerfile",
@ -387,14 +312,6 @@ list.json = {
maintainers = { "@steelsojka" }, maintainers = { "@steelsojka" },
} }
list.jsonnet = {
install_info = {
url = "https://github.com/sourcegraph/tree-sitter-jsonnet",
files = { "src/parser.c", "src/scanner.c" },
},
maintainers = { "@nawordar" },
}
list.css = { list.css = {
install_info = { install_info = {
url = "https://github.com/tree-sitter/tree-sitter-css", url = "https://github.com/tree-sitter/tree-sitter-css",
@ -472,7 +389,7 @@ list.ocaml = {
install_info = { install_info = {
url = "https://github.com/tree-sitter/tree-sitter-ocaml", url = "https://github.com/tree-sitter/tree-sitter-ocaml",
files = { "src/parser.c", "src/scanner.cc" }, files = { "src/parser.c", "src/scanner.cc" },
location = "ocaml", location = "tree-sitter-ocaml/ocaml",
}, },
maintainers = { "@undu" }, maintainers = { "@undu" },
} }
@ -481,7 +398,7 @@ list.ocaml_interface = {
install_info = { install_info = {
url = "https://github.com/tree-sitter/tree-sitter-ocaml", url = "https://github.com/tree-sitter/tree-sitter-ocaml",
files = { "src/parser.c", "src/scanner.cc" }, files = { "src/parser.c", "src/scanner.cc" },
location = "interface", location = "tree-sitter-ocaml_interface/interface",
}, },
maintainers = { "@undu" }, maintainers = { "@undu" },
filetype = "ocamlinterface", filetype = "ocamlinterface",
@ -496,31 +413,13 @@ list.ocamllex = {
maintainers = { "@undu" }, maintainers = { "@undu" },
} }
list.menhir = {
install_info = {
url = "https://github.com/Kerl13/tree-sitter-menhir",
files = { "src/parser.c", "src/scanner.cc" },
},
maintainers = { "@Kerl13" },
filetype = "menhir",
}
list.org = {
install_info = {
url = "https://github.com/milisims/tree-sitter-org",
branch = "main",
files = { "src/parser.c", "src/scanner.cc" },
},
}
list.swift = { list.swift = {
install_info = { install_info = {
url = "https://github.com/alex-pinkus/tree-sitter-swift", url = "https://github.com/alex-pinkus/tree-sitter-swift",
branch = "main",
files = { "src/parser.c", "src/scanner.c" }, files = { "src/parser.c", "src/scanner.c" },
requires_generate_from_grammar = true, requires_generate_from_grammar = true,
generate_requires_npm = true,
}, },
maintainers = { "@alex-pinkus" },
} }
list.c_sharp = { list.c_sharp = {
@ -547,7 +446,7 @@ list.typescript = {
install_info = { install_info = {
url = "https://github.com/tree-sitter/tree-sitter-typescript", url = "https://github.com/tree-sitter/tree-sitter-typescript",
files = { "src/parser.c", "src/scanner.c" }, files = { "src/parser.c", "src/scanner.c" },
location = "typescript", location = "tree-sitter-typescript/typescript",
generate_requires_npm = true, generate_requires_npm = true,
}, },
maintainers = { "@steelsojka" }, maintainers = { "@steelsojka" },
@ -557,7 +456,7 @@ list.tsx = {
install_info = { install_info = {
url = "https://github.com/tree-sitter/tree-sitter-typescript", url = "https://github.com/tree-sitter/tree-sitter-typescript",
files = { "src/parser.c", "src/scanner.c" }, files = { "src/parser.c", "src/scanner.c" },
location = "tsx", location = "tree-sitter-tsx/tsx",
generate_requires_npm = true, generate_requires_npm = true,
}, },
filetype = "typescriptreact", filetype = "typescriptreact",
@ -612,24 +511,9 @@ list.hcl = {
list.markdown = { list.markdown = {
install_info = { install_info = {
url = "https://github.com/MDeiml/tree-sitter-markdown", url = "https://github.com/MDeiml/tree-sitter-markdown",
location = "tree-sitter-markdown",
files = { "src/parser.c", "src/scanner.cc" }, files = { "src/parser.c", "src/scanner.cc" },
branch = "split_parser", branch = "main",
readme_name = "markdown (basic highlighting)",
}, },
maintainers = { "@MDeiml" },
experimental = true,
}
list.markdown_inline = {
install_info = {
url = "https://github.com/MDeiml/tree-sitter-markdown",
location = "tree-sitter-markdown-inline",
files = { "src/parser.c", "src/scanner.cc" },
branch = "split_parser",
readme_name = "markdown_inline (needs to be installed for full markdown highlighting)",
},
maintainers = { "@MDeiml" },
experimental = true, experimental = true,
} }
@ -669,7 +553,6 @@ list.pug = {
}, },
maintainers = { "@zealot128" }, maintainers = { "@zealot128" },
filetype = "pug", filetype = "pug",
experimental = true,
} }
list.vue = { list.vue = {
@ -779,6 +662,8 @@ list.verilog = {
generate_requires_npm = true, generate_requires_npm = true,
}, },
maintainers = { "@zegervdv" }, maintainers = { "@zegervdv" },
-- The parser still uses API version 12, because it does not compile with 13
experimental = true,
} }
list.pascal = { list.pascal = {
@ -794,6 +679,8 @@ list.phpdoc = {
install_info = { install_info = {
url = "https://github.com/claytonrcarter/tree-sitter-phpdoc", url = "https://github.com/claytonrcarter/tree-sitter-phpdoc",
files = { "src/parser.c", "src/scanner.c" }, files = { "src/parser.c", "src/scanner.c" },
-- parser.c in the repo still based on TS 0.17 due to other dependencies
requires_generate_from_grammar = true,
generate_requires_npm = true, generate_requires_npm = true,
}, },
maintainers = { "@mikehaertl" }, maintainers = { "@mikehaertl" },
@ -842,14 +729,6 @@ list.sparql = {
maintainers = { "@bonabeavis" }, maintainers = { "@bonabeavis" },
} }
list.sql = {
install_info = {
url = "https://github.com/derekstride/tree-sitter-sql",
files = { "src/parser.c" },
},
maintainers = { "@derekstride" },
}
list.gdscript = { list.gdscript = {
install_info = { install_info = {
url = "https://github.com/PrestonKnopp/tree-sitter-gdscript", url = "https://github.com/PrestonKnopp/tree-sitter-gdscript",
@ -902,7 +781,7 @@ list.svelte = {
list.r = { list.r = {
install_info = { install_info = {
url = "https://github.com/r-lib/tree-sitter-r", url = "https://github.com/r-lib/tree-sitter-r",
files = { "src/parser.c", "src/scanner.cc" }, files = { "src/parser.c" },
}, },
maintainers = { "@jimhester" }, maintainers = { "@jimhester" },
} }
@ -910,21 +789,12 @@ list.r = {
list.beancount = { list.beancount = {
install_info = { install_info = {
url = "https://github.com/polarmutex/tree-sitter-beancount", url = "https://github.com/polarmutex/tree-sitter-beancount",
files = { "src/parser.c", "src/scanner.cc" }, files = { "src/parser.c" },
branch = "master", branch = "master",
}, },
maintainers = { "@polarmutex" }, maintainers = { "@polarmutex" },
} }
list.rnoweb = {
install_info = {
url = "https://github.com/bamonroe/tree-sitter-rnoweb",
files = { "src/parser.c", "src/scanner.c" },
},
filetype = "rnoweb",
maintainers = { "@bamonroe" },
}
list.latex = { list.latex = {
install_info = { install_info = {
url = "https://github.com/latex-lsp/tree-sitter-latex", url = "https://github.com/latex-lsp/tree-sitter-latex",
@ -979,11 +849,12 @@ list.vim = {
list.help = { list.help = {
install_info = { install_info = {
url = "https://github.com/neovim/tree-sitter-vimdoc", url = "https://github.com/vigoux/tree-sitter-vimdoc",
files = { "src/parser.c" }, files = { "src/parser.c", "src/scanner.c" },
}, },
filetype = "help", filetype = "help",
maintainers = { "@vigoux" }, maintainers = { "@vigoux" },
experimental = true,
} }
list.json5 = { list.json5 = {
@ -1033,7 +904,7 @@ list.llvm = {
list.http = { list.http = {
install_info = { install_info = {
url = "https://github.com/rest-nvim/tree-sitter-http", url = "https://github.com/NTBBloodbath/tree-sitter-http",
branch = "main", branch = "main",
files = { "src/parser.c" }, files = { "src/parser.c" },
generate_requires_npm = true, generate_requires_npm = true,
@ -1102,11 +973,11 @@ list.norg = {
list.vala = { list.vala = {
install_info = { install_info = {
url = "https://github.com/vala-lang/tree-sitter-vala", url = "https://github.com/matbme/tree-sitter-vala",
branch = "master", branch = "main",
files = { "src/parser.c" }, files = { "src/parser.c", "src/scanner.cc" },
}, },
maintainers = { "@Prince781", "@vala-lang" }, maintainers = { "@matbme" },
} }
list.lalrpop = { list.lalrpop = {
@ -1163,136 +1034,6 @@ list.wgsl = {
filetype = "wgsl", filetype = "wgsl",
} }
list.m68k = {
install_info = {
url = "https://github.com/grahambates/tree-sitter-m68k",
files = { "src/parser.c" },
},
maintainers = { "@grahambates" },
filetype = "asm68k",
}
list.proto = {
install_info = {
url = "https://github.com/mitchellh/tree-sitter-proto",
branch = "main",
files = { "src/parser.c" },
},
maintainers = { "@fsouza" },
filetype = "proto",
}
list.v = {
install_info = {
url = "https://github.com/vlang/vls",
files = { "src/parser.c", "src/scanner.c" },
location = "tree_sitter_v",
generate_requires_npm = false,
requires_generate_from_grammar = false,
},
filetype = "vlang",
maintainers = { "@tami5" },
}
list.tiger = {
install_info = {
url = "https://github.com/ambroisie/tree-sitter-tiger",
files = { "src/parser.c", "src/scanner.c" },
branch = "main",
generate_requires_npm = false,
requires_generate_from_grammar = false,
},
filetype = "tiger",
maintainers = { "@ambroisie" },
}
list.sxhkdrc = {
install_info = {
url = "https://github.com/RaafatTurki/tree-sitter-sxhkdrc",
files = { "src/parser.c" },
branch = "master",
generate_requires_npm = false,
requires_generate_from_grammar = false,
filetype = "sxhkdrc",
},
maintainers = { "@RaafatTurki" },
}
list.gitignore = {
install_info = {
url = "https://github.com/shunsambongi/tree-sitter-gitignore",
files = { "src/parser.c" },
branch = "main",
requires_generate_from_grammar = true,
},
maintainers = { "@theHamsta" },
}
list.nickel = {
install_info = {
url = "https://github.com/nickel-lang/tree-sitter-nickel",
files = { "src/parser.c", "src/scanner.cc" },
branch = "main",
},
}
list.gitattributes = {
install_info = {
url = "https://github.com/ObserverOfTime/tree-sitter-gitattributes",
files = { "src/parser.c" },
},
maintainers = { "@ObserverOfTime" },
}
list.git_rebase = {
install_info = {
url = "https://github.com/the-mikedavis/tree-sitter-git-rebase",
files = { "src/parser.c" },
branch = "main",
},
filetype = "gitrebase",
maintainers = { "@gbprod" },
}
list.blueprint = {
install_info = {
url = "https://gitlab.com/gabmus/tree-sitter-blueprint.git",
files = { "src/parser.c" },
},
maintainers = { "@gabmus" },
experimental = true,
}
list.twig = {
install_info = {
url = "https://github.com/gbprod/tree-sitter-twig",
branch = "main",
files = { "src/parser.c" },
},
maintainers = { "@gbprod" },
filetype = "twig",
}
list.diff = {
install_info = {
url = "https://github.com/the-mikedavis/tree-sitter-diff",
branch = "main",
files = { "src/parser.c" },
},
maintainers = { "@gbprod" },
filetype = "gitdiff",
}
list.vhs = {
install_info = {
url = "https://github.com/charmbracelet/tree-sitter-vhs",
branch = "main",
files = { "src/parser.c" },
},
maintainers = { "@caarlos0", "@maaslalani" },
filetype = "tape",
}
local M = { local M = {
list = list, list = list,
filetype_to_parsername = filetype_to_parsername, filetype_to_parsername = filetype_to_parsername,
@ -1318,6 +1059,19 @@ function M.available_parsers()
end end
end end
function M.maintained_parsers()
require("nvim-treesitter.utils").notify(
"ensure_installed='maintained' will be removed April 30, 2022. Specify parsers explicitly or use 'all'.",
vim.log.levels.WARN
)
local has_tree_sitter_cli = vim.fn.executable "tree-sitter" == 1 and vim.fn.executable "node" == 1
return vim.tbl_filter(function(lang)
return M.list[lang].maintainers
and not M.list[lang].experimental
and (has_tree_sitter_cli or not M.list[lang].install_info.requires_generate_from_grammar)
end, M.available_parsers())
end
function M.get_parser_configs() function M.get_parser_configs()
return M.list return M.list
end end

View File

@ -11,10 +11,8 @@ local EMPTY_ITER = function() end
M.built_in_query_groups = { "highlights", "locals", "folds", "indents", "injections" } M.built_in_query_groups = { "highlights", "locals", "folds", "indents", "injections" }
--- Creates a function that checks whether a given query exists -- Creates a function that checks whether a given query exists
--- for a specific language. -- for a specific language.
---@param query string
---@return function(string): boolean
local function get_query_guard(query) local function get_query_guard(query)
return function(lang) return function(lang)
return M.has_query_files(lang, query) return M.has_query_files(lang, query)
@ -25,7 +23,6 @@ for _, query in ipairs(M.built_in_query_groups) do
M["has_" .. query] = get_query_guard(query) M["has_" .. query] = get_query_guard(query)
end end
---@return string[]
function M.available_query_groups() function M.available_query_groups()
local query_files = api.nvim_get_runtime_file("queries/*/*.scm", true) local query_files = api.nvim_get_runtime_file("queries/*/*.scm", true)
local groups = {} local groups = {}
@ -60,19 +57,11 @@ do
end end
end end
---@param lang string
---@param query_name string
---@return string[]
local function runtime_queries(lang, query_name) local function runtime_queries(lang, query_name)
return api.nvim_get_runtime_file(string.format("queries/%s/%s.scm", lang, query_name), true) or {} return api.nvim_get_runtime_file(string.format("queries/%s/%s.scm", lang, query_name), true) or {}
end end
---@type table<string, table<string, boolean>>
local query_files_cache = {} local query_files_cache = {}
---@param lang string
---@param query_name string
---@return boolean
function M.has_query_files(lang, query_name) function M.has_query_files(lang, query_name)
if not query_files_cache[lang] then if not query_files_cache[lang] then
query_files_cache[lang] = {} query_files_cache[lang] = {}
@ -97,8 +86,6 @@ do
local cache = setmetatable({}, mt) local cache = setmetatable({}, mt)
--- Same as `vim.treesitter.query` except will return cached values --- Same as `vim.treesitter.query` except will return cached values
---@param lang string
---@param query_name string
function M.get_query(lang, query_name) function M.get_query(lang, query_name)
if cache[lang][query_name] == nil then if cache[lang][query_name] == nil then
cache[lang][query_name] = tsq.get_query(lang, query_name) cache[lang][query_name] = tsq.get_query(lang, query_name)
@ -111,8 +98,6 @@ do
--- If lang and query_name is both present, will reload for only the lang and query_name. --- If lang and query_name is both present, will reload for only the lang and query_name.
--- If only lang is present, will reload all query_names for that lang --- If only lang is present, will reload all query_names for that lang
--- If none are present, will reload everything --- If none are present, will reload everything
---@param lang string
---@param query_name string
function M.invalidate_query_cache(lang, query_name) function M.invalidate_query_cache(lang, query_name)
if lang and query_name then if lang and query_name then
cache[lang][query_name] = nil cache[lang][query_name] = nil
@ -121,14 +106,14 @@ do
end end
elseif lang and not query_name then elseif lang and not query_name then
query_files_cache[lang] = nil query_files_cache[lang] = nil
for query_name0, _ in pairs(cache[lang]) do for query_name, _ in pairs(cache[lang]) do
M.invalidate_query_cache(lang, query_name0) M.invalidate_query_cache(lang, query_name)
end end
elseif not lang and not query_name then elseif not lang and not query_name then
query_files_cache = {} query_files_cache = {}
for lang0, _ in pairs(cache) do for lang, _ in pairs(cache) do
for query_name0, _ in pairs(cache[lang0]) do for query_name, _ in pairs(cache[lang]) do
M.invalidate_query_cache(lang0, query_name0) M.invalidate_query_cache(lang, query_name)
end end
end end
else else
@ -138,23 +123,11 @@ do
end end
--- This function is meant for an autocommand and not to be used. Only use if file is a query file. --- This function is meant for an autocommand and not to be used. Only use if file is a query file.
---@param fname string
function M.invalidate_query_file(fname) function M.invalidate_query_file(fname)
local fnamemodify = vim.fn.fnamemodify local fnamemodify = vim.fn.fnamemodify
M.invalidate_query_cache(fnamemodify(fname, ":p:h:t"), fnamemodify(fname, ":t:r")) M.invalidate_query_cache(fnamemodify(fname, ":p:h:t"), fnamemodify(fname, ":t:r"))
end end
---@class QueryInfo
---@field root LanguageTree
---@field source integer
---@field start integer
---@field stop integer
---@param bufnr integer
---@param query_name string
---@param root LanguageTree
---@param root_lang string|nil
---@return Query|nil, QueryInfo|nil
local function prepare_query(bufnr, query_name, root, root_lang) local function prepare_query(bufnr, query_name, root, root_lang)
local buf_lang = parsers.get_buf_lang(bufnr) local buf_lang = parsers.get_buf_lang(bufnr)
@ -208,10 +181,6 @@ local function prepare_query(bufnr, query_name, root, root_lang)
} }
end 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) function M.iter_prepared_matches(query, qnode, bufnr, start_row, end_row)
-- A function that splits a string on '.' -- A function that splits a string on '.'
local function split(string) local function split(string)
@ -240,7 +209,7 @@ function M.iter_prepared_matches(query, qnode, bufnr, start_row, end_row)
local matches = query:iter_matches(qnode, bufnr, start_row, end_row) local matches = query:iter_matches(qnode, bufnr, start_row, end_row)
local function iterator() local function iterator()
local pattern, match, metadata = matches() local pattern, match = matches()
if pattern ~= nil then if pattern ~= nil then
local prepared_match = {} local prepared_match = {}
@ -250,8 +219,6 @@ function M.iter_prepared_matches(query, qnode, bufnr, start_row, end_row)
if name ~= nil then if name ~= nil then
local path = split(name .. ".node") local path = split(name .. ".node")
insert_to_path(prepared_match, path, node) insert_to_path(prepared_match, path, node)
local metadata_path = split(name .. ".metadata")
insert_to_path(prepared_match, metadata_path, metadata[id])
end end
end end
@ -280,16 +247,15 @@ function M.iter_prepared_matches(query, qnode, bufnr, start_row, end_row)
end end
--- Return all nodes corresponding to a specific capture path (like @definition.var, @reference.type) --- Return all nodes corresponding to a specific capture path (like @definition.var, @reference.type)
---Works like M.get_references or M.get_scopes except you can choose the capture -- Works like M.get_references or M.get_scopes except you can choose the capture
---Can also be a nested capture like @definition.function to get all nodes defining a function. -- Can also be a nested capture like @definition.function to get all nodes defining a function.
--- --
---@param bufnr integer the buffer -- @param bufnr the buffer
---@param captures string|string[] -- @param captures a single string or a list of strings
---@param query_group string the name of query group (highlights or injections for example) -- @param query_group the name of query group (highlights or injections for example)
---@param root LanguageTree|nil node from where to start the search -- @param root (optional) node from where to start the search
---@param lang string|nil the language from where to get the captures. -- @param lang (optional) the language from where to get the captures.
--- Root nodes can have several languages. -- Root nodes can have several languages.
---@return table|nil
function M.get_capture_matches(bufnr, captures, query_group, root, lang) function M.get_capture_matches(bufnr, captures, query_group, root, lang)
if type(captures) == "string" then if type(captures) == "string" then
captures = { captures } captures = { captures }
@ -321,7 +287,6 @@ function M.iter_captures(bufnr, query_name, root, lang)
if not query then if not query then
return EMPTY_ITER return EMPTY_ITER
end end
assert(params)
local iter = query:iter_captures(params.root, params.source, params.start, params.stop) local iter = query:iter_captures(params.root, params.source, params.start, params.stop)
@ -369,17 +334,16 @@ function M.find_best_match(bufnr, capture_string, query_group, filter_predicate,
return best return best
end end
---Iterates matches from a query file. -- Iterates matches from a query file.
---@param bufnr integer the buffer -- @param bufnr the buffer
---@param query_group string the query file to use -- @param query_group the query file to use
---@param root LanguageTree the root node -- @param root the root node
---@param root_lang string|nil the root node lang, if known -- @param root the root node lang, if known
function M.iter_group_results(bufnr, query_group, root, root_lang) function M.iter_group_results(bufnr, query_group, root, root_lang)
local query, params = prepare_query(bufnr, query_group, root, root_lang) local query, params = prepare_query(bufnr, query_group, root, root_lang)
if not query then if not query then
return EMPTY_ITER return EMPTY_ITER
end end
assert(params)
return M.iter_prepared_matches(query, params.root, params.source, params.start, params.stop) return M.iter_prepared_matches(query, params.root, params.source, params.start, params.stop)
end end
@ -394,25 +358,18 @@ function M.collect_group_results(bufnr, query_group, root, lang)
return matches return matches
end end
---@alias CaptureResFn function(string, LanguageTree, LanguageTree): string, string
--- Same as get_capture_matches except this will recursively get matches for every language in the tree. --- Same as get_capture_matches except this will recursively get matches for every language in the tree.
---@param bufnr integer The bufnr -- @param bufnr The bufnr
---@param capture_or_fn string|CaptureResFn The capture to get. If a function is provided then that -- @param capture_or_fn The capture to get. If a function is provided then that
--- function will be used to resolve both the capture and query argument. -- function will be used to resolve both the capture and query argument.
--- The function can return `nil` to ignore that tree. -- The function can return `nil` to ignore that tree.
---@param query_type string The query to get the capture from. This is ignore if a function is provided -- @param query_type The query to get the capture from. This is ignore if a function is provided
--- for the captuer argument. -- for the captuer argument.
function M.get_capture_matches_recursively(bufnr, capture_or_fn, query_type) function M.get_capture_matches_recursively(bufnr, capture_or_fn, query_type)
---@type CaptureResFn local type_fn = type(capture_or_fn) == "function" and capture_or_fn
local type_fn or function()
if type(capture_or_fn) == "function" then
type_fn = capture_or_fn
else
type_fn = function(_, _, _)
return capture_or_fn, query_type return capture_or_fn, query_type
end end
end
local parser = parsers.get_parser(bufnr) local parser = parsers.get_parser(bufnr)
local matches = {} local matches = {}

View File

@ -128,61 +128,3 @@ query.add_directive("downcase!", function(match, _, bufnr, pred, metadata)
metadata[key] = string.lower(text) metadata[key] = string.lower(text)
end end
end) end)
query.add_directive("exclude_children!", function(match, _pattern, _bufnr, pred, metadata)
local capture_id = pred[2]
local node = match[capture_id]
local start_row, start_col, end_row, end_col = node:range()
local ranges = {}
for i = 0, node:named_child_count() - 1 do
local child = node:named_child(i)
local child_start_row, child_start_col, child_end_row, child_end_col = child:range()
if child_start_row > start_row or child_start_col > start_col then
table.insert(ranges, {
start_row,
start_col,
child_start_row,
child_start_col,
})
end
start_row = child_end_row
start_col = child_end_col
end
if end_row > start_row or end_col > start_col then
table.insert(ranges, { start_row, start_col, end_row, end_col })
end
metadata.content = ranges
end)
-- Trim blank lines from end of the region
-- Arguments are the captures to trim.
query.add_directive("trim!", function(match, _, bufnr, pred, metadata)
for _, id in ipairs { select(2, unpack(pred)) } do
local node = match[id]
local start_row, start_col, end_row, end_col = node:range()
-- Don't trim if region ends in middle of a line
if end_col ~= 0 then
return
end
while true do
-- As we only care when end_col == 0, always inspect one line above end_row.
local end_line = vim.api.nvim_buf_get_lines(bufnr, end_row - 1, end_row, true)[1]
if end_line ~= "" then
break
end
end_row = end_row - 1
end
-- If this produces an invalid range, we just skip it.
if start_row < end_row or (start_row == end_row and start_col <= end_col) then
if not metadata[id] then
metadata[id] = {}
end
metadata[id].range = { start_row, start_col, end_row, end_col }
end
end
end)

View File

@ -49,7 +49,6 @@ function M.select_rm_file_cmd(file, info_msg)
end end
end end
---@return string|nil
function M.select_executable(executables) function M.select_executable(executables)
return vim.tbl_filter(function(c) return vim.tbl_filter(function(c)
return c ~= vim.NIL and fn.executable(c) == 1 return c ~= vim.NIL and fn.executable(c) == 1
@ -179,16 +178,11 @@ function M.select_download_commands(repo, project_name, cache_folder, revision,
local path_sep = utils.get_path_sep() local path_sep = utils.get_path_sep()
local url = repo.url:gsub(".git$", "") local url = repo.url:gsub(".git$", "")
local folder_rev = revision
if is_github and revision:match "^v%d" then
folder_rev = revision:sub(2)
end
return { return {
M.select_install_rm_cmd(cache_folder, project_name .. "-tmp"), M.select_install_rm_cmd(cache_folder, project_name .. "-tmp"),
{ {
cmd = "curl", cmd = "curl",
info = "Downloading " .. project_name .. "...", info = "Downloading...",
err = "Error during download, please verify your internet connection", err = "Error during download, please verify your internet connection",
opts = { opts = {
args = { args = {
@ -205,7 +199,7 @@ function M.select_download_commands(repo, project_name, cache_folder, revision,
M.select_mkdir_cmd(project_name .. "-tmp", cache_folder, "Creating temporary directory"), M.select_mkdir_cmd(project_name .. "-tmp", cache_folder, "Creating temporary directory"),
{ {
cmd = "tar", cmd = "tar",
info = "Extracting " .. project_name .. "...", info = "Extracting...",
err = "Error during tarball extraction.", err = "Error during tarball extraction.",
opts = { opts = {
args = { args = {
@ -219,7 +213,7 @@ function M.select_download_commands(repo, project_name, cache_folder, revision,
}, },
M.select_rm_file_cmd(cache_folder .. path_sep .. project_name .. ".tar.gz"), M.select_rm_file_cmd(cache_folder .. path_sep .. project_name .. ".tar.gz"),
M.select_mv_cmd( M.select_mv_cmd(
utils.join_path(project_name .. "-tmp", url:match "[^/]-$" .. "-" .. folder_rev), utils.join_path(project_name .. "-tmp", url:match "[^/]-$" .. "-" .. revision),
project_name, project_name,
cache_folder cache_folder
), ),
@ -232,7 +226,7 @@ function M.select_download_commands(repo, project_name, cache_folder, revision,
return { return {
{ {
cmd = "git", cmd = "git",
info = "Downloading " .. project_name .. "...", info = "Downloading...",
err = clone_error, err = clone_error,
opts = { opts = {
args = { args = {

View File

@ -1,50 +0,0 @@
local parsers = require "nvim-treesitter.parsers"
local ts_utils = require "nvim-treesitter.ts_utils"
local M = {}
-- Trim spaces and opening brackets from end
local transform_line = function(line)
return line:gsub("%s*[%[%(%{]*%s*$", "")
end
function M.statusline(opts)
if not parsers.has_parser() then
return
end
local options = opts or {}
-- if type(opts) == "number" then
-- options = { indicator_size = opts }
-- end
local bufnr = options.bufnr or 0
local indicator_size = options.indicator_size or 100
local type_patterns = options.type_patterns or { "class", "function", "method" }
local transform_fn = options.transform_fn or transform_line
local separator = options.separator or " -> "
local current_node = ts_utils.get_node_at_cursor()
if not current_node then
return ""
end
local lines = {}
local expr = current_node
while expr do
local line = ts_utils._get_line_for_node(expr, type_patterns, transform_fn, bufnr)
if line ~= "" and not vim.tbl_contains(lines, line) then
table.insert(lines, 1, line)
end
expr = expr:parent()
end
local text = table.concat(lines, separator)
local text_len = #text
if text_len > indicator_size then
return "..." .. text:sub(text_len - indicator_size, text_len)
end
return text
end
return M

View File

@ -5,8 +5,12 @@ local utils = require "nvim-treesitter.utils"
local M = {} local M = {}
local function get_node_text(node, bufnr) --- Gets the actual text content of a node
bufnr = bufnr or api.nvim_get_current_buf() -- @param node the node to get the text from
-- @param bufnr the buffer containing the node
-- @return list of lines of text of the node
function M.get_node_text(node, bufnr)
local bufnr = bufnr or api.nvim_get_current_buf()
if not node then if not node then
return {} return {}
end end
@ -16,9 +20,6 @@ local function get_node_text(node, bufnr)
if start_row ~= end_row then if start_row ~= end_row then
local lines = api.nvim_buf_get_lines(bufnr, start_row, end_row + 1, false) local lines = api.nvim_buf_get_lines(bufnr, start_row, end_row + 1, false)
if next(lines) == nil then
return {}
end
lines[1] = string.sub(lines[1], start_col + 1) lines[1] = string.sub(lines[1], start_col + 1)
-- end_row might be just after the last line. In this case the last line is not truncated. -- end_row might be just after the last line. In this case the last line is not truncated.
if #lines == end_row - start_row + 1 then if #lines == end_row - start_row + 1 then
@ -32,37 +33,6 @@ local function get_node_text(node, bufnr)
end end
end end
---@private
function M._get_line_for_node(node, type_patterns, transform_fn, bufnr)
local node_type = node:type()
local is_valid = false
for _, rgx in ipairs(type_patterns) do
if node_type:find(rgx) then
is_valid = true
break
end
end
if not is_valid then
return ""
end
local line = transform_fn(vim.trim(get_node_text(node, bufnr)[1] or ""))
-- Escape % to avoid statusline to evaluate content as expression
return line:gsub("%%", "%%%%")
end
--- Gets the actual text content of a node
-- @deprecated Use vim.treesitter.query.get_node_text
-- @param node the node to get the text from
-- @param bufnr the buffer containing the node
-- @return list of lines of text of the node
function M.get_node_text(node, bufnr)
vim.notify_once(
"nvim-treesitter.ts_utils.get_node_text is deprecated: use vim.treesitter.query.get_node_text",
vim.log.levels.WARN
)
return get_node_text(node, bufnr)
end
--- Determines whether a node is the parent of another --- Determines whether a node is the parent of another
-- @param dest the possible parent -- @param dest the possible parent
-- @param source the possible child node -- @param source the possible child node
@ -154,7 +124,7 @@ function M.get_named_children(node)
return nodes return nodes
end end
function M.get_node_at_cursor(winnr, ignore_injected_langs) function M.get_node_at_cursor(winnr)
winnr = winnr or 0 winnr = winnr or 0
local cursor = api.nvim_win_get_cursor(winnr) local cursor = api.nvim_win_get_cursor(winnr)
local cursor_range = { cursor[1] - 1, cursor[2] } local cursor_range = { cursor[1] - 1, cursor[2] }
@ -164,19 +134,7 @@ function M.get_node_at_cursor(winnr, ignore_injected_langs)
if not root_lang_tree then if not root_lang_tree then
return return
end end
local root = M.get_root_for_position(cursor_range[1], cursor_range[2], root_lang_tree)
local root
if ignore_injected_langs then
for _, tree in ipairs(root_lang_tree:trees()) do
local tree_root = tree:root()
if tree_root and M.is_in_node_range(tree_root, cursor_range[1], cursor_range[2]) then
root = tree_root
break
end
end
else
root = M.get_root_for_position(cursor_range[1], cursor_range[2], root_lang_tree)
end
if not root then if not root then
return return
@ -262,14 +220,14 @@ function M.update_selection(buf, node, selection_mode)
selection_mode = selection_mode or "charwise" selection_mode = selection_mode or "charwise"
local start_row, start_col, end_row, end_col = M.get_vim_range({ M.get_node_range(node) }, buf) local start_row, start_col, end_row, end_col = M.get_vim_range({ M.get_node_range(node) }, buf)
vim.fn.setpos(".", { buf, start_row, start_col, 0 })
-- Start visual selection in appropriate mode -- Start visual selection in appropriate mode
local v_table = { charwise = "v", linewise = "V", blockwise = "<C-v>" } local v_table = { charwise = "v", linewise = "V", blockwise = "<C-v>" }
---- Call to `nvim_replace_termcodes()` is needed for sending appropriate ---- Call to `nvim_replace_termcodes()` is needed for sending appropriate
---- command to enter blockwise mode ---- command to enter blockwise mode
local mode_string = vim.api.nvim_replace_termcodes(v_table[selection_mode] or selection_mode, true, true, true) local mode_string = vim.api.nvim_replace_termcodes(v_table[selection_mode] or selection_mode, true, true, true)
vim.cmd("normal! " .. mode_string) vim.cmd("normal! " .. mode_string)
vim.fn.setpos(".", { buf, start_row, start_col, 0 })
vim.cmd "normal! o"
vim.fn.setpos(".", { buf, end_row, end_col, 0 }) vim.fn.setpos(".", { buf, end_row, end_col, 0 })
end end
@ -368,8 +326,8 @@ function M.swap_nodes(node_or_range1, node_or_range2, bufnr, cursor_to_second)
local range1 = M.node_to_lsp_range(node_or_range1) local range1 = M.node_to_lsp_range(node_or_range1)
local range2 = M.node_to_lsp_range(node_or_range2) local range2 = M.node_to_lsp_range(node_or_range2)
local text1 = get_node_text(node_or_range1, bufnr) local text1 = M.get_node_text(node_or_range1)
local text2 = get_node_text(node_or_range2, bufnr) local text2 = M.get_node_text(node_or_range2)
local edit1 = { range = range1, newText = table.concat(text2, "\n") } local edit1 = { range = range1, newText = table.concat(text2, "\n") }
local edit2 = { range = range2, newText = table.concat(text1, "\n") } local edit2 = { range = range2, newText = table.concat(text1, "\n") }

View File

@ -10,28 +10,6 @@ function M.notify(msg, log_level, opts)
vim.notify(msg, log_level, vim.tbl_extend("force", default_opts, opts or {})) vim.notify(msg, log_level, vim.tbl_extend("force", default_opts, opts or {}))
end end
-- Returns the system specific path seperator.
---@return string
function M.get_path_sep()
return fn.has "win32" == 1 and "\\" or "/"
end
-- Returns a function that joins the given arguments with separator. Arguments
-- can't be nil. Example:
--[[
print(M.generate_join(" ")("foo", "bar"))
--]]
-- prints "foo bar"
function M.generate_join(separator)
return function(...)
return table.concat({ ... }, separator)
end
end
M.join_path = M.generate_join(M.get_path_sep())
M.join_space = M.generate_join " "
--- Define user defined vim command which calls nvim-treesitter module function --- Define user defined vim command which calls nvim-treesitter module function
--- - If module name is 'mod', it should be defined in hierarchy 'nvim-treesitter.mod' --- - If module name is 'mod', it should be defined in hierarchy 'nvim-treesitter.mod'
--- - A table with name 'commands' should be defined in 'mod' which needs to be passed as --- - A table with name 'commands' should be defined in 'mod' which needs to be passed as
@ -70,11 +48,14 @@ M.join_space = M.generate_join " "
function M.setup_commands(mod, commands) function M.setup_commands(mod, commands)
for command_name, def in pairs(commands) do for command_name, def in pairs(commands) do
local f_args = def.f_args or "<f-args>" local f_args = def.f_args or "<f-args>"
local call_fn = local call_fn = string.format(
string.format("lua require'nvim-treesitter.%s'.commands.%s['run<bang>'](%s)", mod, command_name, f_args) "lua require'nvim-treesitter.%s'.commands.%s['run<bang>'](%s)",
mod,
command_name,
f_args
)
local parts = vim.tbl_flatten { local parts = vim.tbl_flatten {
"command!", "command!",
"-bar",
def.args, def.args,
command_name, command_name,
call_fn, call_fn,
@ -83,32 +64,26 @@ function M.setup_commands(mod, commands)
end end
end end
---@param dir string function M.get_path_sep()
---@param create_err string return fn.has "win32" == 1 and "\\" or "/"
---@param writeable_err string
---@return string|nil, string|nil
function M.create_or_reuse_writable_dir(dir, create_err, writeable_err)
create_err = create_err or M.join_space("Could not create dir '", dir, "': ")
writeable_err = writeable_err or M.join_space("Invalid rights, '", dir, "' should be read/write")
-- Try creating and using parser_dir if it doesn't exist
if not luv.fs_stat(dir) then
local ok, error = pcall(vim.fn.mkdir, dir, "p", "0755")
if not ok then
return nil, M.join_space(create_err, error)
end
return dir
end
-- parser_dir exists, use it if it's read/write
if luv.fs_access(dir, "RW") then
return dir
end
-- parser_dir exists but isn't read/write, give up
return nil, M.join_space(writeable_err, dir, "'")
end end
-- Returns a function that joins the given arguments with separator. Arguments
-- can't be nil. Example:
--[[
print(M.generate_join(" ")("foo", "bar"))
--]]
-- prints "foo bar"
function M.generate_join(separator)
return function(...)
return table.concat({ ... }, separator)
end
end
M.join_path = M.generate_join(M.get_path_sep())
local join_space = M.generate_join " "
function M.get_package_path() function M.get_package_path()
-- Path to this source file, removing the leading '@' -- Path to this source file, removing the leading '@'
local source = string.sub(debug.getinfo(1, "S").source, 2) local source = string.sub(debug.getinfo(1, "S").source, 2)
@ -126,13 +101,56 @@ function M.get_cache_dir()
return "/tmp" return "/tmp"
end end
return nil, M.join_space("Invalid cache rights,", fn.stdpath "data", "or /tmp should be read/write") return nil, join_space("Invalid cache rights,", fn.stdpath "data", "or /tmp should be read/write")
end end
-- Returns $XDG_DATA_HOME/nvim/site, but could use any directory that is in -- Returns $XDG_DATA_HOME/nvim/site, but could use any directory that is in
-- runtimepath -- runtimepath
function M.get_site_dir() function M.get_site_dir()
return M.join_path(fn.stdpath "data", "site") local path_sep = M.get_path_sep()
return M.join_path(fn.stdpath "data", path_sep, "site")
end
-- Try the package dir of the nvim-treesitter plugin first, followed by the
-- "site" dir from "runtimepath". "site" dir will be created if it doesn't
-- exist. Using only the package dir won't work when the plugin is installed
-- with Nix, since the "/nix/store" is read-only.
function M.get_parser_install_dir(folder_name)
folder_name = folder_name or "parser"
local package_path = M.get_package_path()
local package_path_parser_dir = M.join_path(package_path, folder_name)
-- If package_path is read/write, use that
if luv.fs_access(package_path_parser_dir, "RW") then
return package_path_parser_dir
end
local site_dir = M.get_site_dir()
local path_sep = M.get_path_sep()
local parser_dir = M.join_path(site_dir, path_sep, folder_name)
-- Try creating and using parser_dir if it doesn't exist
if not luv.fs_stat(parser_dir) then
local ok, error = pcall(vim.fn.mkdir, parser_dir, "p", "0755")
if not ok then
return nil, join_space("Couldn't create parser dir", parser_dir, ":", error)
end
return parser_dir
end
-- parser_dir exists, use it if it's read/write
if luv.fs_access(parser_dir, "RW") then
return parser_dir
end
-- package_path isn't read/write, parser_dir exists but isn't read/write
-- either, give up
return nil, join_space("Invalid cache rights,", package_path, "or", parser_dir, "should be read/write")
end
function M.get_parser_info_dir()
return M.get_parser_install_dir "parser-info"
end end
-- Gets a property at path -- Gets a property at path
@ -206,7 +224,6 @@ function M.to_func(a)
return type(a) == "function" and a or M.constant(a) return type(a) == "function" and a or M.constant(a)
end end
---@return string|nil
function M.ts_cli_version() function M.ts_cli_version()
if fn.executable "tree-sitter" == 1 then if fn.executable "tree-sitter" == 1 then
local handle = io.popen "tree-sitter -V" local handle = io.popen "tree-sitter -V"

View File

@ -1,34 +0,0 @@
-- Last Change: 2022 Apr 16
if vim.g.loaded_nvim_treesitter then
return
end
vim.g.loaded_nvim_treesitter = true
-- setup modules
require("nvim-treesitter").setup()
local api = vim.api
-- define autocommands
local augroup = api.nvim_create_augroup("NvimTreesitter", {})
api.nvim_create_autocmd("Filetype", {
pattern = "query",
group = augroup,
callback = function()
api.nvim_clear_autocmds {
group = augroup,
event = "BufWritePost",
}
api.nvim_create_autocmd("BufWritePost", {
group = augroup,
buffer = 0,
callback = function(opts)
require("nvim-treesitter.query").invalidate_query_file(opts.file)
end,
desc = "Invalidate query file",
})
end,
desc = "Reload query",
})

View File

@ -1,4 +0,0 @@
[
(record)
(module)
] @fold

View File

@ -1,82 +0,0 @@
;; Constants
(integer) @number
;; Variables and Symbols
(typed_binding (atom (qid) @variable))
(untyped_binding) @variable
(typed_binding (expr) @type)
(id) @function
(bid) @function
(function_name (atom (qid) @function))
(field_name) @function
[(data_name) (record_name)] @constructor
; Set
(SetN) @type.builtin
(expr . (atom) @function)
((atom) @boolean
(#any-of? @boolean "true" "false" "True" "False"))
;; Imports and Module Declarations
"import" @include
(module_name) @namespace
;; Pragmas and comments
(pragma) @preproc
(comment) @comment
;; Keywords
[
"where"
"data"
"rewrite"
"postulate"
"public"
"private"
"tactic"
"Prop"
"quote"
"renaming"
"open"
"in"
"hiding"
"constructor"
"abstract"
"let"
"field"
"mutual"
"module"
"infix"
"infixl"
"infixr"
"record"
(ARROW)
]
@keyword
;;;(expr
;;; f_name: (atom) @function)
;; Brackets
[
"("
")"
"{"
"}"]
@punctuation.bracket
[
"="
] @operator

View File

@ -43,9 +43,8 @@
[ [
(string) (string)
(raw_string) (raw_string)
(ansi_c_string)
(heredoc_body) (heredoc_body)
] @string @spell ] @string
(variable_assignment (word) @string) (variable_assignment (word) @string)
@ -79,14 +78,13 @@
(special_variable_name) @constant (special_variable_name) @constant
; trap -l
((word) @constant.builtin ((word) @constant.builtin
(#match? @constant.builtin "^SIG(HUP|INT|QUIT|ILL|TRAP|ABRT|BUS|FPE|KILL|USR[12]|SEGV|PIPE|ALRM|TERM|STKFLT|CHLD|CONT|STOP|TSTP|TT(IN|OU)|URG|XCPU|XFSZ|VTALRM|PROF|WINCH|IO|PWR|SYS|RTMIN([+]([1-9]|1[0-5]))?|RTMAX(-([1-9]|1[0-4]))?)$")) (#match? @constant.builtin "^SIG(INT|TERM|QUIT|TIN|TOU|STP|HUP)$"))
((word) @boolean ((word) @boolean
(#match? @boolean "^(true|false)$")) (#match? @boolean "^(true|false)$"))
(comment) @comment @spell (comment) @comment
(test_operator) @string (test_operator) @string
(command_substitution (command_substitution
@ -99,7 +97,7 @@
(function_definition (function_definition
name: (word) @function) name: (word) @function)
(command_name (word) @function.call) (command_name (word) @function)
((command_name (word) @function.builtin) ((command_name (word) @function.builtin)
(#any-of? @function.builtin (#any-of? @function.builtin
@ -131,6 +129,3 @@
value: (word) @parameter) value: (word) @parameter)
(regex) @string.regex (regex) @string.regex
((program . (comment) @preproc)
(#match? @preproc "^#!/"))

View File

@ -1,4 +1,4 @@
[ [
(transaction) (transaction)
(section) (heading)
] @fold ] @fold

View File

@ -1,57 +0,0 @@
(object_id) @variable
(string) @string
(escape_sequence) @string.escape
(comment) @comment
(constant) @constant.builtin
(boolean) @boolean
(using) @include
(template) @keyword
(decorator) @attribute
(property_definition (property_name) @property)
(object) @type
(signal_binding (signal_name) @function.builtin)
(signal_binding (function (identifier)) @function)
(signal_binding "swapped" @keyword)
(styles_list "styles" @function.macro)
(layout_definition "layout" @function.macro)
(gettext_string "_" @function.builtin)
(menu_definition "menu" @keyword)
(menu_section "section" @keyword)
(menu_item "item" @function.macro)
(template_definition (template_name_qualifier) @type.qualifier)
(import_statement (gobject_library) @namespace)
(import_statement (version_number) @float)
(float) @float
(number) @number
[
";"
"."
","
] @punctuation.delimiter
[
"("
")"
"["
"]"
"{"
"}"
] @punctuation.bracket

View File

@ -1,5 +1,4 @@
; Lower priority to prefer @parameter when identifier appears in parameter_declaration. (identifier) @variable
((identifier) @variable (#set! "priority" 95))
[ [
"const" "const"
@ -43,16 +42,10 @@
"#elif" "#elif"
"#endif" "#endif"
(preproc_directive) (preproc_directive)
] @preproc ] @keyword
"#include" @include "#include" @include
[ ";" ":" "," ] @punctuation.delimiter
"..." @punctuation.special
[ "(" ")" "[" "]" "{" "}"] @punctuation.bracket
[ [
"=" "="
@ -70,7 +63,6 @@
">>" ">>"
"->" "->"
"."
"<" "<"
"<=" "<="
@ -97,17 +89,20 @@
"++" "++"
] @operator ] @operator
;; Make sure the comma operator is given a highlight group after the comma
;; punctuator so the operator is highlighted properly.
(comma_expression [ "," ] @operator)
[ [
(true) (true)
(false) (false)
] @boolean ] @boolean
[ "." ";" ":" "," ] @punctuation.delimiter
"..." @punctuation.special
(conditional_expression [ "?" ":" ] @conditional) (conditional_expression [ "?" ":" ] @conditional)
[ "(" ")" "[" "]" "{" "}"] @punctuation.bracket
(string_literal) @string (string_literal) @string
(system_lib_string) @string (system_lib_string) @string
(escape_sequence) @string.escape (escape_sequence) @string.escape
@ -125,7 +120,6 @@
(field_identifier) @property)) @_parent (field_identifier) @property)) @_parent
(#not-has-parent? @_parent template_method function_declarator call_expression)) (#not-has-parent? @_parent template_method function_declarator call_expression))
(field_designator) @property
(((field_identifier) @property) (((field_identifier) @property)
(#has-ancestor? @property field_declaration) (#has-ancestor? @property field_declaration)
(#not-has-ancestor? @property function_declarator)) (#not-has-ancestor? @property function_declarator))
@ -148,9 +142,6 @@
(case_statement (case_statement
value: (identifier) @constant) value: (identifier) @constant)
((identifier) @constant.builtin
(#any-of? @constant.builtin "stderr" "stdin" "stdout"))
;; Preproc def / undef ;; Preproc def / undef
(preproc_def (preproc_def
name: (_) @constant) name: (_) @constant)
@ -160,16 +151,16 @@
(#eq? @_u "#undef")) (#eq? @_u "#undef"))
(call_expression (call_expression
function: (identifier) @function.call) function: (identifier) @function)
(call_expression (call_expression
function: (field_expression function: (field_expression
field: (field_identifier) @function.call)) field: (field_identifier) @function))
(function_declarator (function_declarator
declarator: (identifier) @function) declarator: (identifier) @function)
(preproc_function_def (preproc_function_def
name: (identifier) @function.macro) name: (identifier) @function.macro)
(comment) @comment @spell (comment) @comment
;; Parameters ;; Parameters
(parameter_declaration (parameter_declaration
@ -191,7 +182,6 @@
"_unaligned" "_unaligned"
"__unaligned" "__unaligned"
"__declspec" "__declspec"
(attribute_declaration)
] @attribute ] @attribute
(ERROR) @error (ERROR) @error

View File

@ -20,12 +20,12 @@
(invocation_expression (invocation_expression
(member_access_expression (member_access_expression
name: (identifier) @method.call)) name: (identifier) @method))
(invocation_expression (invocation_expression
function: (conditional_access_expression function: (conditional_access_expression
(member_binding_expression (member_binding_expression
name: (identifier) @method.call))) name: (identifier) @method)))
(namespace_declaration (namespace_declaration
name: [(qualified_name) (identifier)] @namespace) name: [(qualified_name) (identifier)] @namespace)
@ -34,7 +34,7 @@
(identifier) @type) (identifier) @type)
(invocation_expression (invocation_expression
(identifier) @method.call) (identifier) @method)
(field_declaration (field_declaration
(variable_declaration (variable_declaration
@ -74,7 +74,7 @@
(implicit_type) @keyword (implicit_type) @keyword
(comment) @comment @spell (comment) @comment
(using_directive (using_directive
(identifier) @type) (identifier) @type)
@ -141,7 +141,7 @@
; Generic Method invocation with generic type ; Generic Method invocation with generic type
(invocation_expression (invocation_expression
function: (generic_name function: (generic_name
. (identifier) @method.call)) . (identifier) @method))
(invocation_expression (invocation_expression
(member_access_expression (member_access_expression

View File

@ -42,10 +42,10 @@
; General function calls ; General function calls
(list_lit (list_lit
. .
(sym_lit) @function.call) (sym_lit) @function)
(anon_fn_lit (anon_fn_lit
. .
(sym_lit) @function.call) (sym_lit) @function)
; Quoted symbols ; Quoted symbols
(quoting_lit (quoting_lit
@ -106,10 +106,7 @@
; Definition functions ; Definition functions
((sym_lit) @keyword ((sym_lit) @keyword
(#any-of? @keyword (#lua-match? @keyword "^def.*$"))
"def" "defonce" "defrecord" "defmacro" "definline"
"defmulti" "defmethod" "defstruct" "defprotocol"
"deftype"))
((sym_lit) @keyword ((sym_lit) @keyword
(#eq? @keyword "declare")) (#eq? @keyword "declare"))
((sym_lit) @keyword.function ((sym_lit) @keyword.function
@ -281,22 +278,19 @@
;; >> Context based highlighting ;; >> Context based highlighting
;; def-likes ; def-likes
;; Correctly highlight docstrings ; Correctly highlight docstrings
;(list_lit (list_lit
;. .
;(sym_lit) @_keyword ; Don't really want to highlight twice (sym_lit) @_keyword ; Don't really want to highlight twice
;(#any-of? @_keyword (#lua-match? @_keyword "^def.*")
;"def" "defonce" "defrecord" "defmacro" "definline" .
;"defmulti" "defmethod" "defstruct" "defprotocol" (sym_lit)
;"deftype") .
;. ;; TODO: Add @comment highlight
;(sym_lit) (str_lit)?
;. .
;;; TODO: Add @comment highlight (_))
;(str_lit)?
;.
;(_))
; Function definitions ; Function definitions
(list_lit (list_lit

View File

@ -9,7 +9,7 @@
[ [
(bracket_comment) (bracket_comment)
(line_comment) (line_comment)
] @comment @spell ] @comment
(normal_command (identifier) @function) (normal_command (identifier) @function)
@ -123,7 +123,3 @@
(#match? @function.builtin "\\c^(add_custom_command)$") (#match? @function.builtin "\\c^(add_custom_command)$")
) )
(escape_sequence) @string.escape
((source_file . (line_comment) @preproc)
(#match? @preproc "^#!/"))

View File

@ -1,5 +1,3 @@
(_) @spell
[ [
"(" "("
")" ")"
@ -9,12 +7,6 @@
(tag (name) @text.note (user)? @constant) (tag (name) @text.note (user)? @constant)
((tag ((name) @text.note))
(#any-of? @text.note "NOTE"))
("text" @text.note
(#any-of? @text.note "NOTE"))
((tag ((name) @text.warning)) ((tag ((name) @text.warning))
(#any-of? @text.warning "TODO" "HACK" "WARNING")) (#any-of? @text.warning "TODO" "HACK" "WARNING"))

View File

@ -66,21 +66,21 @@
(call_expression (call_expression
function: (qualified_identifier function: (qualified_identifier
name: (identifier) @function.call)) name: (identifier) @function))
(call_expression (call_expression
function: (qualified_identifier function: (qualified_identifier
name: (qualified_identifier name: (qualified_identifier
name: (identifier) @function.call))) name: (identifier) @function)))
(call_expression (call_expression
function: function:
(qualified_identifier (qualified_identifier
name: (qualified_identifier name: (qualified_identifier
name: (qualified_identifier name: (qualified_identifier
name: (identifier) @function.call)))) name: (identifier) @function))))
(call_expression (call_expression
function: (field_expression function: (field_expression
field: (field_identifier) @function.call)) field: (field_identifier) @function))
((call_expression ((call_expression
function: (identifier) @constructor) function: (identifier) @constructor)
@ -158,21 +158,27 @@
"new" "new"
"delete" "delete"
"xor" ;; these keywords are not supported by the parser
"bitand" ;"eq"
"bitor" ;"not_eq"
"compl" ;
"not" ;"compl"
"xor_eq" ;"and"
"and_eq" ;"or"
"or_eq" ;
"not_eq" ;"bitand"
"and" ;"bitand_eq"
"or" ;"bitor"
;"bitor_eq"
;"xor"
;"xor_eq"
] @keyword.operator ] @keyword.operator
"<=>" @operator [
"<=>"
"::"
] @operator
"::" @punctuation.delimiter (attribute_declaration) @attribute
(literal_suffix) @operator (literal_suffix) @operator

View File

@ -11,7 +11,7 @@
(important) (important)
] @keyword ] @keyword
(comment) @comment @spell (comment) @comment
[ [
(tag_name) (tag_name)
@ -42,7 +42,7 @@
(attribute_selector (plain_value) @string) (attribute_selector (plain_value) @string)
(pseudo_element_selector "::" (tag_name) @property) (pseudo_element_selector (tag_name) @property)
(pseudo_class_selector (class_name) @property) (pseudo_class_selector (class_name) @property)
[ [

View File

@ -11,5 +11,4 @@
"__forceinline__" "__forceinline__"
"__restrict__" "__restrict__"
"__launch_bounds__" "__launch_bounds__"
"__grid_constant__"
] @keyword ] @keyword

View File

@ -1,6 +0,0 @@
[(addition) (new_file)] @text.diff.add
[(deletion) (old_file)] @text.diff.delete
(commit) @constant
(location) @attribute
(command) @function

View File

@ -26,7 +26,7 @@
"@" "@"
] @operator ] @operator
(comment) @comment @spell (comment) @comment
(image_spec (image_spec
(image_tag (image_tag
@ -47,17 +47,4 @@
((variable) @constant ((variable) @constant
(#lua-match? @constant "^[A-Z][A-Z_0-9]*$")) (#lua-match? @constant "^[A-Z][A-Z_0-9]*$"))
(arg_instruction
. (unquoted_string) @property)
(env_instruction
(env_pair . (unquoted_string) @property))
(expose_instruction
(expose_port) @number)
((stopsignal_instruction) @number
(#match? @number "[0-9][0-9]?$"))
((stopsignal_instruction) @constant.builtin
(#match? @constant.builtin "SIG(ABRT|HUP|INT|KILL|QUIT|STOP|TERM|TSTP)$"))

View File

@ -1,14 +1,5 @@
(identifier) @type (identifier) @type
(keyword) @keyword
[
"strict"
"graph"
"digraph"
"subgraph"
"node"
"edge"
] @keyword
(string_literal) @string (string_literal) @string
(number_literal) @number (number_literal) @number
@ -46,10 +37,9 @@
(identifier) @constant) (identifier) @constant)
) )
(comment) @comment [
(comment)
(preproc) @preproc (preproc)
] @comment
(comment) @spell
(ERROR) @error (ERROR) @error

View File

@ -83,11 +83,11 @@
;-------------------------- ;--------------------------
(call_expression (call_expression
function: (identifier) @function.call) function: (identifier) @function)
(call_expression (call_expression
function: (member_expression function: (member_expression
property: [(property_identifier) (private_property_identifier)] @method.call)) property: [(property_identifier) (private_property_identifier)] @method))
; Variables ; Variables
;---------- ;----------
@ -97,36 +97,22 @@
; Literals ; Literals
;--------- ;---------
(this) @variable.builtin
(super) @variable.builtin
(true) @boolean
(false) @boolean
(null) @constant.builtin
[ [
(this) (comment)
(super) (hash_bang_line)
] @variable.builtin ] @comment
(string) @string
[ (regex) @punctuation.delimiter
(true) (regex_pattern) @string.regex
(false)
] @boolean
[
(null)
(undefined)
] @constant.builtin
(comment) @comment
(hash_bang_line) @preproc
(comment) @spell
(string) @string @spell
(template_string) @string (template_string) @string
(escape_sequence) @string.escape (escape_sequence) @string.escape
(regex_pattern) @string.regex
(regex "/" @punctuation.bracket) ; Regex delimiters
(number) @number (number) @number
((identifier) @number
(#any-of? @number "NaN" "Infinity"))
; Punctuation ; Punctuation
;------------ ;------------
@ -136,9 +122,9 @@
";" @punctuation.delimiter ";" @punctuation.delimiter
"." @punctuation.delimiter "." @punctuation.delimiter
"," @punctuation.delimiter "," @punctuation.delimiter
"?." @punctuation.delimiter
(pair ":" @punctuation.delimiter) (pair ":" @punctuation.delimiter)
(pair_pattern ":" @punctuation.delimiter)
[ [
"--" "--"

View File

@ -45,8 +45,6 @@
] @branch ] @branch
(statement_block "{" @branch) (statement_block "{" @branch)
["}" "]"] @indent_end
[ [
(comment) (comment)
(template_string) (template_string)

View File

@ -1,6 +1,4 @@
(((comment) @_jsdoc_comment (comment) @jsdoc
(#match? @_jsdoc_comment "^/\\*\\*[^\\*].*\\*/")) @jsdoc)
(comment) @comment (comment) @comment
(call_expression (call_expression
@ -20,8 +18,6 @@
arguments: ((template_string) @glimmer arguments: ((template_string) @glimmer
(#offset! @glimmer 0 1 0 -1))) (#offset! @glimmer 0 1 0 -1)))
((glimmer_template) @glimmer)
; styled.div`<css>` ; styled.div`<css>`
(call_expression (call_expression
function: (member_expression function: (member_expression
@ -60,10 +56,3 @@
(#offset! @css 0 1 0 -1))) (#offset! @css 0 1 0 -1)))
(regex_pattern) @regex (regex_pattern) @regex
((comment) @_gql_comment
(#eq? @_gql_comment "/* GraphQL */")
(template_string) @graphql)
(((template_string) @_template_string
(#match? @_template_string "^`#graphql")) @graphql)

View File

@ -23,11 +23,7 @@
(identifier) @definition.import) (identifier) @definition.import)
(function_declaration (function_declaration
((identifier) @definition.function) ((identifier) @definition.var)
(#set! definition.var.scope parent))
(method_definition
((property_identifier) @definition.function)
(#set! definition.var.scope parent)) (#set! definition.var.scope parent))
; References ; References

View File

@ -30,11 +30,9 @@
; Comments ; Comments
(comment) @comment (comment) @comment
(comment) @spell
; Strings ; Strings
(string) @string (string) @string
(string) @spell
; Modules ; Modules
(alias) @type (alias) @type
@ -86,13 +84,13 @@
(stab_clause operator: _ @operator) (stab_clause operator: _ @operator)
; Local Function Calls ; Local Function Calls
(call target: (identifier) @function.call) (call target: (identifier) @function)
; Remote Function Calls ; Remote Function Calls
(call target: (dot left: [ (call target: (dot left: [
(atom) @type (atom) @type
(_) (_)
] right: (identifier) @function.call) (arguments)) ] right: (identifier) @function) (arguments))
; Definition Function Calls ; Definition Function Calls
(call target: ((identifier) @keyword.function (#any-of? @keyword.function (call target: ((identifier) @keyword.function (#any-of? @keyword.function

View File

@ -16,7 +16,7 @@
["*" "**" "?"] @string.special ["*" "**" "?"] @string.special
(command argument: (bareword) @parameter) (command argument: (bareword) @parameter)
(command head: (identifier) @function.call) (command head: (identifier) @function)
((command head: (identifier) @keyword.return) ((command head: (identifier) @keyword.return)
(#eq? @keyword.return "return")) (#eq? @keyword.return "return"))
((command (identifier) @keyword.operator) ((command (identifier) @keyword.operator)
@ -24,7 +24,7 @@
[ [
"+" "-" "*" "/" "%" "<" "<=""==" "!=" ">" "+" "-" "*" "/" "%" "<" "<=""==" "!=" ">"
">=" "<s" "<=s" "==s" "!=s" ">s" ">=s" ">=" "<s" "<=s" "==s" "!=s" ">s" ">=s"
] @function.builtin ] @function
[">" "<" ">>" "<>" "|"] @operator [">" "<" ">>" "<>" "|"] @operator

View File

@ -1,12 +0,0 @@
(comment_directive) @comment
[
"<%#"
"<%"
"<%="
"<%_"
"<%-"
"%>"
"-%>"
"_%>"
] @keyword

View File

@ -1,2 +0,0 @@
(content) @html @combined
(code) @ruby @combined

View File

@ -1,7 +0,0 @@
[
(function_declaration)
(lambda_clause)
(expr_case)
(map)
(module_export)
] @fold

View File

@ -1,104 +0,0 @@
;; keywoord
[
"fun"
"div"
] @keyword
;; bracket
[
"("
")"
"{"
"}"
"["
"]"
"#"
] @punctuation.bracket
;; conditional
[
"receive"
"if"
"case"
"of"
"when"
"after"
"end"
] @conditional
[
"catch"
"try"
"throw"
] @exception
;;; module define
[
"module"
"export"
] @include
;;; operator
[
":"
":="
"?"
"!"
"-"
"+"
"="
"->"
"=>"
"|"
;;;TODO
"$"
] @operator
(comment) @comment
(string) @string
(variable) @variable
(module_name
(atom) @namespace
)
;;; expr_function_call
(expr_function_call
name: (computed_function_name) @function.call
)
(expr_function_call
arguments: (atom) @variable
)
;;; map
(map
(map_entry [
(atom)
(variable)
] @variable)
)
(tuple (atom) @variable)
(pat_tuple ( pattern (atom) @variable))
(computed_function_name) @function
;;; case
(case_clause
pattern: (pattern
(atom) @variable
)
)
(case_clause
body: (atom) @variable
)
;;; function
(qualified_function_name
module_name: (atom) @attribute
function_name: (atom) @function
)
;; function
(function_clause
name: (atom) @function)
;;;lambda
(lambda_clause
arguments:
(pattern) @variable
)

View File

@ -106,7 +106,7 @@
(command_substitution_dollar "$" @punctuation.bracket) (command_substitution_dollar "$" @punctuation.bracket)
; non-bultin command names ; non-bultin command names
(command name: (word) @function.call) (command name: (word) @function)
; derived from builtin -n (fish 3.2.2) ; derived from builtin -n (fish 3.2.2)
(command (command
@ -149,15 +149,11 @@
[(integer) (float)] @number [(integer) (float)] @number
(comment) @comment (comment) @comment
(comment) @spell
(test_option) @string (test_option) @string
((word) @boolean ((word) @boolean
(#any-of? @boolean "true" "false")) (#any-of? @boolean "true" "false"))
((program . (comment) @preproc)
(#match? @preproc "^#!/"))
;; Error ;; Error
(ERROR) @error (ERROR) @error

View File

@ -1,8 +0,0 @@
((command) @keyword
(label)? @constant
(message)? @text @spell)
(option) @operator
(comment) @comment

View File

@ -1,5 +0,0 @@
((operation
(command) @_command
(message) @bash)
(#any-of? @_command "exec" "x"))

View File

@ -1,53 +0,0 @@
(dir_sep) @punctuation.delimiter
(wildcard) @punctuation.special
(quoted_pattern
("\"" @character.special))
(range_notation) @string.special
(range_notation
[ "[" "]" ] @punctuation.bracket)
(range_negation) @operator
(character_class) @constant
(class_range ("-" @operator))
[
(ansi_c_escape)
(escaped_char)
] @string.escape
(attribute
(attr_name) @parameter)
(attribute
(builtin_attr) @variable.builtin)
[
(attr_reset)
(attr_unset)
(attr_set)
] @operator
(boolean_value) @boolean
(string_value) @string
(macro_tag) @preproc
(macro_def
macro_name: (_) @property)
[
(pattern_negation)
(redundant_escape)
(trailing_slash)
] @error
(ERROR) @error
(comment) @comment @spell

View File

@ -1 +0,0 @@
(comment) @comment

View File

@ -1,31 +0,0 @@
(comment) @comment @spell
[
(directory_separator)
(directory_separator_escaped)
] @punctuation.delimiter
[
(wildcard_char_single)
(wildcard_chars)
(wildcard_chars_allow_slash)
(bracket_negation)
] @operator
(negation) @punctuation.special
[
(pattern_char_escaped)
(bracket_char_escaped)
] @string.escape
;; bracket expressions
[
"["
"]"
] @punctuation.bracket
(bracket_char) @constant
(bracket_range
"-" @operator)
(bracket_char_class) @constant.builtin

View File

@ -9,8 +9,5 @@
(method_declaration) (method_declaration)
(type_declaration) (type_declaration)
(var_declaration) (var_declaration)
(composite_literal)
(literal_element)
(block)
] @fold ] @fold

View File

@ -15,17 +15,20 @@
((identifier) @constant ((identifier) @constant
(#eq? @constant "_")) (#eq? @constant "_"))
((identifier) @constant
(#vim-match? @constant "^[A-Z][A-Z\\d_]+$"))
(const_spec (const_spec
name: (identifier) @constant) name: (identifier) @constant)
; Function calls ; Function calls
(call_expression (call_expression
function: (identifier) @function.call) function: (identifier) @function)
(call_expression (call_expression
function: (selector_expression function: (selector_expression
field: (field_identifier) @method.call)) field: (field_identifier) @method))
; Function definitions ; Function definitions
@ -35,9 +38,6 @@
(method_declaration (method_declaration
name: (field_identifier) @method) name: (field_identifier) @method)
(method_spec
name: (field_identifier) @method)
; Operators ; Operators
[ [
@ -123,7 +123,6 @@
((type_identifier) @type.builtin ((type_identifier) @type.builtin
(#any-of? @type.builtin (#any-of? @type.builtin
"any"
"bool" "bool"
"byte" "byte"
"complex128" "complex128"
@ -185,7 +184,7 @@
; Literals ; Literals
(interpreted_string_literal) @string (interpreted_string_literal) @string
(raw_string_literal) @string @spell (raw_string_literal) @string
(rune_literal) @string (rune_literal) @string
(escape_sequence) @string.escape (escape_sequence) @string.escape
@ -197,16 +196,6 @@
(false) @boolean (false) @boolean
(nil) @constant.builtin (nil) @constant.builtin
(keyed_element (comment) @comment
. (literal_element (identifier) @field))
(field_declaration name: (field_identifier) @field)
(comment) @comment @spell
(ERROR) @error (ERROR) @error
((interpreted_string_literal) @spell
(#not-has-parent? @spell
import_spec
)
)

View File

@ -3,6 +3,7 @@
(const_declaration) (const_declaration)
(var_declaration) (var_declaration)
(type_declaration) (type_declaration)
(composite_literal)
(func_literal) (func_literal)
(literal_value) (literal_value)
(expression_case) (expression_case)
@ -10,22 +11,13 @@
(block) (block)
(call_expression) (call_expression)
(parameter_list) (parameter_list)
(struct_type)
] @indent ] @indent
[ [
"case"
"}" "}"
] @branch ] @branch
(const_declaration ")" @branch)
(import_spec_list ")" @branch)
(var_declaration ")" @branch)
[
"}"
")"
] @indent_end
(parameter_list ")" @branch) (parameter_list ")" @branch)
(comment) @ignore (comment) @ignore

View File

@ -1 +1,6 @@
((comment) @c (#offset! @c 1 0 0 -2)
(import_declaration
(import_spec path: (interpreted_string_literal) @_import_path))
(#eq? @_import_path "\"C\""))
(comment) @comment (comment) @comment

View File

@ -177,14 +177,14 @@
(variable) @parameter) (variable) @parameter)
(call_expression (call_expression
function: (qualified_identifier (identifier) @function.call .)) function: (qualified_identifier (identifier) @function .))
(call_expression (call_expression
function: (scoped_identifier (identifier) @function.call .)) function: (scoped_identifier (identifier) @function .))
(call_expression (call_expression
function: (selection_expression function: (selection_expression
(qualified_identifier (identifier) @method.call .))) (qualified_identifier (identifier) @method .)))
(qualified_identifier (qualified_identifier
(_) @namespace . (_) @namespace .

View File

@ -1,5 +0,0 @@
[
(exp_apply)
(exp_do)
(function)
] @fold

View File

@ -81,7 +81,6 @@
"in" "in"
"class" "class"
"instance" "instance"
"pattern"
"data" "data"
"newtype" "newtype"
"family" "family"
@ -117,9 +116,8 @@
(exp_infix (variable) @operator) ; consider infix functions as operators (exp_infix (variable) @operator) ; consider infix functions as operators
(exp_infix (exp_name) @function.call (#set! "priority" 101)) (exp_apply . (exp_name (variable) @function))
(exp_apply . (exp_name (variable) @function.call)) (exp_apply . (exp_name (qualified_variable (variable) @function)))
(exp_apply . (exp_name (qualified_variable (variable) @function.call)))
;; ---------------------------------------------------------------------------- ;; ----------------------------------------------------------------------------
@ -137,12 +135,5 @@
;; ---------------------------------------------------------------------------- ;; ----------------------------------------------------------------------------
;; Quasi-quotes ;; Quasi-quotes
(quoter) @function.call (quoter) @function
; Highlighting of quasiquote_body is handled by injections.scm ; Highlighting of quasiquote_body is handled by injections.scm
;; ----------------------------------------------------------------------------
;; Spell checking
(string) @spell
(comment) @spell

View File

@ -56,23 +56,3 @@
(#eq? @_name "hsx") (#eq? @_name "hsx")
((quasiquote_body) @html) ((quasiquote_body) @html)
) )
;; -----------------------------------------------------------------------------
;; Inline JSON from aeson
(quasiquote
(quoter) @_name
(#eq? @_name "aesonQQ")
((quasiquote_body) @json)
)
;; -----------------------------------------------------------------------------
;; SQL
; postgresql-simple
(quasiquote
(quoter) @_name
(#eq? @_name "sql")
((quasiquote_body) @sql)
)

View File

@ -63,8 +63,8 @@
] @string ] @string
[ [
(heredoc_identifier) ; END (heredoc_identifier) ; <<END
(heredoc_start) ; << or <<- (heredoc_start) ; END
] @punctuation.delimiter ] @punctuation.delimiter
[ [

View File

@ -1,15 +1,13 @@
[ [
(block)
(object) (object)
(block)
(tuple) (tuple)
(function_call) (for_tuple_expr)
(for_object_expr)
] @indent ] @indent
[ [
"]" (object_end)
")" (block_end)
"}" (tuple_end)
] @branch @indent_end ] @branch
(comment) @auto
(ERROR) @auto

View File

@ -1,7 +1 @@
(comment) @comment (comment) @comment
(heredoc_template
(template_literal) @content
(heredoc_identifier) @language
(#set! "language" @language)
(#downcase! "language"))

View File

@ -1,25 +1,14 @@
(h1) @text.title (headline) @text.title
(h2) @text.title
(h3) @text.title
(column_heading) @text.title (column_heading) @text.title
(column_heading
"~" @conceal (#set! conceal ""))
(tag (tag
"*" @conceal (#set! conceal "") "*" @conceal (#set! conceal "")
text: (_) @label) name: (_) @label)
(taglink (option
"'" @conceal (#set! conceal "")
name: (_) @text.literal)
(hotlink
"|" @conceal (#set! conceal "") "|" @conceal (#set! conceal "")
text: (_) @text.reference) destination: (_) @text.uri)
(optionlink (backtick
text: (_) @text.reference)
(codespan
"`" @conceal (#set! conceal "") "`" @conceal (#set! conceal "")
text: (_) @text.literal) content: (_) @string)
(codeblock) @text.literal
(codeblock
">" @conceal (#set! conceal ""))
(block
"<" @conceal (#set! conceal ""))
(argument) @parameter
(keycode) @string.special
(url) @text.uri

View File

@ -1 +0,0 @@
; inherits: cpp

View File

@ -1,35 +0,0 @@
; inherits: cpp
[
"in"
"out"
"inout"
"uniform"
"shared"
"groupshared"
"discard"
"cbuffer"
"row_major"
"column_major"
"globallycoherent"
"centroid"
"noperspective"
"nointerpolation"
"sample"
"linear"
"snorm"
"unorm"
"point"
"line"
"triangleadj"
"lineadj"
"triangle"
] @keyword
(
(identifier) @variable.builtin
(#lua-match? @variable.builtin "^SV_")
)
(hlsl_attribute) @attribute
(hlsl_attribute ["[" "]"] @attribute)

View File

@ -1 +0,0 @@
; inherits: cpp

View File

@ -1,3 +0,0 @@
(preproc_arg) @hlsl
(comment) @comment

View File

@ -1 +0,0 @@
; inherits: cpp

View File

@ -4,7 +4,7 @@
(attribute_name) @tag.attribute (attribute_name) @tag.attribute
(attribute (attribute
(quoted_attribute_value) @string) (quoted_attribute_value) @string)
(text) @text @spell (text) @text
((element (start_tag (tag_name) @_tag) (text) @text.title) ((element (start_tag (tag_name) @_tag) (text) @text.title)
(#match? @_tag "^(h[0-9]|title)$")) (#match? @_tag "^(h[0-9]|title)$"))

View File

@ -9,7 +9,7 @@
(method_declaration (method_declaration
name: (identifier) @method) name: (identifier) @method)
(method_invocation (method_invocation
name: (identifier) @method.call) name: (identifier) @method)
(super) @function.builtin (super) @function.builtin
@ -143,13 +143,13 @@
] @float ] @float
(character_literal) @character (character_literal) @character
[(string_literal) (text_block)] @string (string_literal) @string
(null_literal) @constant.builtin (null_literal) @constant.builtin
[ [
(line_comment) (line_comment)
(block_comment) (block_comment)
] @comment @spell ] @comment
[ [
(true) (true)
@ -178,14 +178,11 @@
"open" "open"
"opens" "opens"
"package" "package"
"permits"
"private" "private"
"protected" "protected"
"provides" "provides"
"public" "public"
"requires" "requires"
"sealed"
"non-sealed"
"static" "static"
"strictfp" "strictfp"
"synchronized" "synchronized"

View File

@ -31,6 +31,3 @@
(formal_parameters (formal_parameters
(assignment_pattern (assignment_pattern
left: (identifier) @parameter)) left: (identifier) @parameter))
;; punctuation
(optional_chain) @punctuation.delimiter

View File

@ -6,7 +6,6 @@
(pair value: (string) @string) (pair value: (string) @string)
(array (string) @string) (array (string) @string)
(string_content (escape_sequence) @string.escape) (string_content (escape_sequence) @string.escape)
(string_content) @spell
(ERROR) @error (ERROR) @error
["," ":"] @punctuation.delimiter ["," ":"] @punctuation.delimiter
"[" @punctuation.bracket "[" @punctuation.bracket

View File

@ -1,3 +1,3 @@
; inherits: json ; inherits: json
(comment) @comment @spell (comment) @comment

View File

@ -1,76 +0,0 @@
[
(true)
(false)
] @boolean
(comment) @comment
(id) @variable
(import) @include
(null) @constant.builtin
(number) @number
(string) @string
(fieldname (id) @label)
[
"["
"]"
"{"
"}"
"("
")"
] @punctuation.bracket
[
"."
","
";"
":"
"::"
":::"
] @punctuation.delimiter
(expr
operator: (_) @operator)
[
"+"
"="
] @operator
"in" @keyword.operator
[
(local)
"assert"
] @keyword
[
"else"
"if"
"then"
] @conditional
[
(dollar)
(self)
] @variable.builtin
((id) @variable.builtin
(#eq? @variable.builtin "std"))
; Function declaration
(bind
function: (id) @function
params: (params
(param
identifier: (id) @parameter)))
; Function call
(expr
(expr (id) @function.call)
"("
(args
(named_argument
(id) @parameter))?
")")
(ERROR) @error

View File

@ -1,8 +0,0 @@
; Styled Jsx <style jsx>
(jsx_element
(jsx_opening_element
(identifier) @_name (#eq? @_name "style")
(jsx_attribute) @_attr (#eq? @_attr "jsx"))
(jsx_expression (template_string) @css
(#offset! @css 0 1 0 -1))
)

View File

@ -12,6 +12,6 @@
(quote_statement) (quote_statement)
(do_clause) (do_clause)
(compound_statement) (compound_expression)
] @fold ] @fold

View File

@ -1,133 +1,120 @@
;;; Identifiers
(identifier) @variable (identifier) @variable
;; In case you want type highlighting based on Julia naming conventions (this might collide with mathematical notation)
;((identifier) @type ; exception: mark `A_foo` sort of identifiers as variables
;(match? @type "^[A-Z][^_]"))
((identifier) @constant
(#match? @constant "^[A-Z][A-Z_]{2}[A-Z_]*$"))
; ;; If you want type highlighting based on Julia naming conventions (this might collide with mathematical notation) [
; ((identifier) @type (triple_string)
; (match? @type "^[A-Z][^_]")) ; exception: Highlight `A_foo` sort of identifiers as variables (string)
] @string
(command_string) @string.special
(string
prefix: (identifier) @constant.builtin)
(macro_identifier) @function.macro (macro_identifier) @function.macro
(macro_identifier (macro_identifier (identifier) @function.macro) ; for any one using the variable highlight
(identifier) @function.macro) ; for any one using the variable highlight
(macro_definition (macro_definition
name: (identifier) @function.macro) name: (identifier) @function.macro
["macro" "end" @keyword])
(quote_expression ":" (identifier)) @symbol
;;; Fields and indexes
(field_expression (field_expression
(identifier)
(identifier) @field .) (identifier) @field .)
(index_expression
(_)
(range_expression
(identifier) @constant.builtin .)
(#eq? @constant.builtin "end"))
;;; Function names
;; definitions
(function_definition (function_definition
name: (identifier) @function) name: (identifier) @function)
(short_function_definition
name: (identifier) @function)
(function_definition
name: (scoped_identifier (identifier) @function .))
(short_function_definition
name: (scoped_identifier (identifier) @function .))
;; calls
(call_expression (call_expression
(identifier) @function.call) (identifier) @function)
(call_expression (call_expression
(field_expression (identifier) @function.call .)) (field_expression (identifier) @method .))
(broadcast_call_expression (broadcast_call_expression
(identifier) @function.call) (identifier) @function)
(broadcast_call_expression (broadcast_call_expression
(field_expression (identifier) @function.call .)) (field_expression (identifier) @method .))
;;; Parameters
(parameter_list (parameter_list
(identifier) @parameter) (identifier) @parameter)
(optional_parameter . (parameter_list
(identifier) @parameter) (optional_parameter .
(slurp_parameter (identifier) @parameter))
(identifier) @parameter)
(typed_parameter (typed_parameter
parameter: (identifier) @parameter (identifier) @parameter
type: (_) @type) (identifier) @type)
(type_parameter_list
(identifier) @type)
(typed_parameter (typed_parameter
type: (_) @type) (identifier) @parameter
(parameterized_identifier) @type)
(function_expression (function_expression
. (identifier) @parameter) ; Single parameter arrow functions . (identifier) @parameter)
(spread_parameter) @parameter
(spread_parameter
(identifier) @parameter)
(named_argument
. (identifier) @parameter)
(argument_list
(typed_expression
(identifier) @parameter
(identifier) @type))
(argument_list
(typed_expression
(identifier) @parameter
(parameterized_identifier) @type))
;; Symbol expressions (:my-wanna-be-lisp-keyword)
(quote_expression
(identifier)) @symbol
;;; Types ;; Parsing error! foo (::Type) gets parsed as two quote expressions
(argument_list
(quote_expression
(quote_expression
(identifier) @type)))
;; Definitions (type_argument_list
(identifier) @type)
(parameterized_identifier (_)) @type
(argument_list
(typed_expression . (identifier) @parameter))
(typed_expression
(identifier) @type .)
(typed_expression
(parameterized_identifier) @type .)
(abstract_definition (abstract_definition
name: (identifier) @type) name: (identifier) @type)
(primitive_definition
name: (identifier) @type)
(struct_definition (struct_definition
name: (identifier) @type) name: (identifier) @type)
;; Annotations (number) @number
(range_expression
(identifier) @number
(#eq? @number "end"))
(range_expression
(_
(identifier) @number
(#eq? @number "end")))
(coefficient_expression
(number)
(identifier) @constant.builtin)
(parametrized_type_expression (_) @type) ;; TODO: operators.
;; Those are a bit difficult to implement since the respective nodes are hidden right now (_power_operator)
(type_parameter_list ;; and heavily use Unicode chars (support for those are bad in vim/lua regexes)
(identifier) @type) ;[;
;(power_operator);
(typed_expression ;(times_operator);
(identifier) @type .) ;(plus_operator);
;(arrow_operator);
(function_definition ;(comparison_operator);
return_type: (identifier) @type) ;(assign_operator);
(short_function_definition ;] @operator ;
return_type: (identifier) @type)
(where_clause
(identifier) @type) ; where clause without braces
;;; Keywords
[
"abstract"
"const"
"macro"
"primitive"
"struct"
"type"
"mutable"
"where"
] @keyword
"end" @keyword "end" @keyword
((identifier) @keyword (#any-of? @keyword "global" "local")) ; Grammar error
(compound_statement
["begin" "end"] @keyword)
(quote_statement
["quote" "end"] @keyword)
(let_statement
["let" "end"] @keyword)
(if_statement (if_statement
["if" "end"] @conditional) ["if" "end"] @conditional)
(elseif_clause (elseif_clause
@ -137,91 +124,67 @@
(ternary_expression (ternary_expression
["?" ":"] @conditional) ["?" ":"] @conditional)
(function_definition ["function" "end"] @keyword.function)
[
(comment)
(block_comment)
] @comment
[
"abstract"
"const"
"macro"
"primitive"
"struct"
"type"
] @keyword
"return" @keyword.return
((identifier) @keyword (#any-of? @keyword "global" "local"))
(compound_expression
["begin" "end"] @keyword)
(try_statement (try_statement
["try" "end"] @exception) ["try" "end" ] @exception)
(finally_clause (finally_clause
"finally" @exception) "finally" @exception)
(catch_clause (catch_clause
"catch" @exception) "catch" @exception)
(quote_statement
["quote" "end"] @keyword)
(let_statement
["let" "end"] @keyword)
(for_statement (for_statement
["for" "end"] @repeat) ["for" "end"] @repeat)
(while_statement (while_statement
["while" "end"] @repeat) ["while" "end"] @repeat)
(break_statement) @repeat
(continue_statement) @repeat
(for_binding
"in" @repeat)
(for_clause (for_clause
"for" @repeat) "for" @repeat)
[ (do_clause
(break_statement) ["do" "end"] @keyword)
(continue_statement)
] @repeat (export_statement
["export"] @include)
(module_definition
["module" "baremodule" "end"] @include)
(import_statement (import_statement
["import" "using"] @include) ["import" "using"] @include)
(export_statement
"export" @include)
(macro_definition (module_definition
["macro" "end" @keyword]) ["module" "end"] @include)
(function_definition ((identifier) @include (#eq? @include "baremodule"))
["function" "end"] @keyword.function)
(do_clause
["do" "end"] @keyword.function)
(function_expression
"->" @keyword.function)
(return_statement
"return" @keyword.return)
(((identifier) @constant.builtin) (#match? @constant.builtin "^(nothing|Inf|NaN)$"))
(((identifier) @boolean) (#eq? @boolean "true"))
(((identifier) @boolean) (#eq? @boolean "false"))
;;; Operators & Punctuation
(operator) @operator
(for_binding ["in" "=" "∈"] @operator)
(pair_expression "=>" @operator)
(range_expression ":" @operator) (range_expression ":" @operator)
(quote_expression ":" @symbol)
(slurp_parameter "..." @operator) ["::" "." "," "..." "!"] @punctuation.delimiter
(spread_expression "..." @operator) ["[" "]" "(" ")" "{" "}"] @punctuation.bracket
"." @operator
["::" "<:"] @operator
["," ";"] @punctuation.delimiter
["(" ")" "[" "]" "{" "}"] @punctuation.bracket
;;; Literals
[
(true)
(false)
] @boolean
(integer_literal) @number
(float_literal) @float
((identifier) @float
(#any-of? @float "NaN" "NaN16" "NaN32"
"Inf" "Inf16" "Inf32"))
((identifier) @constant.builtin
(#any-of? @constant.builtin "nothing" "missing"))
(character_literal) @character
(escape_sequence) @string.escape
(string_literal) @string
(prefixed_string_literal
prefix: (identifier) @function.macro) @string
(command_literal) @string.special
(prefixed_command_literal
prefix: (identifier) @function.macro) @string.special
[
(line_comment)
(block_comment)
] @comment

View File

@ -11,7 +11,7 @@
(quote_statement) (quote_statement)
(do_clause) (do_clause)
(compound_statement) (compound_expression)
(assignment_expression) (assignment_expression)
(binary_expression) (binary_expression)
@ -35,7 +35,8 @@
] @branch ] @branch
[ [
(line_comment) (comment)
(block_comment) (block_comment)
(triple_string)
] @ignore ] @ignore

View File

@ -3,6 +3,6 @@
; (#offset! @markdown 0 3 0 -3)) ; (#offset! @markdown 0 3 0 -3))
[ [
(line_comment) (comment)
(block_comment) (block_comment)
] @comment ] @comment

View File

@ -1,79 +1,59 @@
;;; Variables
(assignment_expression
(identifier) @definition.var)
(assignment_expression
(tuple_expression
(identifier) @definition.var))
;;; let/const bindings (import_statement
(identifier) @definition.import)
(variable_declaration (variable_declaration
(identifier) @definition.var) (identifier) @definition.var)
(variable_declaration (variable_declaration
(tuple_expression (tuple_expression
(identifier) @definition.var)) (identifier) @definition.var))
;;; For bindings
(for_binding (for_binding
(identifier) @definition.var) (identifier) @definition.var)
(for_binding (for_binding
(tuple_expression (tuple_expression
(identifier) @definition.var)) (identifier) @definition.var))
(assignment_expression
;;; Types (tuple_expression
(identifier) @definition.var))
(struct_definition (assignment_expression
name: (identifier) @definition.type) (bare_tuple_expression
(abstract_definition (identifier) @definition.var))
name: (identifier) @definition.type) (assignment_expression
(abstract_definition (identifier) @definition.var)
name: (identifier) @definition.type)
(type_parameter_list (type_parameter_list
(identifier) @definition.type) (identifier) @definition.type)
(type_argument_list
;;; Module imports (identifier) @definition.type)
(struct_definition
(import_statement name: (identifier) @definition.type)
(identifier) @definition.import)
;;; Parameters
(parameter_list (parameter_list
(identifier) @definition.parameter) (identifier) @definition.parameter)
(optional_parameter .
(identifier) @definition.parameter)
(slurp_parameter
(identifier) @definition.parameter)
(typed_parameter (typed_parameter
parameter: (identifier) @definition.parameter (identifier) @definition.parameter
(_)) (identifier))
(function_expression (function_expression
. (identifier) @definition.parameter) ;; Single parameter arrow function . (identifier) @definition.parameter)
(argument_list
(typed_expression
;;; Function/macro definitions (identifier) @definition.parameter
(identifier)))
(spread_parameter
(identifier) @definition.parameter)
(function_definition (function_definition
name: (identifier) @definition.function) @scope name: (identifier) @definition.function) @scope
(short_function_definition
name: (identifier) @definition.function) @scope
(macro_definition (macro_definition
name: (identifier) @definition.macro) @scope name: (identifier) @definition.macro) @scope
(identifier) @reference (identifier) @reference
[ [
(for_statement)
(while_statement)
(try_statement) (try_statement)
(catch_clause)
(finally_clause) (finally_clause)
(let_statement)
(quote_statement) (quote_statement)
(do_clause) (let_statement)
(compound_expression)
(for_statement)
] @scope ] @scope

View File

@ -149,13 +149,13 @@
; function() ; function()
(call_expression (call_expression
. (simple_identifier) @function.call) . (simple_identifier) @function)
; object.function() or object.property.function() ; object.function() or object.property.function()
(call_expression (call_expression
(navigation_expression (navigation_expression
(navigation_suffix (navigation_suffix
(simple_identifier) @function.call) . )) (simple_identifier) @function) . ))
(call_expression (call_expression
. (simple_identifier) @function.builtin . (simple_identifier) @function.builtin
@ -207,11 +207,10 @@
;;; Literals ;;; Literals
(comment) @comment [
(comment)
(shebang_line) @preproc (shebang_line)
] @comment
(comment) @spell
(real_literal) @float (real_literal) @float
[ [
@ -271,9 +270,6 @@
;;; Keywords ;;; Keywords
(type_alias "typealias" @keyword) (type_alias "typealias" @keyword)
(companion_object "companion" @keyword)
[ [
(class_modifier) (class_modifier)
(member_modifier) (member_modifier)

View File

@ -8,7 +8,6 @@
(subparagraph) (subparagraph)
(generic_environment) (generic_environment)
(math_environment)
(comment_environment) (comment_environment)
(displayed_equation) (displayed_equation)
] @fold ] @fold

View File

@ -1,7 +1,7 @@
;; General syntax ;; General syntax
(ERROR) @error (ERROR) @error
(command_name) @function (generic_command) @function
(caption (caption
command: _ @function) command: _ @function)
@ -15,9 +15,6 @@
(comment_environment) (comment_environment)
] @comment ] @comment
((line_comment) @preproc
(#lua-match? @preproc "^%% !TeX"))
[ [
(brack_group) (brack_group)
(brack_group_argc) (brack_group_argc)
@ -35,11 +32,35 @@
;; General environments ;; General environments
(begin (begin
command: _ @text.environment command: _ @text.environment
name: (curly_group_text (text) @text.environment.name)) name: (curly_group_text
(text) @text.environment.name)
(#not-any-of? @text.environment.name
"displaymath" "displaymath*"
"equation" "equation*"
"multline" "multline*"
"eqnarray" "eqnarray*"
"align" "align*"
"array" "array*"
"split" "split*"
"alignat" "alignat*"
"gather" "gather*"
"flalign" "flalign*"))
(end (end
command: _ @text.environment command: _ @text.environment
name: (curly_group_text (text) @text.environment.name)) name: (curly_group_text
(text) @text.environment.name)
(#not-any-of? @text.environment.name
"displaymath" "displaymath*"
"equation" "equation*"
"multline" "multline*"
"eqnarray" "eqnarray*"
"align" "align*"
"array" "array*"
"split" "split*"
"alignat" "alignat*"
"gather" "gather*"
"flalign" "flalign*"))
;; Definitions and references ;; Definitions and references
(new_command_definition (new_command_definition
@ -52,18 +73,10 @@
command: _ @function.macro command: _ @function.macro
declaration: (_) @function) declaration: (_) @function)
(environment_definition
command: _ @function.macro
name: (curly_group_text (_) @text.reference))
(theorem_definition (theorem_definition
command: _ @function.macro command: _ @function.macro
name: (curly_group_text (_) @text.environment.name)) name: (curly_group_text (_) @text.environment.name))
(paired_delimiter_definition
command: _ @function.macro
declaration: (curly_group_command_name (_) @function))
(label_definition (label_definition
command: _ @function.macro command: _ @function.macro
name: (curly_group_text (_) @text.reference)) name: (curly_group_text (_) @text.reference))
@ -110,64 +123,67 @@
(inline_formula) (inline_formula)
] @text.math ] @text.math
(math_environment ((generic_environment
(begin (begin
command: _ @text.math command: _ @text.math
name: (curly_group_text (text) @text.math))) name: (curly_group_text
(text) @_env))) @text.math
(math_environment (#any-of? @_env
(text) @text.math) "displaymath" "displaymath*"
"equation" "equation*"
(math_environment "multline" "multline*"
"eqnarray" "eqnarray*"
"align" "align*"
"array" "array*"
"split" "split*"
"alignat" "alignat*"
"gather" "gather*"
"flalign" "flalign*"))
((generic_environment
(end (end
command: _ @text.math command: _ @text.math
name: (curly_group_text (text) @text.math))) name: (curly_group_text
(text) @_env))) @text.math
(#any-of? @_env
"displaymath" "displaymath*"
"equation" "equation*"
"multline" "multline*"
"eqnarray" "eqnarray*"
"align" "align*"
"array" "array*"
"split" "split*"
"alignat" "alignat*"
"gather" "gather*"
"flalign" "flalign*"))
;; Sectioning ;; Sectioning
(title_declaration
command: _ @namespace
options: (brack_group (_) @text.title)?
text: (curly_group (_) @text.title))
(author_declaration
command: _ @namespace
authors: (curly_group_author_list
((author)+ @text.title)))
(chapter (chapter
command: _ @namespace command: _ @namespace
toc: (brack_group (_) @text.title)? text: (curly_group) @text.title)
text: (curly_group (_) @text.title))
(part (part
command: _ @namespace command: _ @namespace
toc: (brack_group (_) @text.title)? text: (curly_group) @text.title)
text: (curly_group (_) @text.title))
(section (section
command: _ @namespace command: _ @namespace
toc: (brack_group (_) @text.title)? text: (curly_group) @text.title)
text: (curly_group (_) @text.title))
(subsection (subsection
command: _ @namespace command: _ @namespace
toc: (brack_group (_) @text.title)? text: (curly_group) @text.title)
text: (curly_group (_) @text.title))
(subsubsection (subsubsection
command: _ @namespace command: _ @namespace
toc: (brack_group (_) @text.title)? text: (curly_group) @text.title)
text: (curly_group (_) @text.title))
(paragraph (paragraph
command: _ @namespace command: _ @namespace
toc: (brack_group (_) @text.title)? text: (curly_group) @text.title)
text: (curly_group (_) @text.title))
(subparagraph (subparagraph
command: _ @namespace command: _ @namespace
toc: (brack_group (_) @text.title)? text: (curly_group) @text.title)
text: (curly_group (_) @text.title))
;; Beamer frames ;; Beamer frames
(generic_environment (generic_environment
@ -237,10 +253,3 @@
command: _ @include command: _ @include
paths: (curly_group_path_list) @string) paths: (curly_group_path_list) @string)
(
(text) @spell
(#not-has-parent? @spell
inline_formula
displayed_equation
)
)

View File

@ -129,12 +129,7 @@
(identifier) @variable (identifier) @variable
((identifier) @variable.builtin ((identifier) @variable.builtin
(#eq? @variable.builtin "self")) (#match? @variable.builtin "self"))
(variable_list
attribute: (attribute
(["<" ">"] @punctuation.bracket
(identifier) @attribute)))
;; Constants ;; Constants
@ -166,10 +161,10 @@
(parameters (identifier) @parameter) (parameters (identifier) @parameter)
(function_call name: (identifier) @function.call) (function_call name: (identifier) @function)
(function_declaration name: (identifier) @function) (function_declaration name: (identifier) @function)
(function_call name: (dot_index_expression field: (identifier) @function.call)) (function_call name: (dot_index_expression field: (identifier) @function))
(function_declaration name: (dot_index_expression field: (identifier) @function)) (function_declaration name: (dot_index_expression field: (identifier) @function))
(method_index_expression method: (identifier) @method) (method_index_expression method: (identifier) @method)
@ -185,13 +180,13 @@
;; Others ;; Others
(comment) @comment @spell (comment) @comment
(hash_bang_line) @preproc (hash_bang_line) @comment
(number) @number (number) @number
(string) @string @spell (string) @string
;; Error ;; Error
(ERROR) @error (ERROR) @error

View File

@ -3,11 +3,9 @@
(function_declaration) (function_declaration)
(field) (field)
(do_statement) (do_statement)
(method_index_expression)
(while_statement) (while_statement)
(repeat_statement) (repeat_statement)
(if_statement) (if_statement)
"then"
(for_statement) (for_statement)
(return_statement) (return_statement)
(table_constructor) (table_constructor)

View File

@ -16,7 +16,4 @@
arguments: (arguments (string content: _ @query) .)) arguments: (arguments (string content: _ @query) .))
(#eq? @_vimcmd_identifier "vim.treesitter.query.set_query")) (#eq? @_vimcmd_identifier "vim.treesitter.query.set_query"))
;; highlight string as query if starts with `;; query`
((string ("string_content") @query) (#lua-match? @query "^%s*;+%s?query"))
(comment) @comment (comment) @comment

View File

@ -21,19 +21,19 @@
(variable_list (variable_list
(dot_index_expression . (_) @definition.associated (identifier) @definition.var))) (dot_index_expression . (_) @definition.associated (identifier) @definition.var)))
((function_declaration (function_declaration
name: (identifier) @definition.function) name: (identifier) @definition.function)
(#set! definition.function.scope "parent")) (#set! definition.function.scope "parent")
((function_declaration (function_declaration
name: (dot_index_expression name: (dot_index_expression
. (_) @definition.associated (identifier) @definition.function)) . (_) @definition.associated (identifier) @definition.function))
(#set! definition.method.scope "parent")) (#set! definition.method.scope "parent")
((function_declaration (function_declaration
name: (method_index_expression name: (method_index_expression
. (_) @definition.associated (identifier) @definition.method)) . (_) @definition.associated (identifier) @definition.method))
(#set! definition.method.scope "parent")) (#set! definition.method.scope "parent")
(for_generic_clause (for_generic_clause
(variable_list (variable_list

View File

@ -1 +0,0 @@
(element_list) @fold

Some files were not shown because too many files have changed in this diff Show More