on master help sign in
feat: add tree-sitter-make

This commit adds syntax highlighting for GNU Make[^1] makefiles via tree-sitter-make[^2]. [^1]: https://www.gnu.org/software/make/ [^2]: https://github.com/alemuller/tree-sitter-make

commit1c6bc6d455595aa5b8d7d2aa27d025722f57c351 authorEric Crosson <eric.s.crosson@utexas.edu> dateMon 3 Jan 2022, 19:17 (5 years ago) parentc238f20
5 files changed+184−1
.gitmodules+5−1 book/src/generated/lang-support.md+1 helix-syntax/languages/tree-sitter-make+1 languages.toml+7 runtime/queries/make/highlights.scm+170
.gitmodules+5−1
@@ -177,7 +177,7 @@
177177[submodule "helix-syntax/languages/tree-sitter-llvm-mir"]
178178 path = helix-syntax/languages/tree-sitter-llvm-mir
179179 url = https://github.com/Flakebi/tree-sitter-llvm-mir.git
180− shallow = true
180+ shallow = true
181181[submodule "helix-syntax/languages/tree-sitter-git-diff"]
182182 path = helix-syntax/languages/tree-sitter-git-diff
183183 url = https://github.com/the-mikedavis/tree-sitter-git-diff.git
@@ -194,3 +194,7 @@
194194 path = helix-syntax/languages/tree-sitter-regex
195195 url = https://github.com/tree-sitter/tree-sitter-regex.git
196196 shallow = true
197+[submodule "helix-syntax/languages/tree-sitter-make"]
198+ path = helix-syntax/languages/tree-sitter-make
199+ url = https://github.com/alemuller/tree-sitter-make
200+ shallow = true
book/src/generated/lang-support.md+1
@@ -27,6 +27,7 @@
2727| llvm-mir | ✓ | ✓ | ✓ | |
2828| llvm-mir-yaml | ✓ | | ✓ | |
2929| lua | ✓ | | ✓ | |
30+| make | ✓ | | | |
3031| markdown | ✓ | | | |
3132| mint | | | | `mint` |
3233| nix | ✓ | | ✓ | `rnix-lsp` |
helix-syntax/languages/tree-sitter-makenew file+1

Submodule changed.

