diff options
author | Christian Clason <c.clason@uni-graz.at> | 2023-03-03 14:27:30 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-03 14:27:30 +0100 |
commit | 98e051783c26239a47c5cd643e9aea7146b097bd (patch) | |
tree | 79f238252fad0fdb96e0ce7b7c20755b11f841e7 | |
parent | 74c9c413e7600c96c1ad35b0433fc63563130eef (diff) | |
download | rneovim-98e051783c26239a47c5cd643e9aea7146b097bd.tar.gz rneovim-98e051783c26239a47c5cd643e9aea7146b097bd.tar.bz2 rneovim-98e051783c26239a47c5cd643e9aea7146b097bd.zip |
feat(treesitter): bundle query parser and queries (#22483)
skip injections for now
-rw-r--r-- | cmake.deps/CMakeLists.txt | 3 | ||||
-rw-r--r-- | cmake.deps/cmake/BuildTreesitterParsers.cmake | 1 | ||||
-rw-r--r-- | runtime/queries/lua/injections.scm | 8 | ||||
-rw-r--r-- | runtime/queries/query/folds.scm | 6 | ||||
-rw-r--r-- | runtime/queries/query/highlights.scm | 34 | ||||
-rw-r--r-- | runtime/queries/vim/injections.scm | 4 |
6 files changed, 50 insertions, 6 deletions
diff --git a/cmake.deps/CMakeLists.txt b/cmake.deps/CMakeLists.txt index a9a3f45319..12fa94c1c9 100644 --- a/cmake.deps/CMakeLists.txt +++ b/cmake.deps/CMakeLists.txt @@ -190,6 +190,9 @@ set(TREESITTER_VIM_SHA256 1b1cd39e33c8fb02fa7fe3977e844883c2a8508a7edd621f2d21e3 set(TREESITTER_HELP_URL https://github.com/neovim/tree-sitter-vimdoc/archive/v1.3.0.tar.gz) set(TREESITTER_HELP_SHA256 f33f6d49c7d71feb2fd68ef2b2684da150f9f8e486ad9726213631d673942331) +set(TREESITTER_QUERY_URL https://github.com/nvim-treesitter/tree-sitter-query/archive/0717de07078a20a8608c98ad5f26c208949d0e15.tar.gz) +set(TREESITTER_QUERY_SHA256 2f2c79a59e3ff550aef849925e589d69b8a146b3af935504366cc973399d26e1) + set(TREESITTER_URL https://github.com/tree-sitter/tree-sitter/archive/c51896d32dcc11a38e41f36e3deb1a6a9c4f4b14.tar.gz) set(TREESITTER_SHA256 243e07541a9dd71681984b65bffed2d4a259bef0a4ad28cff55cc1c6878b8d18) diff --git a/cmake.deps/cmake/BuildTreesitterParsers.cmake b/cmake.deps/cmake/BuildTreesitterParsers.cmake index fcfcb71036..774fc8a8c3 100644 --- a/cmake.deps/cmake/BuildTreesitterParsers.cmake +++ b/cmake.deps/cmake/BuildTreesitterParsers.cmake @@ -20,3 +20,4 @@ BuildTSParser(c ${TREESITTER_C_URL} ${TREESITTER_C_SHA256} TreesitterParserCMake BuildTSParser(lua ${TREESITTER_LUA_URL} ${TREESITTER_LUA_SHA256} TreesitterParserCMakeLists.txt) BuildTSParser(vim ${TREESITTER_VIM_URL} ${TREESITTER_VIM_SHA256} TreesitterParserCMakeLists.txt) BuildTSParser(help ${TREESITTER_HELP_URL} ${TREESITTER_HELP_SHA256} TreesitterParserCMakeLists.txt) +BuildTSParser(query ${TREESITTER_QUERY_URL} ${TREESITTER_QUERY_SHA256} TreesitterParserCMakeLists.txt) diff --git a/runtime/queries/lua/injections.scm b/runtime/queries/lua/injections.scm index 0e67329139..69acbbbe9f 100644 --- a/runtime/queries/lua/injections.scm +++ b/runtime/queries/lua/injections.scm @@ -11,10 +11,10 @@ arguments: (arguments (string content: _ @vim))) (#any-of? @_vimcmd_identifier "vim.cmd" "vim.api.nvim_command" "vim.api.nvim_exec" "vim.api.nvim_cmd")) -; ((function_call -; name: (_) @_vimcmd_identifier -; arguments: (arguments (string content: _ @query) .)) -; (#eq? @_vimcmd_identifier "vim.treesitter.query.set_query")) +((function_call + name: (_) @_vimcmd_identifier + arguments: (arguments (string content: _ @query) .)) + (#eq? @_vimcmd_identifier "vim.treesitter.query.set_query")) ; ;; highlight string as query if starts with `;; query` ; ((string ("string_content") @query) (#lua-match? @query "^%s*;+%s?query")) diff --git a/runtime/queries/query/folds.scm b/runtime/queries/query/folds.scm new file mode 100644 index 0000000000..47dd965126 --- /dev/null +++ b/runtime/queries/query/folds.scm @@ -0,0 +1,6 @@ +[ + (named_node) + (predicate) + (grouping) + (list) +] @fold diff --git a/runtime/queries/query/highlights.scm b/runtime/queries/query/highlights.scm new file mode 100644 index 0000000000..ee31a7e7ef --- /dev/null +++ b/runtime/queries/query/highlights.scm @@ -0,0 +1,34 @@ +(string) @string +(escape_sequence) @string.escape +(capture (identifier) @type) +(anonymous_node (identifier) @string) +(predicate name: (identifier) @function) +(named_node name: (identifier) @variable) +(field_definition name: (identifier) @property) +(negated_field "!" @operator (identifier) @property) +(comment) @comment @spell + +(quantifier) @operator +(predicate_type) @punctuation.special + +"." @operator + +[ + "[" + "]" + "(" + ")" +] @punctuation.bracket + +":" @punctuation.delimiter +["@" "#"] @punctuation.special +"_" @constant + +((parameters (identifier) @number) + (#match? @number "^[-+]?[0-9]+(.[0-9]+)?$")) + +((program . (comment) @include) + (#match? @include "^;\ +inherits\ *:")) + +((program . (comment) @preproc) + (#match? @preproc "^; +extends")) diff --git a/runtime/queries/vim/injections.scm b/runtime/queries/vim/injections.scm index fdd025bfd9..b53643dc1a 100644 --- a/runtime/queries/vim/injections.scm +++ b/runtime/queries/vim/injections.scm @@ -24,5 +24,5 @@ "patchexpr" "pex" "charconvert" "ccv")) -(comment) @comment -(line_continuation_comment) @comment +; (comment) @comment +; (line_continuation_comment) @comment |