@@ -1,125 +1,186 @@
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
3−[(true) (false) (nil)] @constant.builtin
5+; Operators
5−(keyword
7+; * doc string
6− [(keyword_literal)
8+(unary_operator
7− ":"] @tag)
9+ operator: "@" @comment.doc
9−(keyword
11+ target: (identifier) @comment.doc.__attribute__
10− (keyword_string
12+ (arguments
12− (string_content)
14+ (string) @comment.doc
13− (string_end)] @tag))
15+ (charlist) @comment.doc
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)$"))
21− (unused_identifier)] @comment
23+; * module attribute
25+ operator: "@" @attribute
27+ (identifier) @attribute
29+ target: (identifier) @attribute)
37+ operand: (integer) @operator)
39+(operator_identifier) @operator
42+ operator: _ @operator)
45+ operator: _ @operator)
48+ operator: _ @operator)
51+ operator: _ @operator)
71+(interpolation "#{" @punctuation.special "}" @punctuation.special) @embedded
23−(escape_sequence) @escape
73+(escape_sequence) @string.escape
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)
28−(call function: (function_identifier) @keyword
78+ (keyword)
80+] @string.special.symbol
87+; Note that we explicitly target sigil quoted start/end, so they are not overridden by delimiters
90+ (sigil_name) @__name__
91+ quoted_start: _ @string
92+ quoted_end: _ @string
93+ (#match? @__name__ "^[sS]$")) @string
96+ (sigil_name) @__name__
97+ quoted_start: _ @string.regex
98+ quoted_end: _ @string.regex
99+ (#match? @__name__ "^[rR]$")) @string.regex
102+ (sigil_name) @__name__
103+ quoted_start: _ @string.special
104+ quoted_end: _ @string.special) @string.special
108+; * definition keyword
110+ target: (identifier) @keyword
111+ (#match? @keyword "^(def|defdelegate|defexception|defguard|defguardp|defimpl|defmacro|defmacrop|defmodule|defn|defnp|defoverridable|defp|defprotocol|defstruct)$"))
113+; * kernel or special forms keyword
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)$"))
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)
128+; * just identifier in function definition
130+ target: (identifier) @keyword
37− (_ (_ (_ (_ (_ (identifier) @variable.parameter)))))]))
133+ (identifier) @function
38− (binary_op
134+ (binary_operator
41− function: (function_identifier) @function
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")
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)$"))
56−(call (function_identifier) @keyword
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
68−(anonymous_function
152+ right: (identifier) @function)
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+)
78−(unary_op
162+; * unused
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
87−(module) @type
171+; Comment
89−(unary_op
173+(comment) @comment
90− operator: "@" @attribute
174+
91− [(call
175+; Punctuation
92− function: (function_identifier) @attribute)
176+
93− (identifier) @attribute])
177+[
96− operator: _ @operator)
99− operator: _ @operator)
104− (heredoc_end)] @string)
109− (string_end)] @string)
111−(sigil_start) @string.special
112−(sigil_content) @string
113−(sigil_end) @string.special
116− "#{" @punctuation.special
117− "}" @punctuation.special)
179+] @punctuation
123] @punctuation.delimiter
184] @punctuation.delimiter
@@ -132,7 +193,3 @@
134] @punctuation.bracket
195] @punctuation.bracket
136−(special_identifier) @function.special