Skip to content

Commit bcb7f0d

Browse files
Nidish96ubolonton
andauthored
Improvements to Matlab-mode highlights (#445)
* Created a basic highlighter query set for julia * Bugfixes to Julia queries. Conditionals & exceptions work now. * more highlights * Release 0.12.151 * Improvements to matlab-highlights * matlab switch and if identifiers * matlab for_statement iterator * Reverting version bump --------- Co-authored-by: Tuấn-Anh Nguyễn <[email protected]>
1 parent 6667df3 commit bcb7f0d

File tree

2 files changed

+61
-52
lines changed

2 files changed

+61
-52
lines changed

queries/julia/highlights.scm

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
;;; Identifiers
22

3-
(identifier) @variable
3+
(identifier) @variable.parameter
44

55
; ;; If you want type highlighting based on Julia naming conventions (this might collide with mathematical notation)
66
; ((identifier) @type
@@ -410,7 +410,7 @@
410410
(do_clause
411411
["do" "end"] @keyword.function)
412412
(return_statement
413-
"return" @keyword.return)
413+
"return" @keyword)
414414

415415
[
416416
"const"
@@ -494,3 +494,5 @@
494494
;; (block_comment)
495495
;; ] @comment @spell
496496
(comment) @comment
497+
(triple_string) @comment
498+
(block_comment) @comment

queries/matlab/highlights.scm

Lines changed: 57 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,58 @@
4747

4848
"~" @constant.builtin
4949

50+
; Literals
51+
52+
(escape_sequence) @escape
53+
(formatting_sequence) @escape
54+
(string) @string
55+
(number) @number
56+
(boolean) @constant.builtin
57+
58+
; Punctuation
59+
60+
[ ";" "," "." ] @punctuation.delimiter
61+
[ "(" ")" "[" "]" "{" "}" ] @punctuation.bracket
62+
63+
; Operators
64+
65+
(unary_operator ["+" "-"] @number)
66+
67+
[
68+
"+"
69+
".+"
70+
"-"
71+
".*"
72+
"*"
73+
".*"
74+
"/"
75+
"./"
76+
"\\"
77+
".\\"
78+
"^"
79+
".^"
80+
"'"
81+
".'"
82+
"|"
83+
"&"
84+
"?"
85+
"@"
86+
"<"
87+
"<="
88+
">"
89+
">="
90+
"=="
91+
"~="
92+
"="
93+
"&&"
94+
"||"
95+
":"
96+
] @operator
97+
5098
; Fields/Properties
5199

52-
(field_expression field: (identifier) @property)
100+
(field_expression object: (identifier) @variable)
101+
(field_expression field: (identifier) @variable.parameter)
53102
(superclass "." (identifier) @property)
54103
(property_name "." (identifier) @property)
55104
(property name: (identifier) @property)
@@ -70,6 +119,7 @@
70119
(function_signature name: (identifier) @function)
71120

72121
(function_call name: (identifier) @function.call)
122+
(function_call (arguments) @variable.parameter)
73123

74124
(handle_operator (identifier) @function)
75125
(validation_functions (identifier) @function)
@@ -87,16 +137,19 @@
87137
; Conditionals
88138

89139
(if_statement [ "if" "end" ] @keyword)
140+
(if_statement (identifier) @variable)
90141
(elseif_clause "elseif" @keyword)
91142
(else_clause "else" @keyword)
92143
(switch_statement [ "switch" "end" ] @keyword)
144+
(switch_statement (identifier) @variable)
93145
(case_clause "case" @keyword)
94146
(otherwise_clause "otherwise" @keyword)
95147
(break_statement) @keyword
96148

97149
; Repeats
98150

99151
(for_statement [ "for" "parfor" "end" ] @keyword)
152+
(for_statement (iterator (identifier) @variable))
100153
(while_statement [ "while" "end" ] @keyword)
101154
(continue_statement) @keyword
102155

@@ -105,65 +158,17 @@
105158
(try_statement [ "try" "end" ] @keyword)
106159
(catch_clause "catch" @keyword)
107160

108-
; Punctuation
109-
110-
[ ";" "," "." ] @punctuation.delimiter
111-
[ "(" ")" "[" "]" "{" "}" ] @punctuation.bracket
112-
113-
; Literals
114-
115-
(escape_sequence) @escape
116-
(formatting_sequence) @escape
117-
(string) @string
118-
(number) @number
119-
(boolean) @constant.builtin
120-
121161
; Comments
122162

123163
[ (comment) (line_continuation) ] @comment @spell
124164

125-
; Operators
126-
127-
(unary_operator ["+" "-"] @number)
128-
129-
[
130-
"+"
131-
".+"
132-
"-"
133-
".*"
134-
"*"
135-
".*"
136-
"/"
137-
"./"
138-
"\\"
139-
".\\"
140-
"^"
141-
".^"
142-
"'"
143-
".'"
144-
"|"
145-
"&"
146-
"?"
147-
"@"
148-
"<"
149-
"<="
150-
">"
151-
">="
152-
"=="
153-
"~="
154-
"="
155-
"&&"
156-
"||"
157-
":"
158-
] @operator
159-
160165
; Assignments
161166

162167
(assignment left: (_) @variable)
168+
(assignment right: (_) @variable)
163169
(multioutput_variable (_) @variable)
164170

165171
; Keywords
166-
167172
[
168173
"arguments"
169174
"classdef"
@@ -176,3 +181,5 @@
176181
"properties"
177182
] @keyword
178183

184+
; Binary operation
185+
(binary_operator) @variable

0 commit comments

Comments
 (0)