on master help sign in
add tree-sitter-erlang (#1657)
commit3a83a764e3a03ecf463c8fcfc141e48ed2d807ab authorMichael Davis <mcarsondavis@gmail.com> dateMon 14 Feb 2022, 19:14 (5 years ago) parent8a7aec6
6 files changed+134
.gitmodules+3 book/src/generated/lang-support.md+1 helix-syntax/languages/tree-sitter-erlang+1 languages.toml+9 runtime/queries/erlang/highlights.scm+118 runtime/queries/erlang/injections.scm+2
.gitmodules+3
@@ -226,3 +226,6 @@
226226 path = helix-syntax/languages/tree-sitter-rescript
227227 url = https://github.com/jaredramirez/tree-sitter-rescript
228228 shallow = true
229+[submodule "helix-syntax/languages/tree-sitter-erlang"]
230+ path = helix-syntax/languages/tree-sitter-erlang
231+ url = https://github.com/the-mikedavis/tree-sitter-erlang
book/src/generated/lang-support.md+1
@@ -11,6 +11,7 @@
1111| dockerfile | ✓ | | | `docker-langserver` |
1212| elixir | ✓ | | | `elixir-ls` |
1313| elm | ✓ | | | `elm-language-server` |
14+| erlang | ✓ | | | |
1415| fish | ✓ | ✓ | ✓ | |
1516| git-commit | ✓ | | | |
1617| git-config | ✓ | | | |
helix-syntax/languages/tree-sitter-erlangnew file+1

Submodule changed.

languages.toml+9
@@ -732,3 +732,12 @@ auto-format = true
732732comment-token = "//"
733733language-server = { command = "rescript-language-server", args = ["--stdio"] }
734734indent = { tab-width = 2, unit = " " }
735+
736+[[language]]
737+name = "erlang"
738+scope = "source.erlang"
739+injection-regex = "^erl$"
740+file-types = ["erl", "hrl", "app", "rebar.config"]
741+roots = ["rebar.config"]
742+comment-token = "%%"
743+indent = { tab-width = 4, unit = " " }
runtime/queries/erlang/highlights.scmnew file+118
@@ -0,0 +1,118 @@
1+; Attributes
2+; module declaration
3+(attribute
4+ name: (atom) @keyword
5+ (arguments (atom) @module)
6+ (#eq? @keyword "module"))
7+
8+(attribute
9+ name: (atom) @keyword
10+ (arguments
11+ .
12+ (atom) @module)
13+ (#eq? @keyword "import"))
14+
15+(attribute
16+ name: (atom) @keyword
17+ (arguments
18+ .
19+ (atom) @type
20+ [
21+ (tuple (atom) @variable.other.member)
22+ (tuple
23+ (binary_operator
24+ left: (atom) @variable.other.member
25+ operator: "="))
26+ (tuple
27+ (binary_operator
28+ left:
29+ (binary_operator
30+ left: (atom) @variable.other.member
31+ operator: "=")
32+ operator: "::"))
33+ ])
34+ (#eq? @keyword "record"))
35+
36+(attribute
37+ name: (atom) @keyword
38+ (arguments
39+ .
40+ [
41+ (atom) @keyword.directive
42+ (variable) @keyword.directive
43+ (call
44+ function:
45+ [(variable) (atom)] @keyword.directive)
46+ ])
47+ (#eq? @keyword "define"))
48+
49+(attribute
50+ name: (atom) @keyword
51+ module: (atom) @module
52+ (#eq? @keyword "spec"))
53+
54+; Functions
55+(function name: (atom) @function)
56+(call module: (atom) @module)
57+(call function: (atom) @function)
58+(stab_clause name: (atom) @function)
59+(function_capture module: (atom) @module)
60+(function_capture function: (atom) @function)
61+
62+; Records
63+(record_content
64+ (binary_operator
65+ left: (atom) @variable.other.member
66+ operator: "="))
67+
68+(record field: (atom) @variable.other.member)
69+(record name: (atom) @type)
70+
71+; Keywords
72+((attribute name: (atom) @keyword)
73+ (#match?
74+ @keyword
75+ "^(define|export|export_type|include|include_lib|ifdef|ifndef|if|elif|else|endif|vsn|on_load|behaviour|record|file|type|opaque|spec)$"))
76+
77+["case" "fun" "if" "of" "when" "end" "receive" "try" "catch" "after"] @keyword
78+
79+; Operators
80+(binary_operator
81+ left: (atom) @function
82+ operator: "/"
83+ right: (integer) @constant.numeric.integer)
84+
85+(binary_operator operator: _ @operator)
86+(unary_operator operator: _ @operator)
87+["/" ":" "#" "->"] @operator
88+
89+; Comments
90+((variable) @comment.discard
91+ (#match? @comment.discard "^_"))
92+
93+(tripledot) @comment.discard
94+
95+(comment) @comment
96+
97+; Macros
98+(macro
99+ "?"+ @keyword.directive
100+ name: (_) @keyword.directive)
101+
102+; Basic types
103+(variable) @variable
104+[
105+ (atom)
106+ (quoted_atom)
107+] @string.special.symbol
108+(string) @string
109+(character) @constant.character
110+
111+(integer) @constant.numeric.integer
112+(float) @constant.numeric.float
113+
114+; Punctuation
115+["," "." "-" ";"] @punctuation.delimiter
116+["(" ")" "{" "}" "[" "]" "<<" ">>"] @punctuation.bracket
117+
118+; (ERROR) @error
runtime/queries/erlang/injections.scmnew file+2
@@ -0,0 +1,2 @@
1+((comment) @injection.content
2+ (#set! injection.language "comment"))