2 " Language: C-shell (csh)
3 " Maintainer: Dr. Charles E. Campbell, Jr. <NdrOchipS@PcampbellAfamily.Mbiz>
5 " Last Change: Sep 11, 2006
6 " URL: http://mysite.verizon.net/astronaut/vim/index.html#vimlinks_syntax
8 " For version 5.x: Clear all syntax items
9 " For version 6.x: Quit when a syntax file was already loaded
12 elseif exists("b:current_syntax")
17 syn cluster cshQuoteList contains=cshDblQuote,cshSnglQuote,cshBckQuote
18 syn cluster cshVarList contains=cshExtVar,cshSelector,cshQtyWord,cshArgv,cshSubst
20 " Variables which affect the csh itself
21 syn match cshSetVariables contained "argv\|histchars\|ignoreeof\|noglob\|prompt\|status"
22 syn match cshSetVariables contained "cdpath\|history\|mail\|nonomatch\|savehist\|time"
23 syn match cshSetVariables contained "cwd\|home\|noclobber\|path\|shell\|verbose"
24 syn match cshSetVariables contained "echo"
27 syn keyword cshTodo contained todo
30 " Variable Name Expansion Modifiers
31 syn match cshModifier contained ":\(h\|t\|r\|q\|x\|gh\|gt\|gr\)"
33 " Strings and Comments
34 syn match cshNoEndlineDQ contained "[^\"]\(\\\\\)*$"
35 syn match cshNoEndlineSQ contained "[^\']\(\\\\\)*$"
36 syn match cshNoEndlineBQ contained "[^\`]\(\\\\\)*$"
38 syn region cshDblQuote start=+[^\\]"+lc=1 skip=+\\\\\|\\"+ end=+"+ contains=cshSpecial,cshShellVariables,cshExtVar,cshSelector,cshQtyWord,cshArgv,cshSubst,cshNoEndlineDQ,cshBckQuote,@Spell
39 syn region cshSnglQuote start=+[^\\]'+lc=1 skip=+\\\\\|\\'+ end=+'+ contains=cshNoEndlineSQ,@Spell
40 syn region cshBckQuote start=+[^\\]`+lc=1 skip=+\\\\\|\\`+ end=+`+ contains=cshNoEndlineBQ,@Spell
41 syn region cshDblQuote start=+^"+ skip=+\\\\\|\\"+ end=+"+ contains=cshSpecial,cshExtVar,cshSelector,cshQtyWord,cshArgv,cshSubst,cshNoEndlineDQ,@Spell
42 syn region cshSnglQuote start=+^'+ skip=+\\\\\|\\'+ end=+'+ contains=cshNoEndlineSQ,@Spell
43 syn region cshBckQuote start=+^`+ skip=+\\\\\|\\`+ end=+`+ contains=cshNoEndlineBQ,@Spell
44 syn cluster cshCommentGroup contains=cshTodo,@Spell
45 syn match cshComment "#.*$" contains=@cshCommentGroup
47 " A bunch of useful csh keywords
48 syn keyword cshStatement alias end history onintr setenv unalias
49 syn keyword cshStatement cd eval kill popd shift unhash
50 syn keyword cshStatement chdir exec login pushd source
51 syn keyword cshStatement continue exit logout rehash time unsetenv
52 syn keyword cshStatement dirs glob nice repeat umask wait
53 syn keyword cshStatement echo goto nohup
55 syn keyword cshConditional break case else endsw switch
56 syn keyword cshConditional breaksw default endif
57 syn keyword cshRepeat foreach
59 " Special environment variables
60 syn keyword cshShellVariables HOME LOGNAME PATH TERM USER
62 " Modifiable Variables without {}
63 syn match cshExtVar "\$[a-zA-Z_][a-zA-Z0-9_]*\(:h\|:t\|:r\|:q\|:x\|:gh\|:gt\|:gr\)\=" contains=cshModifier
64 syn match cshSelector "\$[a-zA-Z_][a-zA-Z0-9_]*\[[a-zA-Z_]\+\]\(:h\|:t\|:r\|:q\|:x\|:gh\|:gt\|:gr\)\=" contains=cshModifier
65 syn match cshQtyWord "\$#[a-zA-Z_][a-zA-Z0-9_]*\(:h\|:t\|:r\|:q\|:x\|:gh\|:gt\|:gr\)\=" contains=cshModifier
66 syn match cshArgv "\$\d\+\(:h\|:t\|:r\|:q\|:x\|:gh\|:gt\|:gr\)\=" contains=cshModifier
67 syn match cshArgv "\$\*\(:h\|:t\|:r\|:q\|:x\|:gh\|:gt\|:gr\)\=" contains=cshModifier
69 " Modifiable Variables with {}
70 syn match cshExtVar "\${[a-zA-Z_][a-zA-Z0-9_]*\(:h\|:t\|:r\|:q\|:x\|:gh\|:gt\|:gr\)\=}" contains=cshModifier
71 syn match cshSelector "\${[a-zA-Z_][a-zA-Z0-9_]*\[[a-zA-Z_]\+\]\(:h\|:t\|:r\|:q\|:x\|:gh\|:gt\|:gr\)\=}" contains=cshModifier
72 syn match cshQtyWord "\${#[a-zA-Z_][a-zA-Z0-9_]*\(:h\|:t\|:r\|:q\|:x\|:gh\|:gt\|:gr\)\=}" contains=cshModifier
73 syn match cshArgv "\${\d\+\(:h\|:t\|:r\|:q\|:x\|:gh\|:gt\|:gr\)\=}" contains=cshModifier
75 " UnModifiable Substitutions
76 syn match cshSubstError "\$?[a-zA-Z_][a-zA-Z0-9_]*:\(h\|t\|r\|q\|x\|gh\|gt\|gr\)"
77 syn match cshSubstError "\${?[a-zA-Z_][a-zA-Z0-9_]*:\(h\|t\|r\|q\|x\|gh\|gt\|gr\)}"
78 syn match cshSubstError "\$?[0$<]:\(h\|t\|r\|q\|x\|gh\|gt\|gr\)"
79 syn match cshSubst "\$?[a-zA-Z_][a-zA-Z0-9_]*"
80 syn match cshSubst "\${?[a-zA-Z_][a-zA-Z0-9_]*}"
81 syn match cshSubst "\$?[0$<]"
84 syn match cshRedir ">>&!\|>&!\|>>&\|>>!\|>&\|>!\|>>\|<<\|>\|<"
86 " Handle set expressions
87 syn region cshSetExpr matchgroup=cshSetStmt start="\<set\>\|\<unset\>" end="$\|;" contains=cshComment,cshSetStmt,cshSetVariables,@cshQuoteList
89 " Operators and Expression-Using constructs
90 "syn match cshOperator contained "&&\|!\~\|!=\|<<\|<=\|==\|=\~\|>=\|>>\|\*\|\^\|\~\|||\|!\|\|%\|&\|+\|-\|/\|<\|>\||"
91 syn match cshOperator contained "&&\|!\~\|!=\|<<\|<=\|==\|=\~\|>=\|>>\|\*\|\^\|\~\|||\|!\|%\|&\|+\|-\|/\|<\|>\||"
92 syn match cshOperator contained "[(){}]"
93 syn region cshTest matchgroup=cshStatement start="\<if\>\|\<while\>" skip="\\$" matchgroup=cshStatement end="\<then\>\|$" contains=cshComment,cshOperator,@cshQuoteList,@cshVarLIst
95 " Highlight special characters (those which have a backslash) differently
96 syn match cshSpecial contained "\\\d\d\d\|\\[abcfnrtv\\]"
97 syn match cshNumber "-\=\<\d\+\>"
99 " All other identifiers
100 "syn match cshIdentifier "\<[a-zA-Z._][a-zA-Z0-9._]*\>"
102 " Shell Input Redirection (Here Documents)
104 syn region cshHereDoc matchgroup=cshRedir start="<<-\=\s*\**END[a-zA-Z_0-9]*\**" matchgroup=cshRedir end="^END[a-zA-Z_0-9]*$"
105 syn region cshHereDoc matchgroup=cshRedir start="<<-\=\s*\**EOF\**" matchgroup=cshRedir end="^EOF$"
107 syn region cshHereDoc matchgroup=cshRedir start="<<-\=\s*\**\z(\h\w*\)\**" matchgroup=cshRedir end="^\z1$"
110 " Define the default highlighting.
111 " For version 5.7 and earlier: only when not done already
112 " For version 5.8 and later: only when an item doesn't have highlighting yet
113 if version >= 508 || !exists("did_csh_syntax_inits")
115 let did_csh_syntax_inits = 1
116 command -nargs=+ HiLink hi link <args>
118 command -nargs=+ HiLink hi def link <args>
121 HiLink cshArgv cshVariables
122 HiLink cshBckQuote cshCommand
123 HiLink cshDblQuote cshString
124 HiLink cshExtVar cshVariables
125 HiLink cshHereDoc cshString
126 HiLink cshNoEndlineBQ cshNoEndline
127 HiLink cshNoEndlineDQ cshNoEndline
128 HiLink cshNoEndlineSQ cshNoEndline
129 HiLink cshQtyWord cshVariables
130 HiLink cshRedir cshOperator
131 HiLink cshSelector cshVariables
132 HiLink cshSetStmt cshStatement
133 HiLink cshSetVariables cshVariables
134 HiLink cshSnglQuote cshString
135 HiLink cshSubst cshVariables
137 HiLink cshCommand Statement
138 HiLink cshComment Comment
139 HiLink cshConditional Conditional
140 HiLink cshIdentifier Error
141 HiLink cshModifier Special
142 HiLink cshNoEndline Error
143 HiLink cshNumber Number
144 HiLink cshOperator Operator
145 HiLink cshRedir Statement
146 HiLink cshRepeat Repeat
147 HiLink cshShellVariables Special
148 HiLink cshSpecial Special
149 HiLink cshStatement Statement
150 HiLink cshString String
151 HiLink cshSubstError Error
153 HiLink cshVariables Type
158 let b:current_syntax = "csh"