Mercurial > vim
annotate runtime/syntax/sh.vim @ 3920:c53344bacabf
Updated runtime files.
author | Bram Moolenaar <bram@vim.org> |
---|---|
date | Thu, 15 Nov 2012 21:28:22 +0100 |
parents | 2cfb68fa26cd |
children | fa4089df54bc |
rev | line source |
---|---|
7 | 1 " Vim syntax file |
2 " Language: shell (sh) Korn shell (ksh) bash (sh) | |
3920 | 3 " Maintainer: Charles E. Campbell <NdrOchipS@PcampbellAfamily.Mbiz> |
7 | 4 " Previous Maintainer: Lennart Schultz <Lennart.Schultz@ecmwf.int> |
3920 | 5 " Last Change: Nov 14, 2012 |
6 " Version: 128 | |
507 | 7 " URL: http://mysite.verizon.net/astronaut/vim/index.html#vimlinks_syntax |
1668 | 8 " For options and settings, please use: :help ft-sh-syntax |
2473
d55e70cabe2c
Syntax file updates. (Charles Campbell)
Bram Moolenaar <bram@vim.org>
parents:
2357
diff
changeset
|
9 " This file includes many ideas from ?ric Brunet (eric.brunet@ens.fr) |
7 | 10 |
22 | 11 " For version 5.x: Clear all syntax items {{{1 |
7 | 12 " For version 6.x: Quit when a syntax file was already loaded |
13 if version < 600 | |
14 syntax clear | |
15 elseif exists("b:current_syntax") | |
16 finish | |
17 endif | |
18 | |
3099
887d6d91882e
Updated a few runtime files.
Bram Moolenaar <bram@vim.org>
parents:
2751
diff
changeset
|
19 " AFAICT "." should be considered part of the iskeyword. Using iskeywords in |
3920 | 20 " syntax is dicey, so the following code permits the user to |
21 " g:sh_isk set to a string : specify iskeyword. | |
22 " g:sh_noisk exists : don't change iskeyword | |
23 " g:sh_noisk does not exist : (default) append "." to iskeyword | |
24 if exists("g:sh_isk") && type(g:sh_isk) == 1 " user specifying iskeyword | |
25 exe "setl isk=".g:sh_isk | |
26 elseif !exists("g:sh_noisk") " optionally prevent appending '.' to iskeyword | |
27 setl isk+=. | |
3099
887d6d91882e
Updated a few runtime files.
Bram Moolenaar <bram@vim.org>
parents:
2751
diff
changeset
|
28 endif |
887d6d91882e
Updated a few runtime files.
Bram Moolenaar <bram@vim.org>
parents:
2751
diff
changeset
|
29 |
887d6d91882e
Updated a few runtime files.
Bram Moolenaar <bram@vim.org>
parents:
2751
diff
changeset
|
30 " trying to answer the question: which shell is /bin/sh, really? |
3920 | 31 " If the user has not specified any of g:is_kornshell, g:is_bash, g:is_posix, g:is_sh, then guess. |
3099
887d6d91882e
Updated a few runtime files.
Bram Moolenaar <bram@vim.org>
parents:
2751
diff
changeset
|
32 if !exists("g:is_kornshell") && !exists("g:is_bash") && !exists("g:is_posix") && !exists("g:is_sh") |
887d6d91882e
Updated a few runtime files.
Bram Moolenaar <bram@vim.org>
parents:
2751
diff
changeset
|
33 if executable("/bin/sh") |
887d6d91882e
Updated a few runtime files.
Bram Moolenaar <bram@vim.org>
parents:
2751
diff
changeset
|
34 if resolve("/bin/sh") =~ 'bash$' |
887d6d91882e
Updated a few runtime files.
Bram Moolenaar <bram@vim.org>
parents:
2751
diff
changeset
|
35 let g:is_bash= 1 |
887d6d91882e
Updated a few runtime files.
Bram Moolenaar <bram@vim.org>
parents:
2751
diff
changeset
|
36 elseif resolve("/bin/sh") =~ 'ksh$' |
887d6d91882e
Updated a few runtime files.
Bram Moolenaar <bram@vim.org>
parents:
2751
diff
changeset
|
37 let g:is_ksh = 1 |
887d6d91882e
Updated a few runtime files.
Bram Moolenaar <bram@vim.org>
parents:
2751
diff
changeset
|
38 endif |
887d6d91882e
Updated a few runtime files.
Bram Moolenaar <bram@vim.org>
parents:
2751
diff
changeset
|
39 elseif executable("/usr/bin/sh") |
887d6d91882e
Updated a few runtime files.
Bram Moolenaar <bram@vim.org>
parents:
2751
diff
changeset
|
40 if resolve("/usr/bin//sh") =~ 'bash$' |
887d6d91882e
Updated a few runtime files.
Bram Moolenaar <bram@vim.org>
parents:
2751
diff
changeset
|
41 let g:is_bash= 1 |
887d6d91882e
Updated a few runtime files.
Bram Moolenaar <bram@vim.org>
parents:
2751
diff
changeset
|
42 elseif resolve("/usr/bin//sh") =~ 'ksh$' |
887d6d91882e
Updated a few runtime files.
Bram Moolenaar <bram@vim.org>
parents:
2751
diff
changeset
|
43 let g:is_ksh = 1 |
887d6d91882e
Updated a few runtime files.
Bram Moolenaar <bram@vim.org>
parents:
2751
diff
changeset
|
44 endif |
887d6d91882e
Updated a few runtime files.
Bram Moolenaar <bram@vim.org>
parents:
2751
diff
changeset
|
45 endif |
887d6d91882e
Updated a few runtime files.
Bram Moolenaar <bram@vim.org>
parents:
2751
diff
changeset
|
46 endif |
887d6d91882e
Updated a few runtime files.
Bram Moolenaar <bram@vim.org>
parents:
2751
diff
changeset
|
47 |
22 | 48 " handling /bin/sh with is_kornshell/is_sh {{{1 |
7 | 49 " b:is_sh is set when "#! /bin/sh" is found; |
50 " However, it often is just a masquerade by bash (typically Linux) | |
51 " or kornshell (typically workstations with Posix "sh"). | |
3099
887d6d91882e
Updated a few runtime files.
Bram Moolenaar <bram@vim.org>
parents:
2751
diff
changeset
|
52 " So, when the user sets "g:is_bash", "g:is_kornshell", |
887d6d91882e
Updated a few runtime files.
Bram Moolenaar <bram@vim.org>
parents:
2751
diff
changeset
|
53 " or "g:is_posix", a b:is_sh is converted into b:is_bash/b:is_kornshell, |
7 | 54 " respectively. |
55 if !exists("b:is_kornshell") && !exists("b:is_bash") | |
828 | 56 if exists("g:is_posix") && !exists("g:is_kornshell") |
57 let g:is_kornshell= g:is_posix | |
58 endif | |
59 if exists("g:is_kornshell") | |
7 | 60 let b:is_kornshell= 1 |
61 if exists("b:is_sh") | |
62 unlet b:is_sh | |
63 endif | |
828 | 64 elseif exists("g:is_bash") |
7 | 65 let b:is_bash= 1 |
66 if exists("b:is_sh") | |
67 unlet b:is_sh | |
68 endif | |
69 else | |
70 let b:is_sh= 1 | |
71 endif | |
72 endif | |
73 | |
199 | 74 " set up default g:sh_fold_enabled {{{1 |
7 | 75 if !exists("g:sh_fold_enabled") |
76 let g:sh_fold_enabled= 0 | |
36 | 77 elseif g:sh_fold_enabled != 0 && !has("folding") |
78 let g:sh_fold_enabled= 0 | |
199 | 79 echomsg "Ignoring g:sh_fold_enabled=".g:sh_fold_enabled."; need to re-compile vim for +fold support" |
80 endif | |
1668 | 81 if !exists("s:sh_fold_functions") |
3920 | 82 let s:sh_fold_functions= and(g:sh_fold_enabled,1) |
1668 | 83 endif |
84 if !exists("s:sh_fold_heredoc") | |
3920 | 85 let s:sh_fold_heredoc = and(g:sh_fold_enabled,2) |
1668 | 86 endif |
87 if !exists("s:sh_fold_ifdofor") | |
3920 | 88 let s:sh_fold_ifdofor = and(g:sh_fold_enabled,4) |
1668 | 89 endif |
199 | 90 if g:sh_fold_enabled && &fdm == "manual" |
3920 | 91 " Given that the user provided g:sh_fold_enabled |
92 " AND g:sh_fold_enabled is manual (usual default) | |
93 " implies a desire for syntax-based folding | |
94 setl fdm=syntax | |
7 | 95 endif |
96 | |
199 | 97 " sh syntax is case sensitive {{{1 |
7 | 98 syn case match |
99 | |
22 | 100 " Clusters: contains=@... clusters {{{1 |
7 | 101 "================================== |
2034 | 102 syn cluster shErrorList contains=shDoError,shIfError,shInError,shCaseError,shEsacError,shCurlyError,shParenError,shTestError,shOK |
1668 | 103 if exists("b:is_kornshell") |
104 syn cluster ErrorList add=shDTestError | |
105 endif | |
2497 | 106 syn cluster shArithParenList contains=shArithmetic,shCaseEsac,shDeref,shDerefSimple,shEcho,shEscape,shNumber,shOperator,shPosnParm,shExSingleQuote,shExDoubleQuote,shRedir,shSingleQuote,shDoubleQuote,shStatement,shVariable,shAlias,shTest,shCtrlSeq,shSpecial,shParen,bashSpecialVariables,bashStatement |
1668 | 107 syn cluster shArithList contains=@shArithParenList,shParenError |
2034 | 108 syn cluster shCaseEsacList contains=shCaseStart,shCase,shCaseBar,shCaseIn,shComment,shDeref,shDerefSimple,shCaseCommandSub,shCaseExSingleQuote,shCaseSingleQuote,shCaseDoubleQuote,shCtrlSeq,@shErrorList,shStringSpecial,shCaseRange |
3099
887d6d91882e
Updated a few runtime files.
Bram Moolenaar <bram@vim.org>
parents:
2751
diff
changeset
|
109 syn cluster shCaseList contains=@shCommandSubList,shCaseEsac,shColon,shCommandSub,shComment,shDo,shEcho,shExpr,shFor,shHereDoc,shIf,shRedir,shSetList,shSource,shStatement,shVariable,shCtrlSeq |
3281 | 110 "syn cluster shColonList contains=@shCaseList |
3920 | 111 syn cluster shCommandSubList contains=shArithmetic,shDeref,shDerefSimple,shEscape,shNumber,shOperator,shPosnParm,shExSingleQuote,shSingleQuote,shExDoubleQuote,shDoubleQuote,shStatement,shVariable,shSubSh,shAlias,shTest,shCtrlSeq,shSpecial,shCmdParenRegion |
464 | 112 syn cluster shCurlyList contains=shNumber,shComma,shDeref,shDerefSimple,shDerefSpecial |
3920 | 113 syn cluster shDblQuoteList contains=shCommandSub,shDeref,shDerefSimple,shEscape,shPosnParm,shCtrlSeq,shSpecial |
482 | 114 syn cluster shDerefList contains=shDeref,shDerefSimple,shDerefVar,shDerefSpecial,shDerefWordError,shDerefPPS |
7 | 115 syn cluster shDerefVarList contains=shDerefOp,shDerefVarArray,shDerefOpError |
3920 | 116 syn cluster shEchoList contains=shArithmetic,shCommandSub,shDeref,shDerefSimple,shEscape,shExpr,shExSingleQuote,shExDoubleQuote,shSingleQuote,shDoubleQuote,shCtrlSeq,shEchoQuote |
2497 | 117 syn cluster shExprList1 contains=shCharClass,shNumber,shOperator,shExSingleQuote,shExDoubleQuote,shSingleQuote,shDoubleQuote,shExpr,shDblBrace,shDeref,shDerefSimple,shCtrlSeq |
119 | 118 syn cluster shExprList2 contains=@shExprList1,@shCaseList,shTest |
3099
887d6d91882e
Updated a few runtime files.
Bram Moolenaar <bram@vim.org>
parents:
2751
diff
changeset
|
119 syn cluster shFunctionList contains=@shCommandSubList,shCaseEsac,shColon,shCommandSub,shComment,shDo,shEcho,shExpr,shFor,shHereDoc,shIf,shOption,shRedir,shSetList,shSource,shStatement,shVariable,shOperator,shCtrlSeq |
1201 | 120 if exists("b:is_kornshell") || exists("b:is_bash") |
1668 | 121 syn cluster shFunctionList add=shRepeat |
1201 | 122 syn cluster shFunctionList add=shDblBrace,shDblParen |
123 endif | |
7 | 124 syn cluster shHereBeginList contains=@shCommandSubList |
125 syn cluster shHereList contains=shBeginHere,shHerePayload | |
126 syn cluster shHereListDQ contains=shBeginHere,@shDblQuoteList,shHerePayload | |
2497 | 127 syn cluster shIdList contains=shCommandSub,shWrapLineOperator,shSetOption,shDeref,shDerefSimple,shRedir,shExSingleQuote,shExDoubleQuote,shSingleQuote,shDoubleQuote,shExpr,shCtrlSeq,shStringSpecial |
3281 | 128 syn cluster shIfList contains=@shLoopList,shDblBrace,shDblParen,shFunctionKey,shFunctionOne,shFunctionTwo |
129 syn cluster shLoopList contains=@shCaseList,shTestOpr,shExpr,shDblBrace,shConditional,shCaseEsac,shTest,@shErrorList,shSet,shOption | |
3099
887d6d91882e
Updated a few runtime files.
Bram Moolenaar <bram@vim.org>
parents:
2751
diff
changeset
|
130 syn cluster shSubShList contains=@shCommandSubList,shCaseEsac,shColon,shCommandSub,shComment,shDo,shEcho,shExpr,shFor,shIf,shRedir,shSetList,shSource,shStatement,shVariable,shCtrlSeq,shOperator |
887d6d91882e
Updated a few runtime files.
Bram Moolenaar <bram@vim.org>
parents:
2751
diff
changeset
|
131 syn cluster shTestList contains=shCharClass,shComment,shCommandSub,shDeref,shDerefSimple,shExDoubleQuote,shDoubleQuote,shExpr,shNumber,shOperator,shExSingleQuote,shSingleQuote,shTestOpr,shTest,shCtrlSeq |
22 | 132 " Echo: {{{1 |
7 | 133 " ==== |
134 " This one is needed INSIDE a CommandSub, so that `echo bla` be correct | |
2473
d55e70cabe2c
Syntax file updates. (Charles Campbell)
Bram Moolenaar <bram@vim.org>
parents:
2357
diff
changeset
|
135 syn region shEcho matchgroup=shStatement start="\<echo\>" skip="\\$" matchgroup=shEchoDelim end="$" matchgroup=NONE end="[<>;&|()]"me=e-1 end="\d[<>]"me=e-2 end="\s#"me=e-2 contains=@shEchoList skipwhite nextgroup=shQuickComment |
d55e70cabe2c
Syntax file updates. (Charles Campbell)
Bram Moolenaar <bram@vim.org>
parents:
2357
diff
changeset
|
136 syn region shEcho matchgroup=shStatement start="\<print\>" skip="\\$" matchgroup=shEchoDelim end="$" matchgroup=NONE end="[<>;&|()]"me=e-1 end="\d[<>]"me=e-2 end="\s#"me=e-2 contains=@shEchoList skipwhite nextgroup=shQuickComment |
2034 | 137 syn match shEchoQuote contained '\%(\\\\\)*\\["`'()]' |
7 | 138 |
1668 | 139 " This must be after the strings, so that ... \" will be correct |
2497 | 140 syn region shEmbeddedEcho contained matchgroup=shStatement start="\<print\>" skip="\\$" matchgroup=shEchoDelim end="$" matchgroup=NONE end="[<>;&|`)]"me=e-1 end="\d[<>]"me=e-2 end="\s#"me=e-2 contains=shNumber,shExSingleQuote,shSingleQuote,shDeref,shDerefSimple,shSpecialVar,shOperator,shExDoubleQuote,shDoubleQuote,shCharClass,shCtrlSeq |
7 | 141 |
22 | 142 " Alias: {{{1 |
7 | 143 " ===== |
144 if exists("b:is_kornshell") || exists("b:is_bash") | |
145 syn match shStatement "\<alias\>" | |
3099
887d6d91882e
Updated a few runtime files.
Bram Moolenaar <bram@vim.org>
parents:
2751
diff
changeset
|
146 syn region shAlias matchgroup=shStatement start="\<alias\>\s\+\(\h[-._[:alnum:]]\+\)\@=" skip="\\$" end="\>\|`" |
887d6d91882e
Updated a few runtime files.
Bram Moolenaar <bram@vim.org>
parents:
2751
diff
changeset
|
147 syn region shAlias matchgroup=shStatement start="\<alias\>\s\+\(\h[-._[:alnum:]]\+=\)\@=" skip="\\$" end="=" |
7 | 148 endif |
149 | |
22 | 150 " Error Codes: {{{1 |
151 " ============ | |
3281 | 152 if !exists("g:sh_no_error") |
153 syn match shDoError "\<done\>" | |
154 syn match shIfError "\<fi\>" | |
155 syn match shInError "\<in\>" | |
156 syn match shCaseError ";;" | |
157 syn match shEsacError "\<esac\>" | |
158 syn match shCurlyError "}" | |
159 syn match shParenError ")" | |
160 syn match shOK '\.\(done\|fi\|in\|esac\)' | |
161 if exists("b:is_kornshell") | |
162 syn match shDTestError "]]" | |
163 endif | |
164 syn match shTestError "]" | |
7 | 165 endif |
166 | |
1668 | 167 " Options: {{{1 |
22 | 168 " ==================== |
3920 | 169 syn match shOption "\s\zs[-+][-_a-zA-Z0-9#]\+" |
1668 | 170 syn match shOption "\s\zs--[^ \t$`'"|]\+" |
7 | 171 |
1201 | 172 " File Redirection Highlighted As Operators: {{{1 |
173 "=========================================== | |
174 syn match shRedir "\d\=>\(&[-0-9]\)\=" | |
175 syn match shRedir "\d\=>>-\=" | |
176 syn match shRedir "\d\=<\(&[-0-9]\)\=" | |
177 syn match shRedir "\d<<-\=" | |
178 | |
22 | 179 " Operators: {{{1 |
180 " ========== | |
1201 | 181 syn match shOperator "<<\|>>" contained |
1668 | 182 syn match shOperator "[!&;|]" contained |
183 syn match shOperator "\[[[^:]\|\]]" contained | |
7 | 184 syn match shOperator "!\==" skipwhite nextgroup=shPattern |
2497 | 185 syn match shPattern "\<\S\+\())\)\@=" contained contains=shExSingleQuote,shSingleQuote,shExDoubleQuote,shDoubleQuote,shDeref |
7 | 186 |
22 | 187 " Subshells: {{{1 |
188 " ========== | |
3099
887d6d91882e
Updated a few runtime files.
Bram Moolenaar <bram@vim.org>
parents:
2751
diff
changeset
|
189 syn region shExpr transparent matchgroup=shExprRegion start="{" end="}" contains=@shExprList2 nextgroup=shMoreSpecial |
887d6d91882e
Updated a few runtime files.
Bram Moolenaar <bram@vim.org>
parents:
2751
diff
changeset
|
190 syn region shSubSh transparent matchgroup=shSubShRegion start="[^(]\zs(" end=")" contains=@shSubShList nextgroup=shMoreSpecial |
7 | 191 |
22 | 192 " Tests: {{{1 |
193 "======= | |
2152 | 194 syn region shExpr matchgroup=shRange start="\[" skip=+\\\\\|\\$\|\[+ end="\]" contains=@shTestList,shSpecial |
2034 | 195 syn region shTest transparent matchgroup=shStatement start="\<test\s" skip=+\\\\\|\\$+ matchgroup=NONE end="[;&|]"me=e-1 end="$" contains=@shExprList1 |
1121 | 196 syn match shTestOpr contained "<=\|>=\|!=\|==\|-.\>\|-\(nt\|ot\|ef\|eq\|ne\|lt\|le\|gt\|ge\)\>\|[!<>]" |
197 syn match shTestOpr contained '=' skipwhite nextgroup=shTestDoubleQuote,shTestSingleQuote,shTestPattern | |
198 syn match shTestPattern contained '\w\+' | |
3099
887d6d91882e
Updated a few runtime files.
Bram Moolenaar <bram@vim.org>
parents:
2751
diff
changeset
|
199 syn match shTestDoubleQuote contained '\%(\%(\\\\\)*\\\)\@<!"[^"]*"' |
1121 | 200 syn match shTestSingleQuote contained '\\.' |
201 syn match shTestSingleQuote contained "'[^']*'" | |
7 | 202 if exists("b:is_kornshell") || exists("b:is_bash") |
203 syn region shDblBrace matchgroup=Delimiter start="\[\[" skip=+\\\\\|\\$+ end="\]\]" contains=@shTestList | |
204 syn region shDblParen matchgroup=Delimiter start="((" skip=+\\\\\|\\$+ end="))" contains=@shTestList | |
205 endif | |
206 | |
22 | 207 " Character Class In Range: {{{1 |
208 " ========================= | |
7 | 209 syn match shCharClass contained "\[:\(backspace\|escape\|return\|xdigit\|alnum\|alpha\|blank\|cntrl\|digit\|graph\|lower\|print\|punct\|space\|upper\|tab\):\]" |
210 | |
22 | 211 " Loops: do, if, while, until {{{1 |
212 " ====== | |
3920 | 213 if s:sh_fold_ifdofor |
820 | 214 syn region shDo fold transparent matchgroup=shConditional start="\<do\>" matchgroup=shConditional end="\<done\>" contains=@shLoopList |
3281 | 215 syn region shIf fold transparent matchgroup=shConditional start="\<if\_s" matchgroup=shConditional skip=+-fi\>+ end="\<;\_s*then\>" end="\<fi\>" contains=@shIfList |
3920 | 216 syn region shFor fold matchgroup=shLoop start="\<for\ze\_s\s*\%(((\)\@!" end="\<in\_s" end="\<do\>"me=e-2 contains=@shLoopList,shDblParen skipwhite nextgroup=shCurlyIn |
820 | 217 else |
218 syn region shDo transparent matchgroup=shConditional start="\<do\>" matchgroup=shConditional end="\<done\>" contains=@shLoopList | |
3281 | 219 syn region shIf transparent matchgroup=shConditional start="\<if\_s" matchgroup=shConditional skip=+-fi\>+ end="\<;\_s*then\>" end="\<fi\>" contains=@shIfList |
3920 | 220 syn region shFor matchgroup=shLoop start="\<for\ze\_s\s*\%(((\)\@!" end="\<in\>" end="\<do\>"me=e-2 contains=@shLoopList,shDblParen skipwhite nextgroup=shCurlyIn |
221 syn match shForPP '\<for\>\ze\_s*((' | |
820 | 222 endif |
7 | 223 if exists("b:is_kornshell") || exists("b:is_bash") |
1668 | 224 syn cluster shCaseList add=shRepeat |
225 syn cluster shFunctionList add=shRepeat | |
226 syn region shRepeat matchgroup=shLoop start="\<while\_s" end="\<in\_s" end="\<do\>"me=e-2 contains=@shLoopList,shDblParen,shDblBrace | |
227 syn region shRepeat matchgroup=shLoop start="\<until\_s" end="\<in\_s" end="\<do\>"me=e-2 contains=@shLoopList,shDblParen,shDblBrace | |
228 syn region shCaseEsac matchgroup=shConditional start="\<select\s" matchgroup=shConditional end="\<in\>" end="\<do\>" contains=@shLoopList | |
7 | 229 else |
1668 | 230 syn region shRepeat matchgroup=shLoop start="\<while\_s" end="\<do\>"me=e-2 contains=@shLoopList |
231 syn region shRepeat matchgroup=shLoop start="\<until\_s" end="\<do\>"me=e-2 contains=@shLoopList | |
7 | 232 endif |
464 | 233 syn region shCurlyIn contained matchgroup=Delimiter start="{" end="}" contains=@shCurlyList |
234 syn match shComma contained "," | |
7 | 235 |
22 | 236 " Case: case...esac {{{1 |
7 | 237 " ==== |
1668 | 238 syn match shCaseBar contained skipwhite "\(^\|[^\\]\)\(\\\\\)*\zs|" nextgroup=shCase,shCaseStart,shCaseBar,shComment,shCaseExSingleQuote,shCaseSingleQuote,shCaseDoubleQuote |
7 | 239 syn match shCaseStart contained skipwhite skipnl "(" nextgroup=shCase,shCaseBar |
3920 | 240 if s:sh_fold_ifdofor |
2034 | 241 syn region shCase fold contained skipwhite skipnl matchgroup=shSnglCase start="\%(\\.\|[^#$()'" \t]\)\{-}\zs)" end=";;" end="esac"me=s-1 contains=@shCaseList nextgroup=shCaseStart,shCase,shComment |
820 | 242 syn region shCaseEsac fold matchgroup=shConditional start="\<case\>" end="\<esac\>" contains=@shCaseEsacList |
243 else | |
2034 | 244 syn region shCase contained skipwhite skipnl matchgroup=shSnglCase start="\%(\\.\|[^#$()'" \t]\)\{-}\zs)" end=";;" end="esac"me=s-1 contains=@shCaseList nextgroup=shCaseStart,shCase,shComment |
820 | 245 syn region shCaseEsac matchgroup=shConditional start="\<case\>" end="\<esac\>" contains=@shCaseEsacList |
246 endif | |
167 | 247 syn keyword shCaseIn contained skipwhite skipnl in nextgroup=shCase,shCaseStart,shCaseBar,shComment,shCaseExSingleQuote,shCaseSingleQuote,shCaseDoubleQuote |
248 if exists("b:is_bash") | |
2473
d55e70cabe2c
Syntax file updates. (Charles Campbell)
Bram Moolenaar <bram@vim.org>
parents:
2357
diff
changeset
|
249 syn region shCaseExSingleQuote matchgroup=shQuote start=+\$'+ skip=+\\\\\|\\.+ end=+'+ contains=shStringSpecial,shSpecial skipwhite skipnl nextgroup=shCaseBar contained |
3281 | 250 elseif !exists("g:sh_no_error") |
167 | 251 syn region shCaseExSingleQuote matchgroup=Error start=+\$'+ skip=+\\\\\|\\.+ end=+'+ contains=shStringSpecial skipwhite skipnl nextgroup=shCaseBar contained |
252 endif | |
2473
d55e70cabe2c
Syntax file updates. (Charles Campbell)
Bram Moolenaar <bram@vim.org>
parents:
2357
diff
changeset
|
253 syn region shCaseSingleQuote matchgroup=shQuote start=+'+ end=+'+ contains=shStringSpecial skipwhite skipnl nextgroup=shCaseBar contained |
d55e70cabe2c
Syntax file updates. (Charles Campbell)
Bram Moolenaar <bram@vim.org>
parents:
2357
diff
changeset
|
254 syn region shCaseDoubleQuote matchgroup=shQuote start=+"+ skip=+\\\\\|\\.+ end=+"+ contains=@shDblQuoteList,shStringSpecial skipwhite skipnl nextgroup=shCaseBar contained |
7 | 255 syn region shCaseCommandSub start=+`+ skip=+\\\\\|\\.+ end=+`+ contains=@shCommandSubList skipwhite skipnl nextgroup=shCaseBar contained |
3920 | 256 if exists("b:is_bash") |
257 syn region shCaseRange matchgroup=Delimiter start=+\[+ skip=+\\\\+ end=+\]+ contained contains=shCharClass | |
258 syn match shCharClass '\[:\%(alnum\|alpha\|ascii\|blank\|cntrl\|digit\|graph\|lower\|print\|punct\|space\|upper\|word\|or\|xdigit\):\]' contained | |
259 else | |
260 syn region shCaseRange matchgroup=Delimiter start=+\[+ skip=+\\\\+ end=+\]+ contained | |
261 endif | |
22 | 262 " Misc: {{{1 |
263 "====== | |
7 | 264 syn match shWrapLineOperator "\\$" |
3920 | 265 syn region shCommandSub start="`" skip="\\\\\|\\." end="`" contains=@shCommandSubList |
266 syn match shEscape contained '\%(\\\\\)*\\.' | |
7 | 267 |
22 | 268 " $() and $(()): {{{1 |
7 | 269 " $(..) is not supported by sh (Bourne shell). However, apparently |
270 " some systems (HP?) have as their /bin/sh a (link to) Korn shell | |
271 " (ie. Posix compliant shell). /bin/ksh should work for those | |
272 " systems too, however, so the following syntax will flag $(..) as | |
273 " an Error under /bin/sh. By consensus of vimdev'ers! | |
274 if exists("b:is_kornshell") || exists("b:is_bash") | |
275 syn region shCommandSub matchgroup=shCmdSubRegion start="\$(" skip='\\\\\|\\.' end=")" contains=@shCommandSubList | |
1668 | 276 syn region shArithmetic matchgroup=shArithRegion start="\$((" skip='\\\\\|\\.' end="))" contains=@shArithList |
3445 | 277 syn region shArithmetic matchgroup=shArithRegion start="\$\[" skip='\\\\\|\\.' end="\]" contains=@shArithList |
7 | 278 syn match shSkipInitWS contained "^\s\+" |
3281 | 279 elseif !exists("g:sh_no_error") |
167 | 280 syn region shCommandSub matchgroup=Error start="\$(" end=")" contains=@shCommandSubList |
7 | 281 endif |
3920 | 282 syn region shCmdParenRegion matchgroup=shCmdSubRegion start="(" skip='\\\\\|\\.' end=")" contains=@shCommandSubList |
7 | 283 |
284 if exists("b:is_bash") | |
285 syn cluster shCommandSubList add=bashSpecialVariables,bashStatement | |
286 syn cluster shCaseList add=bashAdminStatement,bashStatement | |
3099
887d6d91882e
Updated a few runtime files.
Bram Moolenaar <bram@vim.org>
parents:
2751
diff
changeset
|
287 syn keyword bashSpecialVariables contained auto_resume BASH BASH_ALIASES BASH_ALIASES BASH_ARGC BASH_ARGC BASH_ARGV BASH_ARGV BASH_CMDS BASH_CMDS BASH_COMMAND BASH_COMMAND BASH_ENV BASH_EXECUTION_STRING BASH_EXECUTION_STRING BASH_LINENO BASH_LINENO BASHOPTS BASHOPTS BASHPID BASHPID BASH_REMATCH BASH_REMATCH BASH_SOURCE BASH_SOURCE BASH_SUBSHELL BASH_SUBSHELL BASH_VERSINFO BASH_VERSION BASH_XTRACEFD BASH_XTRACEFD CDPATH COLUMNS COLUMNS COMP_CWORD COMP_CWORD COMP_KEY COMP_KEY COMP_LINE COMP_LINE COMP_POINT COMP_POINT COMPREPLY COMPREPLY COMP_TYPE COMP_TYPE COMP_WORDBREAKS COMP_WORDBREAKS COMP_WORDS COMP_WORDS COPROC COPROC DIRSTACK EMACS EMACS ENV ENV EUID FCEDIT FIGNORE FUNCNAME FUNCNAME FUNCNEST FUNCNEST GLOBIGNORE GROUPS histchars HISTCMD HISTCONTROL HISTFILE HISTFILESIZE HISTIGNORE HISTSIZE HISTTIMEFORMAT HISTTIMEFORMAT HOME HOSTFILE HOSTNAME HOSTTYPE IFS IGNOREEOF INPUTRC LANG LC_ALL LC_COLLATE LC_CTYPE LC_CTYPE LC_MESSAGES LC_NUMERIC LC_NUMERIC LINENO LINES LINES MACHTYPE MAIL MAILCHECK MAILPATH MAPFILE MAPFILE OLDPWD OPTARG OPTERR OPTIND OSTYPE PATH PIPESTATUS POSIXLY_CORRECT POSIXLY_CORRECT PPID PROMPT_COMMAND PS1 PS2 PS3 PS4 PWD RANDOM READLINE_LINE READLINE_LINE READLINE_POINT READLINE_POINT REPLY SECONDS SHELL SHELL SHELLOPTS SHLVL TIMEFORMAT TIMEOUT TMPDIR TMPDIR UID |
3920 | 288 syn keyword bashStatement chmod clear complete du egrep expr fgrep find gnufind gnugrep grep less ls mkdir mv rm rmdir rpm sed sleep sort strip tail touch |
7 | 289 syn keyword bashAdminStatement daemon killall killproc nice reload restart start status stop |
3920 | 290 syn keyword bashStatement command compgen |
7 | 291 endif |
292 | |
293 if exists("b:is_kornshell") | |
294 syn cluster shCommandSubList add=kshSpecialVariables,kshStatement | |
295 syn cluster shCaseList add=kshStatement | |
296 syn keyword kshSpecialVariables contained CDPATH COLUMNS EDITOR ENV ERRNO FCEDIT FPATH HISTFILE HISTSIZE HOME IFS LINENO LINES MAIL MAILCHECK MAILPATH OLDPWD OPTARG OPTIND PATH PPID PS1 PS2 PS3 PS4 PWD RANDOM REPLY SECONDS SHELL TMOUT VISUAL | |
3920 | 297 syn keyword kshStatement cat chmod clear cp du egrep expr fgrep find grep killall less ls mkdir mv nice printenv rm rmdir sed sort strip stty tail touch tput |
298 syn keyword kshStatement command setgroups setsenv | |
7 | 299 endif |
300 | |
301 syn match shSource "^\.\s" | |
302 syn match shSource "\s\.\s" | |
2034 | 303 "syn region shColon start="^\s*:" end="$" end="\s#"me=e-2 contains=@shColonList |
3281 | 304 "syn region shColon start="^\s*\zs:" end="$" end="\s#"me=e-2 |
305 syn match shColon '^\s*\zs:' | |
7 | 306 |
22 | 307 " String And Character Constants: {{{1 |
308 "================================ | |
1121 | 309 syn match shNumber "-\=\<\d\+\>#\=" |
310 syn match shCtrlSeq "\\\d\d\d\|\\[abcfnrtv0]" contained | |
167 | 311 if exists("b:is_bash") |
2034 | 312 syn match shSpecial "\\\o\o\o\|\\x\x\x\|\\c[^"]\|\\[abefnrtv]" contained |
167 | 313 endif |
314 if exists("b:is_bash") | |
2473
d55e70cabe2c
Syntax file updates. (Charles Campbell)
Bram Moolenaar <bram@vim.org>
parents:
2357
diff
changeset
|
315 syn region shExSingleQuote matchgroup=shQuote start=+\$'+ skip=+\\\\\|\\.+ end=+'+ contains=shStringSpecial,shSpecial |
2497 | 316 syn region shExDoubleQuote matchgroup=shQuote start=+\$"+ skip=+\\\\\|\\.\|\\"+ end=+"+ contains=@shDblQuoteList,shStringSpecial,shSpecial |
3281 | 317 elseif !exists("g:sh_no_error") |
1121 | 318 syn region shExSingleQuote matchGroup=Error start=+\$'+ skip=+\\\\\|\\.+ end=+'+ contains=shStringSpecial |
2497 | 319 syn region shExDoubleQuote matchGroup=Error start=+\$"+ skip=+\\\\\|\\.+ end=+"+ contains=shStringSpecial |
167 | 320 endif |
2473
d55e70cabe2c
Syntax file updates. (Charles Campbell)
Bram Moolenaar <bram@vim.org>
parents:
2357
diff
changeset
|
321 syn region shSingleQuote matchgroup=shQuote start=+'+ end=+'+ contains=@Spell |
3099
887d6d91882e
Updated a few runtime files.
Bram Moolenaar <bram@vim.org>
parents:
2751
diff
changeset
|
322 syn region shDoubleQuote matchgroup=shQuote start=+\%(\%(\\\\\)*\\\)\@<!"+ skip=+\\"+ end=+"+ contains=@shDblQuoteList,shStringSpecial,@Spell |
887d6d91882e
Updated a few runtime files.
Bram Moolenaar <bram@vim.org>
parents:
2751
diff
changeset
|
323 "syn region shDoubleQuote matchgroup=shQuote start=+"+ skip=+\\"+ end=+"+ contains=@shDblQuoteList,shStringSpecial,@Spell |
1698 | 324 syn match shStringSpecial "[^[:print:] \t]" contained |
1201 | 325 syn match shStringSpecial "\%(\\\\\)*\\[\\"'`$()#]" |
3920 | 326 syn match shSpecial "[^\\]\zs\%(\\\\\)*\\[\\"'`$()#]" nextgroup=shMoreSpecial,shComment |
327 syn match shSpecial "^\%(\\\\\)*\\[\\"'`$()#]" nextgroup=shComment | |
2034 | 328 syn match shMoreSpecial "\%(\\\\\)*\\[\\"'`$()#]" nextgroup=shMoreSpecial contained |
7 | 329 |
22 | 330 " Comments: {{{1 |
331 "========== | |
2034 | 332 syn cluster shCommentGroup contains=shTodo,@Spell |
333 syn keyword shTodo contained COMBAK FIXME TODO XXX | |
334 syn match shComment "^\s*\zs#.*$" contains=@shCommentGroup | |
335 syn match shComment "\s\zs#.*$" contains=@shCommentGroup | |
3920 | 336 syn match shComment contained "#.*$" contains=@shCommentGroup |
2034 | 337 syn match shQuickComment contained "#.*$" |
7 | 338 |
22 | 339 " Here Documents: {{{1 |
340 " ========================================= | |
7 | 341 if version < 600 |
342 syn region shHereDoc matchgroup=shRedir start="<<\s*\**END[a-zA-Z_0-9]*\**" matchgroup=shRedir end="^END[a-zA-Z_0-9]*$" contains=@shDblQuoteList | |
343 syn region shHereDoc matchgroup=shRedir start="<<-\s*\**END[a-zA-Z_0-9]*\**" matchgroup=shRedir end="^\s*END[a-zA-Z_0-9]*$" contains=@shDblQuoteList | |
344 syn region shHereDoc matchgroup=shRedir start="<<\s*\**EOF\**" matchgroup=shRedir end="^EOF$" contains=@shDblQuoteList | |
345 syn region shHereDoc matchgroup=shRedir start="<<-\s*\**EOF\**" matchgroup=shRedir end="^\s*EOF$" contains=@shDblQuoteList | |
346 syn region shHereDoc matchgroup=shRedir start="<<\s*\**\.\**" matchgroup=shRedir end="^\.$" contains=@shDblQuoteList | |
347 syn region shHereDoc matchgroup=shRedir start="<<-\s*\**\.\**" matchgroup=shRedir end="^\s*\.$" contains=@shDblQuoteList | |
348 | |
3920 | 349 elseif s:sh_fold_heredoc |
350 syn region shHereDoc matchgroup=shRedir fold start="<<\s*\z([^ \t|]*\)" matchgroup=shRedir end="^\z1\s*$" contains=@shDblQuoteList | |
351 syn region shHereDoc matchgroup=shRedir fold start="<<\s*\"\z([^ \t|]*\)\"" matchgroup=shRedir end="^\z1\s*$" | |
352 syn region shHereDoc matchgroup=shRedir fold start="<<\s*'\z([^ \t|]*\)'" matchgroup=shRedir end="^\z1\s*$" | |
353 syn region shHereDoc matchgroup=shRedir fold start="<<-\s*\z([^ \t|]*\)" matchgroup=shRedir end="^\s*\z1\s*$" contains=@shDblQuoteList | |
354 syn region shHereDoc matchgroup=shRedir fold start="<<-\s*\"\z([^ \t|]*\)\"" matchgroup=shRedir end="^\s*\z1\s*$" | |
355 syn region shHereDoc matchgroup=shRedir fold start="<<-\s*'\z([^ \t|]*\)'" matchgroup=shRedir end="^\s*\z1\s*$" | |
356 syn region shHereDoc matchgroup=shRedir fold start="<<\s*\\\_$\_s*\z([^ \t|]*\)" matchgroup=shRedir end="^\z1\s*$" | |
357 syn region shHereDoc matchgroup=shRedir fold start="<<\s*\\\_$\_s*\"\z([^ \t|]*\)\"" matchgroup=shRedir end="^\z1\s*$" | |
358 syn region shHereDoc matchgroup=shRedir fold start="<<-\s*\\\_$\_s*'\z([^ \t|]*\)'" matchgroup=shRedir end="^\s*\z1\s*$" | |
359 syn region shHereDoc matchgroup=shRedir fold start="<<-\s*\\\_$\_s*\z([^ \t|]*\)" matchgroup=shRedir end="^\s*\z1\s*$" | |
360 syn region shHereDoc matchgroup=shRedir fold start="<<-\s*\\\_$\_s*\"\z([^ \t|]*\)\"" matchgroup=shRedir end="^\s*\z1\s*$" | |
361 syn region shHereDoc matchgroup=shRedir fold start="<<\s*\\\_$\_s*'\z([^ \t|]*\)'" matchgroup=shRedir end="^\z1\s*$" | |
362 syn region shHereDoc matchgroup=shRedir fold start="<<\\\z([^ \t|]*\)" matchgroup=shRedir end="^\z1\s*$" | |
7 | 363 |
364 else | |
3920 | 365 syn region shHereDoc matchgroup=shRedir start="<<\s*\\\=\z([^ \t|]*\)" matchgroup=shRedir end="^\z1\s*$" contains=@shDblQuoteList |
366 syn region shHereDoc matchgroup=shRedir start="<<\s*\"\z([^ \t|]*\)\"" matchgroup=shRedir end="^\z1\s*$" | |
367 syn region shHereDoc matchgroup=shRedir start="<<-\s*\z([^ \t|]*\)" matchgroup=shRedir end="^\s*\z1\s*$" contains=@shDblQuoteList | |
368 syn region shHereDoc matchgroup=shRedir start="<<-\s*'\z([^ \t|]*\)'" matchgroup=shRedir end="^\s*\z1\s*$" | |
369 syn region shHereDoc matchgroup=shRedir start="<<\s*'\z([^ \t|]*\)'" matchgroup=shRedir end="^\z1\s*$" | |
370 syn region shHereDoc matchgroup=shRedir start="<<-\s*\"\z([^ \t|]*\)\"" matchgroup=shRedir end="^\s*\z1\s*$" | |
371 syn region shHereDoc matchgroup=shRedir start="<<\s*\\\_$\_s*\z([^ \t|]*\)" matchgroup=shRedir end="^\z1\s*$" | |
372 syn region shHereDoc matchgroup=shRedir start="<<-\s*\\\_$\_s*\z([^ \t|]*\)" matchgroup=shRedir end="^\s*\z1\s*$" | |
373 syn region shHereDoc matchgroup=shRedir start="<<-\s*\\\_$\_s*'\z([^ \t|]*\)'" matchgroup=shRedir end="^\s*\z1\s*$" | |
374 syn region shHereDoc matchgroup=shRedir start="<<\s*\\\_$\_s*'\z([^ \t|]*\)'" matchgroup=shRedir end="^\z1\s*$" | |
375 syn region shHereDoc matchgroup=shRedir start="<<\s*\\\_$\_s*\"\z([^ \t|]*\)\"" matchgroup=shRedir end="^\z1\s*$" | |
376 syn region shHereDoc matchgroup=shRedir start="<<-\s*\\\_$\_s*\"\z([^ \t|]*\)\"" matchgroup=shRedir end="^\s*\z1\s*$" | |
377 syn region shHereDoc matchgroup=shRedir start="<<\\\z([^ \t|]*\)" matchgroup=shRedir end="^\z1\s*$" | |
7 | 378 endif |
379 | |
22 | 380 " Here Strings: {{{1 |
381 " ============= | |
3099
887d6d91882e
Updated a few runtime files.
Bram Moolenaar <bram@vim.org>
parents:
2751
diff
changeset
|
382 " available for: bash; ksh (really should be ksh93 only) but not if its a posix |
887d6d91882e
Updated a few runtime files.
Bram Moolenaar <bram@vim.org>
parents:
2751
diff
changeset
|
383 if exists("b:is_bash") || (exists("b:is_kornshell") && !exists("g:is_posix")) |
3920 | 384 syn match shRedir "<<<" skipwhite nextgroup=shCmdParenRegion |
22 | 385 endif |
386 | |
387 " Identifiers: {{{1 | |
388 "============= | |
1668 | 389 syn match shSetOption "\s\zs[-+][a-zA-Z0-9]\+\>" contained |
390 syn match shVariable "\<\([bwglsav]:\)\=[a-zA-Z0-9.!@_%+,]*\ze=" nextgroup=shSetIdentifier | |
3920 | 391 syn match shSetIdentifier "=" contained nextgroup=shCmdParenRegion,shPattern,shDeref,shDerefSimple,shDoubleQuote,shExDoubleQuote,shSingleQuote,shExSingleQuote |
7 | 392 if exists("b:is_bash") |
2473
d55e70cabe2c
Syntax file updates. (Charles Campbell)
Bram Moolenaar <bram@vim.org>
parents:
2357
diff
changeset
|
393 syn region shSetList oneline matchgroup=shSet start="\<\(declare\|typeset\|local\|export\|unset\)\>\ze[^/]" end="$" matchgroup=shSetListDelim end="\ze[}|);&]" matchgroup=NONE end="\ze\s\+#\|=" contains=@shIdList |
3920 | 394 syn region shSetList oneline matchgroup=shSet start="\<set\>\ze[^/]" end="\ze[;|)]\|$" matchgroup=shSetListDelim end="\ze[}|);&]" matchgroup=NONE end="\ze\s\+=" contains=@shIdList |
7 | 395 elseif exists("b:is_kornshell") |
2473
d55e70cabe2c
Syntax file updates. (Charles Campbell)
Bram Moolenaar <bram@vim.org>
parents:
2357
diff
changeset
|
396 syn region shSetList oneline matchgroup=shSet start="\<\(typeset\|export\|unset\)\>\ze[^/]" end="$" matchgroup=shSetListDelim end="\ze[}|);&]" matchgroup=NONE end="\ze\s\+[#=]" contains=@shIdList |
d55e70cabe2c
Syntax file updates. (Charles Campbell)
Bram Moolenaar <bram@vim.org>
parents:
2357
diff
changeset
|
397 syn region shSetList oneline matchgroup=shSet start="\<set\>\ze[^/]" end="$" matchgroup=shSetListDelim end="\ze[}|);&]" matchgroup=NONE end="\ze\s\+[#=]" contains=@shIdList |
7 | 398 else |
2473
d55e70cabe2c
Syntax file updates. (Charles Campbell)
Bram Moolenaar <bram@vim.org>
parents:
2357
diff
changeset
|
399 syn region shSetList oneline matchgroup=shSet start="\<\(set\|export\|unset\)\>\ze[^/]" end="$" matchgroup=shSetListDelim end="\ze[}|);&]" matchgroup=NONE end="\ze\s\+[#=]" contains=@shIdList |
7 | 400 endif |
401 | |
22 | 402 " Functions: {{{1 |
1668 | 403 if !exists("g:is_posix") |
404 syn keyword shFunctionKey function skipwhite skipnl nextgroup=shFunctionTwo | |
405 endif | |
406 | |
407 if exists("b:is_bash") | |
3920 | 408 if s:sh_fold_functions |
409 syn region shFunctionOne fold matchgroup=shFunction start="^\s*\h[-a-zA-Z_0-9]*\s*()\_s*{" end="}" contains=@shFunctionList skipwhite skipnl nextgroup=shFunctionStart,shQuickComment | |
1668 | 410 syn region shFunctionTwo fold matchgroup=shFunction start="\h[-a-zA-Z_0-9]*\s*\%(()\)\=\_s*{" end="}" contains=shFunctionKey,@shFunctionList contained skipwhite skipnl nextgroup=shFunctionStart,shQuickComment |
411 else | |
412 syn region shFunctionOne matchgroup=shFunction start="^\s*\h[-a-zA-Z_0-9]*\s*()\_s*{" end="}" contains=@shFunctionList | |
413 syn region shFunctionTwo matchgroup=shFunction start="\h[-a-zA-Z_0-9]*\s*\%(()\)\=\_s*{" end="}" contains=shFunctionKey,@shFunctionList contained | |
414 endif | |
7 | 415 else |
3920 | 416 if s:sh_fold_functions |
1668 | 417 syn region shFunctionOne fold matchgroup=shFunction start="^\s*\h\w*\s*()\_s*{" end="}" contains=@shFunctionList skipwhite skipnl nextgroup=shFunctionStart,shQuickComment |
418 syn region shFunctionTwo fold matchgroup=shFunction start="\h\w*\s*\%(()\)\=\_s*{" end="}" contains=shFunctionKey,@shFunctionList contained skipwhite skipnl nextgroup=shFunctionStart,shQuickComment | |
419 else | |
420 syn region shFunctionOne matchgroup=shFunction start="^\s*\h\w*\s*()\_s*{" end="}" contains=@shFunctionList | |
421 syn region shFunctionTwo matchgroup=shFunction start="\h\w*\s*\%(()\)\=\_s*{" end="}" contains=shFunctionKey,@shFunctionList contained | |
422 endif | |
7 | 423 endif |
424 | |
22 | 425 " Parameter Dereferencing: {{{1 |
426 " ======================== | |
3920 | 427 syn match shDerefSimple "\$\%(\k\+\|\d\)" |
7 | 428 syn region shDeref matchgroup=PreProc start="\${" end="}" contains=@shDerefList,shDerefVarArray |
3281 | 429 if !exists("g:sh_no_error") |
430 syn match shDerefWordError "[^}$[]" contained | |
431 endif | |
7 | 432 syn match shDerefSimple "\$[-#*@!?]" |
433 syn match shDerefSimple "\$\$" | |
434 if exists("b:is_bash") || exists("b:is_kornshell") | |
435 syn region shDeref matchgroup=PreProc start="\${##\=" end="}" contains=@shDerefList | |
1668 | 436 syn region shDeref matchgroup=PreProc start="\${\$\$" end="}" contains=@shDerefList |
7 | 437 endif |
438 | |
22 | 439 " bash: ${!prefix*} and ${#parameter}: {{{1 |
440 " ==================================== | |
7 | 441 if exists("b:is_bash") |
442 syn region shDeref matchgroup=PreProc start="\${!" end="\*\=}" contains=@shDerefList,shDerefOp | |
3920 | 443 syn match shDerefVar contained "{\@<=!\k\+" nextgroup=@shDerefVarList |
7 | 444 endif |
445 | |
446 syn match shDerefSpecial contained "{\@<=[-*@?0]" nextgroup=shDerefOp,shDerefOpError | |
447 syn match shDerefSpecial contained "\({[#!]\)\@<=[[:alnum:]*@_]\+" nextgroup=@shDerefVarList,shDerefOp | |
3920 | 448 syn match shDerefVar contained "{\@<=\k\+" nextgroup=@shDerefVarList |
7 | 449 |
22 | 450 " sh ksh bash : ${var[... ]...} array reference: {{{1 |
7 | 451 syn region shDerefVarArray contained matchgroup=shDeref start="\[" end="]" contains=@shCommandSubList nextgroup=shDerefOp,shDerefOpError |
452 | |
22 | 453 " Special ${parameter OPERATOR word} handling: {{{1 |
7 | 454 " sh ksh bash : ${parameter:-word} word is default value |
455 " sh ksh bash : ${parameter:=word} assign word as default value | |
456 " sh ksh bash : ${parameter:?word} display word if parameter is null | |
457 " sh ksh bash : ${parameter:+word} use word if parameter is not null, otherwise nothing | |
458 " ksh bash : ${parameter#pattern} remove small left pattern | |
459 " ksh bash : ${parameter##pattern} remove large left pattern | |
460 " ksh bash : ${parameter%pattern} remove small right pattern | |
461 " ksh bash : ${parameter%%pattern} remove large right pattern | |
3099
887d6d91882e
Updated a few runtime files.
Bram Moolenaar <bram@vim.org>
parents:
2751
diff
changeset
|
462 " bash : ${parameter^pattern} Case modification |
887d6d91882e
Updated a few runtime files.
Bram Moolenaar <bram@vim.org>
parents:
2751
diff
changeset
|
463 " bash : ${parameter^^pattern} Case modification |
887d6d91882e
Updated a few runtime files.
Bram Moolenaar <bram@vim.org>
parents:
2751
diff
changeset
|
464 " bash : ${parameter,pattern} Case modification |
887d6d91882e
Updated a few runtime files.
Bram Moolenaar <bram@vim.org>
parents:
2751
diff
changeset
|
465 " bash : ${parameter,,pattern} Case modification |
7 | 466 syn cluster shDerefPatternList contains=shDerefPattern,shDerefString |
3281 | 467 if !exists("g:sh_no_error") |
468 syn match shDerefOpError contained ":[[:punct:]]" | |
469 endif | |
7 | 470 syn match shDerefOp contained ":\=[-=?]" nextgroup=@shDerefPatternList |
471 syn match shDerefOp contained ":\=+" nextgroup=@shDerefPatternList | |
472 if exists("b:is_bash") || exists("b:is_kornshell") | |
473 syn match shDerefOp contained "#\{1,2}" nextgroup=@shDerefPatternList | |
474 syn match shDerefOp contained "%\{1,2}" nextgroup=@shDerefPatternList | |
482 | 475 syn match shDerefPattern contained "[^{}]\+" contains=shDeref,shDerefSimple,shDerefPattern,shDerefString,shCommandSub,shDerefEscape nextgroup=shDerefPattern |
7 | 476 syn region shDerefPattern contained start="{" end="}" contains=shDeref,shDerefSimple,shDerefString,shCommandSub nextgroup=shDerefPattern |
482 | 477 syn match shDerefEscape contained '\%(\\\\\)*\\.' |
7 | 478 endif |
3099
887d6d91882e
Updated a few runtime files.
Bram Moolenaar <bram@vim.org>
parents:
2751
diff
changeset
|
479 if exists("b:is_bash") |
887d6d91882e
Updated a few runtime files.
Bram Moolenaar <bram@vim.org>
parents:
2751
diff
changeset
|
480 syn match shDerefOp contained "[,^]\{1,2}" nextgroup=@shDerefPatternList |
887d6d91882e
Updated a few runtime files.
Bram Moolenaar <bram@vim.org>
parents:
2751
diff
changeset
|
481 endif |
2473
d55e70cabe2c
Syntax file updates. (Charles Campbell)
Bram Moolenaar <bram@vim.org>
parents:
2357
diff
changeset
|
482 syn region shDerefString contained matchgroup=shDerefDelim start=+\%(\\\)\@<!'+ end=+'+ contains=shStringSpecial |
d55e70cabe2c
Syntax file updates. (Charles Campbell)
Bram Moolenaar <bram@vim.org>
parents:
2357
diff
changeset
|
483 syn region shDerefString contained matchgroup=shDerefDelim start=+\%(\\\)\@<!"+ skip=+\\"+ end=+"+ contains=@shDblQuoteList,shStringSpecial |
1668 | 484 syn match shDerefString contained "\\["']" nextgroup=shDerefPattern |
7 | 485 |
486 if exists("b:is_bash") | |
482 | 487 " bash : ${parameter:offset} |
488 " bash : ${parameter:offset:length} | |
7 | 489 syn region shDerefOp contained start=":[$[:alnum:]_]"me=e-1 end=":"me=e-1 end="}"me=e-1 contains=@shCommandSubList nextgroup=shDerefPOL |
482 | 490 syn match shDerefPOL contained ":[^}]\+" contains=@shCommandSubList |
491 | |
492 " bash : ${parameter//pattern/string} | |
493 " bash : ${parameter//pattern} | |
494 syn match shDerefPPS contained '/\{1,2}' nextgroup=shDerefPPSleft | |
3920 | 495 syn region shDerefPPSleft contained start='.' skip=@\%(\\\\\)*\\/@ matchgroup=shDerefOp end='/' end='\ze}' nextgroup=shDerefPPSright contains=@shCommandSubList |
496 syn region shDerefPPSright contained start='.' skip=@\%(\\\\\)\+@ end='\ze}' contains=@shCommandSubList | |
7 | 497 endif |
498 | |
1668 | 499 " Arithmetic Parenthesized Expressions: {{{1 |
3920 | 500 syn region shParen matchgroup=shArithRegion start='[^$]\zs(\%(\ze[^(]\|$\)' end=')' contains=@shArithParenList |
1668 | 501 |
22 | 502 " Useful sh Keywords: {{{1 |
503 " =================== | |
7 | 504 syn keyword shStatement break cd chdir continue eval exec exit kill newgrp pwd read readonly return shift test trap ulimit umask wait |
505 syn keyword shConditional contained elif else then | |
3281 | 506 if !exists("g:sh_no_error") |
507 syn keyword shCondError elif else then | |
508 endif | |
7 | 509 |
22 | 510 " Useful ksh Keywords: {{{1 |
511 " ==================== | |
7 | 512 if exists("b:is_kornshell") || exists("b:is_bash") |
2473
d55e70cabe2c
Syntax file updates. (Charles Campbell)
Bram Moolenaar <bram@vim.org>
parents:
2357
diff
changeset
|
513 syn keyword shStatement autoload bg false fc fg functions getopts hash history integer jobs let nohup printf r stop suspend times true type unalias whence |
1668 | 514 if exists("g:is_posix") |
515 syn keyword shStatement command | |
516 else | |
517 syn keyword shStatement time | |
518 endif | |
7 | 519 |
22 | 520 " Useful bash Keywords: {{{1 |
521 " ===================== | |
7 | 522 if exists("b:is_bash") |
523 syn keyword shStatement bind builtin dirs disown enable help local logout popd pushd shopt source | |
524 else | |
525 syn keyword shStatement login newgrp | |
526 endif | |
527 endif | |
528 | |
22 | 529 " Synchronization: {{{1 |
530 " ================ | |
7 | 531 if !exists("sh_minlines") |
532 let sh_minlines = 200 | |
533 endif | |
534 if !exists("sh_maxlines") | |
535 let sh_maxlines = 2 * sh_minlines | |
536 endif | |
537 exec "syn sync minlines=" . sh_minlines . " maxlines=" . sh_maxlines | |
538 syn sync match shCaseEsacSync grouphere shCaseEsac "\<case\>" | |
539 syn sync match shCaseEsacSync groupthere shCaseEsac "\<esac\>" | |
540 syn sync match shDoSync grouphere shDo "\<do\>" | |
541 syn sync match shDoSync groupthere shDo "\<done\>" | |
542 syn sync match shForSync grouphere shFor "\<for\>" | |
543 syn sync match shForSync groupthere shFor "\<in\>" | |
544 syn sync match shIfSync grouphere shIf "\<if\>" | |
545 syn sync match shIfSync groupthere shIf "\<fi\>" | |
546 syn sync match shUntilSync grouphere shRepeat "\<until\>" | |
547 syn sync match shWhileSync grouphere shRepeat "\<while\>" | |
548 | |
22 | 549 " Default Highlighting: {{{1 |
550 " ===================== | |
7 | 551 hi def link shArithRegion shShellVariables |
167 | 552 hi def link shBeginHere shRedir |
7 | 553 hi def link shCaseBar shConditional |
554 hi def link shCaseCommandSub shCommandSub | |
555 hi def link shCaseDoubleQuote shDoubleQuote | |
167 | 556 hi def link shCaseIn shConditional |
2473
d55e70cabe2c
Syntax file updates. (Charles Campbell)
Bram Moolenaar <bram@vim.org>
parents:
2357
diff
changeset
|
557 hi def link shQuote shOperator |
7 | 558 hi def link shCaseSingleQuote shSingleQuote |
559 hi def link shCaseStart shConditional | |
560 hi def link shCmdSubRegion shShellVariables | |
2034 | 561 hi def link shColon shComment |
167 | 562 hi def link shDerefOp shOperator |
563 hi def link shDerefPOL shDerefOp | |
482 | 564 hi def link shDerefPPS shDerefOp |
7 | 565 hi def link shDeref shShellVariables |
2473
d55e70cabe2c
Syntax file updates. (Charles Campbell)
Bram Moolenaar <bram@vim.org>
parents:
2357
diff
changeset
|
566 hi def link shDerefDelim shOperator |
7 | 567 hi def link shDerefSimple shDeref |
568 hi def link shDerefSpecial shDeref | |
569 hi def link shDerefString shDoubleQuote | |
167 | 570 hi def link shDerefVar shDeref |
7 | 571 hi def link shDoubleQuote shString |
572 hi def link shEcho shString | |
2473
d55e70cabe2c
Syntax file updates. (Charles Campbell)
Bram Moolenaar <bram@vim.org>
parents:
2357
diff
changeset
|
573 hi def link shEchoDelim shOperator |
1668 | 574 hi def link shEchoQuote shString |
3920 | 575 hi def link shForPP shLoop |
7 | 576 hi def link shEmbeddedEcho shString |
1668 | 577 hi def link shEscape shCommandSub |
2497 | 578 hi def link shExDoubleQuote shDoubleQuote |
167 | 579 hi def link shExSingleQuote shSingleQuote |
1668 | 580 hi def link shFunction Function |
7 | 581 hi def link shHereDoc shString |
167 | 582 hi def link shHerePayload shHereDoc |
7 | 583 hi def link shLoop shStatement |
2034 | 584 hi def link shMoreSpecial shSpecial |
7 | 585 hi def link shOption shCommandSub |
586 hi def link shPattern shString | |
1668 | 587 hi def link shParen shArithmetic |
7 | 588 hi def link shPosnParm shShellVariables |
1668 | 589 hi def link shQuickComment shComment |
7 | 590 hi def link shRange shOperator |
591 hi def link shRedir shOperator | |
2473
d55e70cabe2c
Syntax file updates. (Charles Campbell)
Bram Moolenaar <bram@vim.org>
parents:
2357
diff
changeset
|
592 hi def link shSetListDelim shOperator |
1668 | 593 hi def link shSetOption shOption |
7 | 594 hi def link shSingleQuote shString |
595 hi def link shSource shOperator | |
596 hi def link shStringSpecial shSpecial | |
597 hi def link shSubShRegion shOperator | |
598 hi def link shTestOpr shConditional | |
1121 | 599 hi def link shTestPattern shString |
600 hi def link shTestDoubleQuote shString | |
601 hi def link shTestSingleQuote shString | |
7 | 602 hi def link shVariable shSetList |
603 hi def link shWrapLineOperator shOperator | |
604 | |
605 if exists("b:is_bash") | |
606 hi def link bashAdminStatement shStatement | |
607 hi def link bashSpecialVariables shShellVariables | |
608 hi def link bashStatement shStatement | |
199 | 609 hi def link shFunctionParen Delimiter |
610 hi def link shFunctionDelim Delimiter | |
3920 | 611 hi def link shCharClass shSpecial |
7 | 612 endif |
613 if exists("b:is_kornshell") | |
614 hi def link kshSpecialVariables shShellVariables | |
615 hi def link kshStatement shStatement | |
199 | 616 hi def link shFunctionParen Delimiter |
7 | 617 endif |
618 | |
3281 | 619 if !exists("g:sh_no_error") |
620 hi def link shCaseError Error | |
621 hi def link shCondError Error | |
622 hi def link shCurlyError Error | |
623 hi def link shDerefError Error | |
624 hi def link shDerefOpError Error | |
625 hi def link shDerefWordError Error | |
626 hi def link shDoError Error | |
627 hi def link shEsacError Error | |
628 hi def link shIfError Error | |
629 hi def link shInError Error | |
630 hi def link shParenError Error | |
631 hi def link shTestError Error | |
632 if exists("b:is_kornshell") | |
633 hi def link shDTestError Error | |
634 endif | |
7 | 635 endif |
636 | |
637 hi def link shArithmetic Special | |
638 hi def link shCharClass Identifier | |
639 hi def link shSnglCase Statement | |
640 hi def link shCommandSub Special | |
641 hi def link shComment Comment | |
642 hi def link shConditional Conditional | |
1121 | 643 hi def link shCtrlSeq Special |
7 | 644 hi def link shExprRegion Delimiter |
199 | 645 hi def link shFunctionKey Function |
7 | 646 hi def link shFunctionName Function |
647 hi def link shNumber Number | |
648 hi def link shOperator Operator | |
649 hi def link shRepeat Repeat | |
650 hi def link shSet Statement | |
651 hi def link shSetList Identifier | |
652 hi def link shShellVariables PreProc | |
653 hi def link shSpecial Special | |
654 hi def link shStatement Statement | |
655 hi def link shString String | |
656 hi def link shTodo Todo | |
657 hi def link shAlias Identifier | |
658 | |
22 | 659 " Set Current Syntax: {{{1 |
660 " =================== | |
7 | 661 if exists("b:is_bash") |
662 let b:current_syntax = "bash" | |
663 elseif exists("b:is_kornshell") | |
664 let b:current_syntax = "ksh" | |
665 else | |
666 let b:current_syntax = "sh" | |
667 endif | |
668 | |
22 | 669 " vim: ts=16 fdm=marker |