From 471b1440f84ea29655cc3013e8a95851ca456d87 Mon Sep 17 00:00:00 2001 From: Jen-Chieh Shen Date: Sat, 9 Sep 2023 18:33:04 -0700 Subject: [PATCH 1/2] feat: Add CMake support (#207) * feat: Add CMake support * fix hl * fix hl * changelog --- .gitmodules | 6 ++ CHANGELOG.md | 1 + queries/cmake/highlights.scm | 129 +++++++++++++++++++++++++++++++++++ repos/cmake | 1 + tree-sitter-langs.el | 1 + 5 files changed, 138 insertions(+) create mode 100644 queries/cmake/highlights.scm create mode 160000 repos/cmake diff --git a/.gitmodules b/.gitmodules index b5f8d7a4..afe21aa8 100644 --- a/.gitmodules +++ b/.gitmodules @@ -376,3 +376,9 @@ branch = master update = none ignore = dirty +[submodule "repos/cmake"] + path = repos/cmake + url = https://github.com/uyha/tree-sitter-cmake + branch = master + update = none + ignore = dirty diff --git a/CHANGELOG.md b/CHANGELOG.md index 938e789b..a994a164 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # Changelog ## Unreleased +- Add `CMake` support ## 0.12.47 - 2023-09-08 - Add `Smithy` grammar diff --git a/queries/cmake/highlights.scm b/queries/cmake/highlights.scm new file mode 100644 index 00000000..7bb15857 --- /dev/null +++ b/queries/cmake/highlights.scm @@ -0,0 +1,129 @@ +[ + (quoted_argument) + (bracket_argument) +] @string + +(variable_ref) @none +(variable) @variable + +[ + (bracket_comment) + (line_comment) +] @comment + +(normal_command (identifier) @function) + +["ENV" "CACHE"] @symbol +["$" "{" "}" "<" ">"] @punctuation.special +["(" ")"] @punctuation.bracket + +[ + (function) + (endfunction) + (macro) + (endmacro) +] @keyword.function + +[ + (if) + (elseif) + (else) + (endif) +] @conditional + +[ + (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)$") +;; ) + +(escape_sequence) @string.escape + +((source_file . (line_comment) @preproc) + (#match? @preproc "^#!/")) diff --git a/repos/cmake b/repos/cmake new file mode 160000 index 00000000..73ab4b8e --- /dev/null +++ b/repos/cmake @@ -0,0 +1 @@ +Subproject commit 73ab4b8e9522f014a67f87f585e820d36fa47408 diff --git a/tree-sitter-langs.el b/tree-sitter-langs.el index 314509bd..b646f548 100644 --- a/tree-sitter-langs.el +++ b/tree-sitter-langs.el @@ -109,6 +109,7 @@ See `tree-sitter-langs-repos'." (clojure-mode . clojure) (csharp-mode . c-sharp) (c++-mode . cpp) + (cmake-mode . cmake) (d-mode . d) (dart-mode . dart) (dockerfile-mode . dockerfile) From c9e433ec4ac051f168f6ca048d1a65f569c41b64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tu=E1=BA=A5n-Anh=20Nguy=E1=BB=85n?= Date: Sun, 10 Sep 2023 01:34:01 +0000 Subject: [PATCH 2/2] Release 0.12.48 --- CHANGELOG.md | 2 ++ tree-sitter-langs-build.el | 2 +- tree-sitter-langs.el | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a994a164..5f162a22 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,8 @@ # Changelog ## Unreleased + +## 0.12.48 - 2023-09-10 - Add `CMake` support ## 0.12.47 - 2023-09-08 diff --git a/tree-sitter-langs-build.el b/tree-sitter-langs-build.el index 067d4899..bb3cc4fb 100644 --- a/tree-sitter-langs-build.el +++ b/tree-sitter-langs-build.el @@ -227,7 +227,7 @@ latest commit." ;; --------------------------------------------------------------------------- ;;; Building language grammars. -(defconst tree-sitter-langs--bundle-version "0.12.47" +(defconst tree-sitter-langs--bundle-version "0.12.48" "Version of the grammar bundle. This should be bumped whenever a language submodule is updated, which should be infrequent (grammar-only changes). It is different from the version of diff --git a/tree-sitter-langs.el b/tree-sitter-langs.el index b646f548..1ed30a75 100644 --- a/tree-sitter-langs.el +++ b/tree-sitter-langs.el @@ -5,7 +5,7 @@ ;; Author: Tuấn-Anh Nguyễn ;; Keywords: languages tools parsers tree-sitter ;; Homepage: https://github.com/emacs-tree-sitter/tree-sitter-langs -;; Version: 0.12.47 +;; Version: 0.12.48 ;; Package-Requires: ((emacs "25.1") (tree-sitter "0.15.0")) ;; SPDX-License-Identifier: MIT