32004
|
1 " Vim syntax file
|
|
2 " Language: fish
|
|
3 " Maintainer: Nicholas Boyle (github.com/nickeb96)
|
|
4 " Repository: https://github.com/nickeb96/fish.vim
|
|
5 " Last Change: February 1, 2023
|
|
6
|
|
7 if exists("b:current_syntax")
|
|
8 finish
|
|
9 endif
|
|
10
|
|
11 let s:cpo_save = &cpo
|
|
12 set cpo&vim
|
|
13
|
|
14
|
|
15 " Statements
|
|
16 syn cluster fishStatement contains=fishKeywordAndOr,fishNot,fishSelectStatement,fishKeyword,fishKeywordIf,fishCommand,fishVariable
|
|
17
|
|
18 syn keyword fishKeywordAndOr and or nextgroup=fishNot,fishSelectStatement,fishKeyword,fishKeywordIf,fishCommand
|
|
19 hi def link fishKeywordAndOr fishOperator
|
|
20
|
|
21 syn keyword fishNot not skipwhite nextgroup=fishSelectStatement,fishKeyword,fishKeywordIf,fishCommand
|
|
22 syn match fishNot /!/ skipwhite nextgroup=fishSelectStatement,fishKeyword,fishKeywordIf,fishCommand
|
|
23 hi def link fishNot fishOperator
|
|
24
|
|
25 syn keyword fishSelectStatement command builtin skipwhite nextgroup=fishKeyword,fishKeywordIf,fishCommand,fishOption
|
|
26 hi def link fishSelectStatement fishKeyword
|
|
27
|
|
28 syn keyword fishKeyword end skipwhite nextgroup=@fishTerminator
|
|
29
|
|
30 syn keyword fishKeywordIf if skipwhite nextgroup=@fishStatement
|
|
31 syn keyword fishKeyword else skipwhite nextgroup=fishKeywordIf,fishSemicolon
|
|
32 hi def link fishKeywordIf fishKeyword
|
|
33
|
|
34 syn keyword fishKeyword switch skipwhite nextgroup=@fishArgument
|
|
35 syn keyword fishKeyword case skipwhite nextgroup=@fishArgument
|
|
36
|
|
37 syn keyword fishKeyword while skipwhite nextgroup=@fishStatement
|
|
38
|
|
39 syn keyword fishKeyword for skipwhite nextgroup=fishForVariable
|
|
40 syn match fishForVariable /[[:alnum:]_]\+/ contained skipwhite nextgroup=fishKeywordIn
|
|
41 syn keyword fishKeywordIn in contained skipwhite nextgroup=@fishArgument
|
|
42 hi def link fishForVariable fishParameter
|
|
43 hi def link fishKeywordIn fishKeyword
|
|
44
|
|
45 syn keyword fishKeyword _ abbr argparse begin bg bind block break breakpoint cd commandline
|
|
46 \ complete continue count disown echo emit eval exec exit false fg function functions
|
|
47 \ history jobs math printf pwd random read realpath return set set_color source status
|
|
48 \ string test time true type ulimit wait
|
|
49 \ skipwhite nextgroup=@fishNext
|
|
50 syn match fishKeyword /\<contains\>/ skipwhite nextgroup=@fishNext
|
|
51
|
|
52 syn match fishCommand /[[:alnum:]_\/[][[:alnum:]+._-]*/ skipwhite nextgroup=@fishNext
|
|
53
|
|
54
|
|
55 " Internally Nested Arguments
|
|
56
|
|
57 syn cluster fishSubscriptArgs contains=fishInnerVariable,fishIndexNum,fishIndexRange,fishInnerCommandSub
|
|
58
|
|
59 syn match fishInnerVariable /\$\+[[:alnum:]_]\+/ contained
|
|
60 syn match fishInnerVariable /\$\+[[:alnum:]_]\+\[/me=e-1,he=e-1 contained nextgroup=fishInnerSubscript
|
|
61 hi def link fishInnerVariable fishVariable
|
|
62
|
|
63 syn region fishInnerSubscript matchgroup=fishVariable start=/\[/ end=/]/ contained
|
|
64 \ keepend contains=@fishSubscriptArgs
|
|
65 hi def link fishInnerSubscript fishSubscript
|
|
66
|
|
67 syn match fishIndexNum /[+-]?[[:digit:]]\+/ contained
|
|
68 hi def link fishIndexNum fishParameter
|
|
69
|
|
70 syn match fishIndexRange /\.\./ contained
|
|
71 hi def link fishIndexRange fishParameter
|
|
72
|
|
73 syn region fishInnerCommandSub matchgroup=fishOperator start=/(/ start=/\$(/ end=/)/ contained
|
|
74 \ contains=@fishStatement
|
|
75 hi def link fishInnerCommandSub fishCommandSub
|
|
76
|
|
77 syn region fishQuotedCommandSub matchgroup=fishOperator start=/\$(/ end=/)/ contained
|
|
78 \ contains=@fishStatement
|
|
79 hi def link fishQuotedCommandSub fishCommandSub
|
|
80
|
|
81 syn match fishBraceExpansionComma /,/ contained
|
|
82 hi def link fishBraceExpansionComma fishOperator
|
|
83
|
|
84 syn match fishBracedParameter '[[:alnum:]\u5b\u5d@:=+.%/!_-]\+' contained contains=fishInnerPathGlob
|
|
85 hi def link fishBracedParameter fishParameter
|
|
86
|
|
87 syn region fishBracedQuote start=/'/ skip=/\\'/ end=/'/ contained
|
|
88 \ contains=fishEscapedEscape,fishEscapedSQuote
|
|
89 syn region fishBracedQuote start=/"/ skip=/\\"/ end=/"/ contained
|
|
90 \ contains=fishEscapedEscape,fishEscapedDQuote,fishEscapedDollar,fishInnerVariable,fishInnerCommandSub
|
|
91 hi def link fishBracedQuote fishQuote
|
|
92
|
|
93
|
|
94 " Arguments
|
|
95
|
|
96 syn cluster fishArgument contains=fishParameter,fishOption,fishVariable,fishPathGlob,fishBraceExpansion,fishQuote,fishCharacter,fishCommandSub,fishRedirection,fishSelfPid
|
|
97
|
|
98 syn match fishParameter '[[:alnum:]\u5b\u5d@:=+.,%/!_-]\+' contained skipwhite nextgroup=@fishNext
|
|
99
|
|
100 syn match fishOption /-[[:alnum:]=_-]*/ contained skipwhite nextgroup=@fishNext
|
|
101
|
|
102 syn match fishPathGlob /\(\~\|*\|?\)/ contained skipwhite nextgroup=@fishNext
|
|
103
|
|
104 syn region fishBraceExpansion matchgroup=fishOperator start=/{/ end=/}/ contained
|
|
105 \ contains=fishBraceExpansionComma,fishInnerVariable,fishInnerCommandSub,fishBracedParameter,fishBracedQuote
|
|
106 \ skipwhite nextgroup=@fishNext
|
|
107
|
|
108 syn match fishVariable /\$\+[[:alnum:]_]\+/ skipwhite nextgroup=@fishNext
|
|
109 syn match fishVariable /\$\+[[:alnum:]_]\+\[/me=e-1,he=e-1 nextgroup=fishSubscript
|
|
110
|
|
111 syn region fishSubscript matchgroup=fishVariable start=/\[/ end=/]/ contained
|
|
112 \ keepend contains=@fishSubscriptArgs
|
|
113 \ skipwhite nextgroup=@fishNext
|
|
114
|
|
115 syn region fishCommandSub matchgroup=fishOperator start=/(/ start=/\$(/ end=/)/ contained
|
|
116 \ contains=@fishStatement
|
|
117 \ skipwhite nextgroup=@fishNext
|
|
118
|
|
119 syn region fishQuote start=/'/ skip=/\\'/ end=/'/ contained
|
|
120 \ contains=fishEscapedEscape,fishEscapedSQuote
|
|
121 \ skipwhite nextgroup=@fishNext
|
|
122 syn region fishQuote start=/"/ skip=/\\"/ end=/"/ contained
|
|
123 \ contains=fishEscapedEscape,fishEscapedDQuote,fishEscapedDollar,fishInnerVariable,fishQuotedCommandSub
|
|
124 \ skipwhite nextgroup=@fishNext
|
|
125
|
|
126 syn match fishEscapedEscape /\\\\/ contained
|
|
127 syn match fishEscapedSQuote /\\'/ contained
|
|
128 syn match fishEscapedDQuote /\\"/ contained
|
|
129 syn match fishEscapedDollar /\\\$/ contained
|
|
130 hi def link fishEscapedEscape fishCharacter
|
|
131 hi def link fishEscapedSQuote fishCharacter
|
|
132 hi def link fishEscapedDQuote fishCharacter
|
|
133 hi def link fishEscapedDollar fishCharacter
|
|
134
|
|
135 syn match fishCharacter /\\[0-7]\{1,3}/ contained skipwhite nextgroup=@fishNext
|
|
136 syn match fishCharacter /\\u[0-9a-fA-F]\{4}/ contained skipwhite nextgroup=@fishNext
|
|
137 syn match fishCharacter /\\U[0-9a-fA-F]\{8}/ contained skipwhite nextgroup=@fishNext
|
|
138 syn match fishCharacter /\\x[0-7][0-9a-fA-F]\|\\x[0-9a-fA-F]/ contained skipwhite nextgroup=@fishNext
|
|
139 syn match fishCharacter /\\X[0-9a-fA-F]\{1,2}/ contained skipwhite nextgroup=@fishNext
|
|
140 syn match fishCharacter /\\[abcefnrtv[\](){}<>\\*?~%#$|&;'" ]/ contained skipwhite nextgroup=@fishNext
|
|
141
|
|
142 syn match fishRedirection /</ contained skipwhite nextgroup=fishRedirectionTarget
|
|
143 syn match fishRedirection /[0-9&]\?>[>?]\?/ contained skipwhite nextgroup=fishRedirectionTarget
|
|
144 syn match fishRedirection /[0-9&]\?>&[0-9-]/ contained skipwhite nextgroup=@fishNext
|
|
145
|
|
146 syn match fishRedirectionTarget /[[:alnum:]$~*?{,}"'\/._-]\+/ contained contains=fishInnerVariable skipwhite nextgroup=@fishNext
|
|
147 hi def link fishRedirectionTarget fishRedirection
|
|
148
|
|
149 syn match fishSelfPid /%self\>/ contained nextgroup=@fishNext
|
|
150 hi def link fishSelfPid fishOperator
|
|
151
|
|
152
|
|
153 " Terminators
|
|
154
|
|
155 syn cluster fishTerminator contains=fishPipe,fishBackgroundJob,fishSemicolon,fishSymbolicAndOr
|
|
156
|
|
157 syn match fishPipe /\(1>\|2>\|&\)\?|/ contained skipwhite nextgroup=@fishStatement
|
|
158 hi def link fishPipe fishEnd
|
|
159
|
|
160 syn match fishBackgroundJob /&$/ contained skipwhite nextgroup=@fishStatement
|
|
161 syn match fishBackgroundJob /&[^<>&|]/me=s+1,he=s+1 contained skipwhite nextgroup=@fishStatement
|
|
162 hi def link fishBackgroundJob fishEnd
|
|
163
|
|
164 syn match fishSemicolon /;/ skipwhite nextgroup=@fishStatement
|
|
165 hi def link fishSemicolon fishEnd
|
|
166
|
|
167 syn match fishSymbolicAndOr /\(&&\|||\)/ contained skipwhite skipempty nextgroup=@fishStatement
|
|
168 hi def link fishSymbolicAndOr fishOperator
|
|
169
|
|
170
|
|
171 " Other
|
|
172
|
|
173 syn cluster fishNext contains=fishEscapedNl,@fishArgument,@fishTerminator
|
|
174
|
|
175 syn match fishEscapedNl /\\$/ skipnl skipwhite contained nextgroup=@fishNext
|
|
176
|
|
177 syn match fishComment /#.*/ contains=fishTodo,@Spell
|
|
178
|
|
179 syn keyword fishTodo TODO contained
|
|
180
|
|
181
|
|
182
|
|
183 syn sync minlines=200
|
|
184 syn sync maxlines=300
|
|
185
|
|
186
|
|
187 " Intermediate highlight groups matching $fish_color_* variables
|
|
188
|
|
189 hi def link fishCommand fish_color_command
|
|
190 hi def link fishComment fish_color_comment
|
|
191 hi def link fishEnd fish_color_end
|
|
192 hi def link fishCharacter fish_color_escape
|
|
193 hi def link fishKeyword fish_color_keyword
|
|
194 hi def link fishEscapedNl fish_color_normal
|
|
195 hi def link fishOperator fish_color_operator
|
|
196 hi def link fishVariable fish_color_operator
|
|
197 hi def link fishInnerVariable fish_color_operator
|
|
198 hi def link fishPathGlob fish_color_operator
|
|
199 hi def link fishOption fish_color_option
|
|
200 hi def link fishParameter fish_color_param
|
|
201 hi def link fishQuote fish_color_quote
|
|
202 hi def link fishRedirection fish_color_redirection
|
|
203
|
|
204
|
|
205 " Default highlight groups
|
|
206
|
|
207 hi def link fish_color_param Normal
|
|
208 hi def link fish_color_normal Normal
|
|
209 hi def link fish_color_option Normal
|
|
210 hi def link fish_color_command Function
|
|
211 hi def link fish_color_keyword Keyword
|
|
212 hi def link fish_color_end Delimiter
|
|
213 hi def link fish_color_operator Operator
|
|
214 hi def link fish_color_redirection Type
|
|
215 hi def link fish_color_quote String
|
|
216 hi def link fish_color_escape Character
|
|
217 hi def link fish_color_comment Comment
|
|
218
|
|
219 hi def link fishTodo Todo
|
|
220
|
|
221
|
|
222 let b:current_syntax = 'fish'
|
|
223
|
|
224 let &cpo = s:cpo_save
|
|
225 unlet s:cpo_save
|