fix(treesitter): update parsers and queries

This commit is contained in:
Christian Clason 2024-04-05 18:06:24 +02:00
parent 73de98256c
commit 39a0e6bf3c
9 changed files with 167 additions and 185 deletions

View File

@ -55,7 +55,7 @@ TREESITTER_PYTHON_URL https://github.com/tree-sitter/tree-sitter-python/archive/
TREESITTER_PYTHON_SHA256 720304a603271fa89e4430a14d6a81a023d6d7d1171b1533e49c0ab44f1e1c13 TREESITTER_PYTHON_SHA256 720304a603271fa89e4430a14d6a81a023d6d7d1171b1533e49c0ab44f1e1c13
TREESITTER_BASH_URL https://github.com/tree-sitter/tree-sitter-bash/archive/v0.21.0.tar.gz TREESITTER_BASH_URL https://github.com/tree-sitter/tree-sitter-bash/archive/v0.21.0.tar.gz
TREESITTER_BASH_SHA256 f0515efda839cfede851adb24ac154227fbc0dfb60c6c11595ecfa9087d43ceb TREESITTER_BASH_SHA256 f0515efda839cfede851adb24ac154227fbc0dfb60c6c11595ecfa9087d43ceb
TREESITTER_MARKDOWN_URL https://github.com/MDeiml/tree-sitter-markdown/archive/v0.2.1.tar.gz TREESITTER_MARKDOWN_URL https://github.com/MDeiml/tree-sitter-markdown/archive/v0.2.3.tar.gz
TREESITTER_MARKDOWN_SHA256 d5dee1f57807a633062d03e19ad59d9b5e28f882da1ebe69a2e31f1df5b308ca TREESITTER_MARKDOWN_SHA256 4909d6023643f1afc3ab219585d4035b7403f3a17849782ab803c5f73c8a31d5
TREESITTER_URL https://github.com/tree-sitter/tree-sitter/archive/v0.22.2.tar.gz TREESITTER_URL https://github.com/tree-sitter/tree-sitter/archive/v0.22.2.tar.gz
TREESITTER_SHA256 0c829523b876d4a37e1bd46a655c133a93669c0fe98fcd84972b168849c27afc TREESITTER_SHA256 0c829523b876d4a37e1bd46a655c133a93669c0fe98fcd84972b168849c27afc

View File

@ -124,10 +124,15 @@
(test_operator) @operator (test_operator) @operator
(command_substitution (command_substitution
"$(" @punctuation.bracket) "$(" @punctuation.special
")" @punctuation.special)
(process_substitution (process_substitution
"<(" @punctuation.bracket) [
"<("
">("
] @punctuation.special
")" @punctuation.special)
(arithmetic_expansion (arithmetic_expansion
[ [
@ -170,12 +175,11 @@
"trap" "type" "typeset" "ulimit" "umask" "unalias" "wait")) "trap" "type" "typeset" "ulimit" "umask" "unalias" "wait"))
(command (command
argument: argument: [
[ (word) @variable.parameter
(word) @variable.parameter (concatenation
(concatenation (word) @variable.parameter)
(word) @variable.parameter) ])
])
(number) @number (number) @number

View File

