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