codekingpro/portable-devtools
115k
1" Vim syntax file2" Language: fish3" Maintainer: Nicholas Boyle (github.com/nickeb96)4" Repository: https://github.com/nickeb96/fish.vim5" Last Change: February 1, 20236 7if exists("b:current_syntax")8 finish9endif10 11let s:cpo_save = &cpo12set cpo&vim13 14 15" Statements16syn cluster fishStatement contains=fishKeywordAndOr,fishNot,fishSelectStatement,fishKeyword,fishKeywordIf,fishCommand,fishVariable17 18syn keyword fishKeywordAndOr and or nextgroup=fishNot,fishSelectStatement,fishKeyword,fishKeywordIf,fishCommand19hi def link fishKeywordAndOr fishOperator20 21syn keyword fishNot not skipwhite nextgroup=fishSelectStatement,fishKeyword,fishKeywordIf,fishCommand22syn match fishNot /!/ skipwhite nextgroup=fishSelectStatement,fishKeyword,fishKeywordIf,fishCommand23hi def link fishNot fishOperator24 25syn keyword fishSelectStatement command builtin skipwhite nextgroup=fishKeyword,fishKeywordIf,fishCommand,fishOption26hi def link fishSelectStatement fishKeyword27 28syn keyword fishKeyword end skipwhite nextgroup=@fishTerminator29 30syn keyword fishKeywordIf if skipwhite nextgroup=@fishStatement31syn keyword fishKeyword else skipwhite nextgroup=fishKeywordIf,fishSemicolon32hi def link fishKeywordIf fishKeyword33 34syn keyword fishKeyword switch skipwhite nextgroup=@fishArgument35syn keyword fishKeyword case skipwhite nextgroup=@fishArgument36 37syn keyword fishKeyword while skipwhite nextgroup=@fishStatement38 39syn keyword fishKeyword for skipwhite nextgroup=fishForVariable40syn match fishForVariable /[[:alnum:]_]\+/ contained skipwhite nextgroup=fishKeywordIn41syn keyword fishKeywordIn in contained skipwhite nextgroup=@fishArgument42hi def link fishForVariable fishParameter43hi def link fishKeywordIn fishKeyword44 45syn keyword fishKeyword _ abbr argparse begin bg bind block break breakpoint cd commandline46 \ complete continue count disown echo emit eval exec exit false fg function functions47 \ history jobs math printf pwd random read realpath return set set_color source status48 \ string test time true type ulimit wait49 \ skipwhite nextgroup=@fishNext50syn match fishKeyword /\<contains\>/ skipwhite nextgroup=@fishNext51 52syn match fishCommand /[[:alnum:]_\/[][[:alnum:]+._-]*/ skipwhite nextgroup=@fishNext53 54 55" Internally Nested Arguments56 57syn cluster fishSubscriptArgs contains=fishInnerVariable,fishIndexNum,fishIndexRange,fishInnerCommandSub58 59syn match fishInnerVariable /\$\+[[:alnum:]_]\+/ contained60syn match fishInnerVariable /\$\+[[:alnum:]_]\+\[/me=e-1,he=e-1 contained nextgroup=fishInnerSubscript61hi def link fishInnerVariable fishVariable62 63syn region fishInnerSubscript matchgroup=fishVariable start=/\[/ end=/]/ contained64 \ keepend contains=@fishSubscriptArgs65hi def link fishInnerSubscript fishSubscript66 67syn match fishIndexNum /[+-]?[[:digit:]]\+/ contained68hi def link fishIndexNum fishParameter69 70syn match fishIndexRange /\.\./ contained71hi def link fishIndexRange fishParameter72 73syn region fishInnerCommandSub matchgroup=fishOperator start=/(/ start=/\$(/ end=/)/ contained74 \ contains=@fishStatement75hi def link fishInnerCommandSub fishCommandSub76 77syn region fishQuotedCommandSub matchgroup=fishOperator start=/\$(/ end=/)/ contained78 \ contains=@fishStatement79hi def link fishQuotedCommandSub fishCommandSub80 81syn match fishBraceExpansionComma /,/ contained82hi def link fishBraceExpansionComma fishOperator83 84syn match fishBracedParameter '[[:alnum:]\u5b\u5d@:=+.%/!_-]\+' contained contains=fishInnerPathGlob85hi def link fishBracedParameter fishParameter86 87syn region fishBracedQuote start=/'/ skip=/\\'/ end=/'/ contained88 \ contains=fishEscapedEscape,fishEscapedSQuote89syn region fishBracedQuote start=/"/ skip=/\\"/ end=/"/ contained90 \ contains=fishEscapedEscape,fishEscapedDQuote,fishEscapedDollar,fishInnerVariable,fishInnerCommandSub91hi def link fishBracedQuote fishQuote92 93 94" Arguments95 96syn cluster fishArgument contains=fishParameter,fishOption,fishVariable,fishPathGlob,fishBraceExpansion,fishQuote,fishCharacter,fishCommandSub,fishRedirection,fishSelfPid97 98syn match fishParameter '[[:alnum:]\u5b\u5d@:=+.,%/!_-]\+' contained skipwhite nextgroup=@fishNext99 100syn match fishOption /-[[:alnum:]=_-]*/ contained skipwhite nextgroup=@fishNext101 102syn match fishPathGlob /\(\~\|*\|?\)/ contained skipwhite nextgroup=@fishNext103 104syn region fishBraceExpansion matchgroup=fishOperator start=/{/ end=/}/ contained105 \ contains=fishBraceExpansionComma,fishInnerVariable,fishInnerCommandSub,fishBracedParameter,fishBracedQuote106 \ skipwhite nextgroup=@fishNext107 108syn match fishVariable /\$\+[[:alnum:]_]\+/ skipwhite nextgroup=@fishNext109syn match fishVariable /\$\+[[:alnum:]_]\+\[/me=e-1,he=e-1 nextgroup=fishSubscript110 111syn region fishSubscript matchgroup=fishVariable start=/\[/ end=/]/ contained112 \ keepend contains=@fishSubscriptArgs113 \ skipwhite nextgroup=@fishNext114 115syn region fishCommandSub matchgroup=fishOperator start=/(/ start=/\$(/ end=/)/ contained116 \ contains=@fishStatement117 \ skipwhite nextgroup=@fishNext118 119syn region fishQuote start=/'/ skip=/\\'/ end=/'/ contained120 \ contains=fishEscapedEscape,fishEscapedSQuote121 \ skipwhite nextgroup=@fishNext122syn region fishQuote start=/"/ skip=/\\"/ end=/"/ contained123 \ contains=fishEscapedEscape,fishEscapedDQuote,fishEscapedDollar,fishInnerVariable,fishQuotedCommandSub124 \ skipwhite nextgroup=@fishNext125 126syn match fishEscapedEscape /\\\\/ contained127syn match fishEscapedSQuote /\\'/ contained128syn match fishEscapedDQuote /\\"/ contained129syn match fishEscapedDollar /\\\$/ contained130hi def link fishEscapedEscape fishCharacter131hi def link fishEscapedSQuote fishCharacter132hi def link fishEscapedDQuote fishCharacter133hi def link fishEscapedDollar fishCharacter134 135syn match fishCharacter /\\[0-7]\{1,3}/ contained skipwhite nextgroup=@fishNext136syn match fishCharacter /\\u[0-9a-fA-F]\{4}/ contained skipwhite nextgroup=@fishNext137syn match fishCharacter /\\U[0-9a-fA-F]\{8}/ contained skipwhite nextgroup=@fishNext138syn match fishCharacter /\\x[0-7][0-9a-fA-F]\|\\x[0-9a-fA-F]/ contained skipwhite nextgroup=@fishNext139syn match fishCharacter /\\X[0-9a-fA-F]\{1,2}/ contained skipwhite nextgroup=@fishNext140syn match fishCharacter /\\[abcefnrtv[\](){}<>\\*?~%#$|&;'" ]/ contained skipwhite nextgroup=@fishNext141 142syn match fishRedirection /</ contained skipwhite nextgroup=fishRedirectionTarget143syn match fishRedirection /[0-9&]\?>[>?]\?/ contained skipwhite nextgroup=fishRedirectionTarget144syn match fishRedirection /[0-9&]\?>&[0-9-]/ contained skipwhite nextgroup=@fishNext145 146syn match fishRedirectionTarget /[[:alnum:]$~*?{,}"'\/._-]\+/ contained contains=fishInnerVariable skipwhite nextgroup=@fishNext147hi def link fishRedirectionTarget fishRedirection148 149syn match fishSelfPid /%self\>/ contained nextgroup=@fishNext150hi def link fishSelfPid fishOperator151 152 153" Terminators154 155syn cluster fishTerminator contains=fishPipe,fishBackgroundJob,fishSemicolon,fishSymbolicAndOr156 157syn match fishPipe /\(1>\|2>\|&\)\?|/ contained skipwhite nextgroup=@fishStatement158hi def link fishPipe fishEnd159 160syn match fishBackgroundJob /&$/ contained skipwhite nextgroup=@fishStatement161syn match fishBackgroundJob /&[^<>&|]/me=s+1,he=s+1 contained skipwhite nextgroup=@fishStatement162hi def link fishBackgroundJob fishEnd163 164syn match fishSemicolon /;/ skipwhite nextgroup=@fishStatement165hi def link fishSemicolon fishEnd166 167syn match fishSymbolicAndOr /\(&&\|||\)/ contained skipwhite skipempty nextgroup=@fishStatement168hi def link fishSymbolicAndOr fishOperator169 170 171" Other172 173syn cluster fishNext contains=fishEscapedNl,@fishArgument,@fishTerminator174 175syn match fishEscapedNl /\\$/ skipnl skipwhite contained nextgroup=@fishNext176 177syn match fishComment /#.*/ contains=fishTodo,@Spell178 179syn keyword fishTodo TODO contained180 181 182 183syn sync minlines=200184syn sync maxlines=300185 186 187" Intermediate highlight groups matching $fish_color_* variables188 189hi def link fishCommand fish_color_command190hi def link fishComment fish_color_comment191hi def link fishEnd fish_color_end192hi def link fishCharacter fish_color_escape193hi def link fishKeyword fish_color_keyword194hi def link fishEscapedNl fish_color_normal195hi def link fishOperator fish_color_operator196hi def link fishVariable fish_color_operator197hi def link fishInnerVariable fish_color_operator198hi def link fishPathGlob fish_color_operator199hi def link fishOption fish_color_option200hi def link fishParameter fish_color_param201hi def link fishQuote fish_color_quote202hi def link fishRedirection fish_color_redirection203 204 205" Default highlight groups 206 207hi def link fish_color_param Normal208hi def link fish_color_normal Normal209hi def link fish_color_option Normal210hi def link fish_color_command Function211hi def link fish_color_keyword Keyword212hi def link fish_color_end Delimiter213hi def link fish_color_operator Operator214hi def link fish_color_redirection Type215hi def link fish_color_quote String216hi def link fish_color_escape Character217hi def link fish_color_comment Comment218 219hi def link fishTodo Todo220 221 222let b:current_syntax = 'fish'223 224let &cpo = s:cpo_save225unlet s:cpo_save226 