@ -142,9 +142,6 @@
(char_literal) @character (char_literal) @character
((preproc_arg) @function.macro
(#set! "priority" 90))
(preproc_defined) @function.macro (preproc_defined) @function.macro
((field_expression ((field_expression
@ -263,18 +260,16 @@
function: (identifier) @function.call) function: (identifier) @function.call)
(call_expression (call_expression
function: function: (field_expression
(field_expression field: (field_identifier) @function.call))
field: (field_identifier) @function.call))
(function_declarator (function_declarator
declarator: (identifier) @function) declarator: (identifier) @function)
(function_declarator (function_declarator
declarator: declarator: (parenthesized_declarator
(parenthesized_declarator (pointer_declarator
(pointer_declarator declarator: (field_identifier) @function)))
declarator: (field_identifier) @function)))
(preproc_function_def (preproc_function_def
name: (identifier) @function.macro) name: (identifier) @function.macro)

View File

@ -180,27 +180,24 @@
(vararg_expression) @variable.parameter.builtin (vararg_expression) @variable.parameter.builtin
(function_declaration (function_declaration
name: name: [
[ (identifier) @function
(identifier) @function (dot_index_expression
(dot_index_expression field: (identifier) @function)
field: (identifier) @function) ])
])
(function_declaration (function_declaration
name: name: (method_index_expression
(method_index_expression method: (identifier) @function.method))
method: (identifier) @function.method))
(assignment_statement (assignment_statement
(variable_list (variable_list
. .
name: name: [
[ (identifier) @function
(identifier) @function (dot_index_expression
(dot_index_expression field: (identifier) @function)
field: (identifier) @function) ])
])
(expression_list (expression_list
. .
value: (function_definition))) value: (function_definition)))
@ -211,14 +208,13 @@
value: (function_definition))) value: (function_definition)))
(function_call (function_call
name: name: [
[ (identifier) @function.call
(identifier) @function.call (dot_index_expression
(dot_index_expression field: (identifier) @function.call)
field: (identifier) @function.call) (method_index_expression
(method_index_expression method: (identifier) @function.method.call)
method: (identifier) @function.method.call) ])
])
(function_call (function_call
(identifier) @function.builtin (identifier) @function.builtin
@ -253,21 +249,19 @@
(dot_index_expression (dot_index_expression
field: (identifier) @_method field: (identifier) @_method
(#any-of? @_method "find" "match" "gmatch" "gsub")) (#any-of? @_method "find" "match" "gmatch" "gsub"))
arguments: arguments: (arguments
(arguments .
. (_)
(_) .
. (string
(string content: (string_content) @string.regexp)))
content: (string_content) @string.regexp)))
;("123"):match("%d+") ;("123"):match("%d+")
(function_call (function_call
(method_index_expression (method_index_expression
method: (identifier) @_method method: (identifier) @_method
(#any-of? @_method "find" "match" "gmatch" "gsub")) (#any-of? @_method "find" "match" "gmatch" "gsub"))
arguments: arguments: (arguments
(arguments .
. (string
(string content: (string_content) @string.regexp)))
content: (string_content) @string.regexp)))

View File

@ -1,67 +1,69 @@
((function_call ((function_call
name: name: [
[ (identifier) @_cdef_identifier
(identifier) @_cdef_identifier (_
(_ _
_ (identifier) @_cdef_identifier)
(identifier) @_cdef_identifier) ]
] arguments: (arguments
arguments: (string
(arguments content: _ @injection.content)))
(string
content: _ @injection.content)))
(#set! injection.language "c") (#set! injection.language "c")
(#eq? @_cdef_identifier "cdef")) (#eq? @_cdef_identifier "cdef"))
((function_call ((function_call
name: (_) @_vimcmd_identifier name: (_) @_vimcmd_identifier
arguments: arguments: (arguments
(arguments (string
(string content: _ @injection.content)))
content: _ @injection.content)))
(#set! injection.language "vim") (#set! injection.language "vim")
(#any-of? @_vimcmd_identifier (#any-of? @_vimcmd_identifier
"vim.cmd" "vim.api.nvim_command" "vim.api.nvim_command" "vim.api.nvim_exec2")) "vim.cmd" "vim.api.nvim_command" "vim.api.nvim_command" "vim.api.nvim_exec2"))
((function_call ((function_call
name: (_) @_vimcmd_identifier name: (_) @_vimcmd_identifier
arguments: arguments: (arguments
(arguments (string
(string content: _ @injection.content) .))
content: _ @injection.content) .))
(#set! injection.language "query") (#set! injection.language "query")
(#any-of? @_vimcmd_identifier "vim.treesitter.query.set" "vim.treesitter.query.parse")) (#any-of? @_vimcmd_identifier "vim.treesitter.query.set" "vim.treesitter.query.parse"))
((function_call ((function_call
name: (_) @_vimcmd_identifier name: (_) @_vimcmd_identifier
arguments: arguments: (arguments
(arguments .
. (_)
(_) .
. (string
(string content: _ @_method)
content: _ @_method) .
. (string
(string content: _ @injection.content)))
content: _ @injection.content)))
(#any-of? @_vimcmd_identifier "vim.rpcrequest" "vim.rpcnotify") (#any-of? @_vimcmd_identifier "vim.rpcrequest" "vim.rpcnotify")
(#eq? @_method "nvim_exec_lua") (#eq? @_method "nvim_exec_lua")
(#set! injection.language "lua")) (#set! injection.language "lua"))
; exec_lua [[ ... ]] in functionaltests
((function_call
name: (identifier) @_function
arguments: (arguments
(string
content: (string_content) @injection.content)))
(#eq? @_function "exec_lua")
(#set! injection.language "lua"))
; vim.api.nvim_create_autocmd("FileType", { command = "injected here" }) ; vim.api.nvim_create_autocmd("FileType", { command = "injected here" })
(function_call (function_call
name: (_) @_vimcmd_identifier name: (_) @_vimcmd_identifier
arguments: arguments: (arguments
(arguments .
. (_)
(_) .
. (table_constructor
(table_constructor (field
(field name: (identifier) @_command
name: (identifier) @_command value: (string
value: content: (_) @injection.content))) .)
(string
content: (_) @injection.content))) .)
; limit so only 2-argument functions gets matched before pred handle ; limit so only 2-argument functions gets matched before pred handle
(#eq? @_vimcmd_identifier "vim.api.nvim_create_autocmd") (#eq? @_vimcmd_identifier "vim.api.nvim_create_autocmd")
(#eq? @_command "command") (#eq? @_command "command")
@ -69,31 +71,29 @@
(function_call (function_call
name: (_) @_user_cmd name: (_) @_user_cmd
arguments: arguments: (arguments
(arguments .
. (_)
(_) .
. (string
(string content: (_) @injection.content)
content: (_) @injection.content) .
. (_) .)
(_) .)
(#eq? @_user_cmd "vim.api.nvim_create_user_command") (#eq? @_user_cmd "vim.api.nvim_create_user_command")
(#set! injection.language "vim")) (#set! injection.language "vim"))
(function_call (function_call
name: (_) @_user_cmd name: (_) @_user_cmd
arguments: arguments: (arguments
(arguments .
. (_)
(_) .
. (_)
(_) .
. (string
(string content: (_) @injection.content)
content: (_) @injection.content) .
. (_) .)
(_) .)
; Limiting predicate handling to only functions with 4 arguments ; Limiting predicate handling to only functions with 4 arguments
(#eq? @_user_cmd "vim.api.nvim_buf_create_user_command") (#eq? @_user_cmd "vim.api.nvim_buf_create_user_command")
(#set! injection.language "vim")) (#set! injection.language "vim"))

View File

@ -111,6 +111,12 @@
((block_quote) @markup.quote ((block_quote) @markup.quote
(#set! "priority" 90)) (#set! "priority" 90))
([
(plus_metadata)
(minus_metadata)
] @keyword.directive
(#set! "priority" 90))
[ [
(block_continuation) (block_continuation)
(block_quote_marker) (block_quote_marker)

View File

@ -35,9 +35,8 @@
((assignment ((assignment
left: (identifier) @type.definition left: (identifier) @type.definition
right: right: (call
(call function: (identifier) @_func))
function: (identifier) @_func))
(#any-of? @_func "TypeVar" "NewType")) (#any-of? @_func "TypeVar" "NewType"))
; Function calls ; Function calls
@ -45,18 +44,16 @@
function: (identifier) @function.call) function: (identifier) @function.call)
(call (call
function: function: (attribute
(attribute attribute: (identifier) @function.method.call))
attribute: (identifier) @function.method.call))
((call ((call
function: (identifier) @constructor) function: (identifier) @constructor)
(#lua-match? @constructor "^%u")) (#lua-match? @constructor "^%u"))
((call ((call
function: function: (attribute
(attribute attribute: (identifier) @constructor))
attribute: (identifier) @constructor))
(#lua-match? @constructor "^%u")) (#lua-match? @constructor "^%u"))
; Decorators ; Decorators
@ -82,7 +79,7 @@
((decorator ((decorator
(identifier) @attribute.builtin) (identifier) @attribute.builtin)
(#any-of? @attribute.builtin "classmethod" "property")) (#any-of? @attribute.builtin "classmethod" "property" "staticmethod"))
; Builtin functions ; Builtin functions
((call ((call
@ -109,10 +106,9 @@
((call ((call
function: (identifier) @_isinstance function: (identifier) @_isinstance
arguments: arguments: (argument_list
(argument_list (_)
(_) (identifier) @type))
(identifier) @type))
(#eq? @_isinstance "isinstance")) (#eq? @_isinstance "isinstance"))
; Normal parameters ; Normal parameters
@ -211,18 +207,16 @@
(string) @string.documentation @spell)) (string) @string.documentation @spell))
(class_definition (class_definition
body: body: (block
(block .
. (expression_statement
(expression_statement (string) @string.documentation @spell)))
(string) @string.documentation @spell)))
(function_definition (function_definition
body: body: (block
(block .
. (expression_statement
(expression_statement (string) @string.documentation @spell)))
(string) @string.documentation @spell)))
; Tokens ; Tokens
[ [
@ -378,32 +372,27 @@
name: (identifier) @type) name: (identifier) @type)
(class_definition (class_definition
body: body: (block
(block (function_definition
(function_definition name: (identifier) @function.method)))
name: (identifier) @function.method)))
(class_definition (class_definition
superclasses: superclasses: (argument_list
(argument_list (identifier) @type))
(identifier) @type))
((class_definition ((class_definition
body: body: (block
(block (expression_statement
(expression_statement (assignment
(assignment left: (identifier) @variable.member))))
left: (identifier) @variable.member))))
(#lua-match? @variable.member "^[%l_].*$")) (#lua-match? @variable.member "^[%l_].*$"))
((class_definition ((class_definition
body: body: (block
(block (expression_statement
(expression_statement (assignment
(assignment left: (_
left: (identifier) @variable.member)))))
(_
(identifier) @variable.member)))))
(#lua-match? @variable.member "^[%l_].*$")) (#lua-match? @variable.member "^[%l_].*$"))
((class_definition ((class_definition
@ -434,12 +423,10 @@
; Regex from the `re` module ; Regex from the `re` module
(call (call
function: function: (attribute
(attribute object: (identifier) @_re)
object: (identifier) @_re) arguments: (argument_list
arguments: .
(argument_list (string
. (string_content) @string.regexp))
(string
(string_content) @string.regexp))
(#eq? @_re "re")) (#eq? @_re "re"))

View File

@ -68,20 +68,18 @@
((predicate ((predicate
name: (identifier) @_name name: (identifier) @_name
parameters: parameters: (parameters
(parameters (string
(string "\"" @string
"\"" @string "\"" @string) @string.regexp))
"\"" @string) @string.regexp))
(#any-of? @_name "match" "not-match" "vim-match" "not-vim-match" "lua-match" "not-lua-match")) (#any-of? @_name "match" "not-match" "vim-match" "not-vim-match" "lua-match" "not-lua-match"))
((predicate ((predicate
name: (identifier) @_name name: (identifier) @_name
parameters: parameters: (parameters
(parameters (string
(string "\"" @string
"\"" @string "\"" @string) @string.regexp
"\"" @string) @string.regexp .
. (string) .))
(string) .))
(#any-of? @_name "gsub" "not-gsub")) (#any-of? @_name "gsub" "not-gsub"))

View File

@ -42,9 +42,8 @@
function: (identifier) @function.call) function: (identifier) @function.call)
(call_expression (call_expression
function: function: (scoped_identifier
(scoped_identifier (identifier) @function.call))
(identifier) @function.call))
(parameters (parameters
(identifier) @variable.parameter) (identifier) @variable.parameter)
@ -206,10 +205,9 @@
(command_attribute (command_attribute
name: _ @property name: _ @property
val: val: (behavior
(behavior name: _ @constant
name: _ @constant val: (identifier)? @function)?)
val: (identifier)? @function)?)
; Edit command ; Edit command
(plus_plus_opt (plus_plus_opt