diff --git a/bundle/nvim-treesitter/.github/FUNDING.yml b/bundle/nvim-treesitter/.github/FUNDING.yml index b2844b214..d463c475f 100644 --- a/bundle/nvim-treesitter/.github/FUNDING.yml +++ b/bundle/nvim-treesitter/.github/FUNDING.yml @@ -1,2 +1 @@ open_collective: "nvim-treesitter" -github: "nvim-treesitter" diff --git a/bundle/nvim-treesitter/.github/ISSUE_TEMPLATE/highlighting_issue.yml b/bundle/nvim-treesitter/.github/ISSUE_TEMPLATE/highlighting_issue.yml index b6c4404fc..6667bd33f 100644 --- a/bundle/nvim-treesitter/.github/ISSUE_TEMPLATE/highlighting_issue.yml +++ b/bundle/nvim-treesitter/.github/ISSUE_TEMPLATE/highlighting_issue.yml @@ -66,7 +66,7 @@ body: description: | 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 - `:TSHighlightCapturesUnderCursor`. + `:TSHighlightCapturesUnderCursor'. validations: required: true diff --git a/bundle/nvim-treesitter/.github/workflows/lint.yml b/bundle/nvim-treesitter/.github/workflows/lint.yml index 8d0bb121f..9b75ab6b0 100644 --- a/bundle/nvim-treesitter/.github/workflows/lint.yml +++ b/bundle/nvim-treesitter/.github/workflows/lint.yml @@ -27,7 +27,7 @@ jobs: steps: - uses: actions/checkout@v2 - name: Lint with stylua - uses: JohnnyMorganz/stylua-action@v1 + uses: JohnnyMorganz/stylua-action@1.0.0 with: token: ${{ secrets.GITHUB_TOKEN }} args: --check . diff --git a/bundle/nvim-treesitter/.github/workflows/test-queries.yml b/bundle/nvim-treesitter/.github/workflows/test-queries.yml index 738bad9a4..d4ec33052 100644 --- a/bundle/nvim-treesitter/.github/workflows/test-queries.yml +++ b/bundle/nvim-treesitter/.github/workflows/test-queries.yml @@ -52,8 +52,7 @@ jobs: runs-on: ${{ matrix.os }} env: CC: ${{ matrix.cc }} - NVIM: ${{ matrix.os == 'windows-2022' && 'nvim-win64\\bin\\nvim.exe' || 'nvim' }} - ALLOWED_INSTALLATION_FAILURES: ${{ matrix.os == 'windows-2022' && 'rnoweb' }} + NVIM: ${{ matrix.os == 'windows-2022' && 'Neovim\\bin\\nvim.exe' || 'nvim' }} steps: - uses: actions/checkout@v2 - uses: ilammy/msvc-dev-cmd@v1 @@ -62,7 +61,7 @@ jobs: - name: Install and prepare Neovim env: NVIM_TAG: ${{ matrix.nvim_tag }} - TREE_SITTER_CLI_TAG: v0.20.6 + TREE_SITTER_CLI_TAG: v0.20.4 run: | bash ./scripts/ci-install-${{ matrix.os }}.sh @@ -82,5 +81,12 @@ jobs: if: matrix.os == 'windows-2022' 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 + env: + SKIP_SWIFT_CHECK: ${{ env.SKIP_SWIFT_CHECK }} run: $NVIM --headless -c "luafile ./scripts/check-queries.lua" -c "q" diff --git a/bundle/nvim-treesitter/.github/workflows/tests.yml b/bundle/nvim-treesitter/.github/workflows/tests.yml index e8f462119..1b445573e 100644 --- a/bundle/nvim-treesitter/.github/workflows/tests.yml +++ b/bundle/nvim-treesitter/.github/workflows/tests.yml @@ -41,7 +41,7 @@ jobs: - name: Install and prepare Neovim env: NVIM_TAG: stable - TREE_SITTER_CLI_TAG: v0.20.6 + TREE_SITTER_CLI_TAG: v0.20.4 run: | bash ./scripts/ci-install-${{ matrix.os }}.sh diff --git a/bundle/nvim-treesitter/.github/workflows/update-lockfile.yml b/bundle/nvim-treesitter/.github/workflows/update-lockfile.yml index 8b328e290..47e55ba42 100644 --- a/bundle/nvim-treesitter/.github/workflows/update-lockfile.yml +++ b/bundle/nvim-treesitter/.github/workflows/update-lockfile.yml @@ -6,7 +6,6 @@ on: push: branches: - master - workflow_dispatch: jobs: update-lockfile: diff --git a/bundle/nvim-treesitter/.github/workflows/update-readme.yml b/bundle/nvim-treesitter/.github/workflows/update-readme.yml index 62f8bd4fc..dba7ba260 100644 --- a/bundle/nvim-treesitter/.github/workflows/update-readme.yml +++ b/bundle/nvim-treesitter/.github/workflows/update-readme.yml @@ -4,7 +4,6 @@ on: push: branches: - master - workflow_dispatch: jobs: update-readme: diff --git a/bundle/nvim-treesitter/CONTRIBUTING.md b/bundle/nvim-treesitter/CONTRIBUTING.md index 5a6fd71ec..b3c51cee5 100644 --- a/bundle/nvim-treesitter/CONTRIBUTING.md +++ b/bundle/nvim-treesitter/CONTRIBUTING.md @@ -89,179 +89,143 @@ effect on highlighting. We will work on improving highlighting in the near futur #### Misc -```scheme -@comment ; line and block comments -@error ; syntax/parser errors -@none ; completely disable the highlight -@preproc ; various preprocessor directives & shebangs -@define ; preprocessor definition directives -@operator ; symbolic operators (e.g. `+` / `*`) +``` +@comment +@debug +@error for error `ERROR` nodes. +@none to disable completely the highlight +@preproc +@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) ``` - -#### Literals - -```scheme -@string ; string literals -@string.regex ; regular expressions -@string.escape ; escape sequences -@string.special ; other special strings (e.g. dates) - -@character ; character literals -@character.special ; special characters (e.g. wildcards) - -@boolean ; boolean literals -@number ; numeric literals -@float ; floating-point number literals +@constant +@constant.builtin +@constant.macro +@string +@string.regex +@string.escape +@string.special +@character +@character.special +@number +@boolean +@float ``` #### Functions -```scheme -@function ; function definitions -@function.builtin ; built-in functions -@function.call ; function calls -@function.macro ; preprocessor macros +``` +@function +@function.builtin +@function.macro +@parameter -@method ; method definitions -@method.call ; method calls +@method +@field +@property -@constructor ; constructor calls and definitions -@parameter ; parameters of a function +@constructor ``` #### Keywords -```scheme -@keyword ; various keywords -@keyword.function ; keywords that define a function (e.g. `func` in Go, `def` in Python) -@keyword.operator ; operators that are English words (e.g. `and` / `or`) -@keyword.return ; keywords like `return` and `yield` +``` +@conditional (e.g. `if`, `else`) +@repeat (e.g. `for`, `while`) +@label for C/Lua-like labels +@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`) -@repeat ; keywords related to loops (e.g. `for` / `while`) -@debug ; keywords related to debugging -@label ; GOTO and other labels (e.g. `label:` in C) -@include ; keywords for including modules (e.g. `import` / `from` in Python) -@exception ; keywords related to exceptions (e.g. `throw` / `catch`) +@type +@type.builtin +@type.definition +@type.qualifier +@namespace for identifiers referring to namespaces +@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 -@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`) +#### Variables -@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` ``` - -#### Identifiers - -```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 +@variable +@variable.builtin ``` #### Text Mainly for markup languages. -```scheme -@text ; non-structured text -@text.strong ; bold text -@text.emphasis ; text with emphasis -@text.underline ; underlined text -@text.strike ; strikethrough text -@text.title ; text that is part of a title -@text.literal ; literal or verbatim text -@text.uri ; URIs (e.g. hyperlinks) -@text.math ; math environments (e.g. `$ ... $` in LaTeX) -@text.environment ; text environments of markup languages -@text.environment.name ; text indicating the type of an environment -@text.reference ; text references, footnotes, citations, etc. +``` +@text +@text.strong +@text.emphasis +@text.underline +@text.strike +@text.title +@text.literal +@text.uri +@text.math (e.g. for LaTeX math environments) +@text.environment (e.g. for text environments of markup languages) +@text.environment.name (e.g. for the name/the string indicating the type of text environment) +@text.reference (for footnotes, text references, citations) -@text.todo ; todo notes -@text.note ; info notes -@text.warning ; warning notes -@text.danger ; danger/error notes +@text.note +@text.warning +@text.danger -@text.diff.add ; added text (for diff files) -@text.diff.delete ; deleted text (for diff files) +@todo ``` #### Tags -Used for XML-like tags. +Used for xml-like tags -```scheme -@tag ; XML tag names -@tag.attribute ; XML tag attributes -@tag.delimiter ; XML tag delimiters +``` +@tag +@tag.attribute +@tag.delimiter ``` #### Conceal - -```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 -``` +@conceal followed by `(#set! conceal "")` for captures that are not used for highlights but only for concealing. ### Locals -```scheme -@definition ; various definitions -@definition.constant ; constants -@definition.function ; functions -@definition.method ; methods -@definition.var ; variables -@definition.parameter ; parameters -@definition.macro ; preprocessor macros -@definition.type ; types or classes -@definition.field ; fields or properties -@definition.enum ; enumerations -@definition.namespace ; modules or namespaces -@definition.import ; imported names -@definition.associated ; the associated type of a variable +``` +@definition for various definitions +@definition.constant +@definition.function +@definition.method +@definition.var +@definition.parameter +@definition.macro +@definition.type +@definition.field +@definition.enum +@definition.namespace for modules or C++ namespaces +@definition.import for imported names -@scope ; scope block -@reference ; identifier reference +@definition.associated to determine the type of a variable +@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 : -```scheme -@fold ; fold this node +``` +@fold ``` 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 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) -@content ; region for the dynamically detected language -@combined ; combine all matches of a pattern as one single block of content +@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. +@combined ; This will combine all matches of a pattern as one single block of content. ``` ### Indents -```scheme -@indent ; indent children when matching this node -@indent_end ; marks the end of indented block -@aligned_indent ; behaves like python aligned/hanging indent -@dedent ; dedent children when matching this node -@branch ; dedent itself when matching this node -@ignore ; do not indent in this node -@auto ; behaves like 'autoindent' buffer option -@zero_indent ; sets this node at position 0 (no indent) +``` +@indent ; Indent children when matching this node +@indent_end ; Marks the end of indented block +@aligned_indent ; Behaves like python aligned/hanging indent +@dedent ; Dedent children when matching this node +@branch ; Dedent itself when matching this node +@ignore ; Do not indent in this node +@auto ; Behaves like 'autoindent' buffer option +@zero_indent ; Sets this node at position 0 (no indent) ``` [Zulip]: https://nvim-treesitter.zulipchat.com diff --git a/bundle/nvim-treesitter/README.md b/bundle/nvim-treesitter/README.md index 7ecaa0e0b..df159b796 100644 --- a/bundle/nvim-treesitter/README.md +++ b/bundle/nvim-treesitter/README.md @@ -63,7 +63,7 @@ For more detailed information on setting these up, see ["Advanced setup"](#advan ## 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`) - 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`) 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") 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 = { -- `false` will disable the whole extension enable = true, -- 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 - -- the name of the parser) + disable highlighting for the `tex` filetype, you need to include `latex` in this list as this is + the name of the parser) -- list of language that will be disabled 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. -- 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 -- [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] [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] [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_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) @@ -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] [dart](https://github.com/UserNobody14/tree-sitter-dart) (maintained by @Akin909) - [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] [dot](https://github.com/rydesun/tree-sitter-dot) (maintained by @rydesun) - [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) - [ ] [elm](https://github.com/elm-tooling/tree-sitter-elm) - [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] [fennel](https://github.com/travonted/tree-sitter-fennel) (maintained by @TravonteD) - [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) - [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] [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] [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) @@ -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) - [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] [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] [hlsl](https://github.com/theHamsta/tree-sitter-hlsl) (maintained by @theHamsta) - [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] [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] [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] [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] [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] [kotlin](https://github.com/fwcd/tree-sitter-kotlin) (maintained by @SalBakraa) - [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] [llvm](https://github.com/benwilliamgraham/tree-sitter-llvm) (maintained by @benwilliamgraham) - [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] [markdown](https://github.com/MDeiml/tree-sitter-markdown) (experimental, maintained by @MDeiml) -- [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) +- [ ] [markdown](https://github.com/MDeiml/tree-sitter-markdown) - [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] [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_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) -- [ ] [org](https://github.com/milisims/tree-sitter-org) - [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] [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] [pioasm](https://github.com/leo60228/tree-sitter-pioasm) (maintained by @leo60228) - [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) (experimental, maintained by @zealot128) +- [x] [pug](https://github.com/zealot128/tree-sitter-pug) (maintained by @zealot128) - [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] [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] [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] [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] [rnoweb](https://github.com/bamonroe/tree-sitter-rnoweb) (maintained by @bamonroe) - [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] [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] [solidity](https://github.com/YongJieYongJie/tree-sitter-solidity) (maintained by @YongJieYongJie) - [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] [surface](https://github.com/connorlay/tree-sitter-surface) (maintained by @connorlay) - [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) -- [x] [sxhkdrc](https://github.com/RaafatTurki/tree-sitter-sxhkdrc) (maintained by @RaafatTurki) +- [ ] [swift](https://github.com/alex-pinkus/tree-sitter-swift) - [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] [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] [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] [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] [v](https://github.com/vlang/vls) (maintained by @tami5) -- [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) (maintained by @zegervdv) -- [x] [vhs](https://github.com/charmbracelet/tree-sitter-vhs) (maintained by @caarlos0, @maaslalani) +- [x] [vala](https://github.com/matbme/tree-sitter-vala) (maintained by @matbme) +- [x] [verilog](https://github.com/tree-sitter/tree-sitter-verilog) (experimental, maintained by @zegervdv) - [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] [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) -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 @@ -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 --- Highlight the @foo.bar capture group with the "Identifier" highlight group -vim.api.nvim_set_hl(0, "@foo.bar", { link = "Identifier" }) +```vim +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' - } -} diff --git a/bundle/nvim-treesitter/doc/nvim-treesitter.txt b/bundle/nvim-treesitter/doc/nvim-treesitter.txt index 4feabb739..edb8579e8 100644 --- a/bundle/nvim-treesitter/doc/nvim-treesitter.txt +++ b/bundle/nvim-treesitter/doc/nvim-treesitter.txt @@ -39,21 +39,12 @@ To enable supported features, put this in your `init.lua` file: > 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" ensure_installed = { "c", "lua", "rust" }, -- Install parsers synchronously (only applied to `ensure_installed`) sync_install = false, - -- Automatically install missing parsers when entering buffer - auto_install = false, - -- List of parsers to ignore installing (for "all") ignore_install = { "javascript" }, @@ -71,7 +62,6 @@ To enable supported features, put this in your `init.lua` file: 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. @@ -351,6 +341,11 @@ get_node_at_cursor(winnr)~ `winnr` will be 0 if nil. 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* 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. 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* diff --git a/bundle/nvim-treesitter/lockfile.json b/bundle/nvim-treesitter/lockfile.json index fff6e13b4..cc26503f2 100644 --- a/bundle/nvim-treesitter/lockfile.json +++ b/bundle/nvim-treesitter/lockfile.json @@ -1,33 +1,27 @@ { - "agda": { - "revision": "80ea622cf952a0059e168e5c92a798b2f1925652" - }, "astro": { - "revision": "947e93089e60c66e681eba22283f4037841451e7" + "revision": "6602ccbf9a5f79845dad62f1e118e07f97e3533c" }, "bash": { - "revision": "77cf8a7cab8904baf1a721762e012644ac1d4c7b" + "revision": "275effdfc0edce774acf7d481f9ea195c6c403cd" }, "beancount": { - "revision": "4cbd1f09cd07c1f1fabf867c2cf354f9da53cc4c" + "revision": "78b8ddca3ab774573a4e3bf64eabd79e9452cea9" }, "bibtex": { "revision": "ccfd77db0ed799b6c22c214fe9d2937f47bc8b34" }, - "blueprint": { - "revision": "6ef91ca8270f0112b9c6d27ecb9966c741a5d103" - }, "c": { - "revision": "7175a6dd5fc1cee660dce6fe23f6043d75af424a" + "revision": "e348e8ec5efd3aac020020e4af53d2ff18f393a9" }, "c_sharp": { - "revision": "3ef3f7f99e16e528e6689eae44dff35150993307" + "revision": "5b6ae1f88e741b9ed738891ad1362fb9f2041671" }, "clojure": { - "revision": "087bac78c53fe1387756cd5b8e68a69b3f6d7244" + "revision": "879f0e726295807d917d576fcf9e1e432c4c20fc" }, "cmake": { - "revision": "6e51463ef3052dd3b328322c22172eda093727ad" + "revision": "5020572408a386d5d2dfac3516584f5edda7a49b" }, "comment": { "revision": "a37ca370310ac6f89b6e0ebf2b86b2219780494e" @@ -39,55 +33,49 @@ "revision": "5e113412aadb78955c27010daa4dbe1d202013cf" }, "cpp": { - "revision": "5ead1e26c6ab71919db0f1880c46a278a93bc5ea" + "revision": "a832195eb3685a279856bb480ce19cff19554b6d" }, "css": { - "revision": "769203d0f9abe1a9a691ac2b9fe4bb4397a73c51" + "revision": "a03f1d2d1dfbf6f8e0fdca5f9ff030228241eb57" }, "cuda": { - "revision": "7f1a79e612160aa02be87f1a24469ae3655fe818" + "revision": "5178a7a5b25dc7ee4a69bf72f31bd6d3ff0a0795" }, "d": { "revision": "c2fbf21bd3aa45495fe13247e040ad5815250032" }, "dart": { - "revision": "53485a8f301254e19c518aa20c80f1bcf7cf5c62" + "revision": "6a25376685d1d47968c2cef06d4db8d84a70025e" }, "devicetree": { - "revision": "ea30a05d0f0446a96d8b096ad11828ad4f8ad849" - }, - "diff": { - "revision": "330eb648bbc257b4e91621e82a85372be7dde27a" + "revision": "877adbfa0174d25894c40fa75ad52d4515a36368" }, "dockerfile": { - "revision": "f913be9bb8689af22114605012693146fbe9ddaa" + "revision": "25c71d6a24cdba8f0c74ef40d4d2d93defd7e196" }, "dot": { - "revision": "9ab85550c896d8b294d9b9ca1e30698736f08cea" + "revision": "917230743aa10f45a408fea2ddb54bbbf5fbe7b7" }, "eex": { "revision": "f742f2fe327463335e8671a87c0b9b396905d1d1" }, "elixir": { - "revision": "b20eaa75565243c50be5e35e253d8beb58f45d56" + "revision": "1dabc1c790e07115175057863808085ea60dd08a" }, "elm": { - "revision": "28bb193640d916dfaf947912c1413cebb0484841" + "revision": "9835f900e4df40277f0701d1bc0b6cee0853f81b" }, "elvish": { - "revision": "f32711e31e987fd5c2c002f3daba02f25c68672f" - }, - "embedded_template": { - "revision": "91fc5ae1140d5c9d922312431f7d251a48d7b8ce" + "revision": "e50787cadd3bc54f6d9c0704493a79078bb8a4e5" }, "erlang": { - "revision": "3a9c769444f08bbccce03845270efac0c641c5e7" + "revision": "fab680273af1a8f5cc0c3a0c62cbf5b1bea71f39" }, "fennel": { - "revision": "517195970428aacca60891b050aa53eabf4ba78d" + "revision": "d37fd84a702b78ff0282f223ece83c61ab062a6e" }, "fish": { - "revision": "84436cf24c2b3176bfbb220922a0fdbd0141e406" + "revision": "d482d70ea8e191c05b2c1b613ed6fdff30a14da0" }, "foam": { "revision": "fdb7f14b885abfc4df57728c9b2a2f2ad24d3cb7" @@ -101,80 +89,68 @@ "gdscript": { "revision": "2a6abdaa47fcb91397e09a97c7433fd995ea46c6" }, - "git_rebase": { - "revision": "127f5b56c1ad3e8a449a7d6e0c7412ead7f7724c" - }, - "gitattributes": { - "revision": "cee9f8865694b29bb9e85e0b90805f92ad3fc47e" - }, - "gitignore": { - "revision": "f4685bf11ac466dd278449bcfe5fd014e94aa504" - }, "gleam": { "revision": "cfcbca3f8f734773878e00d7bfcedea98eb10be2" }, "glimmer": { - "revision": "abcc9970da0ed0645741bf52ea70232374bc9e52" + "revision": "5caf63ac0e3c549b90c9aeb042871206b4b7bc16" }, "glsl": { - "revision": "a743ada24fa17da9acc5665133f07d56e03530be" + "revision": "ffb93961426926554a0ba4a389ea6e9d6fafdea9" }, "go": { - "revision": "05900faa3cdb5d2d8c8bd5e77ee698487e0a8611" + "revision": "c8fed1f0847a65a04a4b8cb7655f5f416e0742ca" }, "godot_resource": { "revision": "b6ef0768711086a86b3297056f9ffb5cc1d77b4a" }, "gomod": { - "revision": "4a65743dbc2bb3094114dd2b43da03c820aa5234" + "revision": "e8f51f8e4363a3d9a427e8f63f4c1bbc5ef5d8d0" }, "gowork": { - "revision": "949a8a470559543857a62102c84700d291fc984c" + "revision": "6dd9dd79fb51e9f2abc829d5e97b15015b6a8ae2" }, "graphql": { "revision": "5e66e961eee421786bdda8495ed1db045e06b5fe" }, "hack": { - "revision": "b7bd6928532ada34dddb1dece4a158ab62c6e783" + "revision": "d434b4e6c9af0524b163d7a912c8ce79d2b1f778" }, "haskell": { - "revision": "bee6b49543e34c2967c6294a4b05e8bd2bf2da59" + "revision": "ed976b81b00ce7b72b99bca75e7a616cc526220c" }, "hcl": { - "revision": "45ce22c16ec924e34517cf785e23c07952e45893" + "revision": "d559c46ba170808b23a73da0cf49f315d221d095" }, "heex": { - "revision": "52b804b1cb2d57e58d90090326d3ef9bd19cf16c" + "revision": "592e22292a367312c35e13de7fdb888f029981d6" }, "help": { - "revision": "49cdef52ded4a886bf34bc474876b09f9270d48f" + "revision": "41ac50500e68fadc139737bbee2a0618628b822b" }, "hjson": { "revision": "02fa3b79b3ff9a296066da6277adfc3f26cbc9e0" }, - "hlsl": { - "revision": "384b26ec65e10f26cf147bfcde772c50ca5ef0d0" - }, "hocon": { - "revision": "c390f10519ae69fdb03b3e5764f5592fb6924bcc" + "revision": "bb412e2633f4a3611a4e16efe58d917093bb4782" }, "html": { - "revision": "29f53d8f4f2335e61bf6418ab8958dac3282077a" + "revision": "161a92474a7bb2e9e830e48e76426f38299d99d1" }, "http": { - "revision": "30a9c1789d64429a830802cde5b1760ff1064312" + "revision": "bfddd16b1cf78e0042fd1f6846a179f76a254e20" }, "java": { - "revision": "09d650def6cdf7f479f4b78f595e9ef5b58ce31e" + "revision": "881b84fe7078651af5077cc4cea4c85f9fddde3b" }, "javascript": { - "revision": "936d976a782e75395d9b1c8c7c7bf4ba6fe0d86b" + "revision": "fdeb68ac8d2bd5a78b943528bb68ceda3aade2eb" }, "jsdoc": { "revision": "189a6a4829beb9cdbe837260653b4a3dfb0cc3db" }, "json": { - "revision": "73076754005a460947cafe8e03a8cf5fa4fa2938" + "revision": "203e239408d642be83edde8988d6e7b20a19f0e8" }, "json5": { "revision": "5dd5cdc418d9659682556b6adca2dd9ace0ac6d2" @@ -182,146 +158,113 @@ "jsonc": { "revision": "02b01653c8a1c198ae7287d566efa86a135b30d5" }, - "jsonnet": { - "revision": "0475a5017ad7dc84845d1d33187f2321abcb261d" - }, "julia": { - "revision": "58d0701550b4cce02acf433eedada03b634cc524" + "revision": "12ea597262125fc22fd2e91aa953ac69b19c26ca" }, "kotlin": { - "revision": "b953dbdd05257fcb2b64bc4d9c1578fac12e3c28" + "revision": "a4f71eb9b8c9b19ded3e0e9470be4b1b77c2b569" }, "lalrpop": { "revision": "7744b56f03ac1e5643fad23c9dd90837fe97291e" }, "latex": { - "revision": "8c75e93cd08ccb7ce1ccab22c1fbd6360e3bcea6" + "revision": "ab9c1c59de5da1a8d8c629c81d856a6378b6f116" }, "ledger": { - "revision": "47b8971448ce5e9abac865f450c1b14fb3b6eee9" + "revision": "1050a25df55a62878102d10e524b5184b316b7ad" }, "llvm": { "revision": "e9948edc41e9e5869af99dddb2b5ff5cc5581af6" }, "lua": { - "revision": "fb30e8cb605e2ebd6c643e6981325a63fbbde320" - }, - "m68k": { - "revision": "d097b123f19c6eaba2bf181c05420d88b9fc489d" + "revision": "2b4ffd5a5ffd0c6b4c84f0d9e003050a70db2a37" }, "make": { "revision": "a4b9187417d6be349ee5fd4b6e77b4172c6827dd" }, "markdown": { - "revision": "272e080bca0efd19a06a7f4252d746417224959e" - }, - "markdown_inline": { - "revision": "272e080bca0efd19a06a7f4252d746417224959e" - }, - "menhir": { - "revision": "db7953acb0d5551f207373c81fa07a57d7b085cb" - }, - "meson": { - "revision": "153d22588fb5c1eee16a165a084f9ea30f29d941" - }, - "nickel": { - "revision": "9d83db400b6c11260b9106f131f93ddda8131933" + "revision": "d24196f9b3e5af6fcb2ec2a0b6cbc5c06f58b85e" }, "ninja": { "revision": "0a95cfdc0745b6ae82f60d3a339b37f19b7b9267" }, "nix": { - "revision": "6b71a810c0acd49b980c50fc79092561f7cee307" + "revision": "6d6aaa50793b8265b6a8b6628577a0083d3b923d" }, "norg": { - "revision": "dfac5ad2740a79b18ae849590a924e7bad3f1b23" + "revision": "17d61df817c1e0a9cdef8d915d4e4c556b7cf68c" }, "ocaml": { - "revision": "cc26b1ef111100f26a137bcbcd39fd4e35be9a59" + "revision": "23d419ba45789c5a47d31448061557716b02750a" }, "ocaml_interface": { - "revision": "cc26b1ef111100f26a137bcbcd39fd4e35be9a59" + "revision": "23d419ba45789c5a47d31448061557716b02750a" }, "ocamllex": { "revision": "ac1d5957e719d49bd6acd27439b79843e4daf8ed" }, - "org": { - "revision": "081179c52b3e8175af62b9b91dc099d010c38770" - }, "pascal": { "revision": "2fd40f477d3e2794af152618ccfac8d92eb72a66" }, "perl": { - "revision": "749d26fe13fb131b92e6515416096e572575b981" + "revision": "bbf86084d9b7eb4768f3fb9fe094b3e0600057b1" }, "php": { - "revision": "ab2e72179ceb8bb0b249c8ac9162a148e911b3dc" + "revision": "3c17a28da38afac41332d3ce79bbd8951867f346" }, "phpdoc": { - "revision": "2f4d16c861b5a454b577d057f247f9902d7b47f5" + "revision": "d9150d4cb5941f6ff10adba89bfa1f11f4b05b37" }, "pioasm": { "revision": "924aadaf5dea2a6074d72027b064f939acf32e20" }, "prisma": { - "revision": "17a59236ac25413b81b1613ea6ba5d8d52d7cd6c" - }, - "proto": { - "revision": "42d82fa18f8afe59b5fc0b16c207ee4f84cb185f" + "revision": "bf0833cbedb2c5b39250f5ba900f1239a16c6749" }, "pug": { - "revision": "63e214905970e75f065688b1e8aa90823c3aacdc" + "revision": "5875f9a7d94836708119b0a1102bb5792e8bf673" }, "python": { - "revision": "b14614e2144b8f9ee54deed5a24f3c6f51f9ffa8" + "revision": "78c4e9b6b2f08e1be23b541ffced47b15e2972ad" }, "ql": { - "revision": "bd087020f0d8c183080ca615d38de0ec827aeeaf" - }, - "qmljs": { - "revision": "0b2b25bcaa7d4925d5f0dda16f6a99c588a437f1" + "revision": "8e7fd7e638d4a0ec7a792ee16b19dbc6407aa810" }, "query": { - "revision": "0695cd0760532de7b54f23c667d459b5d1332b44" + "revision": "5217c6805c09f8fc00ed13d17d5fcb791437aee6" }, "r": { - "revision": "80efda55672d1293aa738f956c7ae384ecdc31b4" - }, - "racket": { - "revision": "09cb27a06415bce529a26774a842f5a80d50d362" + "revision": "cc04302e1bff76fa02e129f332f44636813b0c3c" }, "rasi": { - "revision": "12391343979463a2484e6353e5afb6dcb8c31e8b" + "revision": "e2961f02244c068a67549adf896b0779e4a29516" }, "regex": { "revision": "e1cfca3c79896ff79842f057ea13e529b66af636" }, "rego": { - "revision": "6d70da3a998fd0081efc5d1019c71e74cc1568e9" - }, - "rnoweb": { - "revision": "502c1126dc6777f09af5bef16e72a42f75bd081e" + "revision": "858ca3013da4d50ea1bdb32162a2bfb43641b422" }, "rst": { - "revision": "25e6328872ac3a764ba8b926aea12719741103f1" + "revision": "b74770c0166f28c1a0ab293513a78712ca1c338b" }, "ruby": { - "revision": "c91960320d0f337bdd48308a8ad5500bd2616979" + "revision": "0b107de5415e7470a30ef1a390d9db3306432bdb" }, "rust": { - "revision": "0431a2c60828731f27491ee9fdefe25e250ce9c9" + "revision": "0509e440ae042db6483984b3a56b3c5f24b5d9b9" }, "scala": { - "revision": "140c96cf398693189d4e50f76d19ddfcd8a018f8" + "revision": "ec6047f531e7d4c13787d4ff208b94a84de34165" }, "scheme": { - "revision": "bdcd2c8496701153506a9e3e1b76dfed852873ba" + "revision": "a1d2233f4e5498bb305858323c93525e1dd165c0" }, "scss": { "revision": "c478c6868648eff49eb04a4df90d703dc45b312a" }, "slint": { - "revision": "d422300f5d6ccce8f9a617dfed57aafb636fadb2" + "revision": "0d4dda94f96623302dfc234e06be62a5717f47da" }, "solidity": { "revision": "52ed0880c0126df2f2c7693f215fe6f38e4a2e0a" @@ -329,32 +272,23 @@ "sparql": { "revision": "05f949d3c1c15e3261473a244d3ce87777374dec" }, - "sql": { - "revision": "70c50264ae022193adb364ffa7a767d765ed9857" - }, "supercollider": { - "revision": "90c6d9f777d2b8c4ce497c48b5f270a44bcf3ea0" + "revision": "0f0e5b5a96dd3e048a9c3db648ed969c44068bff" }, "surface": { "revision": "f4586b35ac8548667a9aaa4eae44456c1f43d032" }, "svelte": { - "revision": "52e122ae68b316d3aa960a0a422d3645ba717f42" + "revision": "84c90ee15f851e1541c25c86e8a4338f5b4d5af2" }, "swift": { - "revision": "25f8de356e3c33099ed691bd3b8b5c0fe3a11e15" - }, - "sxhkdrc": { - "revision": "440d5f913d9465c9c776a1bd92334d32febcf065" + "revision": "897df54ad1b2d103dcab3df94f335fceefa230dc" }, "teal": { - "revision": "1ae8c68e90523b26b93af56feb7868fe4214e2b2" - }, - "tiger": { - "revision": "eb1d3714998977ae76ca7c6a102b10ee37efc2b5" + "revision": "fcc5f6f4d194dede4e676834ff28a506e39e17b4" }, "tlaplus": { - "revision": "deaf0e5c573ad4e2bbfc9a29abb7b6dcb572556e" + "revision": "dde405e5128c3c47ab8aa014d21b6e5296ca450f" }, "todotxt": { "revision": "0207f6a4ab6aeafc4b091914d31d8235049a2578" @@ -363,37 +297,28 @@ "revision": "8bd2056818b21860e3d756b5a58c4f6e05fb744e" }, "tsx": { - "revision": "0ab9d99867435a7667c5548a6617a6bf73dbd830" + "revision": "8e9dba7bd7cf089838a036a98be94db53ba2d0a9" }, "turtle": { "revision": "085437f5cb117703b7f520dd92161140a684f092" }, - "twig": { - "revision": "035f549ec8c043e734f04341d7ccdc669bb2ba91" - }, "typescript": { - "revision": "0ab9d99867435a7667c5548a6617a6bf73dbd830" - }, - "v": { - "revision": "66b92a89ef1e149300df79c0b2a934ad959c8eec" + "revision": "8e9dba7bd7cf089838a036a98be94db53ba2d0a9" }, "vala": { - "revision": "8f690bfa639f2b83d1fb938ed3dd98a7ba453e8b" + "revision": "31a08784cc74b61cb10c5d8314cf8a8aa98aa9a8" }, "verilog": { - "revision": "4457145e795b363f072463e697dfe2f6973c9a52" - }, - "vhs": { - "revision": "2f87b9d973597e69552ecf6a4fe16470fbd8c44e" + "revision": "8f6b1f357d1231c420404b5f7a368a73c25adfa2" }, "vim": { - "revision": "4ae7bd67706d7e10afed827ce2ded884ab41650f" + "revision": "68f7cacfd9ae4698181511c9fdd6641bc25a260b" }, "vue": { "revision": "91fe2754796cd8fba5f229505a23fa08f3546c06" }, "wgsl": { - "revision": "af16e7d9e230004888fb52d33599ad38b4cf6052" + "revision": "5ca98b174f7dddf69fb7a80c54d49badd1f1f8c4" }, "yaml": { "revision": "0e36bed171768908f331ff7dff9d956bae016efb" @@ -402,6 +327,6 @@ "revision": "8e9d175982afcefa3dac8ca20d40d1643accd2bd" }, "zig": { - "revision": "d90d38d28ce8cc27bfea8b4e0c75211e9e2398ca" + "revision": "4cff36421dae9c05388b86cd64d2bab4b9ed6676" } } diff --git a/bundle/nvim-treesitter/lua/nvim-treesitter.lua b/bundle/nvim-treesitter/lua/nvim-treesitter.lua index 963fe7309..af46bd017 100644 --- a/bundle/nvim-treesitter/lua/nvim-treesitter.lua +++ b/bundle/nvim-treesitter/lua/nvim-treesitter.lua @@ -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 utils = require "nvim-treesitter.utils" +local ts_utils = require "nvim-treesitter.ts_utils" local info = require "nvim-treesitter.info" local configs = require "nvim-treesitter.configs" -local statusline = require "nvim-treesitter.statusline" +local parsers = require "nvim-treesitter.parsers" -- Registers all query predicates require "nvim-treesitter.query_predicates" @@ -16,7 +21,68 @@ function M.setup() configs.init() end -M.define_modules = configs.define_modules -M.statusline = statusline.statusline +function M.define_modules(...) + 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 diff --git a/bundle/nvim-treesitter/lua/nvim-treesitter/configs.lua b/bundle/nvim-treesitter/lua/nvim-treesitter/configs.lua index 6db2935a0..d4aa98e89 100644 --- a/bundle/nvim-treesitter/lua/nvim-treesitter/configs.lua +++ b/bundle/nvim-treesitter/lua/nvim-treesitter/configs.lua @@ -8,40 +8,17 @@ local caching = require "nvim-treesitter.caching" 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 = { modules = {}, sync_install = false, ensure_installed = {}, - auto_install = false, ignore_install = {}, update_strategy = "lockfile", - parser_install_dir = nil, } -- List of modules that need to be setup on initialization. local queued_modules_defs = {} -- Whether we've initialized the plugin yet. 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 - ----@type {[string]: TSModule} local builtin_modules = { highlight = { module_path = "nvim-treesitter.highlight", @@ -75,9 +52,7 @@ local builtin_modules = { local attached_buffers_by_module = caching.create_buffer_cache() ----Resolves a module by requiring the `module_path` or using the module definition. ----@param mod_name string ----@return TSModule|nil +-- Resolves a module by requiring the `module_path` or using the module definition. local function resolve_module(mod_name) local config_mod = M.get_module(mod_name) @@ -92,10 +67,10 @@ local function resolve_module(mod_name) end end ----Enables and attaches the module to a buffer for lang. ----@param mod string path to module ----@param bufnr integer|nil buffer number, defaults to current buffer ----@param lang string|nil language, defaults to current language +-- Enables and attaches the module to a buffer for lang. +-- @param mod path to module +-- @param bufnr buffer number, defaults to current buffer +-- @param lang language, defaults to current language local function enable_module(mod, bufnr, lang) local module = M.get_module(mod) if not module then @@ -116,29 +91,24 @@ local function enable_module(mod, bufnr, lang) M.attach_module(mod, bufnr, lang) end ----Enables autocomands for the module. ----After the module is loaded `loaded` will be set to true for the module. ----@param mod string path to module +-- Enables autocomands for the module. +-- After the module is loaded `loaded` will be set to true for the module. +-- @param mod path to module local function enable_mod_conf_autocmd(mod) local config_mod = M.get_module(mod) if not config_mod or config_mod.loaded then return end - api.nvim_create_autocmd("FileType", { - group = api.nvim_create_augroup("NvimTreesitter-" .. mod, {}), - callback = function() - require("nvim-treesitter.configs").reattach_module(mod) - end, - desc = "Reattach module", - }) + local cmd = string.format("lua require'nvim-treesitter.configs'.reattach_module('%s')", mod) + api.nvim_command(string.format("autocmd NvimTreesitter FileType * %s", cmd)) config_mod.loaded = true end ----Enables the module globally and for all current buffers. ----After enabled, `enable` will be set to true for the module. ----@param mod string path to module +-- Enables the module globally and for all current buffers. +-- After enabled, `enable` will be set to true for the module. +-- @param mod path to module local function enable_all(mod) local config_mod = M.get_module(mod) if not config_mod then @@ -154,9 +124,9 @@ local function enable_all(mod) end end ----Disables and detaches the module for a buffer. ----@param mod string path to module ----@param bufnr integer buffer number, defaults to current buffer +-- Disables and detaches the module for a buffer. +-- @param mod path to module +-- @param bufnr buffer number, defaults to current buffer local function disable_module(mod, bufnr) local module = M.get_module(mod) if not module then @@ -170,21 +140,23 @@ local function disable_module(mod, bufnr) M.detach_module(mod, bufnr) end ----Disables autocomands for the module. ----After the module is unloaded `loaded` will be set to false for the module. ----@param mod string path to module +-- Disables autocomands for the module. +-- After the module is unloaded `loaded` will be set to false for the module. +-- @param mod path to module local function disable_mod_conf_autocmd(mod) local config_mod = M.get_module(mod) if not config_mod or not config_mod.loaded then return 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 end ----Disables the module globally and for all current buffers. ----After disabled, `enable` will be set to false for the module. ----@param mod string path to module +-- Disables the module globally and for all current buffers. +-- After disabled, `enable` will be set to false for the module. +-- @param mod path to module local function disable_all(mod) local config_mod = M.get_module(mod) if not config_mod then @@ -200,10 +172,10 @@ local function disable_all(mod) end end ----Toggles a module for a buffer ----@param mod string path to module ----@param bufnr integer buffer number, defaults to current buffer ----@param lang string language, defaults to current language +-- Toggles a module for a buffer +-- @param mod path to module +-- @param bufnr buffer number, defaults to current buffer +-- @param lang language, defaults to current language local function toggle_module(mod, bufnr, lang) bufnr = bufnr or api.nvim_get_current_buf() lang = lang or parsers.get_buf_lang(bufnr) @@ -230,10 +202,10 @@ local function toggle_all(mod) end end ----Recurses through all modules including submodules ----@param accumulator function called for each module ----@param root {[string]: TSModule} root configuration table to start at ----@param path string|nil prefix path +-- Recurses through all modules including submodules +-- @param accumulator function called for each module +-- @param root root configuration table to start at +-- @param path prefix path local function recurse_modules(accumulator, root, path) root = root or config.modules @@ -248,9 +220,9 @@ local function recurse_modules(accumulator, root, path) end end ----Shows current configuration of all nvim-treesitter modules ----@param process_function function used as the `process` parameter ---- for vim.inspect (https://github.com/kikito/inspect.lua#optionsprocess) +-- Shows current configuration of all nvim-treesitter modules +-- @param process_function function used as the `process` parameter +-- for vim.inspect (https://github.com/kikito/inspect.lua#optionsprocess) local function config_info(process_function) process_function = process_function or function(item, path) @@ -265,8 +237,29 @@ local function config_info(process_function) print(vim.inspect(config, { process = process_function })) end ----@param query_group string ----@param lang string +if not vim.ui then + 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) lang = lang or parsers.get_buf_lang() 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 ----@param query_group string ----@param lang string function M.edit_query_file_user_after(query_group, lang) lang = lang or parsers.get_buf_lang() local folder = utils.join_path(vim.fn.stdpath "config", "after", "queries", lang) @@ -367,11 +358,11 @@ M.commands = { }, } ----@param mod string module ----@param lang string the language of the buffer ----@param bufnr integer the bufnr +-- @param mod: module (string) +-- @param lang: the language of the buffer (string) +-- @param bufnr: the bufnr (number) 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 end @@ -403,20 +394,11 @@ function M.is_enabled(mod, lang, bufnr) return true end ----Setup call for users to override module configurations. ----@param user_data TSConfig module overrides +-- Setup call for users to override module configurations. +-- @param user_data module overrides function M.setup(user_data) config.modules = vim.tbl_deep_extend("force", config.modules, user_data) 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 {} if #ensure_installed > 0 then @@ -428,7 +410,6 @@ function M.setup(user_data) end config.modules.ensure_installed = nil - config.ensure_installed = ensure_installed recurse_modules(function(_, _, 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 ----Defines a table of modules that can be attached/detached to buffers ----based on language support. A module consist of the following properties: ----* @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. ----* @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. ----* @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` ---- 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 ---- 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 ---- 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 ----and can be loaded lazily. ----@example ----require"nvim-treesitter".define_modules { ---- my_cool_module = { ---- attach = function() ---- do_some_cool_setup() ---- end, ---- detach = function() ---- do_some_cool_teardown() ---- end ---- } ----} ----@param mod_defs TSModule[] +-- Defines a table of modules that can be attached/detached to buffers +-- based on language support. A module consist of the following properties: +-- * @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. +-- * @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. +-- * @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` +-- 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 +-- 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 +-- 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 +-- and can be loaded lazily. +-- @example +-- require"nvim-treesitter".define_modules { +-- my_cool_module = { +-- attach = function() +-- do_some_cool_setup() +-- end, +-- detach = function() +-- do_some_cool_teardown() +-- end +-- } +-- } function M.define_modules(mod_defs) if not is_initialized then table.insert(queued_modules_defs, mod_defs) @@ -491,10 +471,10 @@ function M.define_modules(mod_defs) end end ----Attaches a module to a buffer ----@param mod_name string the module name ----@param bufnr integer the bufnr ----@param lang string the language of the buffer +-- Attaches a module to a buffer +-- @param mod_name the module name +-- @param bufnr the bufnr +-- @param lang the language of the buffer function M.attach_module(mod_name, bufnr, lang) bufnr = bufnr or api.nvim_get_current_buf() lang = lang or parsers.get_buf_lang(bufnr) @@ -506,9 +486,9 @@ function M.attach_module(mod_name, bufnr, lang) end end ----Detaches a module to a buffer ----@param mod_name string the module name ----@param bufnr integer the bufnr +-- Detaches a module to a buffer +-- @param mod_name the module name +-- @param bufnr the bufnr function M.detach_module(mod_name, bufnr) local resolved_mod = resolve_module(mod_name) bufnr = bufnr or api.nvim_get_current_buf() @@ -519,17 +499,17 @@ function M.detach_module(mod_name, bufnr) end end ----Same as attach_module, but if the module is already attached, detach it first. ----@param mod_name string the module name ----@param bufnr integer the bufnr ----@param lang string the language of the buffer +-- Same as attach_module, but if the module is already attached, detach it first. +-- @param mod_name the module name +-- @param bufnr the bufnr +-- @param lang the language of the buffer function M.reattach_module(mod_name, bufnr, lang) M.detach_module(mod_name, bufnr) M.attach_module(mod_name, bufnr, lang) end ----Gets available modules ----@param root {[string]:TSModule} table to find modules +-- Gets available modules +-- @param root root table to find modules function M.available_modules(root) local modules = {} @@ -540,26 +520,25 @@ function M.available_modules(root) return modules end ----Gets a module config by path ----@param mod_path string path to the module ----@return TSModule|nil the module or nil +-- Gets a module config by path +-- @param mod_path path to the module +-- @returns the module or nil function M.get_module(mod_path) local mod = utils.get_at_path(config.modules, mod_path) return M.is_module(mod) and mod or nil end ----Determines whether the provided table is a module. ----A module should contain an attach and detach function. ----@param mod table the module table ----@return boolean +-- Determines whether the provided table is a module. +-- A module should contain an attach and detach function. +-- @param mod the module table function M.is_module(mod) return type(mod) == "table" and ((type(mod.attach) == "function" and type(mod.detach) == "function") or type(mod.module_path) == "string") end ----Initializes built-in modules and any queued modules ----registered by plugins or the user. +-- Initializes built-in modules and any queued modules +-- registered by plugins or the user. function M.init() is_initialized = true M.define_modules(builtin_modules) @@ -569,39 +548,6 @@ function M.init() 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() return config.update_strategy end @@ -610,8 +556,4 @@ function M.get_ignored_parser_installs() return config.ignore_install or {} end -function M.get_ensure_installed_parsers() - return config.ensure_installed or {} -end - return M diff --git a/bundle/nvim-treesitter/lua/nvim-treesitter/fold.lua b/bundle/nvim-treesitter/lua/nvim-treesitter/fold.lua index 50272622f..01a7c08e9 100644 --- a/bundle/nvim-treesitter/lua/nvim-treesitter/fold.lua +++ b/bundle/nvim-treesitter/lua/nvim-treesitter/fold.lua @@ -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") - for _, match in ipairs(matches) do - local start, stop, stop_col - 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 + for _, node in ipairs(matches) do + local start, _, stop, stop_col = node.node:range() if stop_col == 0 then stop = stop - 1 @@ -102,8 +97,6 @@ local folds_levels = tsutils.memoize_by_buf_tick(function(bufnr) return levels end) ----@param lnum integer ----@return string function M.get_fold_indic(lnum) if not parsers.has_parser() or not lnum then return "0" diff --git a/bundle/nvim-treesitter/lua/nvim-treesitter/health.lua b/bundle/nvim-treesitter/lua/nvim-treesitter/health.lua index e308889c4..8cbe0db1c 100644 --- a/bundle/nvim-treesitter/lua/nvim-treesitter/health.lua +++ b/bundle/nvim-treesitter/lua/nvim-treesitter/health.lua @@ -7,26 +7,25 @@ local shell = require "nvim-treesitter.shell_command_selectors" local install = require "nvim-treesitter.install" 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 NVIM_TREESITTER_MINIMUM_ABI = 13 local function install_health() - health.report_start "Installation" - - if fn.has "nvim-0.7" == 0 then - health.report_error "Nvim-treesitter requires Neovim 0.7.0+" - end + health_start "Installation" if fn.executable "tree-sitter" == 0 then - health.report_warn( + health_warn( "`tree-sitter` executable not found (parser generator, only needed for :TSInstallFromGrammar," .. " not required for :TSInstall)" ) else - health.report_ok( + health_ok( "`tree-sitter` found " .. (utils.ts_cli_version() or "(unknown version)") .. " (parser generator, only needed for :TSInstallFromGrammar)" @@ -34,7 +33,7 @@ local function install_health() end if fn.executable "node" == 0 then - health.report_warn( + health_warn( "`node` executable not found (only needed for :TSInstallFromGrammar," .. " not required for :TSInstall)" ) else @@ -42,21 +41,21 @@ local function install_health() local result = handle:read "*a" handle:close() 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 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.", "Check that your `$PATH` is set correctly.", }) else - health.report_ok "`git` executable found." + health_ok "`git` executable found." end local cc = shell.select_executable(install.compilers) if not cc then - health.report_error("`cc` executable not found.", { + health_error("`cc` executable not found.", { "Check that any of " .. vim.inspect(install.compilers) .. " is in your $PATH" @@ -64,7 +63,7 @@ local function install_health() }) else local version = vim.fn.systemlist(cc .. (cc == "cl" and "" or " --version"))[1] - health.report_ok( + health_ok( "`" .. cc .. "` executable found. Selected from " @@ -74,7 +73,7 @@ local function install_health() end if vim.treesitter.language_version 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 " .. vim.treesitter.language_version .. " (required >=" @@ -82,7 +81,7 @@ local function install_health() .. "). Parsers must be compatible with runtime ABI." ) else - health.report_error( + health_error( "Neovim was compiled with tree-sitter runtime ABI version " .. vim.treesitter.language_version .. ".\n" @@ -128,7 +127,7 @@ function M.check() table.insert(error_collection, { parser_name, query_group, err }) end end - table.insert(parser_installation, vim.fn.trim(out, " ", 2)) + table.insert(parser_installation, out) end end local legend = [[ @@ -138,9 +137,9 @@ function M.check() x) errors found in the query, try to run :TSUpdate {lang}]] table.insert(parser_installation, legend) -- 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 - health.report_start "The following errors have been detected:" + health_start "The following errors have been detected:" for _, p in ipairs(error_collection) do local lang, type, err = unpack(p) local lines = {} @@ -161,7 +160,7 @@ function M.check() end end end - health.report_error(table.concat(lines, "\n")) + health_error(table.concat(lines, "\n")) end end end diff --git a/bundle/nvim-treesitter/lua/nvim-treesitter/highlight.lua b/bundle/nvim-treesitter/lua/nvim-treesitter/highlight.lua index 5f7dead61..caca7ee00 100644 --- a/bundle/nvim-treesitter/lua/nvim-treesitter/highlight.lua +++ b/bundle/nvim-treesitter/lua/nvim-treesitter/highlight.lua @@ -6,9 +6,115 @@ local configs = require "nvim-treesitter.configs" local M = {} ----@param config table ----@param lang string ----@return boolean +local hlmap = vim.treesitter.highlighter.hl_map + +-- 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 additional_hl = config.additional_vim_regex_highlighting 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)) end ----@param bufnr integer local function enable_syntax(bufnr) api.nvim_buf_set_option(bufnr, "syntax", "ON") end ----@param bufnr integer function M.stop(bufnr) if ts.highlighter.active[bufnr] then ts.highlighter.active[bufnr]:destroy() end end ----@param bufnr integer ----@param lang string function M.start(bufnr, lang) local parser = parsers.get_parser(bufnr, lang) ts.highlighter.new(parser, {}) end ----@param bufnr integer ----@param lang string function M.attach(bufnr, lang) local config = configs.get_module "highlight" 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) end end ----@param bufnr integer function M.detach(bufnr) M.stop(bufnr) enable_syntax(bufnr) end +function M.set_custom_captures(captures) + for k, v in pairs(captures) do + hlmap[k] = v + end +end + return M diff --git a/bundle/nvim-treesitter/lua/nvim-treesitter/incremental_selection.lua b/bundle/nvim-treesitter/lua/nvim-treesitter/incremental_selection.lua index 5deaaf84e..857f4a482 100644 --- a/bundle/nvim-treesitter/lua/nvim-treesitter/incremental_selection.lua +++ b/bundle/nvim-treesitter/lua/nvim-treesitter/incremental_selection.lua @@ -120,33 +120,17 @@ function M.node_decremental() ts_utils.update_selection(buf, node) 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) local config = configs.get_module "incremental_selection" for funcname, mapping in pairs(config.keymaps) do local mode - local rhs if funcname == "init_selection" then mode = "n" - rhs = M[funcname] else 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()", funcname) end - vim.keymap.set( - mode, - mapping, - rhs, - { buffer = bufnr, silent = true, noremap = true, desc = FUNCTION_DESCRIPTIONS[funcname] } - ) + local cmd = string.format(":lua require'nvim-treesitter.incremental_selection'.%s()", funcname) + api.nvim_buf_set_keymap(bufnr, mode, mapping, cmd, { silent = true, noremap = true }) end end @@ -154,9 +138,9 @@ function M.detach(bufnr) local config = configs.get_module "incremental_selection" for f, mapping in pairs(config.keymaps) do if f == "init_selection" then - vim.keymap.del("n", mapping, { buffer = bufnr }) + api.nvim_buf_del_keymap(bufnr, "n", mapping) else - vim.keymap.del("x", mapping, { buffer = bufnr }) + api.nvim_buf_del_keymap(bufnr, "x", mapping) end end end diff --git a/bundle/nvim-treesitter/lua/nvim-treesitter/indent.lua b/bundle/nvim-treesitter/lua/nvim-treesitter/indent.lua index 0eac0a911..de165904e 100644 --- a/bundle/nvim-treesitter/lua/nvim-treesitter/indent.lua +++ b/bundle/nvim-treesitter/lua/nvim-treesitter/indent.lua @@ -149,19 +149,12 @@ function M.get_indent(lnum) end -- 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 - should_process - and ( - q.indent[node:id()] - and (srow ~= erow or is_in_err) - and (srow ~= lnum - 1 or q.indent[node:id()].start_at_same_line) - ) + not is_processed_by_row[srow] + -- Dear stylua, please don't change the semantics of this statement! + -- stylua: ignore start + and (q.indent[node:id()] and srow ~= erow and ((srow ~= lnum - 1) or q.indent[node:id()].start_at_same_line)) + -- stylua: ignore end then indent = indent + indent_size is_processed = true @@ -202,6 +195,7 @@ local indent_funcs = {} function M.attach(bufnr) indent_funcs[bufnr] = vim.bo.indentexpr vim.bo.indentexpr = "nvim_treesitter#indent()" + vim.api.nvim_command("au Filetype " .. vim.bo.filetype .. " setlocal indentexpr=nvim_treesitter#indent()") end function M.detach(bufnr) diff --git a/bundle/nvim-treesitter/lua/nvim-treesitter/info.lua b/bundle/nvim-treesitter/lua/nvim-treesitter/info.lua index eaeb9751c..ed5a90b8d 100644 --- a/bundle/nvim-treesitter/lua/nvim-treesitter/info.lua +++ b/bundle/nvim-treesitter/lua/nvim-treesitter/info.lua @@ -14,13 +14,11 @@ local function install_info() local parser_list = parsers.available_parsers() table.sort(parser_list) - for _, lang in pairs(parser_list) do - local is_installed = #api.nvim_get_runtime_file("parser/" .. lang .. ".so", false) > 0 - api.nvim_out_write(lang .. string.rep(" ", max_len - #lang + 1)) + for _, ft in pairs(parser_list) do + local is_installed = #api.nvim_get_runtime_file("parser/" .. ft .. ".so", false) > 0 + api.nvim_out_write(ft .. string.rep(" ", max_len - #ft + 1)) if is_installed then 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 api.nvim_out_write "[✗] not installed\n" 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, "buftype", "nofile") - vim.cmd [[ - syntax match TSModuleInfoGood /✓/ - syntax match TSModuleInfoBad /✗/ - syntax match TSModuleInfoHeader /^>>.*$/ contains=TSModuleInfoNamespace - syntax match TSModuleInfoNamespace /^>> \w*/ contained - syntax match TSModuleInfoParser /^[^> ]*\ze / - ]] - - local highlights = { - TSModuleInfoGood = { fg = "LightGreen", bold = true, default = true }, - TSModuleInfoBad = { fg = "Crimson", default = true }, - TSModuleInfoHeader = { link = "Type", default = true }, - TSModuleInfoNamespace = { link = "Statement", default = true }, - TSModuleInfoParser = { link = "Identifier", default = true }, - } - for k, v in pairs(highlights) do - api.nvim_set_hl(0, k, v) - end + api.nvim_exec( + [[ + syntax match TSModuleInfoGood /✓/ + syntax match TSModuleInfoBad /✗/ + syntax match TSModuleInfoHeader /^>>.*$/ contains=TSModuleInfoNamespace + syntax match TSModuleInfoNamespace /^>> \w*/ contained + syntax match TSModuleInfoParser /^[^> ]*\ze / + highlight default TSModuleInfoGood guifg=LightGreen gui=bold + highlight default TSModuleInfoBad guifg=Crimson + highlight default link TSModuleInfoHeader Type + highlight default link TSModuleInfoNamespace Statement + highlight default link TSModuleInfoParser Identifier + ]], + false + ) end local function module_info(module) diff --git a/bundle/nvim-treesitter/lua/nvim-treesitter/install.lua b/bundle/nvim-treesitter/lua/nvim-treesitter/install.lua index 48810b1e2..b65c4b3f0 100644 --- a/bundle/nvim-treesitter/lua/nvim-treesitter/install.lua +++ b/bundle/nvim-treesitter/lua/nvim-treesitter/install.lua @@ -42,14 +42,11 @@ local function get_job_status() .. "]" end ----@param lang string ----@param validate boolean|nil ----@return InstallInfo local function get_parser_install_info(lang, validate) local parser_config = parsers.get_parser_configs()[lang] if not parser_config then - error('Parser not available for language "' .. lang .. '"') + return error("Parser not available for language " .. lang) end local install_info = parser_config.install_info @@ -82,39 +79,30 @@ local function get_revision(lang) return (lockfile[lang] and lockfile[lang].revision) end ----@param lang string ----@return string|nil 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 return vim.fn.readfile(lang_file)[1] end end ----@param lang string ----@return boolean local function is_installed(lang) return #api.nvim_get_runtime_file("parser/" .. lang .. ".so", false) > 0 end ----@param lang string ----@return boolean local function needs_update(lang) local revision = get_revision(lang) return not revision or revision ~= get_installed_revision(lang) end ----@return table local function outdated_parsers() return vim.tbl_filter(function(lang) return needs_update(lang) end, info.installed_parsers()) end ----@param handle userdata ----@param is_stderr boolean local function onread(handle, is_stderr) - return function(_, data) + return function(err, data) if data then if is_stderr then 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 stderr = luv.new_pipe(false) attr.opts.stdio = { nil, stdout, stderr } - ---@type userdata handle = luv.spawn( attr.cmd, attr.opts, @@ -238,12 +225,6 @@ local function iter_cmd_sync(cmd_list) return true 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) parsers.reset_cache() @@ -261,14 +242,10 @@ local function run_install(cache_folder, install_folder, lang, repo, with_sync, if from_local_path then compile_location = repo.url else - local repo_location = project_name - if repo.location then - repo_location = repo_location .. "/" .. repo.location - end - repo_location = repo_location:gsub("/", path_sep) - compile_location = utils.join_path(cache_folder, repo_location) + local repo_location = string.gsub(repo.location or project_name, "/", path_sep) + compile_location = cache_folder .. path_sep .. repo_location 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 @@ -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), { 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, }, { -- auto-attach modules after installation @@ -380,12 +357,6 @@ local function run_install(cache_folder, install_folder, lang, repo, with_sync, 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) if is_installed(lang) and ask_reinstall ~= "force" then if not ask_reinstall then @@ -399,22 +370,11 @@ local function install_lang(lang, ask_reinstall, cache_folder, install_folder, w end end - local ok, install_info = pcall(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 + local install_info = get_parser_install_info(lang, true) run_install(cache_folder, install_folder, lang, install_info, with_sync, generate_from_grammar) end ----@return function local function install(options) options = options or {} local with_sync = options.with_sync @@ -431,20 +391,20 @@ local function install(options) if err then return api.nvim_err_writeln(err) end - assert(cache_folder) - local install_folder - install_folder, err = configs.get_parser_install_dir() + local install_folder, err = utils.get_parser_install_dir() if err then return api.nvim_err_writeln(err) end - assert(install_folder) local languages local ask if ... == "all" then languages = parsers.available_parsers() ask = false + elseif ... == "maintained" then + languages = parsers.maintained_parsers() + ask = false else languages = vim.tbl_flatten { ... } ask = ask_reinstall @@ -464,18 +424,6 @@ local function install(options) 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) options = options or {} return function(...) @@ -514,67 +462,37 @@ function M.update(options) end 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() 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 M.uninstall(langitem) end 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 { ... } 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 return api.nvim_err_writeln(err) end - if vim.tbl_contains(ensure_installed_parsers, lang) then - 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 = install_dir .. path_sep .. lang .. ".so" - local parser_lib = utils.join_path(install_dir, lang) .. ".so" - local all_parsers = vim.api.nvim_get_runtime_file("parser/" .. lang .. ".so", true) - if vim.fn.filereadable(parser_lib) == 1 then - local command_list = { - 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 + local command_list = { + shell.select_rm_file_cmd(parser_lib, "Uninstalling parser for " .. lang), + } + M.iter_cmd(command_list, 1, lang, "Treesitter parser for " .. lang .. " has been uninstalled") end end end diff --git a/bundle/nvim-treesitter/lua/nvim-treesitter/locals.lua b/bundle/nvim-treesitter/lua/nvim-treesitter/locals.lua index dcfba2683..e0da2d02e 100644 --- a/bundle/nvim-treesitter/lua/nvim-treesitter/locals.lua +++ b/bundle/nvim-treesitter/lua/nvim-treesitter/locals.lua @@ -4,7 +4,6 @@ local queries = require "nvim-treesitter.query" local ts_utils = require "nvim-treesitter.ts_utils" -local ts_query = vim.treesitter.query local api = vim.api 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) -- Always use the highest valid scope 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) result[id] = node_entry @@ -211,7 +210,7 @@ end function M.find_definition(node, 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 local id = M.get_definition_id(scope, node_text) @@ -232,7 +231,7 @@ end -- @returns a list of nodes function M.find_usages(node, scope_node, bufnr) 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 return {} @@ -245,7 +244,7 @@ function M.find_usages(node, scope_node, bufnr) if match.reference 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 local def_node, _, kind = M.find_definition(match.reference.node, bufnr) diff --git a/bundle/nvim-treesitter/lua/nvim-treesitter/parsers.lua b/bundle/nvim-treesitter/lua/nvim-treesitter/parsers.lua index 6d444cde1..07332d7c0 100644 --- a/bundle/nvim-treesitter/lua/nvim-treesitter/parsers.lua +++ b/bundle/nvim-treesitter/lua/nvim-treesitter/parsers.lua @@ -17,26 +17,8 @@ local filetype_to_parsername = { OpenFOAM = "foam", pandoc = "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({}, { __newindex = function(table, parsername, parserconfig) rawset( @@ -61,46 +43,6 @@ local list = setmetatable({}, { 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 = { install_info = { url = "https://github.com/6cdh/tree-sitter-scheme", @@ -135,14 +77,6 @@ list.c = { 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 = { install_info = { url = "https://github.com/sogaiu/tree-sitter-clojure", @@ -199,15 +133,6 @@ list.glsl = { 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 = { install_info = { url = "https://github.com/camdencheek/tree-sitter-dockerfile", @@ -387,14 +312,6 @@ list.json = { 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 = { install_info = { url = "https://github.com/tree-sitter/tree-sitter-css", @@ -472,7 +389,7 @@ list.ocaml = { install_info = { url = "https://github.com/tree-sitter/tree-sitter-ocaml", files = { "src/parser.c", "src/scanner.cc" }, - location = "ocaml", + location = "tree-sitter-ocaml/ocaml", }, maintainers = { "@undu" }, } @@ -481,7 +398,7 @@ list.ocaml_interface = { install_info = { url = "https://github.com/tree-sitter/tree-sitter-ocaml", files = { "src/parser.c", "src/scanner.cc" }, - location = "interface", + location = "tree-sitter-ocaml_interface/interface", }, maintainers = { "@undu" }, filetype = "ocamlinterface", @@ -496,31 +413,13 @@ list.ocamllex = { 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 = { install_info = { url = "https://github.com/alex-pinkus/tree-sitter-swift", - branch = "main", files = { "src/parser.c", "src/scanner.c" }, requires_generate_from_grammar = true, + generate_requires_npm = true, }, - maintainers = { "@alex-pinkus" }, } list.c_sharp = { @@ -547,7 +446,7 @@ list.typescript = { install_info = { url = "https://github.com/tree-sitter/tree-sitter-typescript", files = { "src/parser.c", "src/scanner.c" }, - location = "typescript", + location = "tree-sitter-typescript/typescript", generate_requires_npm = true, }, maintainers = { "@steelsojka" }, @@ -557,7 +456,7 @@ list.tsx = { install_info = { url = "https://github.com/tree-sitter/tree-sitter-typescript", files = { "src/parser.c", "src/scanner.c" }, - location = "tsx", + location = "tree-sitter-tsx/tsx", generate_requires_npm = true, }, filetype = "typescriptreact", @@ -612,24 +511,9 @@ list.hcl = { list.markdown = { install_info = { url = "https://github.com/MDeiml/tree-sitter-markdown", - location = "tree-sitter-markdown", files = { "src/parser.c", "src/scanner.cc" }, - branch = "split_parser", - readme_name = "markdown (basic highlighting)", + branch = "main", }, - 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, } @@ -669,7 +553,6 @@ list.pug = { }, maintainers = { "@zealot128" }, filetype = "pug", - experimental = true, } list.vue = { @@ -779,6 +662,8 @@ list.verilog = { generate_requires_npm = true, }, maintainers = { "@zegervdv" }, + -- The parser still uses API version 12, because it does not compile with 13 + experimental = true, } list.pascal = { @@ -794,6 +679,8 @@ list.phpdoc = { install_info = { url = "https://github.com/claytonrcarter/tree-sitter-phpdoc", 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, }, maintainers = { "@mikehaertl" }, @@ -842,14 +729,6 @@ list.sparql = { maintainers = { "@bonabeavis" }, } -list.sql = { - install_info = { - url = "https://github.com/derekstride/tree-sitter-sql", - files = { "src/parser.c" }, - }, - maintainers = { "@derekstride" }, -} - list.gdscript = { install_info = { url = "https://github.com/PrestonKnopp/tree-sitter-gdscript", @@ -902,7 +781,7 @@ list.svelte = { list.r = { install_info = { url = "https://github.com/r-lib/tree-sitter-r", - files = { "src/parser.c", "src/scanner.cc" }, + files = { "src/parser.c" }, }, maintainers = { "@jimhester" }, } @@ -910,21 +789,12 @@ list.r = { list.beancount = { install_info = { url = "https://github.com/polarmutex/tree-sitter-beancount", - files = { "src/parser.c", "src/scanner.cc" }, + files = { "src/parser.c" }, branch = "master", }, 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 = { install_info = { url = "https://github.com/latex-lsp/tree-sitter-latex", @@ -979,11 +849,12 @@ list.vim = { list.help = { install_info = { - url = "https://github.com/neovim/tree-sitter-vimdoc", - files = { "src/parser.c" }, + url = "https://github.com/vigoux/tree-sitter-vimdoc", + files = { "src/parser.c", "src/scanner.c" }, }, filetype = "help", maintainers = { "@vigoux" }, + experimental = true, } list.json5 = { @@ -1033,7 +904,7 @@ list.llvm = { list.http = { install_info = { - url = "https://github.com/rest-nvim/tree-sitter-http", + url = "https://github.com/NTBBloodbath/tree-sitter-http", branch = "main", files = { "src/parser.c" }, generate_requires_npm = true, @@ -1102,11 +973,11 @@ list.norg = { list.vala = { install_info = { - url = "https://github.com/vala-lang/tree-sitter-vala", - branch = "master", - files = { "src/parser.c" }, + url = "https://github.com/matbme/tree-sitter-vala", + branch = "main", + files = { "src/parser.c", "src/scanner.cc" }, }, - maintainers = { "@Prince781", "@vala-lang" }, + maintainers = { "@matbme" }, } list.lalrpop = { @@ -1163,136 +1034,6 @@ list.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 = { list = list, filetype_to_parsername = filetype_to_parsername, @@ -1318,6 +1059,19 @@ function M.available_parsers() 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() return M.list end diff --git a/bundle/nvim-treesitter/lua/nvim-treesitter/query.lua b/bundle/nvim-treesitter/lua/nvim-treesitter/query.lua index bc80d51e6..bad1c27e6 100644 --- a/bundle/nvim-treesitter/lua/nvim-treesitter/query.lua +++ b/bundle/nvim-treesitter/lua/nvim-treesitter/query.lua @@ -11,10 +11,8 @@ local EMPTY_ITER = function() end M.built_in_query_groups = { "highlights", "locals", "folds", "indents", "injections" } ---- Creates a function that checks whether a given query exists ---- for a specific language. ----@param query string ----@return function(string): boolean +-- Creates a function that checks whether a given query exists +-- for a specific language. local function get_query_guard(query) return function(lang) 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) end ----@return string[] function M.available_query_groups() local query_files = api.nvim_get_runtime_file("queries/*/*.scm", true) local groups = {} @@ -60,19 +57,11 @@ do end end ----@param lang string ----@param query_name string ----@return string[] local function runtime_queries(lang, query_name) return api.nvim_get_runtime_file(string.format("queries/%s/%s.scm", lang, query_name), true) or {} end ----@type table> local query_files_cache = {} - ----@param lang string ----@param query_name string ----@return boolean function M.has_query_files(lang, query_name) if not query_files_cache[lang] then query_files_cache[lang] = {} @@ -97,8 +86,6 @@ do local cache = setmetatable({}, mt) --- Same as `vim.treesitter.query` except will return cached values - ---@param lang string - ---@param query_name string function M.get_query(lang, query_name) if cache[lang][query_name] == nil then 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 only lang is present, will reload all query_names for that lang --- If none are present, will reload everything - ---@param lang string - ---@param query_name string function M.invalidate_query_cache(lang, query_name) if lang and query_name then cache[lang][query_name] = nil @@ -121,14 +106,14 @@ do end elseif lang and not query_name then query_files_cache[lang] = nil - for query_name0, _ in pairs(cache[lang]) do - M.invalidate_query_cache(lang, query_name0) + for query_name, _ in pairs(cache[lang]) do + M.invalidate_query_cache(lang, query_name) end elseif not lang and not query_name then query_files_cache = {} - for lang0, _ in pairs(cache) do - for query_name0, _ in pairs(cache[lang0]) do - M.invalidate_query_cache(lang0, query_name0) + for lang, _ in pairs(cache) do + for query_name, _ in pairs(cache[lang]) do + M.invalidate_query_cache(lang, query_name) end end else @@ -138,23 +123,11 @@ do end --- 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) local fnamemodify = vim.fn.fnamemodify M.invalidate_query_cache(fnamemodify(fname, ":p:h:t"), fnamemodify(fname, ":t:r")) 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 buf_lang = parsers.get_buf_lang(bufnr) @@ -208,10 +181,6 @@ local function prepare_query(bufnr, query_name, root, root_lang) } end ----@param query Query ----@param bufnr integer ----@param start_row integer ----@param end_row integer function M.iter_prepared_matches(query, qnode, bufnr, start_row, end_row) -- A function that splits a string on '.' 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 function iterator() - local pattern, match, metadata = matches() + local pattern, match = matches() if pattern ~= nil then local prepared_match = {} @@ -250,8 +219,6 @@ function M.iter_prepared_matches(query, qnode, bufnr, start_row, end_row) if name ~= nil then local path = split(name .. ".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 @@ -280,16 +247,15 @@ function M.iter_prepared_matches(query, qnode, bufnr, start_row, end_row) end --- 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 ----Can also be a nested capture like @definition.function to get all nodes defining a function. ---- ----@param bufnr integer the buffer ----@param captures string|string[] ----@param query_group string the name of query group (highlights or injections for example) ----@param root LanguageTree|nil node from where to start the search ----@param lang string|nil the language from where to get the captures. ---- Root nodes can have several languages. ----@return table|nil +-- 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. +-- +-- @param bufnr the buffer +-- @param captures a single string or a list of strings +-- @param query_group the name of query group (highlights or injections for example) +-- @param root (optional) node from where to start the search +-- @param lang (optional) the language from where to get the captures. +-- Root nodes can have several languages. function M.get_capture_matches(bufnr, captures, query_group, root, lang) if type(captures) == "string" then captures = { captures } @@ -321,7 +287,6 @@ function M.iter_captures(bufnr, query_name, root, lang) if not query then return EMPTY_ITER end - assert(params) 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 end ----Iterates matches from a query file. ----@param bufnr integer the buffer ----@param query_group string the query file to use ----@param root LanguageTree the root node ----@param root_lang string|nil the root node lang, if known +-- Iterates matches from a query file. +-- @param bufnr the buffer +-- @param query_group the query file to use +-- @param root the root node +-- @param root the root node lang, if known function M.iter_group_results(bufnr, query_group, root, root_lang) local query, params = prepare_query(bufnr, query_group, root, root_lang) if not query then return EMPTY_ITER end - assert(params) return M.iter_prepared_matches(query, params.root, params.source, params.start, params.stop) end @@ -394,25 +358,18 @@ function M.collect_group_results(bufnr, query_group, root, lang) return matches 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. ----@param bufnr integer The bufnr ----@param capture_or_fn string|CaptureResFn The capture to get. If a function is provided then that ---- function will be used to resolve both the capture and query argument. ---- 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 ---- for the captuer argument. +-- @param bufnr The bufnr +-- @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. +-- The function can return `nil` to ignore that tree. +-- @param query_type The query to get the capture from. This is ignore if a function is provided +-- for the captuer argument. function M.get_capture_matches_recursively(bufnr, capture_or_fn, query_type) - ---@type CaptureResFn - local type_fn - if type(capture_or_fn) == "function" then - type_fn = capture_or_fn - else - type_fn = function(_, _, _) + local type_fn = type(capture_or_fn) == "function" and capture_or_fn + or function() return capture_or_fn, query_type end - end local parser = parsers.get_parser(bufnr) local matches = {} diff --git a/bundle/nvim-treesitter/lua/nvim-treesitter/query_predicates.lua b/bundle/nvim-treesitter/lua/nvim-treesitter/query_predicates.lua index 0638b6e79..be713304c 100644 --- a/bundle/nvim-treesitter/lua/nvim-treesitter/query_predicates.lua +++ b/bundle/nvim-treesitter/lua/nvim-treesitter/query_predicates.lua @@ -128,61 +128,3 @@ query.add_directive("downcase!", function(match, _, bufnr, pred, metadata) metadata[key] = string.lower(text) 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) diff --git a/bundle/nvim-treesitter/lua/nvim-treesitter/shell_command_selectors.lua b/bundle/nvim-treesitter/lua/nvim-treesitter/shell_command_selectors.lua index 59bbb0e41..e7de09552 100644 --- a/bundle/nvim-treesitter/lua/nvim-treesitter/shell_command_selectors.lua +++ b/bundle/nvim-treesitter/lua/nvim-treesitter/shell_command_selectors.lua @@ -49,7 +49,6 @@ function M.select_rm_file_cmd(file, info_msg) end end ----@return string|nil function M.select_executable(executables) return vim.tbl_filter(function(c) 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 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 { M.select_install_rm_cmd(cache_folder, project_name .. "-tmp"), { cmd = "curl", - info = "Downloading " .. project_name .. "...", + info = "Downloading...", err = "Error during download, please verify your internet connection", opts = { 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"), { cmd = "tar", - info = "Extracting " .. project_name .. "...", + info = "Extracting...", err = "Error during tarball extraction.", opts = { 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_mv_cmd( - utils.join_path(project_name .. "-tmp", url:match "[^/]-$" .. "-" .. folder_rev), + utils.join_path(project_name .. "-tmp", url:match "[^/]-$" .. "-" .. revision), project_name, cache_folder ), @@ -232,7 +226,7 @@ function M.select_download_commands(repo, project_name, cache_folder, revision, return { { cmd = "git", - info = "Downloading " .. project_name .. "...", + info = "Downloading...", err = clone_error, opts = { args = { diff --git a/bundle/nvim-treesitter/lua/nvim-treesitter/statusline.lua b/bundle/nvim-treesitter/lua/nvim-treesitter/statusline.lua deleted file mode 100644 index 82be06537..000000000 --- a/bundle/nvim-treesitter/lua/nvim-treesitter/statusline.lua +++ /dev/null @@ -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 diff --git a/bundle/nvim-treesitter/lua/nvim-treesitter/ts_utils.lua b/bundle/nvim-treesitter/lua/nvim-treesitter/ts_utils.lua index 5994e4bcb..5b7023c57 100644 --- a/bundle/nvim-treesitter/lua/nvim-treesitter/ts_utils.lua +++ b/bundle/nvim-treesitter/lua/nvim-treesitter/ts_utils.lua @@ -5,8 +5,12 @@ local utils = require "nvim-treesitter.utils" local M = {} -local function get_node_text(node, bufnr) - bufnr = bufnr or api.nvim_get_current_buf() +--- Gets the actual text content of a node +-- @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 return {} end @@ -16,9 +20,6 @@ local function get_node_text(node, bufnr) if start_row ~= end_row then 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) -- 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 @@ -32,37 +33,6 @@ local function get_node_text(node, bufnr) 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 -- @param dest the possible parent -- @param source the possible child node @@ -154,7 +124,7 @@ function M.get_named_children(node) return nodes end -function M.get_node_at_cursor(winnr, ignore_injected_langs) +function M.get_node_at_cursor(winnr) winnr = winnr or 0 local cursor = api.nvim_win_get_cursor(winnr) 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 return end - - 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 + local root = M.get_root_for_position(cursor_range[1], cursor_range[2], root_lang_tree) if not root then return @@ -262,14 +220,14 @@ function M.update_selection(buf, node, selection_mode) 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) + vim.fn.setpos(".", { buf, start_row, start_col, 0 }) + -- Start visual selection in appropriate mode local v_table = { charwise = "v", linewise = "V", blockwise = "" } ---- Call to `nvim_replace_termcodes()` is needed for sending appropriate ---- command to enter blockwise mode local mode_string = vim.api.nvim_replace_termcodes(v_table[selection_mode] or selection_mode, true, true, true) 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 }) 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 range2 = M.node_to_lsp_range(node_or_range2) - local text1 = get_node_text(node_or_range1, bufnr) - local text2 = get_node_text(node_or_range2, bufnr) + local text1 = M.get_node_text(node_or_range1) + local text2 = M.get_node_text(node_or_range2) local edit1 = { range = range1, newText = table.concat(text2, "\n") } local edit2 = { range = range2, newText = table.concat(text1, "\n") } diff --git a/bundle/nvim-treesitter/lua/nvim-treesitter/utils.lua b/bundle/nvim-treesitter/lua/nvim-treesitter/utils.lua index 156ba9c31..06e0e03fb 100644 --- a/bundle/nvim-treesitter/lua/nvim-treesitter/utils.lua +++ b/bundle/nvim-treesitter/lua/nvim-treesitter/utils.lua @@ -10,28 +10,6 @@ function M.notify(msg, log_level, opts) vim.notify(msg, log_level, vim.tbl_extend("force", default_opts, opts or {})) 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 --- - 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 @@ -70,11 +48,14 @@ M.join_space = M.generate_join " " function M.setup_commands(mod, commands) for command_name, def in pairs(commands) do local f_args = def.f_args or "" - local call_fn = - string.format("lua require'nvim-treesitter.%s'.commands.%s['run'](%s)", mod, command_name, f_args) + local call_fn = string.format( + "lua require'nvim-treesitter.%s'.commands.%s['run'](%s)", + mod, + command_name, + f_args + ) local parts = vim.tbl_flatten { "command!", - "-bar", def.args, command_name, call_fn, @@ -83,32 +64,26 @@ function M.setup_commands(mod, commands) end end ----@param dir string ----@param create_err string ----@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, "'") +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()) + +local join_space = M.generate_join " " + function M.get_package_path() -- Path to this source file, removing the leading '@' local source = string.sub(debug.getinfo(1, "S").source, 2) @@ -126,13 +101,56 @@ function M.get_cache_dir() return "/tmp" 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 -- Returns $XDG_DATA_HOME/nvim/site, but could use any directory that is in -- runtimepath 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 -- Gets a property at path @@ -206,7 +224,6 @@ function M.to_func(a) return type(a) == "function" and a or M.constant(a) end ----@return string|nil function M.ts_cli_version() if fn.executable "tree-sitter" == 1 then local handle = io.popen "tree-sitter -V" diff --git a/bundle/nvim-treesitter/plugin/nvim-treesitter.lua b/bundle/nvim-treesitter/plugin/nvim-treesitter.lua deleted file mode 100644 index 4ea3925fd..000000000 --- a/bundle/nvim-treesitter/plugin/nvim-treesitter.lua +++ /dev/null @@ -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", -}) diff --git a/bundle/nvim-treesitter/queries/agda/folds.scm b/bundle/nvim-treesitter/queries/agda/folds.scm deleted file mode 100644 index e3258efb9..000000000 --- a/bundle/nvim-treesitter/queries/agda/folds.scm +++ /dev/null @@ -1,4 +0,0 @@ -[ - (record) - (module) -] @fold diff --git a/bundle/nvim-treesitter/queries/agda/highlights.scm b/bundle/nvim-treesitter/queries/agda/highlights.scm deleted file mode 100644 index ed208f1b6..000000000 --- a/bundle/nvim-treesitter/queries/agda/highlights.scm +++ /dev/null @@ -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 diff --git a/bundle/nvim-treesitter/queries/bash/highlights.scm b/bundle/nvim-treesitter/queries/bash/highlights.scm index d1cdb659d..f80986f95 100644 --- a/bundle/nvim-treesitter/queries/bash/highlights.scm +++ b/bundle/nvim-treesitter/queries/bash/highlights.scm @@ -43,9 +43,8 @@ [ (string) (raw_string) - (ansi_c_string) (heredoc_body) -] @string @spell +] @string (variable_assignment (word) @string) @@ -79,14 +78,13 @@ (special_variable_name) @constant -; trap -l ((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 (#match? @boolean "^(true|false)$")) -(comment) @comment @spell +(comment) @comment (test_operator) @string (command_substitution @@ -99,7 +97,7 @@ (function_definition name: (word) @function) -(command_name (word) @function.call) +(command_name (word) @function) ((command_name (word) @function.builtin) (#any-of? @function.builtin @@ -131,6 +129,3 @@ value: (word) @parameter) (regex) @string.regex - -((program . (comment) @preproc) - (#match? @preproc "^#!/")) diff --git a/bundle/nvim-treesitter/queries/beancount/folds.scm b/bundle/nvim-treesitter/queries/beancount/folds.scm index ffe319500..b65ae0115 100644 --- a/bundle/nvim-treesitter/queries/beancount/folds.scm +++ b/bundle/nvim-treesitter/queries/beancount/folds.scm @@ -1,4 +1,4 @@ [ (transaction) - (section) + (heading) ] @fold diff --git a/bundle/nvim-treesitter/queries/blueprint/highlights.scm b/bundle/nvim-treesitter/queries/blueprint/highlights.scm deleted file mode 100644 index 3d4b48266..000000000 --- a/bundle/nvim-treesitter/queries/blueprint/highlights.scm +++ /dev/null @@ -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 diff --git a/bundle/nvim-treesitter/queries/c/highlights.scm b/bundle/nvim-treesitter/queries/c/highlights.scm index 594826366..2ea07a74a 100644 --- a/bundle/nvim-treesitter/queries/c/highlights.scm +++ b/bundle/nvim-treesitter/queries/c/highlights.scm @@ -1,5 +1,4 @@ -; Lower priority to prefer @parameter when identifier appears in parameter_declaration. -((identifier) @variable (#set! "priority" 95)) +(identifier) @variable [ "const" @@ -43,16 +42,10 @@ "#elif" "#endif" (preproc_directive) -] @preproc +] @keyword "#include" @include -[ ";" ":" "," ] @punctuation.delimiter - -"..." @punctuation.special - -[ "(" ")" "[" "]" "{" "}"] @punctuation.bracket - [ "=" @@ -70,7 +63,6 @@ ">>" "->" - "." "<" "<=" @@ -97,17 +89,20 @@ "++" ] @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) (false) ] @boolean +[ "." ";" ":" "," ] @punctuation.delimiter + +"..." @punctuation.special + (conditional_expression [ "?" ":" ] @conditional) + +[ "(" ")" "[" "]" "{" "}"] @punctuation.bracket + (string_literal) @string (system_lib_string) @string (escape_sequence) @string.escape @@ -125,7 +120,6 @@ (field_identifier) @property)) @_parent (#not-has-parent? @_parent template_method function_declarator call_expression)) -(field_designator) @property (((field_identifier) @property) (#has-ancestor? @property field_declaration) (#not-has-ancestor? @property function_declarator)) @@ -148,9 +142,6 @@ (case_statement value: (identifier) @constant) -((identifier) @constant.builtin - (#any-of? @constant.builtin "stderr" "stdin" "stdout")) - ;; Preproc def / undef (preproc_def name: (_) @constant) @@ -160,16 +151,16 @@ (#eq? @_u "#undef")) (call_expression - function: (identifier) @function.call) + function: (identifier) @function) (call_expression function: (field_expression - field: (field_identifier) @function.call)) + field: (field_identifier) @function)) (function_declarator declarator: (identifier) @function) (preproc_function_def name: (identifier) @function.macro) -(comment) @comment @spell +(comment) @comment ;; Parameters (parameter_declaration @@ -191,7 +182,6 @@ "_unaligned" "__unaligned" "__declspec" - (attribute_declaration) ] @attribute (ERROR) @error diff --git a/bundle/nvim-treesitter/queries/c_sharp/highlights.scm b/bundle/nvim-treesitter/queries/c_sharp/highlights.scm index ca327c596..fc3600e0e 100644 --- a/bundle/nvim-treesitter/queries/c_sharp/highlights.scm +++ b/bundle/nvim-treesitter/queries/c_sharp/highlights.scm @@ -20,12 +20,12 @@ (invocation_expression (member_access_expression - name: (identifier) @method.call)) + name: (identifier) @method)) (invocation_expression function: (conditional_access_expression (member_binding_expression - name: (identifier) @method.call))) + name: (identifier) @method))) (namespace_declaration name: [(qualified_name) (identifier)] @namespace) @@ -34,7 +34,7 @@ (identifier) @type) (invocation_expression - (identifier) @method.call) + (identifier) @method) (field_declaration (variable_declaration @@ -74,7 +74,7 @@ (implicit_type) @keyword -(comment) @comment @spell +(comment) @comment (using_directive (identifier) @type) @@ -141,7 +141,7 @@ ; Generic Method invocation with generic type (invocation_expression function: (generic_name - . (identifier) @method.call)) + . (identifier) @method)) (invocation_expression (member_access_expression diff --git a/bundle/nvim-treesitter/queries/clojure/highlights.scm b/bundle/nvim-treesitter/queries/clojure/highlights.scm index 3dc12d531..d6371c522 100644 --- a/bundle/nvim-treesitter/queries/clojure/highlights.scm +++ b/bundle/nvim-treesitter/queries/clojure/highlights.scm @@ -42,10 +42,10 @@ ; General function calls (list_lit . - (sym_lit) @function.call) + (sym_lit) @function) (anon_fn_lit . - (sym_lit) @function.call) + (sym_lit) @function) ; Quoted symbols (quoting_lit @@ -106,10 +106,7 @@ ; Definition functions ((sym_lit) @keyword - (#any-of? @keyword - "def" "defonce" "defrecord" "defmacro" "definline" - "defmulti" "defmethod" "defstruct" "defprotocol" - "deftype")) + (#lua-match? @keyword "^def.*$")) ((sym_lit) @keyword (#eq? @keyword "declare")) ((sym_lit) @keyword.function @@ -281,22 +278,19 @@ ;; >> Context based highlighting -;; def-likes -;; Correctly highlight docstrings -;(list_lit - ;. - ;(sym_lit) @_keyword ; Don't really want to highlight twice - ;(#any-of? @_keyword - ;"def" "defonce" "defrecord" "defmacro" "definline" - ;"defmulti" "defmethod" "defstruct" "defprotocol" - ;"deftype") - ;. - ;(sym_lit) - ;. - ;;; TODO: Add @comment highlight - ;(str_lit)? - ;. - ;(_)) +; def-likes +; Correctly highlight docstrings +(list_lit + . + (sym_lit) @_keyword ; Don't really want to highlight twice + (#lua-match? @_keyword "^def.*") + . + (sym_lit) + . + ;; TODO: Add @comment highlight + (str_lit)? + . + (_)) ; Function definitions (list_lit diff --git a/bundle/nvim-treesitter/queries/cmake/highlights.scm b/bundle/nvim-treesitter/queries/cmake/highlights.scm index 3378480c0..18a87c25e 100644 --- a/bundle/nvim-treesitter/queries/cmake/highlights.scm +++ b/bundle/nvim-treesitter/queries/cmake/highlights.scm @@ -9,7 +9,7 @@ [ (bracket_comment) (line_comment) -] @comment @spell +] @comment (normal_command (identifier) @function) @@ -123,7 +123,3 @@ (#match? @function.builtin "\\c^(add_custom_command)$") ) -(escape_sequence) @string.escape - -((source_file . (line_comment) @preproc) - (#match? @preproc "^#!/")) diff --git a/bundle/nvim-treesitter/queries/comment/highlights.scm b/bundle/nvim-treesitter/queries/comment/highlights.scm index e516c6037..6c3e043c8 100644 --- a/bundle/nvim-treesitter/queries/comment/highlights.scm +++ b/bundle/nvim-treesitter/queries/comment/highlights.scm @@ -1,5 +1,3 @@ -(_) @spell - [ "(" ")" @@ -9,12 +7,6 @@ (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)) (#any-of? @text.warning "TODO" "HACK" "WARNING")) diff --git a/bundle/nvim-treesitter/queries/cpp/highlights.scm b/bundle/nvim-treesitter/queries/cpp/highlights.scm index fb7ee2e5f..8dcbaeff5 100644 --- a/bundle/nvim-treesitter/queries/cpp/highlights.scm +++ b/bundle/nvim-treesitter/queries/cpp/highlights.scm @@ -66,21 +66,21 @@ (call_expression function: (qualified_identifier - name: (identifier) @function.call)) + name: (identifier) @function)) (call_expression function: (qualified_identifier name: (qualified_identifier - name: (identifier) @function.call))) + name: (identifier) @function))) (call_expression function: (qualified_identifier name: (qualified_identifier name: (qualified_identifier - name: (identifier) @function.call)))) + name: (identifier) @function)))) (call_expression function: (field_expression - field: (field_identifier) @function.call)) + field: (field_identifier) @function)) ((call_expression function: (identifier) @constructor) @@ -158,21 +158,27 @@ "new" "delete" - "xor" - "bitand" - "bitor" - "compl" - "not" - "xor_eq" - "and_eq" - "or_eq" - "not_eq" - "and" - "or" + ;; these keywords are not supported by the parser + ;"eq" + ;"not_eq" + ; + ;"compl" + ;"and" + ;"or" + ; + ;"bitand" + ;"bitand_eq" + ;"bitor" + ;"bitor_eq" + ;"xor" + ;"xor_eq" ] @keyword.operator -"<=>" @operator +[ + "<=>" + "::" +] @operator -"::" @punctuation.delimiter +(attribute_declaration) @attribute (literal_suffix) @operator diff --git a/bundle/nvim-treesitter/queries/css/highlights.scm b/bundle/nvim-treesitter/queries/css/highlights.scm index 18bf7f9b4..d8439d678 100644 --- a/bundle/nvim-treesitter/queries/css/highlights.scm +++ b/bundle/nvim-treesitter/queries/css/highlights.scm @@ -11,7 +11,7 @@ (important) ] @keyword -(comment) @comment @spell +(comment) @comment [ (tag_name) @@ -42,7 +42,7 @@ (attribute_selector (plain_value) @string) -(pseudo_element_selector "::" (tag_name) @property) +(pseudo_element_selector (tag_name) @property) (pseudo_class_selector (class_name) @property) [ diff --git a/bundle/nvim-treesitter/queries/cuda/highlights.scm b/bundle/nvim-treesitter/queries/cuda/highlights.scm index 7897c4144..404c72afb 100644 --- a/bundle/nvim-treesitter/queries/cuda/highlights.scm +++ b/bundle/nvim-treesitter/queries/cuda/highlights.scm @@ -11,5 +11,4 @@ "__forceinline__" "__restrict__" "__launch_bounds__" - "__grid_constant__" ] @keyword diff --git a/bundle/nvim-treesitter/queries/diff/highlights.scm b/bundle/nvim-treesitter/queries/diff/highlights.scm deleted file mode 100644 index 4b9cbad60..000000000 --- a/bundle/nvim-treesitter/queries/diff/highlights.scm +++ /dev/null @@ -1,6 +0,0 @@ -[(addition) (new_file)] @text.diff.add -[(deletion) (old_file)] @text.diff.delete - -(commit) @constant -(location) @attribute -(command) @function diff --git a/bundle/nvim-treesitter/queries/dockerfile/highlights.scm b/bundle/nvim-treesitter/queries/dockerfile/highlights.scm index 2d1840e66..af1c088c5 100644 --- a/bundle/nvim-treesitter/queries/dockerfile/highlights.scm +++ b/bundle/nvim-treesitter/queries/dockerfile/highlights.scm @@ -26,7 +26,7 @@ "@" ] @operator -(comment) @comment @spell +(comment) @comment (image_spec (image_tag @@ -47,17 +47,4 @@ ((variable) @constant (#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)$")) diff --git a/bundle/nvim-treesitter/queries/dot/highlights.scm b/bundle/nvim-treesitter/queries/dot/highlights.scm index d8b70a949..86bb9b303 100644 --- a/bundle/nvim-treesitter/queries/dot/highlights.scm +++ b/bundle/nvim-treesitter/queries/dot/highlights.scm @@ -1,14 +1,5 @@ (identifier) @type - -[ - "strict" - "graph" - "digraph" - "subgraph" - "node" - "edge" -] @keyword - +(keyword) @keyword (string_literal) @string (number_literal) @number @@ -46,10 +37,9 @@ (identifier) @constant) ) -(comment) @comment - -(preproc) @preproc - -(comment) @spell +[ +(comment) +(preproc) +] @comment (ERROR) @error diff --git a/bundle/nvim-treesitter/queries/ecma/highlights.scm b/bundle/nvim-treesitter/queries/ecma/highlights.scm index aa490b33c..7334bd1e6 100644 --- a/bundle/nvim-treesitter/queries/ecma/highlights.scm +++ b/bundle/nvim-treesitter/queries/ecma/highlights.scm @@ -83,11 +83,11 @@ ;-------------------------- (call_expression - function: (identifier) @function.call) + function: (identifier) @function) (call_expression function: (member_expression - property: [(property_identifier) (private_property_identifier)] @method.call)) + property: [(property_identifier) (private_property_identifier)] @method)) ; Variables ;---------- @@ -97,36 +97,22 @@ ; Literals ;--------- +(this) @variable.builtin +(super) @variable.builtin + +(true) @boolean +(false) @boolean +(null) @constant.builtin [ - (this) - (super) -] @variable.builtin - -[ - (true) - (false) -] @boolean - -[ - (null) - (undefined) -] @constant.builtin - -(comment) @comment - -(hash_bang_line) @preproc - -(comment) @spell - -(string) @string @spell +(comment) +(hash_bang_line) +] @comment +(string) @string +(regex) @punctuation.delimiter +(regex_pattern) @string.regex (template_string) @string (escape_sequence) @string.escape -(regex_pattern) @string.regex -(regex "/" @punctuation.bracket) ; Regex delimiters - (number) @number -((identifier) @number - (#any-of? @number "NaN" "Infinity")) ; Punctuation ;------------ @@ -136,9 +122,9 @@ ";" @punctuation.delimiter "." @punctuation.delimiter "," @punctuation.delimiter +"?." @punctuation.delimiter (pair ":" @punctuation.delimiter) -(pair_pattern ":" @punctuation.delimiter) [ "--" diff --git a/bundle/nvim-treesitter/queries/ecma/indents.scm b/bundle/nvim-treesitter/queries/ecma/indents.scm index 902bf586a..55cae9b19 100644 --- a/bundle/nvim-treesitter/queries/ecma/indents.scm +++ b/bundle/nvim-treesitter/queries/ecma/indents.scm @@ -45,8 +45,6 @@ ] @branch (statement_block "{" @branch) -["}" "]"] @indent_end - [ (comment) (template_string) diff --git a/bundle/nvim-treesitter/queries/ecma/injections.scm b/bundle/nvim-treesitter/queries/ecma/injections.scm index 6bd5da862..f97f9cd2c 100644 --- a/bundle/nvim-treesitter/queries/ecma/injections.scm +++ b/bundle/nvim-treesitter/queries/ecma/injections.scm @@ -1,6 +1,4 @@ -(((comment) @_jsdoc_comment - (#match? @_jsdoc_comment "^/\\*\\*[^\\*].*\\*/")) @jsdoc) - +(comment) @jsdoc (comment) @comment (call_expression @@ -20,8 +18,6 @@ arguments: ((template_string) @glimmer (#offset! @glimmer 0 1 0 -1))) -((glimmer_template) @glimmer) - ; styled.div`` (call_expression function: (member_expression @@ -60,10 +56,3 @@ (#offset! @css 0 1 0 -1))) (regex_pattern) @regex - -((comment) @_gql_comment - (#eq? @_gql_comment "/* GraphQL */") - (template_string) @graphql) - -(((template_string) @_template_string - (#match? @_template_string "^`#graphql")) @graphql) diff --git a/bundle/nvim-treesitter/queries/ecma/locals.scm b/bundle/nvim-treesitter/queries/ecma/locals.scm index 4c035d269..08c9b8e7d 100644 --- a/bundle/nvim-treesitter/queries/ecma/locals.scm +++ b/bundle/nvim-treesitter/queries/ecma/locals.scm @@ -23,11 +23,7 @@ (identifier) @definition.import) (function_declaration - ((identifier) @definition.function) - (#set! definition.var.scope parent)) - -(method_definition - ((property_identifier) @definition.function) + ((identifier) @definition.var) (#set! definition.var.scope parent)) ; References diff --git a/bundle/nvim-treesitter/queries/elixir/highlights.scm b/bundle/nvim-treesitter/queries/elixir/highlights.scm index fdb92ef35..db9bfbb2d 100644 --- a/bundle/nvim-treesitter/queries/elixir/highlights.scm +++ b/bundle/nvim-treesitter/queries/elixir/highlights.scm @@ -30,11 +30,9 @@ ; Comments (comment) @comment -(comment) @spell ; Strings (string) @string -(string) @spell ; Modules (alias) @type @@ -86,13 +84,13 @@ (stab_clause operator: _ @operator) ; Local Function Calls -(call target: (identifier) @function.call) +(call target: (identifier) @function) ; Remote Function Calls (call target: (dot left: [ (atom) @type (_) -] right: (identifier) @function.call) (arguments)) +] right: (identifier) @function) (arguments)) ; Definition Function Calls (call target: ((identifier) @keyword.function (#any-of? @keyword.function diff --git a/bundle/nvim-treesitter/queries/elvish/highlights.scm b/bundle/nvim-treesitter/queries/elvish/highlights.scm index ab0ce8c1b..4dba8eecb 100644 --- a/bundle/nvim-treesitter/queries/elvish/highlights.scm +++ b/bundle/nvim-treesitter/queries/elvish/highlights.scm @@ -16,7 +16,7 @@ ["*" "**" "?"] @string.special (command argument: (bareword) @parameter) -(command head: (identifier) @function.call) +(command head: (identifier) @function) ((command head: (identifier) @keyword.return) (#eq? @keyword.return "return")) ((command (identifier) @keyword.operator) @@ -24,7 +24,7 @@ [ "+" "-" "*" "/" "%" "<" "<=""==" "!=" ">" ">=" "s" ">=s" -] @function.builtin +] @function [">" "<" ">>" "<>" "|"] @operator diff --git a/bundle/nvim-treesitter/queries/embedded_template/highlights.scm b/bundle/nvim-treesitter/queries/embedded_template/highlights.scm deleted file mode 100644 index 0bf76a7d4..000000000 --- a/bundle/nvim-treesitter/queries/embedded_template/highlights.scm +++ /dev/null @@ -1,12 +0,0 @@ -(comment_directive) @comment - -[ - "<%#" - "<%" - "<%=" - "<%_" - "<%-" - "%>" - "-%>" - "_%>" -] @keyword diff --git a/bundle/nvim-treesitter/queries/embedded_template/injections.scm b/bundle/nvim-treesitter/queries/embedded_template/injections.scm deleted file mode 100644 index d55c87e09..000000000 --- a/bundle/nvim-treesitter/queries/embedded_template/injections.scm +++ /dev/null @@ -1,2 +0,0 @@ -(content) @html @combined -(code) @ruby @combined diff --git a/bundle/nvim-treesitter/queries/erlang/folds.scm b/bundle/nvim-treesitter/queries/erlang/folds.scm deleted file mode 100644 index 39c65c5b2..000000000 --- a/bundle/nvim-treesitter/queries/erlang/folds.scm +++ /dev/null @@ -1,7 +0,0 @@ -[ - (function_declaration) - (lambda_clause) - (expr_case) - (map) - (module_export) -] @fold diff --git a/bundle/nvim-treesitter/queries/erlang/highlights.scm b/bundle/nvim-treesitter/queries/erlang/highlights.scm deleted file mode 100644 index c51019fd5..000000000 --- a/bundle/nvim-treesitter/queries/erlang/highlights.scm +++ /dev/null @@ -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 -) diff --git a/bundle/nvim-treesitter/queries/fish/highlights.scm b/bundle/nvim-treesitter/queries/fish/highlights.scm index 10d54dff7..71c074630 100644 --- a/bundle/nvim-treesitter/queries/fish/highlights.scm +++ b/bundle/nvim-treesitter/queries/fish/highlights.scm @@ -106,7 +106,7 @@ (command_substitution_dollar "$" @punctuation.bracket) ; non-bultin command names -(command name: (word) @function.call) +(command name: (word) @function) ; derived from builtin -n (fish 3.2.2) (command @@ -149,15 +149,11 @@ [(integer) (float)] @number (comment) @comment -(comment) @spell (test_option) @string ((word) @boolean (#any-of? @boolean "true" "false")) -((program . (comment) @preproc) - (#match? @preproc "^#!/")) - ;; Error (ERROR) @error diff --git a/bundle/nvim-treesitter/queries/git_rebase/highlights.scm b/bundle/nvim-treesitter/queries/git_rebase/highlights.scm deleted file mode 100644 index 466bd2f16..000000000 --- a/bundle/nvim-treesitter/queries/git_rebase/highlights.scm +++ /dev/null @@ -1,8 +0,0 @@ -((command) @keyword - (label)? @constant - (message)? @text @spell) - -(option) @operator - -(comment) @comment - diff --git a/bundle/nvim-treesitter/queries/git_rebase/injections.scm b/bundle/nvim-treesitter/queries/git_rebase/injections.scm deleted file mode 100644 index 27388618e..000000000 --- a/bundle/nvim-treesitter/queries/git_rebase/injections.scm +++ /dev/null @@ -1,5 +0,0 @@ -((operation - (command) @_command - (message) @bash) -(#any-of? @_command "exec" "x")) - diff --git a/bundle/nvim-treesitter/queries/gitattributes/highlights.scm b/bundle/nvim-treesitter/queries/gitattributes/highlights.scm deleted file mode 100644 index ecd410972..000000000 --- a/bundle/nvim-treesitter/queries/gitattributes/highlights.scm +++ /dev/null @@ -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 diff --git a/bundle/nvim-treesitter/queries/gitattributes/injections.scm b/bundle/nvim-treesitter/queries/gitattributes/injections.scm deleted file mode 100644 index 4bb7d675d..000000000 --- a/bundle/nvim-treesitter/queries/gitattributes/injections.scm +++ /dev/null @@ -1 +0,0 @@ -(comment) @comment diff --git a/bundle/nvim-treesitter/queries/gitignore/highlights.scm b/bundle/nvim-treesitter/queries/gitignore/highlights.scm deleted file mode 100644 index 6e83ea6f2..000000000 --- a/bundle/nvim-treesitter/queries/gitignore/highlights.scm +++ /dev/null @@ -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 diff --git a/bundle/nvim-treesitter/queries/go/folds.scm b/bundle/nvim-treesitter/queries/go/folds.scm index e1b7a83e9..c79d45720 100644 --- a/bundle/nvim-treesitter/queries/go/folds.scm +++ b/bundle/nvim-treesitter/queries/go/folds.scm @@ -9,8 +9,5 @@ (method_declaration) (type_declaration) (var_declaration) - (composite_literal) - (literal_element) - (block) ] @fold diff --git a/bundle/nvim-treesitter/queries/go/highlights.scm b/bundle/nvim-treesitter/queries/go/highlights.scm index aaa6fe6b1..07c788ec7 100644 --- a/bundle/nvim-treesitter/queries/go/highlights.scm +++ b/bundle/nvim-treesitter/queries/go/highlights.scm @@ -15,17 +15,20 @@ ((identifier) @constant (#eq? @constant "_")) +((identifier) @constant + (#vim-match? @constant "^[A-Z][A-Z\\d_]+$")) + (const_spec name: (identifier) @constant) ; Function calls (call_expression - function: (identifier) @function.call) + function: (identifier) @function) (call_expression function: (selector_expression - field: (field_identifier) @method.call)) + field: (field_identifier) @method)) ; Function definitions @@ -35,9 +38,6 @@ (method_declaration name: (field_identifier) @method) -(method_spec - name: (field_identifier) @method) - ; Operators [ @@ -123,7 +123,6 @@ ((type_identifier) @type.builtin (#any-of? @type.builtin - "any" "bool" "byte" "complex128" @@ -185,7 +184,7 @@ ; Literals (interpreted_string_literal) @string -(raw_string_literal) @string @spell +(raw_string_literal) @string (rune_literal) @string (escape_sequence) @string.escape @@ -197,16 +196,6 @@ (false) @boolean (nil) @constant.builtin -(keyed_element - . (literal_element (identifier) @field)) -(field_declaration name: (field_identifier) @field) - -(comment) @comment @spell +(comment) @comment (ERROR) @error - -((interpreted_string_literal) @spell - (#not-has-parent? @spell - import_spec - ) -) diff --git a/bundle/nvim-treesitter/queries/go/indents.scm b/bundle/nvim-treesitter/queries/go/indents.scm index c6ac18969..f274ffb11 100644 --- a/bundle/nvim-treesitter/queries/go/indents.scm +++ b/bundle/nvim-treesitter/queries/go/indents.scm @@ -3,6 +3,7 @@ (const_declaration) (var_declaration) (type_declaration) + (composite_literal) (func_literal) (literal_value) (expression_case) @@ -10,22 +11,13 @@ (block) (call_expression) (parameter_list) - (struct_type) ] @indent [ + "case" "}" ] @branch -(const_declaration ")" @branch) -(import_spec_list ")" @branch) -(var_declaration ")" @branch) - -[ - "}" - ")" -] @indent_end - (parameter_list ")" @branch) (comment) @ignore diff --git a/bundle/nvim-treesitter/queries/go/injections.scm b/bundle/nvim-treesitter/queries/go/injections.scm index 4bb7d675d..2391c1a7a 100644 --- a/bundle/nvim-treesitter/queries/go/injections.scm +++ b/bundle/nvim-treesitter/queries/go/injections.scm @@ -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 diff --git a/bundle/nvim-treesitter/queries/hack/highlights.scm b/bundle/nvim-treesitter/queries/hack/highlights.scm index 0ae9a9bc0..9ec38266a 100644 --- a/bundle/nvim-treesitter/queries/hack/highlights.scm +++ b/bundle/nvim-treesitter/queries/hack/highlights.scm @@ -177,14 +177,14 @@ (variable) @parameter) (call_expression - function: (qualified_identifier (identifier) @function.call .)) + function: (qualified_identifier (identifier) @function .)) (call_expression - function: (scoped_identifier (identifier) @function.call .)) + function: (scoped_identifier (identifier) @function .)) (call_expression function: (selection_expression - (qualified_identifier (identifier) @method.call .))) + (qualified_identifier (identifier) @method .))) (qualified_identifier (_) @namespace . diff --git a/bundle/nvim-treesitter/queries/haskell/folds.scm b/bundle/nvim-treesitter/queries/haskell/folds.scm deleted file mode 100644 index 28eadf8f3..000000000 --- a/bundle/nvim-treesitter/queries/haskell/folds.scm +++ /dev/null @@ -1,5 +0,0 @@ -[ - (exp_apply) - (exp_do) - (function) -] @fold diff --git a/bundle/nvim-treesitter/queries/haskell/highlights.scm b/bundle/nvim-treesitter/queries/haskell/highlights.scm index c37c33b3e..03744f5d6 100644 --- a/bundle/nvim-treesitter/queries/haskell/highlights.scm +++ b/bundle/nvim-treesitter/queries/haskell/highlights.scm @@ -81,7 +81,6 @@ "in" "class" "instance" - "pattern" "data" "newtype" "family" @@ -117,9 +116,8 @@ (exp_infix (variable) @operator) ; consider infix functions as operators -(exp_infix (exp_name) @function.call (#set! "priority" 101)) -(exp_apply . (exp_name (variable) @function.call)) -(exp_apply . (exp_name (qualified_variable (variable) @function.call))) +(exp_apply . (exp_name (variable) @function)) +(exp_apply . (exp_name (qualified_variable (variable) @function))) ;; ---------------------------------------------------------------------------- @@ -137,12 +135,5 @@ ;; ---------------------------------------------------------------------------- ;; Quasi-quotes -(quoter) @function.call +(quoter) @function ; Highlighting of quasiquote_body is handled by injections.scm - -;; ---------------------------------------------------------------------------- -;; Spell checking - -(string) @spell -(comment) @spell - diff --git a/bundle/nvim-treesitter/queries/haskell/injections.scm b/bundle/nvim-treesitter/queries/haskell/injections.scm index 206248f6e..0b231a7a1 100644 --- a/bundle/nvim-treesitter/queries/haskell/injections.scm +++ b/bundle/nvim-treesitter/queries/haskell/injections.scm @@ -56,23 +56,3 @@ (#eq? @_name "hsx") ((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) -) diff --git a/bundle/nvim-treesitter/queries/hcl/highlights.scm b/bundle/nvim-treesitter/queries/hcl/highlights.scm index f6512148c..67e85cb61 100644 --- a/bundle/nvim-treesitter/queries/hcl/highlights.scm +++ b/bundle/nvim-treesitter/queries/hcl/highlights.scm @@ -63,8 +63,8 @@ ] @string [ - (heredoc_identifier) ; END - (heredoc_start) ; << or <<- + (heredoc_identifier) ; <" @conceal (#set! conceal "")) -(block - "<" @conceal (#set! conceal "")) -(argument) @parameter -(keycode) @string.special -(url) @text.uri + content: (_) @string) diff --git a/bundle/nvim-treesitter/queries/hlsl/folds.scm b/bundle/nvim-treesitter/queries/hlsl/folds.scm deleted file mode 100644 index b617fdc56..000000000 --- a/bundle/nvim-treesitter/queries/hlsl/folds.scm +++ /dev/null @@ -1 +0,0 @@ -; inherits: cpp diff --git a/bundle/nvim-treesitter/queries/hlsl/highlights.scm b/bundle/nvim-treesitter/queries/hlsl/highlights.scm deleted file mode 100644 index b93a90da8..000000000 --- a/bundle/nvim-treesitter/queries/hlsl/highlights.scm +++ /dev/null @@ -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) diff --git a/bundle/nvim-treesitter/queries/hlsl/indents.scm b/bundle/nvim-treesitter/queries/hlsl/indents.scm deleted file mode 100644 index b617fdc56..000000000 --- a/bundle/nvim-treesitter/queries/hlsl/indents.scm +++ /dev/null @@ -1 +0,0 @@ -; inherits: cpp diff --git a/bundle/nvim-treesitter/queries/hlsl/injections.scm b/bundle/nvim-treesitter/queries/hlsl/injections.scm deleted file mode 100644 index 537ae542d..000000000 --- a/bundle/nvim-treesitter/queries/hlsl/injections.scm +++ /dev/null @@ -1,3 +0,0 @@ -(preproc_arg) @hlsl - -(comment) @comment diff --git a/bundle/nvim-treesitter/queries/hlsl/locals.scm b/bundle/nvim-treesitter/queries/hlsl/locals.scm deleted file mode 100644 index b617fdc56..000000000 --- a/bundle/nvim-treesitter/queries/hlsl/locals.scm +++ /dev/null @@ -1 +0,0 @@ -; inherits: cpp diff --git a/bundle/nvim-treesitter/queries/html_tags/highlights.scm b/bundle/nvim-treesitter/queries/html_tags/highlights.scm index b6a90f726..419b4568d 100644 --- a/bundle/nvim-treesitter/queries/html_tags/highlights.scm +++ b/bundle/nvim-treesitter/queries/html_tags/highlights.scm @@ -4,7 +4,7 @@ (attribute_name) @tag.attribute (attribute (quoted_attribute_value) @string) -(text) @text @spell +(text) @text ((element (start_tag (tag_name) @_tag) (text) @text.title) (#match? @_tag "^(h[0-9]|title)$")) diff --git a/bundle/nvim-treesitter/queries/java/highlights.scm b/bundle/nvim-treesitter/queries/java/highlights.scm index db9453d9c..dfac3aadf 100644 --- a/bundle/nvim-treesitter/queries/java/highlights.scm +++ b/bundle/nvim-treesitter/queries/java/highlights.scm @@ -9,7 +9,7 @@ (method_declaration name: (identifier) @method) (method_invocation - name: (identifier) @method.call) + name: (identifier) @method) (super) @function.builtin @@ -143,13 +143,13 @@ ] @float (character_literal) @character -[(string_literal) (text_block)] @string +(string_literal) @string (null_literal) @constant.builtin [ (line_comment) (block_comment) -] @comment @spell +] @comment [ (true) @@ -178,14 +178,11 @@ "open" "opens" "package" -"permits" "private" "protected" "provides" "public" "requires" -"sealed" -"non-sealed" "static" "strictfp" "synchronized" diff --git a/bundle/nvim-treesitter/queries/javascript/highlights.scm b/bundle/nvim-treesitter/queries/javascript/highlights.scm index b62679c4b..57634434e 100644 --- a/bundle/nvim-treesitter/queries/javascript/highlights.scm +++ b/bundle/nvim-treesitter/queries/javascript/highlights.scm @@ -31,6 +31,3 @@ (formal_parameters (assignment_pattern left: (identifier) @parameter)) - -;; punctuation -(optional_chain) @punctuation.delimiter diff --git a/bundle/nvim-treesitter/queries/json/highlights.scm b/bundle/nvim-treesitter/queries/json/highlights.scm index f41b44a5a..1ac778982 100644 --- a/bundle/nvim-treesitter/queries/json/highlights.scm +++ b/bundle/nvim-treesitter/queries/json/highlights.scm @@ -6,7 +6,6 @@ (pair value: (string) @string) (array (string) @string) (string_content (escape_sequence) @string.escape) -(string_content) @spell (ERROR) @error ["," ":"] @punctuation.delimiter "[" @punctuation.bracket diff --git a/bundle/nvim-treesitter/queries/jsonc/highlights.scm b/bundle/nvim-treesitter/queries/jsonc/highlights.scm index e50112155..a51c5c7e7 100644 --- a/bundle/nvim-treesitter/queries/jsonc/highlights.scm +++ b/bundle/nvim-treesitter/queries/jsonc/highlights.scm @@ -1,3 +1,3 @@ ; inherits: json -(comment) @comment @spell +(comment) @comment diff --git a/bundle/nvim-treesitter/queries/jsonnet/highlights.scm b/bundle/nvim-treesitter/queries/jsonnet/highlights.scm deleted file mode 100644 index eb8d22be9..000000000 --- a/bundle/nvim-treesitter/queries/jsonnet/highlights.scm +++ /dev/null @@ -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 diff --git a/bundle/nvim-treesitter/queries/jsx/injections.scm b/bundle/nvim-treesitter/queries/jsx/injections.scm deleted file mode 100644 index 3a96931b0..000000000 --- a/bundle/nvim-treesitter/queries/jsx/injections.scm +++ /dev/null @@ -1,8 +0,0 @@ -; Styled Jsx