Skip to content

Commit

Permalink
feat: Add Make support (#253)
Browse files Browse the repository at this point in the history
  • Loading branch information
jcs090218 authored Oct 4, 2023
1 parent e3b6390 commit fe36869
Show file tree
Hide file tree
Showing 5 changed files with 208 additions and 78 deletions.
6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Changelog

## Unreleased
- Add `Make` support

## 0.12.53 - 2023-10-04
- Add `reStructuredText` support
Expand Down
116 changes: 116 additions & 0 deletions queries/make/highlights.scm
Original file line number Diff line number Diff line change
@@ -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)
1 change: 1 addition & 0 deletions repos/make
Submodule make added at a4b918
162 changes: 84 additions & 78 deletions tree-sitter-langs.el
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit fe36869

Please sign in to comment.