diff options
author | ath3 | 2021-10-22 23:57:21 +0000 |
---|---|---|
committer | GitHub | 2021-10-22 23:57:21 +0000 |
commit | 787ba4f233a38e42cfeab5c5125122d7d7b85e8f (patch) | |
tree | 65ffc5ec151db68c9967ebfecec2640d4df87722 | |
parent | 6c995fa6906f9d6895d27fd4b595ba254cbb966a (diff) |
CMake support (#888)
-rw-r--r-- | .gitmodules | 4 | ||||
m--------- | helix-syntax/languages/tree-sitter-cmake | 0 | ||||
-rw-r--r-- | languages.toml | 8 | ||||
-rw-r--r-- | runtime/queries/cmake/highlights.scm | 97 |
4 files changed, 109 insertions, 0 deletions
diff --git a/.gitmodules b/.gitmodules index 01260b84..7ed34ad3 100644 --- a/.gitmodules +++ b/.gitmodules @@ -130,3 +130,7 @@ path = helix-syntax/languages/tree-sitter-tsq url = https://github.com/tree-sitter/tree-sitter-tsq shallow = true +[submodule "helix-syntax/languages/tree-sitter-cmake"] + path = helix-syntax/languages/tree-sitter-cmake + url = https://github.com/uyha/tree-sitter-cmake + shallow = true diff --git a/helix-syntax/languages/tree-sitter-cmake b/helix-syntax/languages/tree-sitter-cmake new file mode 160000 +Subproject f6616f1e417ee8b62daf251aa1daa5d73781c59 diff --git a/languages.toml b/languages.toml index 67f4d3d6..a393b4a6 100644 --- a/languages.toml +++ b/languages.toml @@ -346,3 +346,11 @@ file-types = ["scm"] roots = [] comment-token = ";" indent = { tab-width = 2, unit = " " } + +[[language]] +name = "cmake" +scope = "source.cmake" +file-types = ["cmake", "CMakeLists.txt"] +roots = [] +comment-token = "#" +indent = { tab-width = 2, unit = " " } diff --git a/runtime/queries/cmake/highlights.scm b/runtime/queries/cmake/highlights.scm new file mode 100644 index 00000000..71e9b5d9 --- /dev/null +++ b/runtime/queries/cmake/highlights.scm @@ -0,0 +1,97 @@ +[ + (quoted_argument) + (bracket_argument) + ] @string + +(variable) @variable + +[ + (bracket_comment) + (line_comment) + ] @comment + +(normal_command (identifier) @function) + +["ENV" "CACHE"] @string.special.symbol +["$" "{" "}" "<" ">"] @punctuation +["(" ")"] @punctuation.bracket + +[ + (function) + (endfunction) + (macro) + (endmacro) + ] @keyword.function + +[ + (if) + (elseif) + (else) + (endif) + ] @keyword.control.conditional + +[ + (foreach) + (endforeach) + (while) + (endwhile) + ] @keyword.control.repeat + +(function_command + (function) + . (argument) @function + (argument)* @variable.parameter + ) + +(macro_command + (macro) + . (argument) @function.macro + (argument)* @variable.parameter + ) + +(normal_command + (identifier) @function.builtin + . (argument) @variable + (#match? @function.builtin "^(?i)(set)$")) + +(normal_command + (identifier) @function.builtin + . (argument) + (argument) @constant + (#match? @constant "^(?:PARENT_SCOPE|CACHE)$") + (#match? @function.builtin "^(?i)(unset)$")) + +(normal_command + (identifier) @function.builtin + . (argument) + . (argument) + (argument) @constant + (#match? @constant "^(?:PARENT_SCOPE|CACHE|FORCE)$") + (#match? @function.builtin "^(?i)(set)$") + ) + +((argument) @constant.builtin.boolean + (#match? @constant.builtin.boolean "^(?i)(?:1|on|yes|true|y|0|off|no|false|n|ignore|notfound|.*-notfound)$") + ) + +(if_command + (if) + (argument) @operator + (#match? @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 + (#match? @constant "^(?:ALL|COMMAND|DEPENDS|BYPRODUCTS|WORKING_DIRECTORY|COMMENT|JOB_POOL|VERBATIM|USES_TERMINAL|COMMAND_EXPAND_LISTS|SOURCES)$") + (#match? @function.builtin "^(?i)(add_custom_target)$") + ) + +(normal_command + (identifier) @function.builtin + (argument) @constant + (#match? @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 "^(?i)(add_custom_command)$") + ) + |