on master help sign in
Added elixir syntax

Using custom fork for now to get around generating the source files

commitca042a4bde48be12734aa832e91c3cb3a9e6a931 authorCorey Powell <mistdragon100@gmail.com> dateTue 1 Jun 2021, 14:46 (5 years ago) parent67b1cd3
4 files changed+160
.gitmodules+4 helix-syntax/src/lib.rs+1 languages.toml+9 runtime/queries/elixir/highlights.scm+146
.gitmodules+4
@@ -82,3 +82,7 @@
8282 path = helix-syntax/languages/tree-sitter-toml
8383 url = https://github.com/ikatyang/tree-sitter-toml
8484 shallow = true
85+[submodule "helix-syntax/languages/tree-sitter-elixir"]
86+ path = helix-syntax/languages/tree-sitter-elixir
87+ url = https://github.com/IceDragon200/tree-sitter-elixir
88+ shallow = true
helix-syntax/src/lib.rs+1
@@ -72,6 +72,7 @@ mk_langs!(
7272 (CSharp, tree_sitter_c_sharp),
7373 (Cpp, tree_sitter_cpp),
7474 (Css, tree_sitter_css),
75+ (Elixir, tree_sitter_elixir),
7576 (Go, tree_sitter_go),
7677 // (Haskell, tree_sitter_haskell),
7778 (Html, tree_sitter_html),
languages.toml+9
@@ -17,6 +17,15 @@ roots = []
1717
1818indent = { tab-width = 2, unit = " " }
1919
20+[[language]]
21+name = "elixir"
22+scope = "source.elixir"
23+injection-regex = "elixir"
24+file-types = ["ex", "exs"]
25+roots = []
26+
27+indent = { tab-width = 2, unit = " " }
28+
2029[[language]]
2130name = "json"
2231scope = "source.json"
runtime/queries/elixir/highlights.scmnew file+146
@@ -0,0 +1,146 @@
1+["when" "and" "or" "not in" "not" "in" "fn" "do" "end" "catch" "rescue" "after" "else"] @keyword
2+
3+[(true) (false) (nil)] @constant.builtin
4+
5+(keyword
6+ [(keyword_literal)
7+ ":"] @tag)
8+
9+(keyword
10+ (keyword_string
11+ [(string_start)
12+ (string_content)
13+ (string_end)] @tag))
14+
15+[(atom_literal)
16+ (atom_start)
17+ (atom_content)
18+ (atom_end)] @tag
19+
20+(comment) @comment
21+
22+(escape_sequence) @escape
23+
24+(call function: (function_identifier) @keyword
25+ (#match? @keyword "^(defmodule|defexception|defp|def|with|case|cond|raise|import|require|use|defmacrop|defmacro|defguardp|defguard|defdelegate|defstruct|alias|defimpl|defprotocol|defoverridable|receive|if|for|try|throw|unless|reraise|super|quote|unquote|unquote_splicing)$"))
26+
27+(call function: (function_identifier) @keyword
28+ [(call
29+ function: (function_identifier) @function
30+ (arguments
31+ [(identifier) @variable.parameter
32+ (_ (identifier) @variable.parameter)
33+ (_ (_ (identifier) @variable.parameter))
34+ (_ (_ (_ (identifier) @variable.parameter)))
35+ (_ (_ (_ (_ (identifier) @variable.parameter))))
36+ (_ (_ (_ (_ (_ (identifier) @variable.parameter)))))]))
37+ (binary_op
38+ left:
39+ (call
40+ function: (function_identifier) @function
41+ (arguments
42+ [(identifier) @variable.parameter
43+ (_ (identifier) @variable.parameter)
44+ (_ (_ (identifier) @variable.parameter))
45+ (_ (_ (_ (identifier) @variable.parameter)))
46+ (_ (_ (_ (_ (identifier) @variable.parameter))))
47+ (_ (_ (_ (_ (_ (identifier) @variable.parameter)))))]))
48+ operator: "when")
49+ (binary_op
50+ left: (identifier) @variable.parameter
51+ operator: _ @function
52+ right: (identifier) @variable.parameter)]
53+ (#match? @keyword "^(defp|def|defmacrop|defmacro|defguardp|defguard|defdelegate)$")
54+ (#match? @variable.parameter "^[^_]"))
55+
56+(call (function_identifier) @keyword
57+ [(call
58+ function: (function_identifier) @function)
59+ (identifier) @function
60+ (binary_op
61+ left:
62+ [(call
63+ function: (function_identifier) @function)
64+ (identifier) @function]
65+ operator: "when")]
66+ (#match? @keyword "^(defp|def|defmacrop|defmacro|defguardp|defguard|defdelegate)$"))
67+
68+(anonymous_function
69+ (stab_expression
70+ left: (bare_arguments
71+ [(identifier) @variable.parameter
72+ (_ (identifier) @variable.parameter)
73+ (_ (_ (identifier) @variable.parameter))
74+ (_ (_ (_ (identifier) @variable.parameter)))
75+ (_ (_ (_ (_ (identifier) @variable.parameter))))
76+ (_ (_ (_ (_ (_ (identifier) @variable.parameter)))))]))
77+ (#match? @variable.parameter "^[^_]"))
78+
79+(unary_op
80+ operator: "@"
81+ (call (identifier) @attribute
82+ (heredoc
83+ [(heredoc_start)
84+ (heredoc_content)
85+ (heredoc_end)] @doc))
86+ (#match? @attribute "^(doc|moduledoc)$"))
87+
88+(module) @type
89+
90+(unary_op
91+ operator: "@" @attribute
92+ [(call
93+ function: (function_identifier) @attribute)
94+ (identifier) @attribute])
95+
96+(unary_op
97+ operator: _ @operator)
98+
99+(binary_op
100+ operator: _ @operator)
101+
102+(heredoc
103+ [(heredoc_start)
104+ (heredoc_content)
105+ (heredoc_end)] @string)
106+
107+(string
108+ [(string_start)
109+ (string_content)
110+ (string_end)] @string)
111+
112+(sigil_start) @string.special
113+(sigil_content) @string
114+(sigil_end) @string.special
115+
116+(interpolation
117+ "#{" @punctuation.special
118+ "}" @punctuation.special)
119+
120+[
121+ ","
122+ "->"
123+ "."
124+] @punctuation.delimiter
125+
126+[
127+ "("
128+ ")"
129+ "["
130+ "]"
131+ "{"
132+ "}"
133+ "<<"
134+ ">>"
135+] @punctuation.bracket
136+
137+[(identifier) @function.special
138+ (#match? @function.special "^__.+__$")]
139+
140+[(remote_identifier) @function.special
141+ (#match? @function.special "^__.+__$")]
142+
143+[(identifier) @comment
144+ (#match? @comment "^_")]
145+
146+(ERROR) @warning