Skip to content

Commit

Permalink
fix(cmake): Improve CMake highlight.scm (#244)
Browse files Browse the repository at this point in the history
* fix(cmake): Improve CMake highlight.scm

* Changelog
  • Loading branch information
jcs090218 authored Sep 10, 2023
1 parent c9e433e commit e082069
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 91 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Changelog

## Unreleased
- Improve `CMake` highlight.scm

## 0.12.48 - 2023-09-10
- Add `CMake` support
Expand Down
184 changes: 93 additions & 91 deletions queries/cmake/highlights.scm
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
[
(quoted_argument)
(bracket_argument)
] @string
] @string

(variable_ref) @none
(variable) @variable

[
(bracket_comment)
(line_comment)
] @comment
] @comment

(normal_command (identifier) @function)

Expand All @@ -22,108 +22,110 @@
(endfunction)
(macro)
(endmacro)
] @keyword.function
] @keyword

[
(if)
(elseif)
(else)
(endif)
] @conditional
] @keyword

[
(foreach)
(endforeach)
(while)
(endwhile)
] @repeat

;; (function_command
;; (function)
;; . (argument) @function
;; (argument)* @parameter
;; )

;; (macro_command
;; (macro)
;; . (argument) @function.macro
;; (argument)* @parameter
;; )
;;
;; (normal_command
;; (identifier) @function.builtin
;; . (argument) @variable
;; (#match? @function.builtin "\\c^(set)$")
;; )
;;
;; (normal_command
;; (identifier) @function.builtin
;; (#match? @function.builtin "\\c^(set)$")
;; (
;; (argument) @constant
;; (#any-of? @constant "PARENT_SCOPE")
;; ) .
;; )
;;
;; (normal_command
;; (identifier) @function.builtin
;; (#match? @function.builtin "\\c^(set)$")
;; . (argument)
;; (
;; (argument) @_cache @constant
;; .
;; (argument) @_type @constant
;; (#any-of? @_cache "CACHE")
;; (#any-of? @_type "BOOL" "FILEPATH" "PATH" "STRING" "INTERNAL")
;; )
;; )
;; (normal_command
;; (identifier) @function.builtin
;; (#match? @function.builtin "\\c^(set)$")
;; . (argument)
;; (argument) @_cache
;; (#any-of? @_cache "CACHE")
;; (
;; (argument) @_force @constant
;; (#any-of? @_force "FORCE")
;; ) .
;; )

;; ((argument) @boolean
;; (#match? @boolean "\\c^(1|on|yes|true|y|0|off|no|false|n|ignore|notfound|.*-notfound)$")
;; )
;;
;; (if_command
;; (if)
;; (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"
;; "MATCHES"
;; "LESS" "GREATER" "EQUAL" "LESS_EQUAL" "GREATER_EQUAL"
;; "STRLESS" "STRGREATER" "STREQUAL" "STRLESS_EQUAL" "STRGREATER_EQUAL"
;; "VERSION_LESS" "VERSION_GREATER" "VERSION_EQUAL" "VERSION_LESS_EQUAL" "VERSION_GREATER_EQUAL"
;; )
;; )
;;
;; (normal_command
;; (identifier) @function.builtin
;; . (argument)
;; (argument) @constant
;; (#any-of? @constant "ALL" "COMMAND" "DEPENDS" "BYPRODUCTS" "WORKING_DIRECTORY" "COMMENT"
;; "JOB_POOL" "VERBATIM" "USES_TERMINAL" "COMMAND_EXPAND_LISTS" "SOURCES")
;; (#match? @function.builtin "\\c^(add_custom_target)$")
;; )
;;
;; (normal_command
;; (identifier) @function.builtin
;; (argument) @constant
;; (#any-of? @constant "OUTPUT" "COMMAND" "MAIN_DEPENDENCY" "DEPENDS" "BYPRODUCTS" "IMPLICIT_DEPENDS" "WORKING_DIRECTORY"
;; "COMMENT" "DEPFILE" "JOB_POOL" "VERBATIM" "APPEND" "USES_TERMINAL" "COMMAND_EXPAND_LISTS")
;; (#match? @function.builtin "\\c^(add_custom_command)$")
;; )
] @keyword

(function_command
(function)
(argument_list
. (argument) @function
(argument)* @parameter))

(macro_command
(macro)
(argument_list
. (argument) @function.macro
(argument)* @parameter
))

(normal_command
(identifier) @function.builtin
(argument_list
. (argument) @variable
(#match? @function.builtin "^(set)$")))

(normal_command
(identifier) @function.builtin
(#match? @function.builtin "^(set)$")
(argument_list
(argument) @constant
(#any-of? @constant "PARENT_SCOPE")
) .
)

(normal_command
(identifier) @function.builtin
(#match? @function.builtin "^(set)$")
(argument_list
. (argument)
(
(argument) @_cache @constant
.
(argument) @_type @constant
(#any-of? @_cache "CACHE")
(#any-of? @_type "BOOL" "FILEPATH" "PATH" "STRING" "INTERNAL")
)))

(normal_command
(identifier) @function.builtin
(#match? @function.builtin "^(set)$")
(argument_list
. (argument)
(argument) @_cache
(#any-of? @_cache "CACHE")
(
(argument) @_force @constant
(#any-of? @_force "FORCE")
) .
))

((argument) @boolean
(#match? @boolean "^(1|on|yes|true|y|0|off|no|false|n|ignore|notfound|.*-notfound)$"))

(if_command
(if)
(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"
"MATCHES"
"LESS" "GREATER" "EQUAL" "LESS_EQUAL" "GREATER_EQUAL"
"STRLESS" "STRGREATER" "STREQUAL" "STRLESS_EQUAL" "STRGREATER_EQUAL"
"VERSION_LESS" "VERSION_GREATER" "VERSION_EQUAL" "VERSION_LESS_EQUAL" "VERSION_GREATER_EQUAL"
)))

(normal_command
(identifier) @function.builtin
(argument_list
(argument) @constant
(#any-of? @constant "ALL" "COMMAND" "DEPENDS" "BYPRODUCTS" "WORKING_DIRECTORY" "COMMENT"
"JOB_POOL" "VERBATIM" "USES_TERMINAL" "COMMAND_EXPAND_LISTS" "SOURCES")
(#match? @function.builtin "^(add_custom_target)$")))

(normal_command
(identifier) @function.builtin
(argument_list
(argument) @constant
(#any-of? @constant "OUTPUT" "COMMAND" "MAIN_DEPENDENCY" "DEPENDS" "BYPRODUCTS" "IMPLICIT_DEPENDS" "WORKING_DIRECTORY"
"COMMENT" "DEPFILE" "JOB_POOL" "VERBATIM" "APPEND" "USES_TERMINAL" "COMMAND_EXPAND_LISTS")
(#match? @function.builtin "^(add_custom_command)$")))

(escape_sequence) @string.escape

((source_file . (line_comment) @preproc)
(#match? @preproc "^#!/"))
(#match? @preproc "^#!/"))

0 comments on commit e082069

Please sign in to comment.