mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-13 17:00:09 -04:00
feat(cmake): update cmake parser, adapt highlight.scm, and add indents.scm
This commit is contained in:
parent
f04f137acb
commit
e68ad094cd
3 changed files with 93 additions and 44 deletions
|
|
@ -48,7 +48,7 @@
|
||||||
"revision": "6e41628e9d18b19caea1cb1d72aae4ccff5bdfe9"
|
"revision": "6e41628e9d18b19caea1cb1d72aae4ccff5bdfe9"
|
||||||
},
|
},
|
||||||
"cmake": {
|
"cmake": {
|
||||||
"revision": "aafadc0d657faa99e483a4f2c70dbe64491b1802"
|
"revision": "3dfc596025431b21e839d392c171f6f97c2a4258"
|
||||||
},
|
},
|
||||||
"comment": {
|
"comment": {
|
||||||
"revision": "c9a7e2df7cac2dfb730f766a4f343308f84ff346"
|
"revision": "c9a7e2df7cac2dfb730f766a4f343308f84ff346"
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
(normal_command
|
(normal_command
|
||||||
(identifier)
|
(identifier)
|
||||||
(argument (unquoted_argument)) @constant
|
(argument_list
|
||||||
|
(argument (unquoted_argument)) @constant
|
||||||
|
)
|
||||||
(#lua-match? @constant "^[%u@][%u%d_]+$")
|
(#lua-match? @constant "^[%u@][%u%d_]+$")
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -55,32 +57,40 @@
|
||||||
|
|
||||||
(function_command
|
(function_command
|
||||||
(function)
|
(function)
|
||||||
. (argument) @function
|
(argument_list
|
||||||
(argument)* @parameter
|
. (argument) @function
|
||||||
|
(argument)* @parameter
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
(macro_command
|
(macro_command
|
||||||
(macro)
|
(macro)
|
||||||
. (argument) @function.macro
|
(argument_list
|
||||||
(argument)* @parameter
|
. (argument) @function.macro
|
||||||
|
(argument)* @parameter
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
(block_def
|
(block_def
|
||||||
(block_command
|
(block_command
|
||||||
(block) @function.builtin
|
(block) @function.builtin
|
||||||
(argument (unquoted_argument) @constant)
|
(argument_list
|
||||||
|
(argument (unquoted_argument) @constant)
|
||||||
|
)
|
||||||
(#any-of? @constant "SCOPE_FOR" "POLICIES" "VARIABLES" "PROPAGATE")
|
(#any-of? @constant "SCOPE_FOR" "POLICIES" "VARIABLES" "PROPAGATE")
|
||||||
)
|
)
|
||||||
(endblock_command (endblock) @function.builtin)
|
(endblock_command (endblock) @function.builtin)
|
||||||
)
|
)
|
||||||
|
;
|
||||||
((argument) @boolean
|
((argument) @boolean
|
||||||
(#match? @boolean "\\c^(1|on|yes|true|y|0|off|no|false|n|ignore|notfound|.*-notfound)$")
|
(#match? @boolean "\\c^(1|on|yes|true|y|0|off|no|false|n|ignore|notfound|.*-notfound)$")
|
||||||
)
|
)
|
||||||
|
;
|
||||||
(if_command
|
(if_command
|
||||||
(if)
|
(if)
|
||||||
(argument) @keyword.operator
|
(argument_list
|
||||||
|
(argument) @keyword.operator
|
||||||
|
)
|
||||||
(#any-of? @keyword.operator "NOT" "AND" "OR"
|
(#any-of? @keyword.operator "NOT" "AND" "OR"
|
||||||
"COMMAND" "POLICY" "TARGET" "TEST" "DEFINED" "IN_LIST"
|
"COMMAND" "POLICY" "TARGET" "TEST" "DEFINED" "IN_LIST"
|
||||||
"EXISTS" "IS_NEWER_THAN" "IS_DIRECTORY" "IS_SYMLINK" "IS_ABSOLUTE"
|
"EXISTS" "IS_NEWER_THAN" "IS_DIRECTORY" "IS_SYMLINK" "IS_ABSOLUTE"
|
||||||
|
|
@ -92,7 +102,9 @@
|
||||||
)
|
)
|
||||||
(elseif_command
|
(elseif_command
|
||||||
(elseif)
|
(elseif)
|
||||||
(argument) @keyword.operator
|
(argument_list
|
||||||
|
(argument) @keyword.operator
|
||||||
|
)
|
||||||
(#any-of? @keyword.operator "NOT" "AND" "OR"
|
(#any-of? @keyword.operator "NOT" "AND" "OR"
|
||||||
"COMMAND" "POLICY" "TARGET" "TEST" "DEFINED" "IN_LIST"
|
"COMMAND" "POLICY" "TARGET" "TEST" "DEFINED" "IN_LIST"
|
||||||
"EXISTS" "IS_NEWER_THAN" "IS_DIRECTORY" "IS_SYMLINK" "IS_ABSOLUTE"
|
"EXISTS" "IS_NEWER_THAN" "IS_DIRECTORY" "IS_SYMLINK" "IS_ABSOLUTE"
|
||||||
|
|
@ -110,77 +122,93 @@
|
||||||
|
|
||||||
(normal_command
|
(normal_command
|
||||||
(identifier) @_function
|
(identifier) @_function
|
||||||
. (argument) @variable
|
(argument_list
|
||||||
|
. (argument) @variable
|
||||||
|
)
|
||||||
(#match? @_function "\\c^set$")
|
(#match? @_function "\\c^set$")
|
||||||
)
|
)
|
||||||
|
|
||||||
(normal_command
|
(normal_command
|
||||||
(identifier) @_function
|
(identifier) @_function
|
||||||
(#match? @_function "\\c^set$")
|
(#match? @_function "\\c^set$")
|
||||||
. (argument)
|
(argument_list
|
||||||
(
|
. (argument)
|
||||||
|
(
|
||||||
(argument) @_cache @storageclass
|
(argument) @_cache @storageclass
|
||||||
.
|
.
|
||||||
(argument) @_type @type
|
(argument) @_type @type
|
||||||
(#any-of? @_cache "CACHE")
|
(#any-of? @_cache "CACHE")
|
||||||
(#any-of? @_type "BOOL" "FILEPATH" "PATH" "STRING" "INTERNAL")
|
(#any-of? @_type "BOOL" "FILEPATH" "PATH" "STRING" "INTERNAL")
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
(normal_command
|
(normal_command
|
||||||
(identifier) @_function
|
(identifier) @_function
|
||||||
(#match? @_function "\\c^unset$")
|
(#match? @_function "\\c^unset$")
|
||||||
. (argument)
|
(argument_list
|
||||||
(argument) @storageclass
|
. (argument)
|
||||||
(#any-of? @storageclass "CACHE" "PARENT_SCOPE")
|
(argument) @storageclass
|
||||||
|
(#any-of? @storageclass "CACHE" "PARENT_SCOPE")
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
(normal_command
|
(normal_command
|
||||||
(identifier) @_function
|
(identifier) @_function
|
||||||
(#match? @_function "\\c^list$")
|
(#match? @_function "\\c^list$")
|
||||||
. (argument) @constant
|
(argument_list
|
||||||
(#any-of? @constant "LENGTH" "GET" "JOIN" "SUBLIST" "FIND")
|
. (argument) @constant
|
||||||
. (argument) @variable
|
(#any-of? @constant "LENGTH" "GET" "JOIN" "SUBLIST" "FIND")
|
||||||
(argument) @variable .
|
. (argument) @variable
|
||||||
|
(argument) @variable .
|
||||||
|
)
|
||||||
)
|
)
|
||||||
(normal_command
|
(normal_command
|
||||||
(identifier) @_function
|
(identifier) @_function
|
||||||
(#match? @_function "\\c^list$")
|
(#match? @_function "\\c^list$")
|
||||||
. (argument) @constant
|
(argument_list
|
||||||
. (argument) @variable
|
. (argument) @constant
|
||||||
(#any-of? @constant "APPEND" "FILTER" "INSERT"
|
. (argument) @variable
|
||||||
"POP_BACK" "POP_FRONT" "PREPEND"
|
(#any-of? @constant "APPEND" "FILTER" "INSERT"
|
||||||
"REMOVE_ITEM" "REMOVE_AT" "REMOVE_DUPLICATES"
|
"POP_BACK" "POP_FRONT" "PREPEND"
|
||||||
"REVERSE" "SORT")
|
"REMOVE_ITEM" "REMOVE_AT" "REMOVE_DUPLICATES"
|
||||||
|
"REVERSE" "SORT")
|
||||||
|
)
|
||||||
)
|
)
|
||||||
(normal_command
|
(normal_command
|
||||||
(identifier) @_function
|
(identifier) @_function
|
||||||
(#match? @_function "\\c^list$")
|
(#match? @_function "\\c^list$")
|
||||||
. (argument) @_transform @constant
|
(argument_list
|
||||||
. (argument) @variable
|
. (argument) @_transform @constant
|
||||||
. (argument) @_action @constant
|
. (argument) @variable
|
||||||
(#eq? @_transform "TRANSFORM")
|
. (argument) @_action @constant
|
||||||
(#any-of? @_action "APPEND" "PREPEND" "TOUPPER" "TOLOWER" "STRIP" "GENEX_STRIP" "REPLACE")
|
(#eq? @_transform "TRANSFORM")
|
||||||
|
(#any-of? @_action "APPEND" "PREPEND" "TOUPPER" "TOLOWER" "STRIP" "GENEX_STRIP" "REPLACE")
|
||||||
|
)
|
||||||
)
|
)
|
||||||
(normal_command
|
(normal_command
|
||||||
(identifier) @_function
|
(identifier) @_function
|
||||||
(#match? @_function "\\c^list$")
|
(#match? @_function "\\c^list$")
|
||||||
. (argument) @_transform @constant
|
(argument_list
|
||||||
. (argument) @variable
|
. (argument) @_transform @constant
|
||||||
. (argument) @_action @constant
|
. (argument) @variable
|
||||||
. (argument)? @_selector @constant
|
. (argument) @_action @constant
|
||||||
(#eq? @_transform "TRANSFORM")
|
. (argument)? @_selector @constant
|
||||||
(#any-of? @_action "APPEND" "PREPEND" "TOUPPER" "TOLOWER" "STRIP" "GENEX_STRIP" "REPLACE")
|
(#eq? @_transform "TRANSFORM")
|
||||||
(#any-of? @_selector "AT" "FOR" "REGEX")
|
(#any-of? @_action "APPEND" "PREPEND" "TOUPPER" "TOLOWER" "STRIP" "GENEX_STRIP" "REPLACE")
|
||||||
|
(#any-of? @_selector "AT" "FOR" "REGEX")
|
||||||
|
)
|
||||||
)
|
)
|
||||||
(normal_command
|
(normal_command
|
||||||
(identifier) @_function
|
(identifier) @_function
|
||||||
(#match? @_function "\\c^list$")
|
(#match? @_function "\\c^list$")
|
||||||
. (argument) @_transform @constant
|
(argument_list
|
||||||
(argument) @constant .
|
. (argument) @_transform @constant
|
||||||
(argument) @variable
|
(argument) @constant .
|
||||||
(#eq? @_transform "TRANSFORM")
|
(argument) @variable
|
||||||
(#eq? @constant "OUTPUT_VARIABLE")
|
(#eq? @_transform "TRANSFORM")
|
||||||
|
(#eq? @constant "OUTPUT_VARIABLE")
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
(escape_sequence) @string.escape
|
(escape_sequence) @string.escape
|
||||||
|
|
|
||||||
21
queries/cmake/indents.scm
Normal file
21
queries/cmake/indents.scm
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
[
|
||||||
|
(normal_command)
|
||||||
|
(if_condition)
|
||||||
|
(foreach_loop)
|
||||||
|
(while_loop)
|
||||||
|
(function_def)
|
||||||
|
(macro_def)
|
||||||
|
(block_def)
|
||||||
|
] @indent.begin
|
||||||
|
|
||||||
|
[
|
||||||
|
(elseif_command)
|
||||||
|
(elseif_command)
|
||||||
|
(endif_command)
|
||||||
|
(endforeach_command)
|
||||||
|
(endfunction_command)
|
||||||
|
(endmacro_command)
|
||||||
|
(endblock_command)
|
||||||
|
] @indent.branch
|
||||||
|
|
||||||
|
(normal_command ")" @indent.branch)
|
||||||
Loading…
Add table
Add a link
Reference in a new issue