on master help sign in
Julia queries: prevent constructors to be highlighted as functions
26b2f0aChristoph Horn
runtime/queries/julia/highlights.scm+37−19
@@ -85,8 +85,11 @@
85; Function definition
85; Function definition
86; -------------------
86; -------------------
87
87
88+(
88−(function_definition
89+ (function_definition
89− name: (identifier) @function)
90+ name: (identifier) @function)
91+ ; prevent constructors (PascalCase) to be highlighted as functions
92+ (#match? @function "^[^A-Z]"))
90
93
91(parameter_list
94(parameter_list
92 (identifier) @variable.parameter)
95 (identifier) @variable.parameter)
@@ -108,17 +111,26 @@
108; Functions calls
111; Functions calls
109; ---------------
112; ---------------
110
113
114+(
111−(call_expression
115+ (call_expression
112− (identifier) @function)
116+ (identifier) @function)
117+ ; prevent constructors (PascalCase) to be highlighted as functions
118+ (#match? @function "^[^A-Z]"))
113
119
120+(
114−(broadcast_call_expression
121+ (broadcast_call_expression
115− (identifier) @function)
122+ (identifier) @function)
123+ (#match? @function "^[^A-Z]"))
116
124
125+(
117−(call_expression
126+ (call_expression
118− (field_expression (identifier) @function .))
127+ (field_expression (identifier) @function .))
128+ (#match? @function "^[^A-Z]"))
119
129
130+(
120−(broadcast_call_expression
131+ (broadcast_call_expression
121− (field_expression (identifier) @function .))
132+ (field_expression (identifier) @function .))
133+ (#match? @function "^[^A-Z]"))
122
134
123; ------
135; ------
124; Macros
136; Macros
@@ -228,19 +240,25 @@
228; Remaining identifiers
240; Remaining identifiers
229; ---------------------
241; ---------------------
230
242
231−; could also be namespace but this should cover the majority
232−(field_expression
233− . (_)
234− (identifier) @variable.other.member)
235−
236(const_statement
243(const_statement
237 (variable_declaration
244 (variable_declaration
238 . (identifier) @constant))
245 . (identifier) @constant))
239
246
247+; SCREAMING_SNAKE_CASE
248+(
240−((identifier) @type
249+ (identifier) @constant
241− (match? @type "([A-Z][a-z0-9]+)+$"))
250+ (match? @constant "^[A-Z][A-Z0-9_]*$"))
242
251
252+; remaining identifiers that start with capital letters should be types (PascalCase)
253+(
243−((identifier) @constant
254+ (identifier) @type
244− (match? @constant "^[A-Z][A-Z0-9_]+$"))
255+ (match? @type "^[A-Z]"))
256+
257+; Field expressions are either module content or struct fields.
258+; Module types and constants should already be captured, so this
259+; assumes the remaining identifiers to be struct fields.
260+(field_expression
261+ (_)
262+ (identifier) @variable.other.member)
245
263
246(identifier) @variable
264(identifier) @variable