on master help sign in
add highlights query from elixir-lang/tree-sitter-elixir
d1b434dMichael Davis
runtime/queries/elixir/highlights.scm+179−122
@@ -1,125 +1,186 @@
1+; Reserved keywords
2+
1−["when" "and" "or" "not in" "not" "in" "fn" "do" "end" "catch" "rescue" "after" "else"] @keyword
3+["when" "and" "or" "not" "in" "fn" "do" "end" "catch" "rescue" "after" "else"] @keyword
2−
4+
3−[(true) (false) (nil)] @constant.builtin
5+; Operators
4−
6+
5−(keyword
7+; * doc string
6− [(keyword_literal)
8+(unary_operator
7− ":"] @tag)
9+ operator: "@" @comment.doc
8−
10+ operand: (call
9−(keyword
11+ target: (identifier) @comment.doc.__attribute__
10− (keyword_string
12+ (arguments
11− [(string_start)
13+ [
12− (string_content)
14+ (string) @comment.doc
13− (string_end)] @tag))
15+ (charlist) @comment.doc
14−
16+ (sigil
15−[(atom_literal)
17+ quoted_start: _ @comment.doc
16− (atom_start)
18+ quoted_end: _ @comment.doc) @comment.doc
17− (atom_content)
19+ (boolean) @comment.doc
18− (atom_end)] @tag
20+ ]))
19−
21+ (#match? @comment.doc.__attribute__ "^(moduledoc|typedoc|doc)$"))
20−[(comment)
22+
21− (unused_identifier)] @comment
23+; * module attribute
22−
24+(unary_operator
25+ operator: "@" @attribute
26+ operand: [
27+ (identifier) @attribute
28+ (call
29+ target: (identifier) @attribute)
30+ (boolean) @attribute
31+ (nil) @attribute
32+ ])
33+
34+; * capture operand
35+(unary_operator
36+ operator: "&"
37+ operand: (integer) @operator)
38+
39+(operator_identifier) @operator
40+
41+(unary_operator
42+ operator: _ @operator)
43+
44+(binary_operator
45+ operator: _ @operator)
46+
47+(dot
48+ operator: _ @operator)
49+
50+(stab_clause
51+ operator: _ @operator)
52+
53+; Literals
54+
55+[
56+ (boolean)
57+ (nil)
58+] @constant
59+
60+[
61+ (integer)
62+ (float)
63+] @number
64+
65+(alias) @type
66+
67+(char) @constant
68+
69+; Quoted content
70+
71+(interpolation "#{" @punctuation.special "}" @punctuation.special) @embedded
72+
23−(escape_sequence) @escape
73+(escape_sequence) @string.escape
24−
74+
25−(call function: (function_identifier) @keyword
75+[
26− (#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)$"))
76+ (atom)
27−
77+ (quoted_atom)
28−(call function: (function_identifier) @keyword
78+ (keyword)
79+ (quoted_keyword)
80+] @string.special.symbol
81+
82+[
83+ (string)
84+ (charlist)
85+] @string
86+
87+; Note that we explicitly target sigil quoted start/end, so they are not overridden by delimiters
88+
89+(sigil
90+ (sigil_name) @__name__
91+ quoted_start: _ @string
92+ quoted_end: _ @string
93+ (#match? @__name__ "^[sS]$")) @string
94+
95+(sigil
96+ (sigil_name) @__name__
97+ quoted_start: _ @string.regex
98+ quoted_end: _ @string.regex
99+ (#match? @__name__ "^[rR]$")) @string.regex
100+
101+(sigil
102+ (sigil_name) @__name__
103+ quoted_start: _ @string.special
104+ quoted_end: _ @string.special) @string.special
105+
106+; Calls
107+
108+; * definition keyword
109+(call
110+ target: (identifier) @keyword
111+ (#match? @keyword "^(def|defdelegate|defexception|defguard|defguardp|defimpl|defmacro|defmacrop|defmodule|defn|defnp|defoverridable|defp|defprotocol|defstruct)$"))
112+
113+; * kernel or special forms keyword
114+(call
115+ target: (identifier) @keyword
116+ (#match? @keyword "^(alias|case|cond|else|for|if|import|quote|raise|receive|require|reraise|super|throw|try|unless|unquote|unquote_splicing|use|with)$"))
117+
118+; * function call
29− [(call
119+(call
30− function: (function_identifier) @function
120+ target: [
31− (arguments
121+ ; local
32− [(identifier) @variable.parameter
33− (_ (identifier) @variable.parameter)
122+ (identifier) @function
34− (_ (_ (identifier) @variable.parameter))
123+ ; remote
35− (_ (_ (_ (identifier) @variable.parameter)))
124+ (dot
36− (_ (_ (_ (_ (identifier) @variable.parameter))))
125+ right: (identifier) @function)
126+ ])
127+
128+; * just identifier in function definition
129+(call
130+ target: (identifier) @keyword
131+ (arguments
132+ [
37− (_ (_ (_ (_ (_ (identifier) @variable.parameter)))))]))
133+ (identifier) @function
38− (binary_op
134+ (binary_operator
39− left:
40− (call
41− function: (function_identifier) @function
42− (arguments
43− [(identifier) @variable.parameter
135+ left: (identifier) @function
44− (_ (identifier) @variable.parameter)
45− (_ (_ (identifier) @variable.parameter))
46− (_ (_ (_ (identifier) @variable.parameter)))
47− (_ (_ (_ (_ (identifier) @variable.parameter))))
48− (_ (_ (_ (_ (_ (identifier) @variable.parameter)))))]))
49 operator: "when")
136 operator: "when")
50− (binary_op
137+ ])
51− left: (identifier) @variable.parameter
138+ (#match? @keyword "^(def|defdelegate|defguard|defguardp|defmacro|defmacrop|defn|defnp|defp)$"))
52− operator: _ @function
139+
53− right: (identifier) @variable.parameter)]
140+; * pipe into identifier (definition)
54− (#match? @keyword "^(defp|def|defmacrop|defmacro|defguardp|defguard|defdelegate)$"))
55−
56−(call (function_identifier) @keyword
57− [(call
141+(call
58− function: (function_identifier) @function)
142+ target: (identifier) @keyword
59− (identifier) @function
143+ (arguments
60− (binary_op
144+ (binary_operator
61− left:
145+ operator: "|>"
62− [(call
146+ right: (identifier) @variable))
63− function: (function_identifier) @function)
147+ (#match? @keyword "^(def|defdelegate|defguard|defguardp|defmacro|defmacrop|defn|defnp|defp)$"))
64− (identifier) @function]
148+
65− operator: "when")]
149+; * pipe into identifier (function call)
66− (#match? @keyword "^(defp|def|defmacrop|defmacro|defguardp|defguard|defdelegate)$"))
150+(binary_operator
67−
151+ operator: "|>"
68−(anonymous_function
152+ right: (identifier) @function)
69− (stab_expression
153+
70− left: (bare_arguments
154+; Identifiers
71− [(identifier) @variable.parameter
155+
72− (_ (identifier) @variable.parameter)
156+; * special
73− (_ (_ (identifier) @variable.parameter))
157+(
74− (_ (_ (_ (identifier) @variable.parameter)))
158+ (identifier) @constant.builtin
75− (_ (_ (_ (_ (identifier) @variable.parameter))))
159+ (#match? @constant.builtin "^(__MODULE__|__DIR__|__ENV__|__CALLER__|__STACKTRACE__)$")
76− (_ (_ (_ (_ (_ (identifier) @variable.parameter)))))])))
160+)
77−
161+
78−(unary_op
162+; * unused
79− operator: "@"
163+(
80− (call (identifier) @attribute
164+ (identifier) @comment.unused
81− (heredoc
165+ (#match? @comment.unused "^_")
82− [(heredoc_start)
166+)
83− (heredoc_content)
167+
84− (heredoc_end)] @doc))
168+; * regular
85− (#match? @attribute "^(doc|moduledoc)$"))
169+(identifier) @variable
86−
170+
87−(module) @type
171+; Comment
88−
172+
89−(unary_op
173+(comment) @comment
90− operator: "@" @attribute
174+
91− [(call
175+; Punctuation
92− function: (function_identifier) @attribute)
176+
93− (identifier) @attribute])
177+[
94−
178+ "%"
95−(unary_op
96− operator: _ @operator)
97−
98−(binary_op
99− operator: _ @operator)
100−
101−(heredoc
102− [(heredoc_start)
103− (heredoc_content)
104− (heredoc_end)] @string)
105−
106−(string
107− [(string_start)
108− (string_content)
109− (string_end)] @string)
110−
111−(sigil_start) @string.special
112−(sigil_content) @string
113−(sigil_end) @string.special
114−
115−(interpolation
116− "#{" @punctuation.special
117− "}" @punctuation.special)
179+] @punctuation
118
180
119[
181[
120 ","
182 ","
121− "->"
183+ ";"
122− "."
123] @punctuation.delimiter
184] @punctuation.delimiter
124
185
125[
186[
@@ -132,7 +193,3 @@
132 "<<"
193 "<<"
133 ">>"
194 ">>"
134] @punctuation.bracket
195] @punctuation.bracket
135−
136−(special_identifier) @function.special
137−
138−(ERROR) @warning