From 09a5ffee3586cdf7f7e210b01ff404a79893c70a Mon Sep 17 00:00:00 2001 From: wsdjeg Date: Sun, 13 Nov 2022 23:50:23 +0800 Subject: [PATCH] perf(treesitter): update bundle nvim-treesitter --- bundle/nvim-treesitter/.github/FUNDING.yml | 1 + .../ISSUE_TEMPLATE/highlighting_issue.yml | 2 +- .../.github/workflows/lint.yml | 2 +- .../.github/workflows/test-queries.yml | 12 +- .../.github/workflows/tests.yml | 2 +- .../.github/workflows/update-lockfile.yml | 1 + .../.github/workflows/update-readme.yml | 1 + bundle/nvim-treesitter/CONTRIBUTING.md | 260 ++++++---- bundle/nvim-treesitter/README.md | 121 ++++- .../autoload/nvim_treesitter.vim | 6 +- .../contrib/nvim-treesitter-scm-1.rockspec | 32 ++ .../nvim-treesitter/doc/nvim-treesitter.txt | 308 +---------- bundle/nvim-treesitter/lockfile.json | 225 +++++--- .../nvim-treesitter/lua/nvim-treesitter.lua | 72 +-- .../lua/nvim-treesitter/configs.lua | 282 ++++++---- .../lua/nvim-treesitter/fold.lua | 11 +- .../lua/nvim-treesitter/health.lua | 39 +- .../lua/nvim-treesitter/highlight.lua | 127 +---- .../nvim-treesitter/incremental_selection.lua | 24 +- .../lua/nvim-treesitter/indent.lua | 18 +- .../lua/nvim-treesitter/info.lua | 41 +- .../lua/nvim-treesitter/install.lua | 142 +++-- .../lua/nvim-treesitter/locals.lua | 9 +- .../lua/nvim-treesitter/parsers.lua | 312 +++++++++-- .../lua/nvim-treesitter/query.lua | 103 ++-- .../lua/nvim-treesitter/query_predicates.lua | 58 +++ .../shell_command_selectors.lua | 14 +- .../lua/nvim-treesitter/statusline.lua | 50 ++ .../lua/nvim-treesitter/ts_utils.lua | 66 ++- .../lua/nvim-treesitter/utils.lua | 117 ++--- .../plugin/nvim-treesitter.lua | 34 ++ bundle/nvim-treesitter/queries/agda/folds.scm | 4 + .../queries/agda/highlights.scm | 82 +++ .../queries/bash/highlights.scm | 13 +- .../queries/beancount/folds.scm | 2 +- .../queries/blueprint/highlights.scm | 57 +++ .../nvim-treesitter/queries/c/highlights.scm | 34 +- .../queries/c_sharp/highlights.scm | 10 +- .../queries/clojure/highlights.scm | 38 +- .../queries/cmake/highlights.scm | 6 +- .../queries/comment/highlights.scm | 8 + .../queries/cpp/highlights.scm | 40 +- .../queries/css/highlights.scm | 4 +- .../queries/cuda/highlights.scm | 1 + .../queries/diff/highlights.scm | 6 + .../queries/dockerfile/highlights.scm | 15 +- .../queries/dot/highlights.scm | 20 +- .../queries/ecma/highlights.scm | 44 +- .../nvim-treesitter/queries/ecma/indents.scm | 2 + .../queries/ecma/injections.scm | 13 +- .../nvim-treesitter/queries/ecma/locals.scm | 6 +- .../queries/elixir/highlights.scm | 6 +- .../queries/elvish/highlights.scm | 4 +- .../queries/embedded_template/highlights.scm | 12 + .../queries/embedded_template/injections.scm | 2 + .../nvim-treesitter/queries/erlang/folds.scm | 7 + .../queries/erlang/highlights.scm | 104 ++++ .../queries/fish/highlights.scm | 6 +- .../queries/git_rebase/highlights.scm | 8 + .../queries/git_rebase/injections.scm | 5 + .../queries/gitattributes/highlights.scm | 53 ++ .../queries/gitattributes/injections.scm | 1 + .../queries/gitignore/highlights.scm | 31 ++ bundle/nvim-treesitter/queries/go/folds.scm | 3 + .../nvim-treesitter/queries/go/highlights.scm | 25 +- bundle/nvim-treesitter/queries/go/indents.scm | 12 +- .../nvim-treesitter/queries/go/injections.scm | 5 - .../queries/hack/highlights.scm | 6 +- .../nvim-treesitter/queries/haskell/folds.scm | 5 + .../queries/haskell/highlights.scm | 15 +- .../queries/haskell/injections.scm | 20 + .../queries/hcl/highlights.scm | 4 +- .../nvim-treesitter/queries/hcl/indents.scm | 16 +- .../queries/hcl/injections.scm | 6 + .../queries/help/highlights.scm | 29 +- bundle/nvim-treesitter/queries/hlsl/folds.scm | 1 + .../queries/hlsl/highlights.scm | 35 ++ .../nvim-treesitter/queries/hlsl/indents.scm | 1 + .../queries/hlsl/injections.scm | 3 + .../nvim-treesitter/queries/hlsl/locals.scm | 1 + .../queries/html_tags/highlights.scm | 2 +- .../queries/java/highlights.scm | 9 +- .../queries/javascript/highlights.scm | 3 + .../queries/json/highlights.scm | 1 + .../queries/jsonc/highlights.scm | 2 +- .../queries/jsonnet/highlights.scm | 76 +++ .../queries/jsx/injections.scm | 8 + .../nvim-treesitter/queries/julia/folds.scm | 2 +- .../queries/julia/highlights.scm | 299 ++++++----- .../nvim-treesitter/queries/julia/indents.scm | 5 +- .../queries/julia/injections.scm | 2 +- .../nvim-treesitter/queries/julia/locals.scm | 92 ++-- .../queries/kotlin/highlights.scm | 16 +- .../nvim-treesitter/queries/latex/folds.scm | 1 + .../queries/latex/highlights.scm | 115 ++--- .../queries/lua/highlights.scm | 17 +- .../nvim-treesitter/queries/lua/indents.scm | 2 + .../queries/lua/injections.scm | 3 + bundle/nvim-treesitter/queries/lua/locals.scm | 12 +- bundle/nvim-treesitter/queries/m68k/folds.scm | 1 + .../queries/m68k/highlights.scm | 71 +++ .../queries/m68k/injections.scm | 1 + .../nvim-treesitter/queries/m68k/locals.scm | 22 + bundle/nvim-treesitter/queries/make/folds.scm | 7 + .../queries/make/highlights.scm | 3 +- .../queries/markdown/folds.scm | 14 +- .../queries/markdown/highlights.scm | 47 +- .../queries/markdown/injections.scm | 12 +- .../queries/markdown_inline/highlights.scm | 91 ++++ .../queries/markdown_inline/injections.scm | 1 + .../queries/menhir/highlights.scm | 29 ++ .../queries/menhir/injections.scm | 1 + .../nvim-treesitter/queries/meson/folds.scm | 9 + .../queries/meson/highlights.scm | 81 +++ .../queries/meson/injections.scm | 1 + .../queries/nickel/highlights.scm | 61 +++ bundle/nvim-treesitter/queries/nix/folds.scm | 16 +- .../queries/nix/highlights.scm | 44 +- bundle/nvim-treesitter/queries/nix/locals.scm | 10 +- .../queries/ocaml/highlights.scm | 17 +- .../queries/perl/highlights.scm | 8 +- bundle/nvim-treesitter/queries/php/folds.scm | 15 +- .../queries/php/highlights.scm | 23 +- .../nvim-treesitter/queries/php/indents.scm | 6 +- .../queries/php/injections.scm | 17 + .../queries/phpdoc/highlights.scm | 2 + .../nvim-treesitter/queries/proto/folds.scm | 5 + .../queries/proto/highlights.scm | 63 +++ .../nvim-treesitter/queries/python/folds.scm | 19 +- .../queries/python/highlights.scm | 29 +- bundle/nvim-treesitter/queries/ql/folds.scm | 7 + .../nvim-treesitter/queries/ql/highlights.scm | 3 +- .../nvim-treesitter/queries/qmljs/folds.scm | 8 + .../queries/qmljs/highlights.scm | 154 ++++++ .../queries/query/highlights.scm | 5 +- .../nvim-treesitter/queries/r/highlights.scm | 5 +- .../nvim-treesitter/queries/racket/folds.scm | 1 + .../queries/racket/highlights.scm | 138 +++++ .../queries/racket/injections.scm | 2 + .../nvim-treesitter/queries/rnoweb/folds.scm | 3 + .../queries/rnoweb/highlights.scm | 2 + .../queries/rnoweb/injections.scm | 7 + .../queries/rst/highlights.scm | 12 +- .../queries/rst/injections.scm | 2 +- .../queries/ruby/highlights.scm | 7 +- .../nvim-treesitter/queries/ruby/indents.scm | 5 +- bundle/nvim-treesitter/queries/rust/folds.scm | 1 - .../queries/rust/highlights.scm | 61 ++- .../nvim-treesitter/queries/rust/indents.scm | 1 - .../nvim-treesitter/queries/rust/locals.scm | 3 +- .../queries/scala/highlights.scm | 8 +- .../queries/scheme/highlights.scm | 9 +- .../queries/scss/highlights.scm | 7 + .../queries/slint/highlights.scm | 31 ++ .../queries/solidity/highlights.scm | 6 +- .../queries/sql/highlights.scm | 183 +++++++ .../queries/sql/injections.scm | 3 + .../queries/swift/highlights.scm | 36 +- .../nvim-treesitter/queries/sxhkdrc/folds.scm | 3 + .../queries/sxhkdrc/highlights.scm | 10 + .../queries/sxhkdrc/injections.scm | 1 + .../queries/teal/highlights.scm | 2 +- .../nvim-treesitter/queries/tiger/folds.scm | 19 + .../queries/tiger/highlights.scm | 125 +++++ .../nvim-treesitter/queries/tiger/indents.scm | 69 +++ .../queries/tiger/injections.scm | 3 + .../nvim-treesitter/queries/tiger/locals.scm | 39 ++ .../queries/tlaplus/highlights.scm | 82 ++- .../queries/tlaplus/locals.scm | 73 ++- .../queries/toml/highlights.scm | 2 +- .../queries/tsx/injections.scm | 2 +- .../queries/twig/highlights.scm | 60 +++ .../queries/twig/injections.scm | 2 + .../queries/typescript/highlights.scm | 5 +- bundle/nvim-treesitter/queries/v/folds.scm | 6 + .../nvim-treesitter/queries/v/highlights.scm | 408 +++++++++++++++ bundle/nvim-treesitter/queries/v/indents.scm | 17 + .../nvim-treesitter/queries/v/injections.scm | 6 + bundle/nvim-treesitter/queries/v/locals.scm | 29 ++ bundle/nvim-treesitter/queries/vala/folds.scm | 12 + .../queries/vala/highlights.scm | 484 ++++++++---------- .../queries/verilog/highlights.scm | 4 +- .../queries/vhs/highlights.scm | 38 ++ bundle/nvim-treesitter/queries/vim/folds.scm | 4 + .../queries/vim/highlights.scm | 72 ++- .../queries/vim/injections.scm | 12 +- .../queries/wgsl/highlights.scm | 2 +- .../nvim-treesitter/queries/wgsl/indents.scm | 19 + bundle/nvim-treesitter/queries/yaml/folds.scm | 3 +- .../queries/yaml/highlights.scm | 9 +- .../nvim-treesitter/queries/yaml/indents.scm | 5 +- .../nvim-treesitter/queries/yang/indents.scm | 10 + .../queries/zig/highlights.scm | 6 +- .../nvim-treesitter/queries/zig/indents.scm | 2 + .../nvim-treesitter/scripts/check-queries.lua | 59 ++- .../scripts/ci-install-macos-latest.sh | 3 +- .../scripts/ci-install-ubuntu-latest.sh | 9 +- .../nvim-treesitter/scripts/minimal_init.lua | 4 +- .../nvim-treesitter/tests/indent/css_spec.lua | 8 +- .../tests/indent/ecma/array-issue3382.js | 2 + .../tests/indent/ecma/new-line-after-class.js | 2 + .../tests/indent/go/const_declaration.go | 7 + .../tests/indent/go/issue-2369-newline.go | 8 + .../tests/indent/go/issue-3288.go | 22 + .../tests/indent/go/multiple-vars.go | 19 + .../nvim-treesitter/tests/indent/go/switch.go | 14 + .../nvim-treesitter/tests/indent/go_spec.lua | 5 +- .../tests/indent/hcl/function_call.tf | 6 + .../indent/hcl/indent-in-multiline-objects.tf | 6 + .../indent/hcl/indent-in-multiline-tuples.tf | 6 + .../tests/indent/hcl/multiline-comments.tf | 7 + .../tests/indent/hcl/multiple-attributes.tf | 4 + .../tests/indent/hcl/multiple-blocks.tf | 6 + .../tests/indent/hcl/nested_blocks.tf | 5 + .../tests/indent/hcl/no-indent-after-brace.tf | 4 + .../nvim-treesitter/tests/indent/hcl_spec.lua | 35 ++ .../tests/indent/javascript_spec.lua | 6 + .../nvim-treesitter/tests/indent/lua/cond.lua | 2 + .../tests/indent/lua/method_index_expr.lua | 3 + .../nvim-treesitter/tests/indent/lua_spec.lua | 4 + .../tests/indent/php/enum-indent.php | 4 + .../tests/indent/php/issue-3591.php | 5 + .../nvim-treesitter/tests/indent/php_spec.lua | 9 +- .../tests/indent/ruby/indent-assignment.rb | 2 + .../tests/indent/ruby/indent-brackets.rb | 5 + .../tests/indent/ruby/indent-parens.rb | 5 + .../ruby/indent-parenthesized-statements.rb | 2 + .../tests/indent/ruby/indent-unless.rb | 2 + .../tests/indent/ruby/period-issue-3364.rb | 7 + .../tests/indent/ruby_spec.lua | 20 + .../tests/indent/rust/if_let_cond.rs | 7 + .../tests/indent/rust_spec.lua | 3 + .../tests/indent/tiger/classes.tig | 14 + .../tests/indent/tiger/control-flow.tig | 22 + .../tests/indent/tiger/functions.tig | 14 + .../tests/indent/tiger/groupings.tig | 10 + .../indent/tiger/values-and-expressions.tig | 30 ++ .../tests/indent/tiger_spec.lua | 138 +++++ .../tests/indent/wgsl/basic.wgsl | 43 ++ .../tests/indent/wgsl_spec.lua | 19 + .../indent/yaml/autoindent-mapping-pair.yaml | 2 + .../indent/yaml/indent-sequence-items.yaml | 2 + .../tests/indent/yaml_spec.lua | 20 + .../tests/indent/zig/pr-3269.zig | 10 + .../nvim-treesitter/tests/indent/zig_spec.lua | 22 + .../cpp/static-namespace-functions.cpp | 6 +- .../tests/query/highlights/cpp/test.cpp | 5 +- .../tests/query/highlights/ecma/test.ts | 11 +- .../gitattributes/test.gitattributes | 37 ++ .../tests/query/highlights/lua/test.lua | 12 +- .../tests/query/highlights/markdown/test.md | 30 +- .../query/highlights/python/future_import.py | 4 + .../query/highlights/python/raise_from.py | 6 + .../tests/query/highlights/rust/for.rs | 15 + .../query/highlights/tiger/built-ins.tig | 44 ++ .../tests/query/highlights/tiger/comment.tig | 6 + .../query/highlights/tiger/functions.tig | 9 + .../query/highlights/tiger/identifiers.tig | 30 ++ .../tests/query/highlights/tiger/imports.tig | 4 + .../tests/query/highlights/tiger/keywords.tig | 42 ++ .../tests/query/highlights/tiger/literals.tig | 9 + .../query/highlights/tiger/meta-variables.tig | 14 + .../highlights/tiger/object-oriented.tig | 29 ++ .../query/highlights/tiger/operators.tig | 49 ++ .../tests/query/highlights/xhp-intro.hack | 2 +- .../tests/query/highlights_spec.lua | 6 +- .../tests/query/injection_spec.lua | 4 +- .../tests/unit/ts_utils_spec.lua | 67 +++ 268 files changed, 6163 insertions(+), 2022 deletions(-) create mode 100644 bundle/nvim-treesitter/contrib/nvim-treesitter-scm-1.rockspec create mode 100644 bundle/nvim-treesitter/lua/nvim-treesitter/statusline.lua create mode 100644 bundle/nvim-treesitter/plugin/nvim-treesitter.lua create mode 100644 bundle/nvim-treesitter/queries/agda/folds.scm create mode 100644 bundle/nvim-treesitter/queries/agda/highlights.scm create mode 100644 bundle/nvim-treesitter/queries/blueprint/highlights.scm create mode 100644 bundle/nvim-treesitter/queries/diff/highlights.scm create mode 100644 bundle/nvim-treesitter/queries/embedded_template/highlights.scm create mode 100644 bundle/nvim-treesitter/queries/embedded_template/injections.scm create mode 100644 bundle/nvim-treesitter/queries/erlang/folds.scm create mode 100644 bundle/nvim-treesitter/queries/erlang/highlights.scm create mode 100644 bundle/nvim-treesitter/queries/git_rebase/highlights.scm create mode 100644 bundle/nvim-treesitter/queries/git_rebase/injections.scm create mode 100644 bundle/nvim-treesitter/queries/gitattributes/highlights.scm create mode 100644 bundle/nvim-treesitter/queries/gitattributes/injections.scm create mode 100644 bundle/nvim-treesitter/queries/gitignore/highlights.scm create mode 100644 bundle/nvim-treesitter/queries/haskell/folds.scm create mode 100644 bundle/nvim-treesitter/queries/hlsl/folds.scm create mode 100644 bundle/nvim-treesitter/queries/hlsl/highlights.scm create mode 100644 bundle/nvim-treesitter/queries/hlsl/indents.scm create mode 100644 bundle/nvim-treesitter/queries/hlsl/injections.scm create mode 100644 bundle/nvim-treesitter/queries/hlsl/locals.scm create mode 100644 bundle/nvim-treesitter/queries/jsonnet/highlights.scm create mode 100644 bundle/nvim-treesitter/queries/jsx/injections.scm create mode 100644 bundle/nvim-treesitter/queries/m68k/folds.scm create mode 100644 bundle/nvim-treesitter/queries/m68k/highlights.scm create mode 100644 bundle/nvim-treesitter/queries/m68k/injections.scm create mode 100644 bundle/nvim-treesitter/queries/m68k/locals.scm create mode 100644 bundle/nvim-treesitter/queries/make/folds.scm create mode 100644 bundle/nvim-treesitter/queries/markdown_inline/highlights.scm create mode 100644 bundle/nvim-treesitter/queries/markdown_inline/injections.scm create mode 100644 bundle/nvim-treesitter/queries/menhir/highlights.scm create mode 100644 bundle/nvim-treesitter/queries/menhir/injections.scm create mode 100644 bundle/nvim-treesitter/queries/meson/folds.scm create mode 100644 bundle/nvim-treesitter/queries/meson/highlights.scm create mode 100644 bundle/nvim-treesitter/queries/meson/injections.scm create mode 100644 bundle/nvim-treesitter/queries/nickel/highlights.scm create mode 100644 bundle/nvim-treesitter/queries/proto/folds.scm create mode 100644 bundle/nvim-treesitter/queries/proto/highlights.scm create mode 100644 bundle/nvim-treesitter/queries/ql/folds.scm create mode 100644 bundle/nvim-treesitter/queries/qmljs/folds.scm create mode 100644 bundle/nvim-treesitter/queries/qmljs/highlights.scm create mode 100644 bundle/nvim-treesitter/queries/racket/folds.scm create mode 100644 bundle/nvim-treesitter/queries/racket/highlights.scm create mode 100644 bundle/nvim-treesitter/queries/racket/injections.scm create mode 100644 bundle/nvim-treesitter/queries/rnoweb/folds.scm create mode 100644 bundle/nvim-treesitter/queries/rnoweb/highlights.scm create mode 100644 bundle/nvim-treesitter/queries/rnoweb/injections.scm create mode 100644 bundle/nvim-treesitter/queries/sql/highlights.scm create mode 100644 bundle/nvim-treesitter/queries/sql/injections.scm create mode 100644 bundle/nvim-treesitter/queries/sxhkdrc/folds.scm create mode 100644 bundle/nvim-treesitter/queries/sxhkdrc/highlights.scm create mode 100644 bundle/nvim-treesitter/queries/sxhkdrc/injections.scm create mode 100644 bundle/nvim-treesitter/queries/tiger/folds.scm create mode 100644 bundle/nvim-treesitter/queries/tiger/highlights.scm create mode 100644 bundle/nvim-treesitter/queries/tiger/indents.scm create mode 100644 bundle/nvim-treesitter/queries/tiger/injections.scm create mode 100644 bundle/nvim-treesitter/queries/tiger/locals.scm create mode 100644 bundle/nvim-treesitter/queries/twig/highlights.scm create mode 100644 bundle/nvim-treesitter/queries/twig/injections.scm create mode 100644 bundle/nvim-treesitter/queries/v/folds.scm create mode 100644 bundle/nvim-treesitter/queries/v/highlights.scm create mode 100644 bundle/nvim-treesitter/queries/v/indents.scm create mode 100644 bundle/nvim-treesitter/queries/v/injections.scm create mode 100644 bundle/nvim-treesitter/queries/v/locals.scm create mode 100644 bundle/nvim-treesitter/queries/vala/folds.scm create mode 100644 bundle/nvim-treesitter/queries/vhs/highlights.scm create mode 100644 bundle/nvim-treesitter/queries/vim/folds.scm create mode 100644 bundle/nvim-treesitter/queries/wgsl/indents.scm create mode 100644 bundle/nvim-treesitter/queries/yang/indents.scm create mode 100644 bundle/nvim-treesitter/tests/indent/ecma/array-issue3382.js create mode 100644 bundle/nvim-treesitter/tests/indent/ecma/new-line-after-class.js create mode 100644 bundle/nvim-treesitter/tests/indent/go/const_declaration.go create mode 100644 bundle/nvim-treesitter/tests/indent/go/issue-2369-newline.go create mode 100644 bundle/nvim-treesitter/tests/indent/go/issue-3288.go create mode 100644 bundle/nvim-treesitter/tests/indent/go/multiple-vars.go create mode 100644 bundle/nvim-treesitter/tests/indent/go/switch.go create mode 100644 bundle/nvim-treesitter/tests/indent/hcl/function_call.tf create mode 100644 bundle/nvim-treesitter/tests/indent/hcl/indent-in-multiline-objects.tf create mode 100644 bundle/nvim-treesitter/tests/indent/hcl/indent-in-multiline-tuples.tf create mode 100644 bundle/nvim-treesitter/tests/indent/hcl/multiline-comments.tf create mode 100644 bundle/nvim-treesitter/tests/indent/hcl/multiple-attributes.tf create mode 100644 bundle/nvim-treesitter/tests/indent/hcl/multiple-blocks.tf create mode 100644 bundle/nvim-treesitter/tests/indent/hcl/nested_blocks.tf create mode 100644 bundle/nvim-treesitter/tests/indent/hcl/no-indent-after-brace.tf create mode 100644 bundle/nvim-treesitter/tests/indent/hcl_spec.lua create mode 100644 bundle/nvim-treesitter/tests/indent/lua/method_index_expr.lua create mode 100644 bundle/nvim-treesitter/tests/indent/php/enum-indent.php create mode 100644 bundle/nvim-treesitter/tests/indent/php/issue-3591.php create mode 100644 bundle/nvim-treesitter/tests/indent/ruby/indent-assignment.rb create mode 100644 bundle/nvim-treesitter/tests/indent/ruby/indent-brackets.rb create mode 100644 bundle/nvim-treesitter/tests/indent/ruby/indent-parens.rb create mode 100644 bundle/nvim-treesitter/tests/indent/ruby/indent-parenthesized-statements.rb create mode 100644 bundle/nvim-treesitter/tests/indent/ruby/indent-unless.rb create mode 100644 bundle/nvim-treesitter/tests/indent/ruby/period-issue-3364.rb create mode 100644 bundle/nvim-treesitter/tests/indent/ruby_spec.lua create mode 100644 bundle/nvim-treesitter/tests/indent/rust/if_let_cond.rs create mode 100644 bundle/nvim-treesitter/tests/indent/tiger/classes.tig create mode 100644 bundle/nvim-treesitter/tests/indent/tiger/control-flow.tig create mode 100644 bundle/nvim-treesitter/tests/indent/tiger/functions.tig create mode 100644 bundle/nvim-treesitter/tests/indent/tiger/groupings.tig create mode 100644 bundle/nvim-treesitter/tests/indent/tiger/values-and-expressions.tig create mode 100644 bundle/nvim-treesitter/tests/indent/tiger_spec.lua create mode 100644 bundle/nvim-treesitter/tests/indent/wgsl/basic.wgsl create mode 100644 bundle/nvim-treesitter/tests/indent/wgsl_spec.lua create mode 100644 bundle/nvim-treesitter/tests/indent/yaml/autoindent-mapping-pair.yaml create mode 100644 bundle/nvim-treesitter/tests/indent/yaml/indent-sequence-items.yaml create mode 100644 bundle/nvim-treesitter/tests/indent/yaml_spec.lua create mode 100644 bundle/nvim-treesitter/tests/indent/zig/pr-3269.zig create mode 100644 bundle/nvim-treesitter/tests/indent/zig_spec.lua create mode 100644 bundle/nvim-treesitter/tests/query/highlights/gitattributes/test.gitattributes create mode 100644 bundle/nvim-treesitter/tests/query/highlights/python/future_import.py create mode 100644 bundle/nvim-treesitter/tests/query/highlights/python/raise_from.py create mode 100644 bundle/nvim-treesitter/tests/query/highlights/rust/for.rs create mode 100644 bundle/nvim-treesitter/tests/query/highlights/tiger/built-ins.tig create mode 100644 bundle/nvim-treesitter/tests/query/highlights/tiger/comment.tig create mode 100644 bundle/nvim-treesitter/tests/query/highlights/tiger/functions.tig create mode 100644 bundle/nvim-treesitter/tests/query/highlights/tiger/identifiers.tig create mode 100644 bundle/nvim-treesitter/tests/query/highlights/tiger/imports.tig create mode 100644 bundle/nvim-treesitter/tests/query/highlights/tiger/keywords.tig create mode 100644 bundle/nvim-treesitter/tests/query/highlights/tiger/literals.tig create mode 100644 bundle/nvim-treesitter/tests/query/highlights/tiger/meta-variables.tig create mode 100644 bundle/nvim-treesitter/tests/query/highlights/tiger/object-oriented.tig create mode 100644 bundle/nvim-treesitter/tests/query/highlights/tiger/operators.tig diff --git a/bundle/nvim-treesitter/.github/FUNDING.yml b/bundle/nvim-treesitter/.github/FUNDING.yml index d463c475f..b2844b214 100644 --- a/bundle/nvim-treesitter/.github/FUNDING.yml +++ b/bundle/nvim-treesitter/.github/FUNDING.yml @@ -1 +1,2 @@ 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 6667bd33f..b6c4404fc 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 9b75ab6b0..8d0bb121f 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@1.0.0 + uses: JohnnyMorganz/stylua-action@v1 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 d4ec33052..738bad9a4 100644 --- a/bundle/nvim-treesitter/.github/workflows/test-queries.yml +++ b/bundle/nvim-treesitter/.github/workflows/test-queries.yml @@ -52,7 +52,8 @@ jobs: runs-on: ${{ matrix.os }} env: CC: ${{ matrix.cc }} - NVIM: ${{ matrix.os == 'windows-2022' && 'Neovim\\bin\\nvim.exe' || 'nvim' }} + NVIM: ${{ matrix.os == 'windows-2022' && 'nvim-win64\\bin\\nvim.exe' || 'nvim' }} + ALLOWED_INSTALLATION_FAILURES: ${{ matrix.os == 'windows-2022' && 'rnoweb' }} steps: - uses: actions/checkout@v2 - uses: ilammy/msvc-dev-cmd@v1 @@ -61,7 +62,7 @@ jobs: - name: Install and prepare Neovim env: NVIM_TAG: ${{ matrix.nvim_tag }} - TREE_SITTER_CLI_TAG: v0.20.4 + TREE_SITTER_CLI_TAG: v0.20.6 run: | bash ./scripts/ci-install-${{ matrix.os }}.sh @@ -81,12 +82,5 @@ 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 1b445573e..e8f462119 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.4 + TREE_SITTER_CLI_TAG: v0.20.6 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 47e55ba42..8b328e290 100644 --- a/bundle/nvim-treesitter/.github/workflows/update-lockfile.yml +++ b/bundle/nvim-treesitter/.github/workflows/update-lockfile.yml @@ -6,6 +6,7 @@ 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 dba7ba260..62f8bd4fc 100644 --- a/bundle/nvim-treesitter/.github/workflows/update-readme.yml +++ b/bundle/nvim-treesitter/.github/workflows/update-readme.yml @@ -4,6 +4,7 @@ on: push: branches: - master + workflow_dispatch: jobs: update-readme: diff --git a/bundle/nvim-treesitter/CONTRIBUTING.md b/bundle/nvim-treesitter/CONTRIBUTING.md index b3c51cee5..5a6fd71ec 100644 --- a/bundle/nvim-treesitter/CONTRIBUTING.md +++ b/bundle/nvim-treesitter/CONTRIBUTING.md @@ -89,143 +89,179 @@ effect on highlighting. We will work on improving highlighting in the near futur #### Misc -``` -@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. +```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. `+` / `*`) ``` -#### Constants +#### Punctuation +```scheme +@punctuation.delimiter ; delimiters (e.g. `;` / `.` / `,`) +@punctuation.bracket ; brackets (e.g. `()` / `{}` / `[]`) +@punctuation.special ; special symbols (e.g. `{}` in string interpolation) ``` -@constant -@constant.builtin -@constant.macro -@string -@string.regex -@string.escape -@string.special -@character -@character.special -@number -@boolean -@float + +#### 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 ``` #### Functions -``` -@function -@function.builtin -@function.macro -@parameter +```scheme +@function ; function definitions +@function.builtin ; built-in functions +@function.call ; function calls +@function.macro ; preprocessor macros -@method -@field -@property +@method ; method definitions +@method.call ; method calls -@constructor +@constructor ; constructor calls and definitions +@parameter ; parameters of a function ``` #### Keywords -``` -@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 +```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` -@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 +@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`) ``` -@conceal followed by `(#set! conceal "")` for captures that are not used for highlights but only for concealing. +#### Types -#### Variables +```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`) +@storageclass ; visibility/life-time modifiers +@storageclass.lifetime ; life-time modifiers (e.g. `static`) +@attribute ; attribute annotations (e.g. Python decorators) +@field ; object and struct fields +@property ; similar to `@field` ``` -@variable -@variable.builtin + +#### 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 ``` #### Text Mainly for markup languages. -``` -@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) +```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.note -@text.warning -@text.danger +@text.todo ; todo notes +@text.note ; info notes +@text.warning ; warning notes +@text.danger ; danger/error notes -@todo +@text.diff.add ; added text (for diff files) +@text.diff.delete ; deleted text (for diff files) ``` #### Tags -Used for xml-like tags +Used for XML-like tags. -``` -@tag -@tag.attribute -@tag.delimiter +```scheme +@tag ; XML tag names +@tag.attribute ; XML tag attributes +@tag.delimiter ; XML tag delimiters ``` #### Conceal -@conceal followed by `(#set! conceal "")` for captures that are not used for highlights but only for concealing. + +```scheme +@conceal ; for captures that are only used for concealing +``` + +`@conceal` must be followed by `(#set! conceal "")`. + +#### Spell + +```scheme +@spell ; for defining regions to be spellchecked +``` + +#### Non-standard + +These captures are used by some languages but don't have any default highlights. +They fall back to the parent capture if they are not manually defined. + +```scheme +@variable.global +``` ### Locals -``` -@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 +```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.associated to determine the type of a variable -@definition.doc for documentation adjacent to a definition. E.g. - -@scope -@reference -@constructor +@scope ; scope block +@reference ; identifier reference ``` @@ -259,8 +295,8 @@ Possible scope values are: You can define folds for a given language by adding a `folds.scm` query : -``` -@fold +```scheme +@fold ; fold this node ``` If the `fold.scm` query is not present, this will fallback to the `@scope` captures in the `locals` @@ -274,25 +310,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. -``` -@{language} ; e.g. @html to describe a html region +```scheme +@{lang} ; 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 ; This will 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 ; combine all matches of a pattern as one single block of content ``` ### Indents -``` -@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) +```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) ``` [Zulip]: https://nvim-treesitter.zulipchat.com diff --git a/bundle/nvim-treesitter/README.md b/bundle/nvim-treesitter/README.md index df159b796..7ecaa0e0b 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 latest stable version or [nightly](https://github.com/neovim/neovim#install-from-source) +- **Neovim 0.8.0 or later** built with **tree-sitter 0.20.3+** (latest [nightly](https://github.com/neovim/neovim#install-from-source) recommended) - `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,18 +109,33 @@ 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). @@ -157,10 +172,12 @@ 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) @@ -174,12 +191,14 @@ 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) @@ -187,6 +206,9 @@ 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) @@ -199,17 +221,19 @@ 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/vigoux/tree-sitter-vimdoc) (experimental, maintained by @vigoux) +- [x] [help](https://github.com/neovim/tree-sitter-vimdoc) (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/NTBBloodbath/tree-sitter-http) (maintained by @NTBBloodbath) +- [x] [http](https://github.com/rest-nvim/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) @@ -217,28 +241,38 @@ 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) -- [ ] [markdown](https://github.com/MDeiml/tree-sitter-markdown) +- [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) - [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] [pug](https://github.com/zealot128/tree-sitter-pug) (maintained by @zealot128) +- [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] [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) @@ -248,19 +282,25 @@ 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) -- [ ] [swift](https://github.com/alex-pinkus/tree-sitter-swift) +- [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) - [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] [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] [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] [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) @@ -269,6 +309,7 @@ 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 @@ -294,17 +335,22 @@ require'nvim-treesitter.configs'.setup { } ``` -You can add custom highlight captures with: +To customize the syntax highlighting of a capture, simply define or link a highlight group of the same name: -```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 edb8579e8..4feabb739 100644 --- a/bundle/nvim-treesitter/doc/nvim-treesitter.txt +++ b/bundle/nvim-treesitter/doc/nvim-treesitter.txt @@ -39,12 +39,21 @@ 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" }, @@ -62,6 +71,7 @@ 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. @@ -341,11 +351,6 @@ 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)~ @@ -471,299 +476,6 @@ 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 cc26503f2..fff6e13b4 100644 --- a/bundle/nvim-treesitter/lockfile.json +++ b/bundle/nvim-treesitter/lockfile.json @@ -1,27 +1,33 @@ { + "agda": { + "revision": "80ea622cf952a0059e168e5c92a798b2f1925652" + }, "astro": { - "revision": "6602ccbf9a5f79845dad62f1e118e07f97e3533c" + "revision": "947e93089e60c66e681eba22283f4037841451e7" }, "bash": { - "revision": "275effdfc0edce774acf7d481f9ea195c6c403cd" + "revision": "77cf8a7cab8904baf1a721762e012644ac1d4c7b" }, "beancount": { - "revision": "78b8ddca3ab774573a4e3bf64eabd79e9452cea9" + "revision": "4cbd1f09cd07c1f1fabf867c2cf354f9da53cc4c" }, "bibtex": { "revision": "ccfd77db0ed799b6c22c214fe9d2937f47bc8b34" }, + "blueprint": { + "revision": "6ef91ca8270f0112b9c6d27ecb9966c741a5d103" + }, "c": { - "revision": "e348e8ec5efd3aac020020e4af53d2ff18f393a9" + "revision": "7175a6dd5fc1cee660dce6fe23f6043d75af424a" }, "c_sharp": { - "revision": "5b6ae1f88e741b9ed738891ad1362fb9f2041671" + "revision": "3ef3f7f99e16e528e6689eae44dff35150993307" }, "clojure": { - "revision": "879f0e726295807d917d576fcf9e1e432c4c20fc" + "revision": "087bac78c53fe1387756cd5b8e68a69b3f6d7244" }, "cmake": { - "revision": "5020572408a386d5d2dfac3516584f5edda7a49b" + "revision": "6e51463ef3052dd3b328322c22172eda093727ad" }, "comment": { "revision": "a37ca370310ac6f89b6e0ebf2b86b2219780494e" @@ -33,49 +39,55 @@ "revision": "5e113412aadb78955c27010daa4dbe1d202013cf" }, "cpp": { - "revision": "a832195eb3685a279856bb480ce19cff19554b6d" + "revision": "5ead1e26c6ab71919db0f1880c46a278a93bc5ea" }, "css": { - "revision": "a03f1d2d1dfbf6f8e0fdca5f9ff030228241eb57" + "revision": "769203d0f9abe1a9a691ac2b9fe4bb4397a73c51" }, "cuda": { - "revision": "5178a7a5b25dc7ee4a69bf72f31bd6d3ff0a0795" + "revision": "7f1a79e612160aa02be87f1a24469ae3655fe818" }, "d": { "revision": "c2fbf21bd3aa45495fe13247e040ad5815250032" }, "dart": { - "revision": "6a25376685d1d47968c2cef06d4db8d84a70025e" + "revision": "53485a8f301254e19c518aa20c80f1bcf7cf5c62" }, "devicetree": { - "revision": "877adbfa0174d25894c40fa75ad52d4515a36368" + "revision": "ea30a05d0f0446a96d8b096ad11828ad4f8ad849" + }, + "diff": { + "revision": "330eb648bbc257b4e91621e82a85372be7dde27a" }, "dockerfile": { - "revision": "25c71d6a24cdba8f0c74ef40d4d2d93defd7e196" + "revision": "f913be9bb8689af22114605012693146fbe9ddaa" }, "dot": { - "revision": "917230743aa10f45a408fea2ddb54bbbf5fbe7b7" + "revision": "9ab85550c896d8b294d9b9ca1e30698736f08cea" }, "eex": { "revision": "f742f2fe327463335e8671a87c0b9b396905d1d1" }, "elixir": { - "revision": "1dabc1c790e07115175057863808085ea60dd08a" + "revision": "b20eaa75565243c50be5e35e253d8beb58f45d56" }, "elm": { - "revision": "9835f900e4df40277f0701d1bc0b6cee0853f81b" + "revision": "28bb193640d916dfaf947912c1413cebb0484841" }, "elvish": { - "revision": "e50787cadd3bc54f6d9c0704493a79078bb8a4e5" + "revision": "f32711e31e987fd5c2c002f3daba02f25c68672f" + }, + "embedded_template": { + "revision": "91fc5ae1140d5c9d922312431f7d251a48d7b8ce" }, "erlang": { - "revision": "fab680273af1a8f5cc0c3a0c62cbf5b1bea71f39" + "revision": "3a9c769444f08bbccce03845270efac0c641c5e7" }, "fennel": { - "revision": "d37fd84a702b78ff0282f223ece83c61ab062a6e" + "revision": "517195970428aacca60891b050aa53eabf4ba78d" }, "fish": { - "revision": "d482d70ea8e191c05b2c1b613ed6fdff30a14da0" + "revision": "84436cf24c2b3176bfbb220922a0fdbd0141e406" }, "foam": { "revision": "fdb7f14b885abfc4df57728c9b2a2f2ad24d3cb7" @@ -89,68 +101,80 @@ "gdscript": { "revision": "2a6abdaa47fcb91397e09a97c7433fd995ea46c6" }, + "git_rebase": { + "revision": "127f5b56c1ad3e8a449a7d6e0c7412ead7f7724c" + }, + "gitattributes": { + "revision": "cee9f8865694b29bb9e85e0b90805f92ad3fc47e" + }, + "gitignore": { + "revision": "f4685bf11ac466dd278449bcfe5fd014e94aa504" + }, "gleam": { "revision": "cfcbca3f8f734773878e00d7bfcedea98eb10be2" }, "glimmer": { - "revision": "5caf63ac0e3c549b90c9aeb042871206b4b7bc16" + "revision": "abcc9970da0ed0645741bf52ea70232374bc9e52" }, "glsl": { - "revision": "ffb93961426926554a0ba4a389ea6e9d6fafdea9" + "revision": "a743ada24fa17da9acc5665133f07d56e03530be" }, "go": { - "revision": "c8fed1f0847a65a04a4b8cb7655f5f416e0742ca" + "revision": "05900faa3cdb5d2d8c8bd5e77ee698487e0a8611" }, "godot_resource": { "revision": "b6ef0768711086a86b3297056f9ffb5cc1d77b4a" }, "gomod": { - "revision": "e8f51f8e4363a3d9a427e8f63f4c1bbc5ef5d8d0" + "revision": "4a65743dbc2bb3094114dd2b43da03c820aa5234" }, "gowork": { - "revision": "6dd9dd79fb51e9f2abc829d5e97b15015b6a8ae2" + "revision": "949a8a470559543857a62102c84700d291fc984c" }, "graphql": { "revision": "5e66e961eee421786bdda8495ed1db045e06b5fe" }, "hack": { - "revision": "d434b4e6c9af0524b163d7a912c8ce79d2b1f778" + "revision": "b7bd6928532ada34dddb1dece4a158ab62c6e783" }, "haskell": { - "revision": "ed976b81b00ce7b72b99bca75e7a616cc526220c" + "revision": "bee6b49543e34c2967c6294a4b05e8bd2bf2da59" }, "hcl": { - "revision": "d559c46ba170808b23a73da0cf49f315d221d095" + "revision": "45ce22c16ec924e34517cf785e23c07952e45893" }, "heex": { - "revision": "592e22292a367312c35e13de7fdb888f029981d6" + "revision": "52b804b1cb2d57e58d90090326d3ef9bd19cf16c" }, "help": { - "revision": "41ac50500e68fadc139737bbee2a0618628b822b" + "revision": "49cdef52ded4a886bf34bc474876b09f9270d48f" }, "hjson": { "revision": "02fa3b79b3ff9a296066da6277adfc3f26cbc9e0" }, + "hlsl": { + "revision": "384b26ec65e10f26cf147bfcde772c50ca5ef0d0" + }, "hocon": { - "revision": "bb412e2633f4a3611a4e16efe58d917093bb4782" + "revision": "c390f10519ae69fdb03b3e5764f5592fb6924bcc" }, "html": { - "revision": "161a92474a7bb2e9e830e48e76426f38299d99d1" + "revision": "29f53d8f4f2335e61bf6418ab8958dac3282077a" }, "http": { - "revision": "bfddd16b1cf78e0042fd1f6846a179f76a254e20" + "revision": "30a9c1789d64429a830802cde5b1760ff1064312" }, "java": { - "revision": "881b84fe7078651af5077cc4cea4c85f9fddde3b" + "revision": "09d650def6cdf7f479f4b78f595e9ef5b58ce31e" }, "javascript": { - "revision": "fdeb68ac8d2bd5a78b943528bb68ceda3aade2eb" + "revision": "936d976a782e75395d9b1c8c7c7bf4ba6fe0d86b" }, "jsdoc": { "revision": "189a6a4829beb9cdbe837260653b4a3dfb0cc3db" }, "json": { - "revision": "203e239408d642be83edde8988d6e7b20a19f0e8" + "revision": "73076754005a460947cafe8e03a8cf5fa4fa2938" }, "json5": { "revision": "5dd5cdc418d9659682556b6adca2dd9ace0ac6d2" @@ -158,113 +182,146 @@ "jsonc": { "revision": "02b01653c8a1c198ae7287d566efa86a135b30d5" }, + "jsonnet": { + "revision": "0475a5017ad7dc84845d1d33187f2321abcb261d" + }, "julia": { - "revision": "12ea597262125fc22fd2e91aa953ac69b19c26ca" + "revision": "58d0701550b4cce02acf433eedada03b634cc524" }, "kotlin": { - "revision": "a4f71eb9b8c9b19ded3e0e9470be4b1b77c2b569" + "revision": "b953dbdd05257fcb2b64bc4d9c1578fac12e3c28" }, "lalrpop": { "revision": "7744b56f03ac1e5643fad23c9dd90837fe97291e" }, "latex": { - "revision": "ab9c1c59de5da1a8d8c629c81d856a6378b6f116" + "revision": "8c75e93cd08ccb7ce1ccab22c1fbd6360e3bcea6" }, "ledger": { - "revision": "1050a25df55a62878102d10e524b5184b316b7ad" + "revision": "47b8971448ce5e9abac865f450c1b14fb3b6eee9" }, "llvm": { "revision": "e9948edc41e9e5869af99dddb2b5ff5cc5581af6" }, "lua": { - "revision": "2b4ffd5a5ffd0c6b4c84f0d9e003050a70db2a37" + "revision": "fb30e8cb605e2ebd6c643e6981325a63fbbde320" + }, + "m68k": { + "revision": "d097b123f19c6eaba2bf181c05420d88b9fc489d" }, "make": { "revision": "a4b9187417d6be349ee5fd4b6e77b4172c6827dd" }, "markdown": { - "revision": "d24196f9b3e5af6fcb2ec2a0b6cbc5c06f58b85e" + "revision": "272e080bca0efd19a06a7f4252d746417224959e" + }, + "markdown_inline": { + "revision": "272e080bca0efd19a06a7f4252d746417224959e" + }, + "menhir": { + "revision": "db7953acb0d5551f207373c81fa07a57d7b085cb" + }, + "meson": { + "revision": "153d22588fb5c1eee16a165a084f9ea30f29d941" + }, + "nickel": { + "revision": "9d83db400b6c11260b9106f131f93ddda8131933" }, "ninja": { "revision": "0a95cfdc0745b6ae82f60d3a339b37f19b7b9267" }, "nix": { - "revision": "6d6aaa50793b8265b6a8b6628577a0083d3b923d" + "revision": "6b71a810c0acd49b980c50fc79092561f7cee307" }, "norg": { - "revision": "17d61df817c1e0a9cdef8d915d4e4c556b7cf68c" + "revision": "dfac5ad2740a79b18ae849590a924e7bad3f1b23" }, "ocaml": { - "revision": "23d419ba45789c5a47d31448061557716b02750a" + "revision": "cc26b1ef111100f26a137bcbcd39fd4e35be9a59" }, "ocaml_interface": { - "revision": "23d419ba45789c5a47d31448061557716b02750a" + "revision": "cc26b1ef111100f26a137bcbcd39fd4e35be9a59" }, "ocamllex": { "revision": "ac1d5957e719d49bd6acd27439b79843e4daf8ed" }, + "org": { + "revision": "081179c52b3e8175af62b9b91dc099d010c38770" + }, "pascal": { "revision": "2fd40f477d3e2794af152618ccfac8d92eb72a66" }, "perl": { - "revision": "bbf86084d9b7eb4768f3fb9fe094b3e0600057b1" + "revision": "749d26fe13fb131b92e6515416096e572575b981" }, "php": { - "revision": "3c17a28da38afac41332d3ce79bbd8951867f346" + "revision": "ab2e72179ceb8bb0b249c8ac9162a148e911b3dc" }, "phpdoc": { - "revision": "d9150d4cb5941f6ff10adba89bfa1f11f4b05b37" + "revision": "2f4d16c861b5a454b577d057f247f9902d7b47f5" }, "pioasm": { "revision": "924aadaf5dea2a6074d72027b064f939acf32e20" }, "prisma": { - "revision": "bf0833cbedb2c5b39250f5ba900f1239a16c6749" + "revision": "17a59236ac25413b81b1613ea6ba5d8d52d7cd6c" + }, + "proto": { + "revision": "42d82fa18f8afe59b5fc0b16c207ee4f84cb185f" }, "pug": { - "revision": "5875f9a7d94836708119b0a1102bb5792e8bf673" + "revision": "63e214905970e75f065688b1e8aa90823c3aacdc" }, "python": { - "revision": "78c4e9b6b2f08e1be23b541ffced47b15e2972ad" + "revision": "b14614e2144b8f9ee54deed5a24f3c6f51f9ffa8" }, "ql": { - "revision": "8e7fd7e638d4a0ec7a792ee16b19dbc6407aa810" + "revision": "bd087020f0d8c183080ca615d38de0ec827aeeaf" + }, + "qmljs": { + "revision": "0b2b25bcaa7d4925d5f0dda16f6a99c588a437f1" }, "query": { - "revision": "5217c6805c09f8fc00ed13d17d5fcb791437aee6" + "revision": "0695cd0760532de7b54f23c667d459b5d1332b44" }, "r": { - "revision": "cc04302e1bff76fa02e129f332f44636813b0c3c" + "revision": "80efda55672d1293aa738f956c7ae384ecdc31b4" + }, + "racket": { + "revision": "09cb27a06415bce529a26774a842f5a80d50d362" }, "rasi": { - "revision": "e2961f02244c068a67549adf896b0779e4a29516" + "revision": "12391343979463a2484e6353e5afb6dcb8c31e8b" }, "regex": { "revision": "e1cfca3c79896ff79842f057ea13e529b66af636" }, "rego": { - "revision": "858ca3013da4d50ea1bdb32162a2bfb43641b422" + "revision": "6d70da3a998fd0081efc5d1019c71e74cc1568e9" + }, + "rnoweb": { + "revision": "502c1126dc6777f09af5bef16e72a42f75bd081e" }, "rst": { - "revision": "b74770c0166f28c1a0ab293513a78712ca1c338b" + "revision": "25e6328872ac3a764ba8b926aea12719741103f1" }, "ruby": { - "revision": "0b107de5415e7470a30ef1a390d9db3306432bdb" + "revision": "c91960320d0f337bdd48308a8ad5500bd2616979" }, "rust": { - "revision": "0509e440ae042db6483984b3a56b3c5f24b5d9b9" + "revision": "0431a2c60828731f27491ee9fdefe25e250ce9c9" }, "scala": { - "revision": "ec6047f531e7d4c13787d4ff208b94a84de34165" + "revision": "140c96cf398693189d4e50f76d19ddfcd8a018f8" }, "scheme": { - "revision": "a1d2233f4e5498bb305858323c93525e1dd165c0" + "revision": "bdcd2c8496701153506a9e3e1b76dfed852873ba" }, "scss": { "revision": "c478c6868648eff49eb04a4df90d703dc45b312a" }, "slint": { - "revision": "0d4dda94f96623302dfc234e06be62a5717f47da" + "revision": "d422300f5d6ccce8f9a617dfed57aafb636fadb2" }, "solidity": { "revision": "52ed0880c0126df2f2c7693f215fe6f38e4a2e0a" @@ -272,23 +329,32 @@ "sparql": { "revision": "05f949d3c1c15e3261473a244d3ce87777374dec" }, + "sql": { + "revision": "70c50264ae022193adb364ffa7a767d765ed9857" + }, "supercollider": { - "revision": "0f0e5b5a96dd3e048a9c3db648ed969c44068bff" + "revision": "90c6d9f777d2b8c4ce497c48b5f270a44bcf3ea0" }, "surface": { "revision": "f4586b35ac8548667a9aaa4eae44456c1f43d032" }, "svelte": { - "revision": "84c90ee15f851e1541c25c86e8a4338f5b4d5af2" + "revision": "52e122ae68b316d3aa960a0a422d3645ba717f42" }, "swift": { - "revision": "897df54ad1b2d103dcab3df94f335fceefa230dc" + "revision": "25f8de356e3c33099ed691bd3b8b5c0fe3a11e15" + }, + "sxhkdrc": { + "revision": "440d5f913d9465c9c776a1bd92334d32febcf065" }, "teal": { - "revision": "fcc5f6f4d194dede4e676834ff28a506e39e17b4" + "revision": "1ae8c68e90523b26b93af56feb7868fe4214e2b2" + }, + "tiger": { + "revision": "eb1d3714998977ae76ca7c6a102b10ee37efc2b5" }, "tlaplus": { - "revision": "dde405e5128c3c47ab8aa014d21b6e5296ca450f" + "revision": "deaf0e5c573ad4e2bbfc9a29abb7b6dcb572556e" }, "todotxt": { "revision": "0207f6a4ab6aeafc4b091914d31d8235049a2578" @@ -297,28 +363,37 @@ "revision": "8bd2056818b21860e3d756b5a58c4f6e05fb744e" }, "tsx": { - "revision": "8e9dba7bd7cf089838a036a98be94db53ba2d0a9" + "revision": "0ab9d99867435a7667c5548a6617a6bf73dbd830" }, "turtle": { "revision": "085437f5cb117703b7f520dd92161140a684f092" }, + "twig": { + "revision": "035f549ec8c043e734f04341d7ccdc669bb2ba91" + }, "typescript": { - "revision": "8e9dba7bd7cf089838a036a98be94db53ba2d0a9" + "revision": "0ab9d99867435a7667c5548a6617a6bf73dbd830" + }, + "v": { + "revision": "66b92a89ef1e149300df79c0b2a934ad959c8eec" }, "vala": { - "revision": "31a08784cc74b61cb10c5d8314cf8a8aa98aa9a8" + "revision": "8f690bfa639f2b83d1fb938ed3dd98a7ba453e8b" }, "verilog": { - "revision": "8f6b1f357d1231c420404b5f7a368a73c25adfa2" + "revision": "4457145e795b363f072463e697dfe2f6973c9a52" + }, + "vhs": { + "revision": "2f87b9d973597e69552ecf6a4fe16470fbd8c44e" }, "vim": { - "revision": "68f7cacfd9ae4698181511c9fdd6641bc25a260b" + "revision": "4ae7bd67706d7e10afed827ce2ded884ab41650f" }, "vue": { "revision": "91fe2754796cd8fba5f229505a23fa08f3546c06" }, "wgsl": { - "revision": "5ca98b174f7dddf69fb7a80c54d49badd1f1f8c4" + "revision": "af16e7d9e230004888fb52d33599ad38b4cf6052" }, "yaml": { "revision": "0e36bed171768908f331ff7dff9d956bae016efb" @@ -327,6 +402,6 @@ "revision": "8e9d175982afcefa3dac8ca20d40d1643accd2bd" }, "zig": { - "revision": "4cff36421dae9c05388b86cd64d2bab4b9ed6676" + "revision": "d90d38d28ce8cc27bfea8b4e0c75211e9e2398ca" } } diff --git a/bundle/nvim-treesitter/lua/nvim-treesitter.lua b/bundle/nvim-treesitter/lua/nvim-treesitter.lua index af46bd017..963fe7309 100644 --- a/bundle/nvim-treesitter/lua/nvim-treesitter.lua +++ b/bundle/nvim-treesitter/lua/nvim-treesitter.lua @@ -1,13 +1,8 @@ -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 parsers = require "nvim-treesitter.parsers" +local statusline = require "nvim-treesitter.statusline" -- Registers all query predicates require "nvim-treesitter.query_predicates" @@ -21,68 +16,7 @@ function M.setup() configs.init() end -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 +M.define_modules = configs.define_modules +M.statusline = statusline.statusline return M diff --git a/bundle/nvim-treesitter/lua/nvim-treesitter/configs.lua b/bundle/nvim-treesitter/lua/nvim-treesitter/configs.lua index d4aa98e89..6db2935a0 100644 --- a/bundle/nvim-treesitter/lua/nvim-treesitter/configs.lua +++ b/bundle/nvim-treesitter/lua/nvim-treesitter/configs.lua @@ -8,17 +8,40 @@ 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", @@ -52,7 +75,9 @@ 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. +---Resolves a module by requiring the `module_path` or using the module definition. +---@param mod_name string +---@return TSModule|nil local function resolve_module(mod_name) local config_mod = M.get_module(mod_name) @@ -67,10 +92,10 @@ local function resolve_module(mod_name) end end --- 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 +---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 local function enable_module(mod, bufnr, lang) local module = M.get_module(mod) if not module then @@ -91,24 +116,29 @@ 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 path to module +---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 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 - local cmd = string.format("lua require'nvim-treesitter.configs'.reattach_module('%s')", mod) - api.nvim_command(string.format("autocmd NvimTreesitter FileType * %s", cmd)) + 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", + }) 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 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 string path to module local function enable_all(mod) local config_mod = M.get_module(mod) if not config_mod then @@ -124,9 +154,9 @@ local function enable_all(mod) end end --- Disables and detaches the module for a buffer. --- @param mod path to module --- @param bufnr buffer number, defaults to current buffer +---Disables and detaches the module for a buffer. +---@param mod string path to module +---@param bufnr integer buffer number, defaults to current buffer local function disable_module(mod, bufnr) local module = M.get_module(mod) if not module then @@ -140,23 +170,21 @@ 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 path to module +---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 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 - -- TODO(kyazdani): detach the correct autocmd... doesn't work when using %s, cmd. - -- This will remove all autocomands! - api.nvim_command "autocmd! NvimTreesitter FileType *" + api.nvim_clear_autocmds { event = "FileType", group = "NvimTreesitter-" .. mod } 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 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 string path to module local function disable_all(mod) local config_mod = M.get_module(mod) if not config_mod then @@ -172,10 +200,10 @@ local function disable_all(mod) end end --- 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 +---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 local function toggle_module(mod, bufnr, lang) bufnr = bufnr or api.nvim_get_current_buf() lang = lang or parsers.get_buf_lang(bufnr) @@ -202,10 +230,10 @@ local function toggle_all(mod) end end --- 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 +---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 local function recurse_modules(accumulator, root, path) root = root or config.modules @@ -220,9 +248,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) @@ -237,29 +265,8 @@ local function config_info(process_function) print(vim.inspect(config, { process = process_function })) end -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 - +---@param query_group string +---@param lang string 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) @@ -277,6 +284,8 @@ 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) @@ -358,11 +367,11 @@ M.commands = { }, } --- @param mod: module (string) --- @param lang: the language of the buffer (string) --- @param bufnr: the bufnr (number) +---@param mod string module +---@param lang string the language of the buffer +---@param bufnr integer the bufnr function M.is_enabled(mod, lang, bufnr) - if not parsers.list[lang] or not parsers.has_parser(lang) then + if not parsers.has_parser(lang) then return false end @@ -394,11 +403,20 @@ function M.is_enabled(mod, lang, bufnr) return true end --- Setup call for users to override module configurations. --- @param user_data module overrides +---Setup call for users to override module configurations. +---@param user_data TSConfig 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 @@ -410,6 +428,7 @@ 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) @@ -419,32 +438,33 @@ 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 --- } --- } +---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[] function M.define_modules(mod_defs) if not is_initialized then table.insert(queued_modules_defs, mod_defs) @@ -471,10 +491,10 @@ function M.define_modules(mod_defs) end end --- Attaches a module to a buffer --- @param mod_name the module name --- @param bufnr the bufnr --- @param lang the language of the buffer +---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 function M.attach_module(mod_name, bufnr, lang) bufnr = bufnr or api.nvim_get_current_buf() lang = lang or parsers.get_buf_lang(bufnr) @@ -486,9 +506,9 @@ function M.attach_module(mod_name, bufnr, lang) end end --- Detaches a module to a buffer --- @param mod_name the module name --- @param bufnr the bufnr +---Detaches a module to a buffer +---@param mod_name string the module name +---@param bufnr integer the bufnr function M.detach_module(mod_name, bufnr) local resolved_mod = resolve_module(mod_name) bufnr = bufnr or api.nvim_get_current_buf() @@ -499,17 +519,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 the module name --- @param bufnr the bufnr --- @param lang the language of the buffer +---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 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 root table to find modules +---Gets available modules +---@param root {[string]:TSModule} table to find modules function M.available_modules(root) local modules = {} @@ -520,25 +540,26 @@ function M.available_modules(root) return modules end --- Gets a module config by path --- @param mod_path path to the module --- @returns the module or nil +---Gets a module config by path +---@param mod_path string path to the module +---@return TSModule|nil 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 the module table +---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 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) @@ -548,6 +569,39 @@ 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 @@ -556,4 +610,8 @@ 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 01a7c08e9..50272622f 100644 --- a/bundle/nvim-treesitter/lua/nvim-treesitter/fold.lua +++ b/bundle/nvim-treesitter/lua/nvim-treesitter/fold.lua @@ -39,8 +39,13 @@ local folds_levels = tsutils.memoize_by_buf_tick(function(bufnr) local min_fold_lines = api.nvim_win_get_option(0, "foldminlines") - for _, node in ipairs(matches) do - local start, _, stop, stop_col = node.node:range() + 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 if stop_col == 0 then stop = stop - 1 @@ -97,6 +102,8 @@ 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 8cbe0db1c..e308889c4 100644 --- a/bundle/nvim-treesitter/lua/nvim-treesitter/health.lua +++ b/bundle/nvim-treesitter/lua/nvim-treesitter/health.lua @@ -7,25 +7,26 @@ local shell = require "nvim-treesitter.shell_command_selectors" local install = require "nvim-treesitter.install" local utils = require "nvim-treesitter.utils" -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 health = vim.health or require "health" local M = {} local NVIM_TREESITTER_MINIMUM_ABI = 13 local function install_health() - health_start "Installation" + health.report_start "Installation" + + if fn.has "nvim-0.7" == 0 then + health.report_error "Nvim-treesitter requires Neovim 0.7.0+" + end if fn.executable "tree-sitter" == 0 then - health_warn( + health.report_warn( "`tree-sitter` executable not found (parser generator, only needed for :TSInstallFromGrammar," .. " not required for :TSInstall)" ) else - health_ok( + health.report_ok( "`tree-sitter` found " .. (utils.ts_cli_version() or "(unknown version)") .. " (parser generator, only needed for :TSInstallFromGrammar)" @@ -33,7 +34,7 @@ local function install_health() end if fn.executable "node" == 0 then - health_warn( + health.report_warn( "`node` executable not found (only needed for :TSInstallFromGrammar," .. " not required for :TSInstall)" ) else @@ -41,21 +42,21 @@ local function install_health() local result = handle:read "*a" handle:close() local version = vim.split(result, "\n")[1] - health_ok("`node` found " .. version .. " (only needed for :TSInstallFromGrammar)") + health.report_ok("`node` found " .. version .. " (only needed for :TSInstallFromGrammar)") end if fn.executable "git" == 0 then - health_error("`git` executable not found.", { + health.report_error("`git` executable not found.", { "Install it with your package manager.", "Check that your `$PATH` is set correctly.", }) else - health_ok "`git` executable found." + health.report_ok "`git` executable found." end local cc = shell.select_executable(install.compilers) if not cc then - health_error("`cc` executable not found.", { + health.report_error("`cc` executable not found.", { "Check that any of " .. vim.inspect(install.compilers) .. " is in your $PATH" @@ -63,7 +64,7 @@ local function install_health() }) else local version = vim.fn.systemlist(cc .. (cc == "cl" and "" or " --version"))[1] - health_ok( + health.report_ok( "`" .. cc .. "` executable found. Selected from " @@ -73,7 +74,7 @@ local function install_health() end if vim.treesitter.language_version then if vim.treesitter.language_version >= NVIM_TREESITTER_MINIMUM_ABI then - health_ok( + health.report_ok( "Neovim was compiled with tree-sitter runtime ABI version " .. vim.treesitter.language_version .. " (required >=" @@ -81,7 +82,7 @@ local function install_health() .. "). Parsers must be compatible with runtime ABI." ) else - health_error( + health.report_error( "Neovim was compiled with tree-sitter runtime ABI version " .. vim.treesitter.language_version .. ".\n" @@ -127,7 +128,7 @@ function M.check() table.insert(error_collection, { parser_name, query_group, err }) end end - table.insert(parser_installation, out) + table.insert(parser_installation, vim.fn.trim(out, " ", 2)) end end local legend = [[ @@ -137,9 +138,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_start(table.concat(parser_installation, "\n")) + health.report_start(table.concat(parser_installation, "\n")) if #error_collection > 0 then - health_start "The following errors have been detected:" + health.report_start "The following errors have been detected:" for _, p in ipairs(error_collection) do local lang, type, err = unpack(p) local lines = {} @@ -160,7 +161,7 @@ function M.check() end end end - health_error(table.concat(lines, "\n")) + health.report_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 caca7ee00..5f7dead61 100644 --- a/bundle/nvim-treesitter/lua/nvim-treesitter/highlight.lua +++ b/bundle/nvim-treesitter/lua/nvim-treesitter/highlight.lua @@ -6,115 +6,9 @@ local configs = require "nvim-treesitter.configs" local M = {} -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" - +---@param config table +---@param lang string +---@return boolean local function should_enable_vim_regex(config, lang) local additional_hl = config.additional_vim_regex_highlighting local is_table = type(additional_hl) == "table" @@ -122,38 +16,39 @@ 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 should_enable_vim_regex(config, lang) then + if config and 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 857f4a482..5deaaf84e 100644 --- a/bundle/nvim-treesitter/lua/nvim-treesitter/incremental_selection.lua +++ b/bundle/nvim-treesitter/lua/nvim-treesitter/incremental_selection.lua @@ -120,17 +120,33 @@ 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 - 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 }) + vim.keymap.set( + mode, + mapping, + rhs, + { buffer = bufnr, silent = true, noremap = true, desc = FUNCTION_DESCRIPTIONS[funcname] } + ) end end @@ -138,9 +154,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 - api.nvim_buf_del_keymap(bufnr, "n", mapping) + vim.keymap.del("n", mapping, { buffer = bufnr }) else - api.nvim_buf_del_keymap(bufnr, "x", mapping) + vim.keymap.del("x", mapping, { buffer = bufnr }) end end end diff --git a/bundle/nvim-treesitter/lua/nvim-treesitter/indent.lua b/bundle/nvim-treesitter/lua/nvim-treesitter/indent.lua index de165904e..0eac0a911 100644 --- a/bundle/nvim-treesitter/lua/nvim-treesitter/indent.lua +++ b/bundle/nvim-treesitter/lua/nvim-treesitter/indent.lua @@ -149,12 +149,19 @@ 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 - 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 + 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) + ) then indent = indent + indent_size is_processed = true @@ -195,7 +202,6 @@ 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 ed5a90b8d..eaeb9751c 100644 --- a/bundle/nvim-treesitter/lua/nvim-treesitter/info.lua +++ b/bundle/nvim-treesitter/lua/nvim-treesitter/info.lua @@ -14,11 +14,13 @@ local function install_info() local parser_list = parsers.available_parsers() table.sort(parser_list) - 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)) + 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)) 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 @@ -115,21 +117,24 @@ local function print_info_modules(parserlist, module) api.nvim_buf_set_option(curbuf, "modified", false) api.nvim_buf_set_option(curbuf, "buftype", "nofile") - 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 - ) + 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 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 b65c4b3f0..48810b1e2 100644 --- a/bundle/nvim-treesitter/lua/nvim-treesitter/install.lua +++ b/bundle/nvim-treesitter/lua/nvim-treesitter/install.lua @@ -42,11 +42,14 @@ 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 - return error("Parser not available for language " .. lang) + error('Parser not available for language "' .. lang .. '"') end local install_info = parser_config.install_info @@ -79,30 +82,39 @@ 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(utils.get_parser_info_dir(), lang .. ".revision") + local lang_file = utils.join_path(configs.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(err, data) + return function(_, data) if data then if is_stderr then complete_error_output[handle] = (complete_error_output[handle] or "") .. data @@ -147,6 +159,7 @@ 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, @@ -225,6 +238,12 @@ 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() @@ -242,10 +261,14 @@ 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 = string.gsub(repo.location or project_name, "/", path_sep) - compile_location = cache_folder .. path_sep .. repo_location + 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) end - local parser_lib_name = install_folder .. path_sep .. lang .. ".so" + local parser_lib_name = utils.join_path(install_folder, lang) .. ".so" generate_from_grammar = repo.requires_generate_from_grammar or generate_from_grammar @@ -329,7 +352,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(utils.get_parser_info_dir(), lang .. ".revision")) + vim.fn.writefile({ revision or "" }, utils.join_path(configs.get_parser_info_dir(), lang .. ".revision")) end, }, { -- auto-attach modules after installation @@ -357,6 +380,12 @@ 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 @@ -370,11 +399,22 @@ local function install_lang(lang, ask_reinstall, cache_folder, install_folder, w end end - local install_info = get_parser_install_info(lang, true) + 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 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 @@ -391,20 +431,20 @@ local function install(options) if err then return api.nvim_err_writeln(err) end + assert(cache_folder) - local install_folder, err = utils.get_parser_install_dir() + local install_folder + install_folder, err = configs.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 @@ -424,6 +464,18 @@ 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(...) @@ -462,37 +514,67 @@ function M.update(options) end function M.uninstall(...) - local path_sep = "/" - if fn.has "win32" == 1 then - path_sep = "\\" - end - - if vim.tbl_contains({ "all", "maintained" }, ...) then + if vim.tbl_contains({ "all" }, ...) 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 = utils.get_parser_install_dir() + local install_dir, err = configs.get_parser_install_dir() if err then return api.nvim_err_writeln(err) end - local parser_lib = install_dir .. path_sep .. lang .. ".so" + 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 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") + 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 end end end diff --git a/bundle/nvim-treesitter/lua/nvim-treesitter/locals.lua b/bundle/nvim-treesitter/lua/nvim-treesitter/locals.lua index e0da2d02e..dcfba2683 100644 --- a/bundle/nvim-treesitter/lua/nvim-treesitter/locals.lua +++ b/bundle/nvim-treesitter/lua/nvim-treesitter/locals.lua @@ -4,6 +4,7 @@ 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 = {} @@ -162,7 +163,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_utils.get_node_text(node_entry.node, bufnr)[1] + local node_text = ts_query.get_node_text(node_entry.node, bufnr) local id = M.get_definition_id(scope, node_text) result[id] = node_entry @@ -210,7 +211,7 @@ end function M.find_definition(node, bufnr) local def_lookup = M.get_definitions_lookup_table(bufnr) - local node_text = ts_utils.get_node_text(node, bufnr)[1] + local node_text = ts_query.get_node_text(node, bufnr) for scope in M.iter_scope_tree(node, bufnr) do local id = M.get_definition_id(scope, node_text) @@ -231,7 +232,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_utils.get_node_text(node, bufnr)[1] + local node_text = ts_query.get_node_text(node, bufnr) if not node_text or #node_text < 1 then return {} @@ -244,7 +245,7 @@ function M.find_usages(node, scope_node, bufnr) if match.reference and match.reference.node - and ts_utils.get_node_text(match.reference.node, bufnr)[1] == node_text + and ts_query.get_node_text(match.reference.node, bufnr) == 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 07332d7c0..6d444cde1 100644 --- a/bundle/nvim-treesitter/lua/nvim-treesitter/parsers.lua +++ b/bundle/nvim-treesitter/lua/nvim-treesitter/parsers.lua @@ -17,8 +17,26 @@ 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( @@ -43,6 +61,46 @@ 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", @@ -77,6 +135,14 @@ 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", @@ -133,6 +199,15 @@ 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", @@ -312,6 +387,14 @@ 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", @@ -389,7 +472,7 @@ list.ocaml = { install_info = { url = "https://github.com/tree-sitter/tree-sitter-ocaml", files = { "src/parser.c", "src/scanner.cc" }, - location = "tree-sitter-ocaml/ocaml", + location = "ocaml", }, maintainers = { "@undu" }, } @@ -398,7 +481,7 @@ list.ocaml_interface = { install_info = { url = "https://github.com/tree-sitter/tree-sitter-ocaml", files = { "src/parser.c", "src/scanner.cc" }, - location = "tree-sitter-ocaml_interface/interface", + location = "interface", }, maintainers = { "@undu" }, filetype = "ocamlinterface", @@ -413,13 +496,31 @@ 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 = { @@ -446,7 +547,7 @@ list.typescript = { install_info = { url = "https://github.com/tree-sitter/tree-sitter-typescript", files = { "src/parser.c", "src/scanner.c" }, - location = "tree-sitter-typescript/typescript", + location = "typescript", generate_requires_npm = true, }, maintainers = { "@steelsojka" }, @@ -456,7 +557,7 @@ list.tsx = { install_info = { url = "https://github.com/tree-sitter/tree-sitter-typescript", files = { "src/parser.c", "src/scanner.c" }, - location = "tree-sitter-tsx/tsx", + location = "tsx", generate_requires_npm = true, }, filetype = "typescriptreact", @@ -511,9 +612,24 @@ 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 = "main", + branch = "split_parser", + readme_name = "markdown (basic highlighting)", }, + maintainers = { "@MDeiml" }, + experimental = true, +} + +list.markdown_inline = { + install_info = { + url = "https://github.com/MDeiml/tree-sitter-markdown", + location = "tree-sitter-markdown-inline", + files = { "src/parser.c", "src/scanner.cc" }, + branch = "split_parser", + readme_name = "markdown_inline (needs to be installed for full markdown highlighting)", + }, + maintainers = { "@MDeiml" }, experimental = true, } @@ -553,6 +669,7 @@ list.pug = { }, maintainers = { "@zealot128" }, filetype = "pug", + experimental = true, } list.vue = { @@ -662,8 +779,6 @@ 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 = { @@ -679,8 +794,6 @@ 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" }, @@ -729,6 +842,14 @@ 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", @@ -781,7 +902,7 @@ list.svelte = { list.r = { install_info = { url = "https://github.com/r-lib/tree-sitter-r", - files = { "src/parser.c" }, + files = { "src/parser.c", "src/scanner.cc" }, }, maintainers = { "@jimhester" }, } @@ -789,12 +910,21 @@ list.r = { list.beancount = { install_info = { url = "https://github.com/polarmutex/tree-sitter-beancount", - files = { "src/parser.c" }, + files = { "src/parser.c", "src/scanner.cc" }, 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", @@ -849,12 +979,11 @@ list.vim = { list.help = { install_info = { - url = "https://github.com/vigoux/tree-sitter-vimdoc", - files = { "src/parser.c", "src/scanner.c" }, + url = "https://github.com/neovim/tree-sitter-vimdoc", + files = { "src/parser.c" }, }, filetype = "help", maintainers = { "@vigoux" }, - experimental = true, } list.json5 = { @@ -904,7 +1033,7 @@ list.llvm = { list.http = { install_info = { - url = "https://github.com/NTBBloodbath/tree-sitter-http", + url = "https://github.com/rest-nvim/tree-sitter-http", branch = "main", files = { "src/parser.c" }, generate_requires_npm = true, @@ -973,11 +1102,11 @@ list.norg = { list.vala = { install_info = { - url = "https://github.com/matbme/tree-sitter-vala", - branch = "main", - files = { "src/parser.c", "src/scanner.cc" }, + url = "https://github.com/vala-lang/tree-sitter-vala", + branch = "master", + files = { "src/parser.c" }, }, - maintainers = { "@matbme" }, + maintainers = { "@Prince781", "@vala-lang" }, } list.lalrpop = { @@ -1034,6 +1163,136 @@ 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, @@ -1059,19 +1318,6 @@ 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 bad1c27e6..bc80d51e6 100644 --- a/bundle/nvim-treesitter/lua/nvim-treesitter/query.lua +++ b/bundle/nvim-treesitter/lua/nvim-treesitter/query.lua @@ -11,8 +11,10 @@ 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. +--- Creates a function that checks whether a given query exists +--- for a specific language. +---@param query string +---@return function(string): boolean local function get_query_guard(query) return function(lang) return M.has_query_files(lang, query) @@ -23,6 +25,7 @@ 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 = {} @@ -57,11 +60,19 @@ 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] = {} @@ -86,6 +97,8 @@ 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) @@ -98,6 +111,8 @@ 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 @@ -106,14 +121,14 @@ do end elseif lang and not query_name then query_files_cache[lang] = nil - for query_name, _ in pairs(cache[lang]) do - M.invalidate_query_cache(lang, query_name) + for query_name0, _ in pairs(cache[lang]) do + M.invalidate_query_cache(lang, query_name0) end elseif not lang and not query_name then query_files_cache = {} - for lang, _ in pairs(cache) do - for query_name, _ in pairs(cache[lang]) do - M.invalidate_query_cache(lang, query_name) + for lang0, _ in pairs(cache) do + for query_name0, _ in pairs(cache[lang0]) do + M.invalidate_query_cache(lang0, query_name0) end end else @@ -123,11 +138,23 @@ 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) @@ -181,6 +208,10 @@ 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) @@ -209,7 +240,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 = matches() + local pattern, match, metadata = matches() if pattern ~= nil then local prepared_match = {} @@ -219,6 +250,8 @@ 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 @@ -247,15 +280,16 @@ 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 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. +---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 function M.get_capture_matches(bufnr, captures, query_group, root, lang) if type(captures) == "string" then captures = { captures } @@ -287,6 +321,7 @@ 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) @@ -334,16 +369,17 @@ function M.find_best_match(bufnr, capture_string, query_group, filter_predicate, return best end --- 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 +---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 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 @@ -358,18 +394,25 @@ 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 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. +---@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. function M.get_capture_matches_recursively(bufnr, capture_or_fn, query_type) - local type_fn = type(capture_or_fn) == "function" and capture_or_fn - or function() + ---@type CaptureResFn + local type_fn + if type(capture_or_fn) == "function" then + type_fn = capture_or_fn + else + type_fn = 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 be713304c..0638b6e79 100644 --- a/bundle/nvim-treesitter/lua/nvim-treesitter/query_predicates.lua +++ b/bundle/nvim-treesitter/lua/nvim-treesitter/query_predicates.lua @@ -128,3 +128,61 @@ 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 e7de09552..59bbb0e41 100644 --- a/bundle/nvim-treesitter/lua/nvim-treesitter/shell_command_selectors.lua +++ b/bundle/nvim-treesitter/lua/nvim-treesitter/shell_command_selectors.lua @@ -49,6 +49,7 @@ 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 @@ -178,11 +179,16 @@ 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...", + info = "Downloading " .. project_name .. "...", err = "Error during download, please verify your internet connection", opts = { args = { @@ -199,7 +205,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...", + info = "Extracting " .. project_name .. "...", err = "Error during tarball extraction.", opts = { args = { @@ -213,7 +219,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 "[^/]-$" .. "-" .. revision), + utils.join_path(project_name .. "-tmp", url:match "[^/]-$" .. "-" .. folder_rev), project_name, cache_folder ), @@ -226,7 +232,7 @@ function M.select_download_commands(repo, project_name, cache_folder, revision, return { { cmd = "git", - info = "Downloading...", + info = "Downloading " .. project_name .. "...", 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 new file mode 100644 index 000000000..82be06537 --- /dev/null +++ b/bundle/nvim-treesitter/lua/nvim-treesitter/statusline.lua @@ -0,0 +1,50 @@ +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 5b7023c57..5994e4bcb 100644 --- a/bundle/nvim-treesitter/lua/nvim-treesitter/ts_utils.lua +++ b/bundle/nvim-treesitter/lua/nvim-treesitter/ts_utils.lua @@ -5,12 +5,8 @@ local utils = require "nvim-treesitter.utils" local M = {} ---- 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() +local function get_node_text(node, bufnr) + bufnr = bufnr or api.nvim_get_current_buf() if not node then return {} end @@ -20,6 +16,9 @@ function M.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 @@ -33,6 +32,37 @@ function M.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 @@ -124,7 +154,7 @@ function M.get_named_children(node) return nodes end -function M.get_node_at_cursor(winnr) +function M.get_node_at_cursor(winnr, ignore_injected_langs) winnr = winnr or 0 local cursor = api.nvim_win_get_cursor(winnr) local cursor_range = { cursor[1] - 1, cursor[2] } @@ -134,7 +164,19 @@ function M.get_node_at_cursor(winnr) if not root_lang_tree then return end - local root = M.get_root_for_position(cursor_range[1], cursor_range[2], root_lang_tree) + + local root + if ignore_injected_langs then + for _, tree in ipairs(root_lang_tree:trees()) do + local tree_root = tree:root() + if tree_root and M.is_in_node_range(tree_root, cursor_range[1], cursor_range[2]) then + root = tree_root + break + end + end + else + root = M.get_root_for_position(cursor_range[1], cursor_range[2], root_lang_tree) + end if not root then return @@ -220,14 +262,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 @@ -326,8 +368,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 = M.get_node_text(node_or_range1) - local text2 = M.get_node_text(node_or_range2) + local text1 = get_node_text(node_or_range1, bufnr) + local text2 = get_node_text(node_or_range2, bufnr) 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 06e0e03fb..156ba9c31 100644 --- a/bundle/nvim-treesitter/lua/nvim-treesitter/utils.lua +++ b/bundle/nvim-treesitter/lua/nvim-treesitter/utils.lua @@ -10,6 +10,28 @@ 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 @@ -48,14 +70,11 @@ end 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, @@ -64,26 +83,32 @@ function M.setup_commands(mod, commands) end end -function M.get_path_sep() - return fn.has "win32" == 1 and "\\" or "/" -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 --- 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) + return dir end + + -- parser_dir exists, use it if it's read/write + if luv.fs_access(dir, "RW") then + return dir + end + + -- parser_dir exists but isn't read/write, give up + return nil, M.join_space(writeable_err, dir, "'") end -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) @@ -101,56 +126,13 @@ function M.get_cache_dir() return "/tmp" end - return nil, join_space("Invalid cache rights,", fn.stdpath "data", "or /tmp should be read/write") + return nil, M.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() - 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" + return M.join_path(fn.stdpath "data", "site") end -- Gets a property at path @@ -224,6 +206,7 @@ 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 new file mode 100644 index 000000000..4ea3925fd --- /dev/null +++ b/bundle/nvim-treesitter/plugin/nvim-treesitter.lua @@ -0,0 +1,34 @@ +-- 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 new file mode 100644 index 000000000..e3258efb9 --- /dev/null +++ b/bundle/nvim-treesitter/queries/agda/folds.scm @@ -0,0 +1,4 @@ +[ + (record) + (module) +] @fold diff --git a/bundle/nvim-treesitter/queries/agda/highlights.scm b/bundle/nvim-treesitter/queries/agda/highlights.scm new file mode 100644 index 000000000..ed208f1b6 --- /dev/null +++ b/bundle/nvim-treesitter/queries/agda/highlights.scm @@ -0,0 +1,82 @@ + +;; 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 f80986f95..d1cdb659d 100644 --- a/bundle/nvim-treesitter/queries/bash/highlights.scm +++ b/bundle/nvim-treesitter/queries/bash/highlights.scm @@ -43,8 +43,9 @@ [ (string) (raw_string) + (ansi_c_string) (heredoc_body) -] @string +] @string @spell (variable_assignment (word) @string) @@ -78,13 +79,14 @@ (special_variable_name) @constant +; trap -l ((word) @constant.builtin - (#match? @constant.builtin "^SIG(INT|TERM|QUIT|TIN|TOU|STP|HUP)$")) + (#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]))?)$")) ((word) @boolean (#match? @boolean "^(true|false)$")) -(comment) @comment +(comment) @comment @spell (test_operator) @string (command_substitution @@ -97,7 +99,7 @@ (function_definition name: (word) @function) -(command_name (word) @function) +(command_name (word) @function.call) ((command_name (word) @function.builtin) (#any-of? @function.builtin @@ -129,3 +131,6 @@ 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 b65ae0115..ffe319500 100644 --- a/bundle/nvim-treesitter/queries/beancount/folds.scm +++ b/bundle/nvim-treesitter/queries/beancount/folds.scm @@ -1,4 +1,4 @@ [ (transaction) - (heading) + (section) ] @fold diff --git a/bundle/nvim-treesitter/queries/blueprint/highlights.scm b/bundle/nvim-treesitter/queries/blueprint/highlights.scm new file mode 100644 index 000000000..3d4b48266 --- /dev/null +++ b/bundle/nvim-treesitter/queries/blueprint/highlights.scm @@ -0,0 +1,57 @@ +(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 2ea07a74a..594826366 100644 --- a/bundle/nvim-treesitter/queries/c/highlights.scm +++ b/bundle/nvim-treesitter/queries/c/highlights.scm @@ -1,4 +1,5 @@ -(identifier) @variable +; Lower priority to prefer @parameter when identifier appears in parameter_declaration. +((identifier) @variable (#set! "priority" 95)) [ "const" @@ -42,10 +43,16 @@ "#elif" "#endif" (preproc_directive) -] @keyword +] @preproc "#include" @include +[ ";" ":" "," ] @punctuation.delimiter + +"..." @punctuation.special + +[ "(" ")" "[" "]" "{" "}"] @punctuation.bracket + [ "=" @@ -63,6 +70,7 @@ ">>" "->" + "." "<" "<=" @@ -89,20 +97,17 @@ "++" ] @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 @@ -120,6 +125,7 @@ (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)) @@ -142,6 +148,9 @@ (case_statement value: (identifier) @constant) +((identifier) @constant.builtin + (#any-of? @constant.builtin "stderr" "stdin" "stdout")) + ;; Preproc def / undef (preproc_def name: (_) @constant) @@ -151,16 +160,16 @@ (#eq? @_u "#undef")) (call_expression - function: (identifier) @function) + function: (identifier) @function.call) (call_expression function: (field_expression - field: (field_identifier) @function)) + field: (field_identifier) @function.call)) (function_declarator declarator: (identifier) @function) (preproc_function_def name: (identifier) @function.macro) -(comment) @comment +(comment) @comment @spell ;; Parameters (parameter_declaration @@ -182,6 +191,7 @@ "_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 fc3600e0e..ca327c596 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)) + name: (identifier) @method.call)) (invocation_expression function: (conditional_access_expression (member_binding_expression - name: (identifier) @method))) + name: (identifier) @method.call))) (namespace_declaration name: [(qualified_name) (identifier)] @namespace) @@ -34,7 +34,7 @@ (identifier) @type) (invocation_expression - (identifier) @method) + (identifier) @method.call) (field_declaration (variable_declaration @@ -74,7 +74,7 @@ (implicit_type) @keyword -(comment) @comment +(comment) @comment @spell (using_directive (identifier) @type) @@ -141,7 +141,7 @@ ; Generic Method invocation with generic type (invocation_expression function: (generic_name - . (identifier) @method)) + . (identifier) @method.call)) (invocation_expression (member_access_expression diff --git a/bundle/nvim-treesitter/queries/clojure/highlights.scm b/bundle/nvim-treesitter/queries/clojure/highlights.scm index d6371c522..3dc12d531 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) + (sym_lit) @function.call) (anon_fn_lit . - (sym_lit) @function) + (sym_lit) @function.call) ; Quoted symbols (quoting_lit @@ -106,7 +106,10 @@ ; Definition functions ((sym_lit) @keyword - (#lua-match? @keyword "^def.*$")) + (#any-of? @keyword + "def" "defonce" "defrecord" "defmacro" "definline" + "defmulti" "defmethod" "defstruct" "defprotocol" + "deftype")) ((sym_lit) @keyword (#eq? @keyword "declare")) ((sym_lit) @keyword.function @@ -278,19 +281,22 @@ ;; >> Context based highlighting -; 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)? - . - (_)) +;; 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)? + ;. + ;(_)) ; Function definitions (list_lit diff --git a/bundle/nvim-treesitter/queries/cmake/highlights.scm b/bundle/nvim-treesitter/queries/cmake/highlights.scm index 18a87c25e..3378480c0 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 +] @comment @spell (normal_command (identifier) @function) @@ -123,3 +123,7 @@ (#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 6c3e043c8..e516c6037 100644 --- a/bundle/nvim-treesitter/queries/comment/highlights.scm +++ b/bundle/nvim-treesitter/queries/comment/highlights.scm @@ -1,3 +1,5 @@ +(_) @spell + [ "(" ")" @@ -7,6 +9,12 @@ (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 8dcbaeff5..fb7ee2e5f 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)) + name: (identifier) @function.call)) (call_expression function: (qualified_identifier name: (qualified_identifier - name: (identifier) @function))) + name: (identifier) @function.call))) (call_expression function: (qualified_identifier name: (qualified_identifier name: (qualified_identifier - name: (identifier) @function)))) + name: (identifier) @function.call)))) (call_expression function: (field_expression - field: (field_identifier) @function)) + field: (field_identifier) @function.call)) ((call_expression function: (identifier) @constructor) @@ -158,27 +158,21 @@ "new" "delete" - ;; these keywords are not supported by the parser - ;"eq" - ;"not_eq" - ; - ;"compl" - ;"and" - ;"or" - ; - ;"bitand" - ;"bitand_eq" - ;"bitor" - ;"bitor_eq" - ;"xor" - ;"xor_eq" + "xor" + "bitand" + "bitor" + "compl" + "not" + "xor_eq" + "and_eq" + "or_eq" + "not_eq" + "and" + "or" ] @keyword.operator -[ - "<=>" - "::" -] @operator +"<=>" @operator -(attribute_declaration) @attribute +"::" @punctuation.delimiter (literal_suffix) @operator diff --git a/bundle/nvim-treesitter/queries/css/highlights.scm b/bundle/nvim-treesitter/queries/css/highlights.scm index d8439d678..18bf7f9b4 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 +(comment) @comment @spell [ (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 404c72afb..7897c4144 100644 --- a/bundle/nvim-treesitter/queries/cuda/highlights.scm +++ b/bundle/nvim-treesitter/queries/cuda/highlights.scm @@ -11,4 +11,5 @@ "__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 new file mode 100644 index 000000000..4b9cbad60 --- /dev/null +++ b/bundle/nvim-treesitter/queries/diff/highlights.scm @@ -0,0 +1,6 @@ +[(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 af1c088c5..2d1840e66 100644 --- a/bundle/nvim-treesitter/queries/dockerfile/highlights.scm +++ b/bundle/nvim-treesitter/queries/dockerfile/highlights.scm @@ -26,7 +26,7 @@ "@" ] @operator -(comment) @comment +(comment) @comment @spell (image_spec (image_tag @@ -47,4 +47,17 @@ ((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 86bb9b303..d8b70a949 100644 --- a/bundle/nvim-treesitter/queries/dot/highlights.scm +++ b/bundle/nvim-treesitter/queries/dot/highlights.scm @@ -1,5 +1,14 @@ (identifier) @type -(keyword) @keyword + +[ + "strict" + "graph" + "digraph" + "subgraph" + "node" + "edge" +] @keyword + (string_literal) @string (number_literal) @number @@ -37,9 +46,10 @@ (identifier) @constant) ) -[ -(comment) -(preproc) -] @comment +(comment) @comment + +(preproc) @preproc + +(comment) @spell (ERROR) @error diff --git a/bundle/nvim-treesitter/queries/ecma/highlights.scm b/bundle/nvim-treesitter/queries/ecma/highlights.scm index 7334bd1e6..aa490b33c 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) + function: (identifier) @function.call) (call_expression function: (member_expression - property: [(property_identifier) (private_property_identifier)] @method)) + property: [(property_identifier) (private_property_identifier)] @method.call)) ; Variables ;---------- @@ -97,22 +97,36 @@ ; Literals ;--------- -(this) @variable.builtin -(super) @variable.builtin - -(true) @boolean -(false) @boolean -(null) @constant.builtin [ -(comment) -(hash_bang_line) -] @comment -(string) @string -(regex) @punctuation.delimiter -(regex_pattern) @string.regex + (this) + (super) +] @variable.builtin + +[ + (true) + (false) +] @boolean + +[ + (null) + (undefined) +] @constant.builtin + +(comment) @comment + +(hash_bang_line) @preproc + +(comment) @spell + +(string) @string @spell (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 ;------------ @@ -122,9 +136,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 55cae9b19..902bf586a 100644 --- a/bundle/nvim-treesitter/queries/ecma/indents.scm +++ b/bundle/nvim-treesitter/queries/ecma/indents.scm @@ -45,6 +45,8 @@ ] @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 f97f9cd2c..6bd5da862 100644 --- a/bundle/nvim-treesitter/queries/ecma/injections.scm +++ b/bundle/nvim-treesitter/queries/ecma/injections.scm @@ -1,4 +1,6 @@ -(comment) @jsdoc +(((comment) @_jsdoc_comment + (#match? @_jsdoc_comment "^/\\*\\*[^\\*].*\\*/")) @jsdoc) + (comment) @comment (call_expression @@ -18,6 +20,8 @@ arguments: ((template_string) @glimmer (#offset! @glimmer 0 1 0 -1))) +((glimmer_template) @glimmer) + ; styled.div`` (call_expression function: (member_expression @@ -56,3 +60,10 @@ (#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 08c9b8e7d..4c035d269 100644 --- a/bundle/nvim-treesitter/queries/ecma/locals.scm +++ b/bundle/nvim-treesitter/queries/ecma/locals.scm @@ -23,7 +23,11 @@ (identifier) @definition.import) (function_declaration - ((identifier) @definition.var) + ((identifier) @definition.function) + (#set! definition.var.scope parent)) + +(method_definition + ((property_identifier) @definition.function) (#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 db9bfbb2d..fdb92ef35 100644 --- a/bundle/nvim-treesitter/queries/elixir/highlights.scm +++ b/bundle/nvim-treesitter/queries/elixir/highlights.scm @@ -30,9 +30,11 @@ ; Comments (comment) @comment +(comment) @spell ; Strings (string) @string +(string) @spell ; Modules (alias) @type @@ -84,13 +86,13 @@ (stab_clause operator: _ @operator) ; Local Function Calls -(call target: (identifier) @function) +(call target: (identifier) @function.call) ; Remote Function Calls (call target: (dot left: [ (atom) @type (_) -] right: (identifier) @function) (arguments)) +] right: (identifier) @function.call) (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 4dba8eecb..ab0ce8c1b 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) +(command head: (identifier) @function.call) ((command head: (identifier) @keyword.return) (#eq? @keyword.return "return")) ((command (identifier) @keyword.operator) @@ -24,7 +24,7 @@ [ "+" "-" "*" "/" "%" "<" "<=""==" "!=" ">" ">=" "s" ">=s" -] @function +] @function.builtin [">" "<" ">>" "<>" "|"] @operator diff --git a/bundle/nvim-treesitter/queries/embedded_template/highlights.scm b/bundle/nvim-treesitter/queries/embedded_template/highlights.scm new file mode 100644 index 000000000..0bf76a7d4 --- /dev/null +++ b/bundle/nvim-treesitter/queries/embedded_template/highlights.scm @@ -0,0 +1,12 @@ +(comment_directive) @comment + +[ + "<%#" + "<%" + "<%=" + "<%_" + "<%-" + "%>" + "-%>" + "_%>" +] @keyword diff --git a/bundle/nvim-treesitter/queries/embedded_template/injections.scm b/bundle/nvim-treesitter/queries/embedded_template/injections.scm new file mode 100644 index 000000000..d55c87e09 --- /dev/null +++ b/bundle/nvim-treesitter/queries/embedded_template/injections.scm @@ -0,0 +1,2 @@ +(content) @html @combined +(code) @ruby @combined diff --git a/bundle/nvim-treesitter/queries/erlang/folds.scm b/bundle/nvim-treesitter/queries/erlang/folds.scm new file mode 100644 index 000000000..39c65c5b2 --- /dev/null +++ b/bundle/nvim-treesitter/queries/erlang/folds.scm @@ -0,0 +1,7 @@ +[ + (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 new file mode 100644 index 000000000..c51019fd5 --- /dev/null +++ b/bundle/nvim-treesitter/queries/erlang/highlights.scm @@ -0,0 +1,104 @@ +;; 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 71c074630..10d54dff7 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) +(command name: (word) @function.call) ; derived from builtin -n (fish 3.2.2) (command @@ -149,11 +149,15 @@ [(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 new file mode 100644 index 000000000..466bd2f16 --- /dev/null +++ b/bundle/nvim-treesitter/queries/git_rebase/highlights.scm @@ -0,0 +1,8 @@ +((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 new file mode 100644 index 000000000..27388618e --- /dev/null +++ b/bundle/nvim-treesitter/queries/git_rebase/injections.scm @@ -0,0 +1,5 @@ +((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 new file mode 100644 index 000000000..ecd410972 --- /dev/null +++ b/bundle/nvim-treesitter/queries/gitattributes/highlights.scm @@ -0,0 +1,53 @@ +(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 new file mode 100644 index 000000000..4bb7d675d --- /dev/null +++ b/bundle/nvim-treesitter/queries/gitattributes/injections.scm @@ -0,0 +1 @@ +(comment) @comment diff --git a/bundle/nvim-treesitter/queries/gitignore/highlights.scm b/bundle/nvim-treesitter/queries/gitignore/highlights.scm new file mode 100644 index 000000000..6e83ea6f2 --- /dev/null +++ b/bundle/nvim-treesitter/queries/gitignore/highlights.scm @@ -0,0 +1,31 @@ +(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 c79d45720..e1b7a83e9 100644 --- a/bundle/nvim-treesitter/queries/go/folds.scm +++ b/bundle/nvim-treesitter/queries/go/folds.scm @@ -9,5 +9,8 @@ (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 07c788ec7..aaa6fe6b1 100644 --- a/bundle/nvim-treesitter/queries/go/highlights.scm +++ b/bundle/nvim-treesitter/queries/go/highlights.scm @@ -15,20 +15,17 @@ ((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) + function: (identifier) @function.call) (call_expression function: (selector_expression - field: (field_identifier) @method)) + field: (field_identifier) @method.call)) ; Function definitions @@ -38,6 +35,9 @@ (method_declaration name: (field_identifier) @method) +(method_spec + name: (field_identifier) @method) + ; Operators [ @@ -123,6 +123,7 @@ ((type_identifier) @type.builtin (#any-of? @type.builtin + "any" "bool" "byte" "complex128" @@ -184,7 +185,7 @@ ; Literals (interpreted_string_literal) @string -(raw_string_literal) @string +(raw_string_literal) @string @spell (rune_literal) @string (escape_sequence) @string.escape @@ -196,6 +197,16 @@ (false) @boolean (nil) @constant.builtin -(comment) @comment +(keyed_element + . (literal_element (identifier) @field)) +(field_declaration name: (field_identifier) @field) + +(comment) @comment @spell (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 f274ffb11..c6ac18969 100644 --- a/bundle/nvim-treesitter/queries/go/indents.scm +++ b/bundle/nvim-treesitter/queries/go/indents.scm @@ -3,7 +3,6 @@ (const_declaration) (var_declaration) (type_declaration) - (composite_literal) (func_literal) (literal_value) (expression_case) @@ -11,13 +10,22 @@ (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 2391c1a7a..4bb7d675d 100644 --- a/bundle/nvim-treesitter/queries/go/injections.scm +++ b/bundle/nvim-treesitter/queries/go/injections.scm @@ -1,6 +1 @@ -((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 9ec38266a..0ae9a9bc0 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 .)) + function: (qualified_identifier (identifier) @function.call .)) (call_expression - function: (scoped_identifier (identifier) @function .)) + function: (scoped_identifier (identifier) @function.call .)) (call_expression function: (selection_expression - (qualified_identifier (identifier) @method .))) + (qualified_identifier (identifier) @method.call .))) (qualified_identifier (_) @namespace . diff --git a/bundle/nvim-treesitter/queries/haskell/folds.scm b/bundle/nvim-treesitter/queries/haskell/folds.scm new file mode 100644 index 000000000..28eadf8f3 --- /dev/null +++ b/bundle/nvim-treesitter/queries/haskell/folds.scm @@ -0,0 +1,5 @@ +[ + (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 03744f5d6..c37c33b3e 100644 --- a/bundle/nvim-treesitter/queries/haskell/highlights.scm +++ b/bundle/nvim-treesitter/queries/haskell/highlights.scm @@ -81,6 +81,7 @@ "in" "class" "instance" + "pattern" "data" "newtype" "family" @@ -116,8 +117,9 @@ (exp_infix (variable) @operator) ; consider infix functions as operators -(exp_apply . (exp_name (variable) @function)) -(exp_apply . (exp_name (qualified_variable (variable) @function))) +(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))) ;; ---------------------------------------------------------------------------- @@ -135,5 +137,12 @@ ;; ---------------------------------------------------------------------------- ;; Quasi-quotes -(quoter) @function +(quoter) @function.call ; 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 0b231a7a1..206248f6e 100644 --- a/bundle/nvim-treesitter/queries/haskell/injections.scm +++ b/bundle/nvim-treesitter/queries/haskell/injections.scm @@ -56,3 +56,23 @@ (#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 67e85cb61..f6512148c 100644 --- a/bundle/nvim-treesitter/queries/hcl/highlights.scm +++ b/bundle/nvim-treesitter/queries/hcl/highlights.scm @@ -63,8 +63,8 @@ ] @string [ - (heredoc_identifier) ; <" @conceal (#set! conceal "")) +(block + "<" @conceal (#set! conceal "")) +(argument) @parameter +(keycode) @string.special +(url) @text.uri diff --git a/bundle/nvim-treesitter/queries/hlsl/folds.scm b/bundle/nvim-treesitter/queries/hlsl/folds.scm new file mode 100644 index 000000000..b617fdc56 --- /dev/null +++ b/bundle/nvim-treesitter/queries/hlsl/folds.scm @@ -0,0 +1 @@ +; inherits: cpp diff --git a/bundle/nvim-treesitter/queries/hlsl/highlights.scm b/bundle/nvim-treesitter/queries/hlsl/highlights.scm new file mode 100644 index 000000000..b93a90da8 --- /dev/null +++ b/bundle/nvim-treesitter/queries/hlsl/highlights.scm @@ -0,0 +1,35 @@ +; 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 new file mode 100644 index 000000000..b617fdc56 --- /dev/null +++ b/bundle/nvim-treesitter/queries/hlsl/indents.scm @@ -0,0 +1 @@ +; inherits: cpp diff --git a/bundle/nvim-treesitter/queries/hlsl/injections.scm b/bundle/nvim-treesitter/queries/hlsl/injections.scm new file mode 100644 index 000000000..537ae542d --- /dev/null +++ b/bundle/nvim-treesitter/queries/hlsl/injections.scm @@ -0,0 +1,3 @@ +(preproc_arg) @hlsl + +(comment) @comment diff --git a/bundle/nvim-treesitter/queries/hlsl/locals.scm b/bundle/nvim-treesitter/queries/hlsl/locals.scm new file mode 100644 index 000000000..b617fdc56 --- /dev/null +++ b/bundle/nvim-treesitter/queries/hlsl/locals.scm @@ -0,0 +1 @@ +; inherits: cpp diff --git a/bundle/nvim-treesitter/queries/html_tags/highlights.scm b/bundle/nvim-treesitter/queries/html_tags/highlights.scm index 419b4568d..b6a90f726 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 +(text) @text @spell ((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 dfac3aadf..db9453d9c 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) + name: (identifier) @method.call) (super) @function.builtin @@ -143,13 +143,13 @@ ] @float (character_literal) @character -(string_literal) @string +[(string_literal) (text_block)] @string (null_literal) @constant.builtin [ (line_comment) (block_comment) -] @comment +] @comment @spell [ (true) @@ -178,11 +178,14 @@ "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 57634434e..b62679c4b 100644 --- a/bundle/nvim-treesitter/queries/javascript/highlights.scm +++ b/bundle/nvim-treesitter/queries/javascript/highlights.scm @@ -31,3 +31,6 @@ (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 1ac778982..f41b44a5a 100644 --- a/bundle/nvim-treesitter/queries/json/highlights.scm +++ b/bundle/nvim-treesitter/queries/json/highlights.scm @@ -6,6 +6,7 @@ (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 a51c5c7e7..e50112155 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 +(comment) @comment @spell diff --git a/bundle/nvim-treesitter/queries/jsonnet/highlights.scm b/bundle/nvim-treesitter/queries/jsonnet/highlights.scm new file mode 100644 index 000000000..eb8d22be9 --- /dev/null +++ b/bundle/nvim-treesitter/queries/jsonnet/highlights.scm @@ -0,0 +1,76 @@ +[ + (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 new file mode 100644 index 000000000..3a96931b0 --- /dev/null +++ b/bundle/nvim-treesitter/queries/jsx/injections.scm @@ -0,0 +1,8 @@ +; Styled Jsx