backport treesitter parser and queries (#23767)

This commit is contained in:
Christian Clason 2023-05-26 19:19:28 +02:00 committed by GitHub
parent 3591252cc8
commit a090be56bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 44 additions and 15 deletions

View File

@ -187,8 +187,8 @@ set(LIBICONV_SHA256 ccf536620a45458d26ba83887a983b96827001e92a13847b45e4925cc891
set(TREESITTER_C_URL https://github.com/tree-sitter/tree-sitter-c/archive/v0.20.2.tar.gz)
set(TREESITTER_C_SHA256 af66fde03feb0df4faf03750102a0d265b007e5d957057b6b293c13116a70af2 )
set(TREESITTER_LUA_URL https://github.com/MunifTanjim/tree-sitter-lua/archive/v0.0.14.tar.gz)
set(TREESITTER_LUA_SHA256 930d0370dc15b66389869355c8e14305b9ba7aafd36edbfdb468c8023395016d)
set(TREESITTER_LUA_URL https://github.com/MunifTanjim/tree-sitter-lua/archive/v0.0.17.tar.gz)
set(TREESITTER_LUA_SHA256 8963fd0a185d786c164dfca3824941c7eaec497ce49a3a0bc24bf753f5e0e59c)
set(TREESITTER_VIM_URL https://github.com/neovim/tree-sitter-vim/archive/v0.3.0.tar.gz)
set(TREESITTER_VIM_SHA256 403acec3efb7cdb18ff3d68640fc823502a4ffcdfbb71cec3f98aa786c21cbe2)
set(TREESITTER_VIMDOC_URL https://github.com/neovim/tree-sitter-vimdoc/archive/v2.0.0.tar.gz)

View File

@ -117,12 +117,19 @@
(preproc_defined)
] @function.macro
(field_identifier) @property
(((field_expression
(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))
(statement_identifier) @label
[
(type_identifier)
(sized_type_specifier)
(type_descriptor)
] @type
@ -138,6 +145,8 @@
(primitive_type) @type.builtin
(sized_type_specifier _ @type.builtin type: _?)
((identifier) @constant
(#lua-match? @constant "^[A-Z][A-Z0-9_]+$"))
(enumerator
@ -163,6 +172,10 @@
field: (field_identifier) @function.call))
(function_declarator
declarator: (identifier) @function)
(function_declarator
declarator: (parenthesized_declarator
(pointer_declarator
declarator: (field_identifier) @function)))
(preproc_function_def
name: (identifier) @function.macro)

View File

@ -127,8 +127,14 @@
(identifier) @variable
((identifier) @constant.builtin
(#eq? @constant.builtin "_VERSION"))
((identifier) @variable.builtin
(#any-of? @variable.builtin "_G" "_VERSION" "debug" "io" "jit" "math" "os" "package" "self" "string" "table" "utf8"))
(#eq? @variable.builtin "self"))
((identifier) @namespace.builtin
(#any-of? @namespace.builtin "_G" "debug" "io" "jit" "math" "os" "package" "string" "table" "utf8"))
((identifier) @keyword.coroutine
(#eq? @keyword.coroutine "coroutine"))
@ -210,5 +216,7 @@
(string) @string @spell
(escape_sequence) @string.escape
;; Error
(ERROR) @error

View File

@ -13,6 +13,14 @@
(#set! injection.language "vim")
(#any-of? @_vimcmd_identifier "vim.cmd" "vim.api.nvim_command" "vim.api.nvim_exec2" "vim.api.nvim_cmd"))
; vim.rcprequest(123, "nvim_exec_lua", "return vim.api.nvim_buf_get_lines(0, 0, -1, false)", false)
((function_call
name: (_) @_vimcmd_identifier
arguments: (arguments . (_) . (string content: _ @_method) . (string content: _ @injection.content)))
(#set! injection.language "lua")
(#any-of? @_vimcmd_identifier "vim.rpcrequest" "vim.rpcnotify")
(#eq? @_method "nvim_exec_lua"))
((function_call
name: (_) @_vimcmd_identifier
arguments: (arguments (string content: _ @injection.content) .))
@ -20,7 +28,7 @@
(#any-of? @_vimcmd_identifier "vim.treesitter.query.set" "vim.treesitter.query.parse"))
;; highlight string as query if starts with `;; query`
((string ("string_content") @injection.content)
(string content: _ @injection.content
(#set! injection.language "query")
(#lua-match? @injection.content "^%s*;+%s?query"))

View File

@ -27,8 +27,8 @@
((parameters (identifier) @number)
(#match? @number "^[-+]?[0-9]+(.[0-9]+)?$"))
((program . (comment) @include)
(#match? @include "^;\ +inherits\ *:"))
((program . (comment)* . (comment) @include)
(#lua-match? @include "^;+ *inherits *:"))
((program . (comment) @preproc)
(#match? @preproc "^; +extends"))
((program . (comment)* . (comment) @preproc)
(#lua-match? @preproc "^;+ *extends"))

View File

@ -275,7 +275,7 @@
; Options
((set_value) @number
(#match? @number "^[0-9]+(\.[0-9]+)?$"))
(#lua-match? @number "^[%d]+(%.[%d]+)?$"))
(inv_option "!" @operator)
(set_item "?" @operator)

View File

@ -1,7 +1,7 @@
(h1) @text.title
(h2) @text.title
(h3) @text.title
(column_heading) @text.title
(h1) @text.title.1
(h2) @text.title.2
(h3) @text.title.3
(column_heading) @text.title.4
(column_heading
"~" @conceal (#set! conceal ""))
(tag