@@ -0,0 +1,156 @@
1+;; Operators
2+
3+[
4+ "&&"
5+ "||"
6+ "|"
7+ "&"
8+ "="
9+ "!="
10+ ".."
11+ "!"
12+ (direction)
13+ (stream_redirect)
14+ (test_option)
15+] @operator
16+
17+[
18+ "not"
19+ "and"
20+ "or"
21+] @keyword.operator
22+
23+;; Conditionals
24+
25+(if_statement
26+[
27+ "if"
28+ "end"
29+] @keyword.control.conditional)
30+
31+(switch_statement
32+[
33+ "switch"
34+ "end"
35+] @keyword.control.conditional)
36+
37+(case_clause
38+[
39+ "case"
40+] @keyword.control.conditional)
41+
42+(else_clause
43+[
44+ "else"
45+] @keyword.control.conditional)
46+
47+(else_if_clause
48+[
49+ "else"
50+ "if"
51+] @keyword.control.conditional)
52+
53+;; Loops/Blocks
54+
55+(while_statement
56+[
57+ "while"
58+ "end"
59+] @keyword.control.repeat)
60+
61+(for_statement
62+[
63+ "for"
64+ "end"
65+] @keyword.control.repeat)
66+
67+(begin_statement
68+[
69+ "begin"
70+ "end"
71+] @keyword.control.repeat)
72+
73+;; Keywords
74+
75+[
76+ "in"
77+ (break)
78+ (continue)
79+] @keyword
80+
81+"return" @keyword.control.return
82+
83+;; Punctuation
84+
85+[
86+ "["
87+ "]"
88+ "{"
89+ "}"
90+ "("
91+ ")"
92+] @punctuation.bracket
93+
94+"," @punctuation.delimiter
95+
96+;; Commands
97+
98+(command
99+ argument: [
100+ (word) @variable.parameter (#match? @variable.parameter "^-")
101+ ]
102+)
103+
104+; non-bultin command names
105+(command name: (word) @function)
106+
107+; derived from builtin -n (fish 3.2.2)
108+(command
109+ name: [
110+ (word) @function.builtin
111+ (#match? @function.builtin "^(\.|:|_|alias|argparse|bg|bind|block|breakpoint|builtin|cd|command|commandline|complete|contains|count|disown|echo|emit|eval|exec|exit|fg|functions|history|isatty|jobs|math|printf|pwd|random|read|realpath|set|set_color|source|status|string|test|time|type|ulimit|wait)$")
112+ ]
113+)
114+
115+(test_command "test" @function.builtin)
116+
117+;; Functions
118+
119+(function_definition ["function" "end"] @keyword.function)
120+
121+(function_definition
122+ name: [
123+ (word) (concatenation)
124+ ]
125+@function)
126+
127+(function_definition
128+ option: [
129+ (word)
130+ (concatenation (word))
131+ ] @variable.parameter (#match? @variable.parameter "^-")
132+)
133+
134+;; Strings
135+
136+[(double_quote_string) (single_quote_string)] @string
137+(escape_sequence) @constant.character.escape
138+
139+;; Variables
140+
141+(variable_name) @variable
142+(variable_expansion) @constant
143+
144+;; Nodes
145+
146+(integer) @constant.numeric.integer
147+(float) @constant.numeric.float
148+(comment) @comment
149+(test_option) @string
150+
151+((word) @constant.builtin.boolean
152+(#match? @constant.builtin.boolean "^(true|false)$"))
153+
154+;; Error
155+
156+(ERROR) @error