aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUy Ha <hchanuy@gmail.com>2023-06-28 15:19:58 +0000
committerChristian Clason <c.clason@uni-graz.at>2023-06-28 18:35:25 +0200
commite68ad094cdae7eab4317e3e0241978ef69a60a5c (patch)
treed304d6215c6b8ba2e95c584b810d19a738f54a80
parentUpdate parsers: c, groovy, html (diff)
downloadnvim-treesitter-e68ad094cdae7eab4317e3e0241978ef69a60a5c.tar
nvim-treesitter-e68ad094cdae7eab4317e3e0241978ef69a60a5c.tar.gz
nvim-treesitter-e68ad094cdae7eab4317e3e0241978ef69a60a5c.tar.bz2
nvim-treesitter-e68ad094cdae7eab4317e3e0241978ef69a60a5c.tar.lz
nvim-treesitter-e68ad094cdae7eab4317e3e0241978ef69a60a5c.tar.xz
nvim-treesitter-e68ad094cdae7eab4317e3e0241978ef69a60a5c.tar.zst
nvim-treesitter-e68ad094cdae7eab4317e3e0241978ef69a60a5c.zip
feat(cmake): update cmake parser, adapt highlight.scm, and add indents.scm
-rw-r--r--lockfile.json2
-rw-r--r--queries/cmake/highlights.scm114
-rw-r--r--queries/cmake/indents.scm21
3 files changed, 93 insertions, 44 deletions
diff --git a/lockfile.json b/lockfile.json
index 904cac6e7..87bdc57d5 100644
--- a/lockfile.json
+++ b/lockfile.json
@@ -48,7 +48,7 @@
"revision": "6e41628e9d18b19caea1cb1d72aae4ccff5bdfe9"
},
"cmake": {
- "revision": "aafadc0d657faa99e483a4f2c70dbe64491b1802"
+ "revision": "3dfc596025431b21e839d392c171f6f97c2a4258"
},
"comment": {
"revision": "c9a7e2df7cac2dfb730f766a4f343308f84ff346"
diff --git a/queries/cmake/highlights.scm b/queries/cmake/highlights.scm
index b6cc26d2c..af6b70cc8 100644
--- a/queries/cmake/highlights.scm
+++ b/queries/cmake/highlights.scm
@@ -1,6 +1,8 @@
(normal_command
(identifier)
- (argument (unquoted_argument)) @constant
+ (argument_list
+ (argument (unquoted_argument)) @constant
+ )
(#lua-match? @constant "^[%u@][%u%d_]+$")
)
@@ -55,32 +57,40 @@
(function_command
(function)
- . (argument) @function
- (argument)* @parameter
+ (argument_list
+ . (argument) @function
+ (argument)* @parameter
+ )
)
(macro_command
(macro)
- . (argument) @function.macro
- (argument)* @parameter
+ (argument_list
+ . (argument) @function.macro
+ (argument)* @parameter
+ )
)
(block_def
(block_command
(block) @function.builtin
- (argument (unquoted_argument) @constant)
+ (argument_list
+ (argument (unquoted_argument) @constant)
+ )
(#any-of? @constant "SCOPE_FOR" "POLICIES" "VARIABLES" "PROPAGATE")
)
(endblock_command (endblock) @function.builtin)
)
-
+;
((argument) @boolean
(#match? @boolean "\\c^(1|on|yes|true|y|0|off|no|false|n|ignore|notfound|.*-notfound)$")
)
-
+;
(if_command
(if)
- (argument) @keyword.operator
+ (argument_list
+ (argument) @keyword.operator
+ )
(#any-of? @keyword.operator "NOT" "AND" "OR"
"COMMAND" "POLICY" "TARGET" "TEST" "DEFINED" "IN_LIST"
"EXISTS" "IS_NEWER_THAN" "IS_DIRECTORY" "IS_SYMLINK" "IS_ABSOLUTE"
@@ -92,7 +102,9 @@
)
(elseif_command
(elseif)
- (argument) @keyword.operator
+ (argument_list
+ (argument) @keyword.operator
+ )
(#any-of? @keyword.operator "NOT" "AND" "OR"
"COMMAND" "POLICY" "TARGET" "TEST" "DEFINED" "IN_LIST"
"EXISTS" "IS_NEWER_THAN" "IS_DIRECTORY" "IS_SYMLINK" "IS_ABSOLUTE"
@@ -110,77 +122,93 @@
(normal_command
(identifier) @_function
- . (argument) @variable
+ (argument_list
+ . (argument) @variable
+ )
(#match? @_function "\\c^set$")
)
(normal_command
(identifier) @_function
(#match? @_function "\\c^set$")
- . (argument)
- (
+ (argument_list
+ . (argument)
+ (
(argument) @_cache @storageclass
.
(argument) @_type @type
(#any-of? @_cache "CACHE")
(#any-of? @_type "BOOL" "FILEPATH" "PATH" "STRING" "INTERNAL")
+ )
)
)
(normal_command
(identifier) @_function
(#match? @_function "\\c^unset$")
- . (argument)
- (argument) @storageclass
- (#any-of? @storageclass "CACHE" "PARENT_SCOPE")
+ (argument_list
+ . (argument)
+ (argument) @storageclass
+ (#any-of? @storageclass "CACHE" "PARENT_SCOPE")
+ )
)
(normal_command
(identifier) @_function
(#match? @_function "\\c^list$")
- . (argument) @constant
- (#any-of? @constant "LENGTH" "GET" "JOIN" "SUBLIST" "FIND")
- . (argument) @variable
- (argument) @variable .
+ (argument_list
+ . (argument) @constant
+ (#any-of? @constant "LENGTH" "GET" "JOIN" "SUBLIST" "FIND")
+ . (argument) @variable
+ (argument) @variable .
+ )
)
(normal_command
(identifier) @_function
(#match? @_function "\\c^list$")
- . (argument) @constant
- . (argument) @variable
- (#any-of? @constant "APPEND" "FILTER" "INSERT"
- "POP_BACK" "POP_FRONT" "PREPEND"
- "REMOVE_ITEM" "REMOVE_AT" "REMOVE_DUPLICATES"
- "REVERSE" "SORT")
+ (argument_list
+ . (argument) @constant
+ . (argument) @variable
+ (#any-of? @constant "APPEND" "FILTER" "INSERT"
+ "POP_BACK" "POP_FRONT" "PREPEND"
+ "REMOVE_ITEM" "REMOVE_AT" "REMOVE_DUPLICATES"
+ "REVERSE" "SORT")
+ )
)
(normal_command
(identifier) @_function
(#match? @_function "\\c^list$")
- . (argument) @_transform @constant
- . (argument) @variable
- . (argument) @_action @constant
- (#eq? @_transform "TRANSFORM")
- (#any-of? @_action "APPEND" "PREPEND" "TOUPPER" "TOLOWER" "STRIP" "GENEX_STRIP" "REPLACE")
+ (argument_list
+ . (argument) @_transform @constant
+ . (argument) @variable
+ . (argument) @_action @constant
+ (#eq? @_transform "TRANSFORM")
+ (#any-of? @_action "APPEND" "PREPEND" "TOUPPER" "TOLOWER" "STRIP" "GENEX_STRIP" "REPLACE")
+ )
)
(normal_command
(identifier) @_function
(#match? @_function "\\c^list$")
- . (argument) @_transform @constant
- . (argument) @variable
- . (argument) @_action @constant
- . (argument)? @_selector @constant
- (#eq? @_transform "TRANSFORM")
- (#any-of? @_action "APPEND" "PREPEND" "TOUPPER" "TOLOWER" "STRIP" "GENEX_STRIP" "REPLACE")
- (#any-of? @_selector "AT" "FOR" "REGEX")
+ (argument_list
+ . (argument) @_transform @constant
+ . (argument) @variable
+ . (argument) @_action @constant
+ . (argument)? @_selector @constant
+ (#eq? @_transform "TRANSFORM")
+ (#any-of? @_action "APPEND" "PREPEND" "TOUPPER" "TOLOWER" "STRIP" "GENEX_STRIP" "REPLACE")
+ (#any-of? @_selector "AT" "FOR" "REGEX")
+ )
)
(normal_command
(identifier) @_function
(#match? @_function "\\c^list$")
- . (argument) @_transform @constant
- (argument) @constant .
- (argument) @variable
- (#eq? @_transform "TRANSFORM")
- (#eq? @constant "OUTPUT_VARIABLE")
+ (argument_list
+ . (argument) @_transform @constant
+ (argument) @constant .
+ (argument) @variable
+ (#eq? @_transform "TRANSFORM")
+ (#eq? @constant "OUTPUT_VARIABLE")
+ )
)
(escape_sequence) @string.escape
diff --git a/queries/cmake/indents.scm b/queries/cmake/indents.scm
new file mode 100644
index 000000000..6bb45d4f0
--- /dev/null
+++ b/queries/cmake/indents.scm
@@ -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)