languages.toml+7
@@ -390,6 +390,13 @@ indent = { tab-width = 2, unit = " " }
390390language-server = { command = "cmake-language-server" }
391391injection-regex = "cmake"
392392
393+[[language]]
394+name = "make"
395+scope = "source.make"
396+file-types = ["Makefile", "makefile", "justfile", ".justfile"]
397+roots =[]
398+comment-token = "#"
399+
393400[[language]]
394401name = "glsl"
395402scope = "source.glsl"
runtime/queries/make/highlights.scmnew file+170
@@ -0,0 +1,170 @@
1+[
2+ "("
3+ ")"
4+ "{"
5+ "}"
6+] @punctuation.bracket
7+
8+[
9+ ":"
10+ "&:"
11+ "::"
12+ "|"
13+ ";"
14+ "\""
15+ "'"
16+ ","
17+] @punctuation.delimiter
18+
19+[
20+ "$"
21+ "$$"
22+] @punctuation.special
23+
24+(automatic_variable
25+ [ "@" "%" "<" "?" "^" "+" "/" "*" "D" "F"] @punctuation.special)
26+
27+(automatic_variable
28+ "/" @error . ["D" "F"])
29+
30+[
31+ "="
32+ ":="
33+ "::="
34+ "?="
35+ "+="
36+ "!="
37+ "@"
38+ "-"
39+ "+"
40+] @operator
41+
42+[
43+ (text)
44+ (string)
45+ (raw_text)
46+] @string
47+
48+(variable_assignment (word) @string)
49+
50+[
51+ "ifeq"
52+ "ifneq"
53+ "ifdef"
54+ "ifndef"
55+ "else"
56+ "endif"
57+ "if"
58+ "or" ; boolean functions are conditional in make grammar
59+ "and"
60+] @keyword.control.conditional
61+
62+"foreach" @keyword.control.repeat
63+
64+[
65+ "define"
66+ "endef"
67+ "vpath"
68+ "undefine"
69+ "export"
70+ "unexport"
71+ "override"
72+ "private"
73+; "load"
74+] @keyword
75+
76+[
77+ "include"
78+ "sinclude"
79+ "-include"
80+] @keyword.control.import
81+
82+[
83+ "subst"
84+ "patsubst"
85+ "strip"
86+ "findstring"
87+ "filter"
88+ "filter-out"
89+ "sort"
90+ "word"
91+ "words"
92+ "wordlist"
93+ "firstword"
94+ "lastword"
95+ "dir"
96+ "notdir"
97+ "suffix"
98+ "basename"
99+ "addsuffix"
100+ "addprefix"
101+ "join"
102+ "wildcard"
103+ "realpath"
104+ "abspath"
105+ "call"
106+ "eval"
107+ "file"
108+ "value"
109+ "shell"
110+] @keyword.function
111+
112+[
113+ "error"
114+ "warning"
115+ "info"
116+] @keyword.control.exception
117+
118+;; Variable
119+(variable_assignment
120+ name: (word) @variable)
121+
122+(variable_reference
123+ (word) @variable)
124+
125+(comment) @comment
126+
127+((word) @clean @string.regexp
128+ (#match? @clean "[%\*\?]"))
129+
130+(function_call
131+ function: "error"
132+ (arguments (text) @error))
133+
134+(function_call
135+ function: "warning"
136+ (arguments (text) @warning))
137+
138+(function_call
139+ function: "info"
140+ (arguments (text) @info))
141+
142+;; Install Command Categories
143+;; Others special variables
144+;; Variables Used by Implicit Rules
145+[
146+ "VPATH"
147+ ".RECIPEPREFIX"
148+] @constant.builtin
149+
150+(variable_assignment
151+ name: (word) @clean @constant.builtin
152+ (#match? @clean "^(AR|AS|CC|CXX|CPP|FC|M2C|PC|CO|GET|LEX|YACC|LINT|MAKEINFO|TEX|TEXI2DVI|WEAVE|CWEAVE|TANGLE|CTANGLE|RM|ARFLAGS|ASFLAGS|CFLAGS|CXXFLAGS|COFLAGS|CPPFLAGS|FFLAGS|GFLAGS|LDFLAGS|LDLIBS|LFLAGS|YFLAGS|PFLAGS|RFLAGS|LINTFLAGS|PRE_INSTALL|POST_INSTALL|NORMAL_INSTALL|PRE_UNINSTALL|POST_UNINSTALL|NORMAL_UNINSTALL|MAKEFILE_LIST|MAKE_RESTARTS|MAKE_TERMOUT|MAKE_TERMERR|\.DEFAULT_GOAL|\.RECIPEPREFIX|\.EXTRA_PREREQS)$"))
153+
154+(variable_reference
155+ (word) @clean @constant.builtin
156+ (#match? @clean "^(AR|AS|CC|CXX|CPP|FC|M2C|PC|CO|GET|LEX|YACC|LINT|MAKEINFO|TEX|TEXI2DVI|WEAVE|CWEAVE|TANGLE|CTANGLE|RM|ARFLAGS|ASFLAGS|CFLAGS|CXXFLAGS|COFLAGS|CPPFLAGS|FFLAGS|GFLAGS|LDFLAGS|LDLIBS|LFLAGS|YFLAGS|PFLAGS|RFLAGS|LINTFLAGS|PRE_INSTALL|POST_INSTALL|NORMAL_INSTALL|PRE_UNINSTALL|POST_UNINSTALL|NORMAL_UNINSTALL|MAKEFILE_LIST|MAKE_RESTARTS|MAKE_TERMOUT|MAKE_TERMERR|\.DEFAULT_GOAL|\.RECIPEPREFIX|\.EXTRA_PREREQS\.VARIABLES|\.FEATURES|\.INCLUDE_DIRS|\.LOADED)$"))
157+
158+;; Standart targets
159+(targets
160+ (word) @constant.macro
161+ (#match? @constant.macro "^(all|install|install-html|install-dvi|install-pdf|install-ps|uninstall|install-strip|clean|distclean|mostlyclean|maintainer-clean|TAGS|info|dvi|html|pdf|ps|dist|check|installcheck|installdirs)$"))
162+
163+(targets
164+ (word) @constant.macro
165+ (#match? @constant.macro "^(all|install|install-html|install-dvi|install-pdf|install-ps|uninstall|install-strip|clean|distclean|mostlyclean|maintainer-clean|TAGS|info|dvi|html|pdf|ps|dist|check|installcheck|installdirs)$"))
166+
167+;; Builtin targets
168+(targets
169+ (word) @constant.macro
170+ (#match? @constant.macro "^\.(PHONY|SUFFIXES|DEFAULT|PRECIOUS|INTERMEDIATE|SECONDARY|SECONDEXPANSION|DELETE_ON_ERROR|IGNORE|LOW_RESOLUTION_TIME|SILENT|EXPORT_ALL_VARIABLES|NOTPARALLEL|ONESHELL|POSIX)$"))