Skip to content

Commit 4a51195

Browse files
committed
Add basic queries to work as syntax highlighter on nvim.
1 parent 02201ae commit 4a51195

File tree

1 file changed

+91
-0
lines changed

1 file changed

+91
-0
lines changed

queries/highlights.scm

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
(identifier) @variable
2+
3+
((constant) @constant
4+
(#match? @constant "^[A-Z\\d_]+$"))
5+
6+
[
7+
"alias"
8+
"begin"
9+
"break"
10+
"case"
11+
"class"
12+
"def"
13+
"do"
14+
"end"
15+
"ensure"
16+
"in"
17+
"module"
18+
"next"
19+
"rescue"
20+
"then"
21+
"unless"
22+
"until"
23+
"when"
24+
"while"
25+
] @keyword
26+
["return" "yield"] @keyword.return
27+
["if" "else" "elsif"] @keyword.conditional
28+
["rescue"] @keyword.exception
29+
30+
(pseudo_constant) @constant.builtin
31+
32+
; literals
33+
(string) @string
34+
35+
(symbol) @string.special.symbol
36+
37+
(regex) @string.regex
38+
39+
(string_escape_sequence) @escape
40+
41+
[(integer) (float)] @number
42+
43+
[(true) (false)] @boolean
44+
45+
(nil) @constant.builtin
46+
47+
(interpolation
48+
"#{" @punctuation.special
49+
"}" @punctuation.special) @embedded
50+
51+
(comment) @comment
52+
53+
; Operators
54+
55+
[
56+
"="
57+
"=>"
58+
"->"
59+
] @operator
60+
61+
[
62+
","
63+
";"
64+
"."
65+
] @punctuation.delimiter
66+
67+
[
68+
"("
69+
")"
70+
"["
71+
"]"
72+
"{"
73+
"}"
74+
] @punctuation.bracket
75+
76+
(class_def name: [(constant) (generic_type)] @type)
77+
78+
(module_def name: [(constant) (generic_type)] @module)
79+
80+
(struct_def name: [(constant) (generic_type)] @type)
81+
82+
(enum_def name: [(constant)] @type)
83+
84+
(method_def name: [(identifier) (constant)] @function.method)
85+
86+
(param name: [(identifier)] @variable.parameter)
87+
88+
[
89+
(class_var)
90+
(instance_var)
91+
] @property

0 commit comments

Comments
 (0)