on master help sign in
Add parameter highlights to Erlang
5a1bed2Michael Davis
runtime/queries/erlang/highlights.scm+31−3
@@ -65,6 +65,37 @@
65(function_capture module: (atom) @namespace)
65(function_capture module: (atom) @namespace)
66(function_capture function: (atom) @function)
66(function_capture function: (atom) @function)
67
67
68+; Ignored variables
69+((variable) @comment.discard
70+ (#match? @comment.discard "^_"))
71+
72+; Parameters
73+; specs
74+((attribute
75+ name: (atom) @keyword
76+ (stab_clause
77+ pattern: (arguments (variable) @variable.parameter)
78+ body: (variable)? @variable.parameter))
79+ (#match? @keyword "(spec|callback)"))
80+; functions
81+(function_clause pattern: (arguments (variable) @variable.parameter))
82+; anonymous functions
83+(stab_clause pattern: (arguments (variable) @variable.parameter))
84+; parametric types
85+((attribute
86+ name: (atom) @keyword
87+ (arguments
88+ (binary_operator
89+ left: (call (arguments (variable) @variable.parameter))
90+ operator: "::")))
91+ (#match? @keyword "(type|opaque)"))
92+; macros
93+((attribute
94+ name: (atom) @keyword
95+ (arguments
96+ (call (arguments (variable) @variable.parameter))))
97+ (#eq? @keyword "define"))
98+
68; Records
99; Records
69(record_content
100(record_content
70 (binary_operator
101 (binary_operator
@@ -105,9 +136,6 @@
105 name: (_) @keyword.directive)
136 name: (_) @keyword.directive)
106
137
107; Comments
138; Comments
108−((variable) @comment.discard
109− (#match? @comment.discard "^_"))
110−
111(tripledot) @comment.discard
139(tripledot) @comment.discard
112
140
113[(comment) (line_comment) (shebang)] @comment
141[(comment) (line_comment) (shebang)] @comment
runtime/queries/erlang/locals.scmnew file+30
@@ -0,0 +1,30 @@
1+; Specs and Callbacks
2+(attribute
3+ (stab_clause
4+ pattern: (arguments (variable) @local.definition)
5+ ; If a spec uses a variable as the return type (and later a `when` clause to type it):
6+ body: (variable)? @local.definition)) @local.scope
7+
8+; parametric `-type`s
9+((attribute
10+ name: (atom) @_type
11+ (arguments
12+ (binary_operator
13+ left: (call (arguments (variable) @local.definition))
14+ operator: "::") @local.scope))
15+ (#match? @_type "(type|opaque)"))
16+
17+; macros
18+((attribute
19+ name: (atom) @_define
20+ (arguments
21+ (call (arguments (variable) @local.definition)))) @local.scope
22+ (#eq? @_define "define"))
23+
24+; `fun`s
25+(anonymous_function (stab_clause pattern: (arguments (variable) @local.definition))) @local.scope
26+
27+; Ordinary functions
28+(function_clause pattern: (arguments (variable) @local.definition)) @local.scope
29+
30+(variable) @local.reference