From fe3686962cd845fd20ce0ec2790e4d30691e6bf2 Mon Sep 17 00:00:00 2001 From: Jen-Chieh Shen Date: Wed, 4 Oct 2023 15:33:17 -0700 Subject: [PATCH] feat: Add Make support (#253) --- .gitmodules | 6 ++ CHANGELOG.md | 1 + queries/make/highlights.scm | 116 ++++++++++++++++++++++++++ repos/make | 1 + tree-sitter-langs.el | 162 +++++++++++++++++++----------------- 5 files changed, 208 insertions(+), 78 deletions(-) create mode 100644 queries/make/highlights.scm create mode 160000 repos/make diff --git a/.gitmodules b/.gitmodules index 590d53bf..e045da1b 100644 --- a/.gitmodules +++ b/.gitmodules @@ -406,3 +406,9 @@ branch = master update = none ignore = dirty +[submodule "repos/make"] + path = repos/make + url = https://github.com/alemuller/tree-sitter-make + branch = main + update = none + ignore = dirty diff --git a/CHANGELOG.md b/CHANGELOG.md index 127bb5c4..c8ebb9fa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # Changelog ## Unreleased +- Add `Make` support ## 0.12.53 - 2023-10-04 - Add `reStructuredText` support diff --git a/queries/make/highlights.scm b/queries/make/highlights.scm new file mode 100644 index 00000000..f94c567b --- /dev/null +++ b/queries/make/highlights.scm @@ -0,0 +1,116 @@ +(comment) @comment @spell + +(conditional + (_ [ + "ifeq" + "else" + "ifneq" + "ifdef" + "ifndef" + ] @conditional) + "endif" @conditional) + +(rule (targets + (word) @function.builtin + (#any-of? @function.builtin + ".DEFAULT" + ".SUFFIXES" + ".DELETE_ON_ERROR" + ".EXPORT_ALL_VARIABLES" + ".IGNORE" + ".INTERMEDIATE" + ".LOW_RESOLUTION_TIME" + ".NOTPARALLEL" + ".ONESHELL" + ".PHONY" + ".POSIX" + ".PRECIOUS" + ".SECONDARY" + ".SECONDEXPANSION" + ".SILENT" + ".SUFFIXES"))) + +(rule ["&:" ":" "::"] @operator) + +(export_directive "export" @keyword) +(override_directive "override" @keyword) +(include_directive ["include" "-include"] @include) + +(variable_assignment + (word) @symbol) +(variable_assignment [ + "?=" + ":=" + "+=" + "=" + ] @operator) + + +(variable_assignment + (word) @variable.builtin + (#any-of? @variable.builtin + ".DEFAULT_GOAL" + ".EXTRA_PREREQS" + ".FEATURES" + ".INCLUDE_DIRS" + ".RECIPEPREFIX" + ".SHELLFLAGS" + ".VARIABLES" + "MAKEARGS" + "MAKEFILE_LIST" + "MAKEFLAGS" + "MAKE_RESTARTS" + "MAKE_TERMERR" + "MAKE_TERMOUT" + "SHELL" + )) + + +; Use string to match bash +(variable_reference (word) @string) @operator + + +(shell_function + ["$" "(" ")"] @operator + "shell" @function.builtin) + +(function_call ["$" "(" ")"] @operator) +(substitution_reference ["$" "(" ")"] @operator) + +(function_call [ + "subst" + "patsubst" + "strip" + "findstring" + "filter" + "filter-out" + "sort" + "word" + "words" + "wordlist" + "firstword" + "lastword" + "dir" + "notdir" + "suffix" + "basename" + "addsuffix" + "addprefix" + "join" + "wildcard" + "realpath" + "abspath" + "error" + "warning" + "info" + "origin" + "flavor" + "foreach" + "if" + "or" + "and" + "call" + "eval" + "file" + "value" + ] @function.builtin) diff --git a/repos/make b/repos/make new file mode 160000 index 00000000..a4b91874 --- /dev/null +++ b/repos/make @@ -0,0 +1 @@ +Subproject commit a4b9187417d6be349ee5fd4b6e77b4172c6827dd diff --git a/tree-sitter-langs.el b/tree-sitter-langs.el index 9bfd69fb..0d71b731 100644 --- a/tree-sitter-langs.el +++ b/tree-sitter-langs.el @@ -98,84 +98,90 @@ See `tree-sitter-langs-repos'." "Link known major modes to languages provided by the bundle." (dolist (entry (reverse - '((ada-mode . ada) - (agda-mode . agda) - (agda2-mode . agda) - (fasm-mode . asm) - (masm-mode . asm) - (nasm-mode . asm) - (sh-mode . bash) - (beancount-mode . beancount) - (bibtex-mode . bibtex) - (c-mode . c) - (caml-mode . ocaml) - (clojure-mode . clojure) - (csharp-mode . c-sharp) - (c++-mode . cpp) - (cmake-mode . cmake) - (d-mode . d) - (dart-mode . dart) - (dockerfile-mode . dockerfile) - (css-mode . css) - (elm-mode . elm) - (elixir-mode . elixir) - (emacs-lisp-mode . elisp) - (erlang-mode . erlang) - (ess-r-mode . r) - (fennel-mode . fennel) - (f90-mode . fortran) - (fortran-mode . fortran) - (gdscript-mode . gdscript) - (go-mode . go) - (haskell-mode . haskell) - (hcl-mode . hcl) - (terraform-mode . hcl) - (html-mode . html) - (markdown-mode . markdown) - (mhtml-mode . html) - (nix-mode . nix) - (jai-mode . jai) - (java-mode . java) - (javascript-mode . javascript) - (js-mode . javascript) - (js2-mode . javascript) - (js3-mode . javascript) - (json-mode . json) - (jsonc-mode . json) - (jsonnet-mode . jsonnet) - (julia-mode . julia) - (kotlin-mode . kotlin) - (latex-mode . latex) - (lua-mode . lua) - (matlab-mode . matlab) - (mermaid-mode . mermaid) - (meson-mode . meson) - (noir-mode . noir) - (ocaml-mode . ocaml) - (pascal-mode . pascal) - (perl-mode . perl) - (php-mode . php) - (prisma-mode . prisma) - (python-mode . python) - (pygn-mode . pgn) - (rjsx-mode . javascript) - (rst-mode . rst) - (ruby-mode . ruby) - (rust-mode . rust) - (rustic-mode . rust) - (scala-mode . scala) - (scheme-mode . scheme) - (smithy-mode . smithy) - (swift-mode . swift) - (toml-mode . toml) - (conf-toml-mode . toml) - (tuareg-mode . ocaml) - (typescript-mode . typescript) - (verilog-mode . verilog) - (vhdl-mode . vhdl) - (nxml-mode . xml) - (yaml-mode . yaml) - (zig-mode . zig)))) + '((ada-mode . ada) + (agda-mode . agda) + (agda2-mode . agda) + (fasm-mode . asm) + (masm-mode . asm) + (nasm-mode . asm) + (sh-mode . bash) + (beancount-mode . beancount) + (bibtex-mode . bibtex) + (c-mode . c) + (caml-mode . ocaml) + (clojure-mode . clojure) + (csharp-mode . c-sharp) + (c++-mode . cpp) + (cmake-mode . cmake) + (d-mode . d) + (dart-mode . dart) + (dockerfile-mode . dockerfile) + (css-mode . css) + (elm-mode . elm) + (elixir-mode . elixir) + (emacs-lisp-mode . elisp) + (erlang-mode . erlang) + (ess-r-mode . r) + (fennel-mode . fennel) + (f90-mode . fortran) + (fortran-mode . fortran) + (gdscript-mode . gdscript) + (go-mode . go) + (haskell-mode . haskell) + (hcl-mode . hcl) + (terraform-mode . hcl) + (html-mode . html) + (markdown-mode . markdown) + (mhtml-mode . html) + (nix-mode . nix) + (jai-mode . jai) + (java-mode . java) + (javascript-mode . javascript) + (js-mode . javascript) + (js2-mode . javascript) + (js3-mode . javascript) + (json-mode . json) + (jsonc-mode . json) + (jsonnet-mode . jsonnet) + (julia-mode . julia) + (kotlin-mode . kotlin) + (latex-mode . latex) + (lua-mode . lua) + (makefile-mode . make) + (makefile-automake-mode . make) + (makefile-gmake-mode . make) + (makefile-makepp-mode . make) + (makefile-bsdmake-mode . make) + (makefile-imake-mode . make) + (matlab-mode . matlab) + (mermaid-mode . mermaid) + (meson-mode . meson) + (noir-mode . noir) + (ocaml-mode . ocaml) + (pascal-mode . pascal) + (perl-mode . perl) + (php-mode . php) + (prisma-mode . prisma) + (python-mode . python) + (pygn-mode . pgn) + (rjsx-mode . javascript) + (rst-mode . rst) + (ruby-mode . ruby) + (rust-mode . rust) + (rustic-mode . rust) + (scala-mode . scala) + (scheme-mode . scheme) + (smithy-mode . smithy) + (swift-mode . swift) + (toml-mode . toml) + (conf-toml-mode . toml) + (tuareg-mode . ocaml) + (typescript-mode . typescript) + (verilog-mode . verilog) + (vhdl-mode . vhdl) + (nxml-mode . xml) + (yaml-mode . yaml) + (zig-mode . zig)))) (cl-pushnew entry tree-sitter-major-mode-language-alist :key #'car)) (advice-remove 'tree-sitter--setup #'tree-sitter-langs--init-major-mode-alist))