Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CMake support #888

Merged
merged 1 commit into from
Oct 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions helix-syntax/languages/tree-sitter-cmake
Submodule tree-sitter-cmake added at f6616f
8 changes: 8 additions & 0 deletions languages.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = " " }
97 changes: 97 additions & 0 deletions runtime/queries/cmake/highlights.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
[
(quoted_argument)
(bracket_argument)
] @string

(variable) @variable
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(variable_ref) @none

Was the query taken and modified from original master branch of nvim-treesitter? Seemed different to me here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, its ported from nvim-treesitter.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i didnt find @none in the documentation, should put variable_ref back in scm, and use some other scope for it?


[
(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)$")
)