7
|
1 " Vim syntax file
|
|
2 " Language: C-shell (csh)
|
|
3 " Maintainer: Dr. Charles E. Campbell, Jr. <NdrOchipS@PcampbellAfamily.Mbiz>
|
1121
|
4 " Version: 10
|
|
5 " Last Change: Sep 11, 2006
|
507
|
6 " URL: http://mysite.verizon.net/astronaut/vim/index.html#vimlinks_syntax
|
7
|
7
|
|
8 " For version 5.x: Clear all syntax items
|
|
9 " For version 6.x: Quit when a syntax file was already loaded
|
|
10 if version < 600
|
|
11 syntax clear
|
|
12 elseif exists("b:current_syntax")
|
|
13 finish
|
|
14 endif
|
|
15
|
|
16 " clusters:
|
|
17 syn cluster cshQuoteList contains=cshDblQuote,cshSnglQuote,cshBckQuote
|
|
18 syn cluster cshVarList contains=cshExtVar,cshSelector,cshQtyWord,cshArgv,cshSubst
|
|
19
|
|
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"
|
|
25
|
|
26 syn case ignore
|
|
27 syn keyword cshTodo contained todo
|
|
28 syn case match
|
|
29
|
|
30 " Variable Name Expansion Modifiers
|
|
31 syn match cshModifier contained ":\(h\|t\|r\|q\|x\|gh\|gt\|gr\)"
|
|
32
|
|
33 " Strings and Comments
|
|
34 syn match cshNoEndlineDQ contained "[^\"]\(\\\\\)*$"
|
|
35 syn match cshNoEndlineSQ contained "[^\']\(\\\\\)*$"
|
|
36 syn match cshNoEndlineBQ contained "[^\`]\(\\\\\)*$"
|
|
37
|
1121
|
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
|
7
|
44 syn cluster cshCommentGroup contains=cshTodo,@Spell
|
|
45 syn match cshComment "#.*$" contains=@cshCommentGroup
|
|
46
|
|
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
|
|
54
|
|
55 syn keyword cshConditional break case else endsw switch
|
|
56 syn keyword cshConditional breaksw default endif
|
|
57 syn keyword cshRepeat foreach
|
|
58
|
|
59 " Special environment variables
|
|
60 syn keyword cshShellVariables HOME LOGNAME PATH TERM USER
|
|
61
|
|
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
|
|
68
|
|
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
|
|
74
|
|
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$<]"
|
|
82
|
|
83 " I/O redirection
|
|
84 syn match cshRedir ">>&!\|>&!\|>>&\|>>!\|>&\|>!\|>>\|<<\|>\|<"
|
|
85
|
|
86 " Handle set expressions
|
|
87 syn region cshSetExpr matchgroup=cshSetStmt start="\<set\>\|\<unset\>" end="$\|;" contains=cshComment,cshSetStmt,cshSetVariables,@cshQuoteList
|
|
88
|
|
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
|
|
94
|
|
95 " Highlight special characters (those which have a backslash) differently
|
|
96 syn match cshSpecial contained "\\\d\d\d\|\\[abcfnrtv\\]"
|
|
97 syn match cshNumber "-\=\<\d\+\>"
|
|
98
|
|
99 " All other identifiers
|
|
100 "syn match cshIdentifier "\<[a-zA-Z._][a-zA-Z0-9._]*\>"
|
|
101
|
|
102 " Shell Input Redirection (Here Documents)
|
|
103 if version < 600
|
|
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$"
|
|
106 else
|
|
107 syn region cshHereDoc matchgroup=cshRedir start="<<-\=\s*\**\z(\h\w*\)\**" matchgroup=cshRedir end="^\z1$"
|
|
108 endif
|
|
109
|
|
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")
|
|
114 if version < 508
|
|
115 let did_csh_syntax_inits = 1
|
|
116 command -nargs=+ HiLink hi link <args>
|
|
117 else
|
|
118 command -nargs=+ HiLink hi def link <args>
|
|
119 endif
|
|
120
|
|
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
|
|
136
|
|
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
|
|
152 HiLink cshTodo Todo
|
|
153 HiLink cshVariables Type
|
|
154
|
|
155 delcommand HiLink
|
|
156 endif
|
|
157
|
|
158 let b:current_syntax = "csh"
|
|
159
|
|
160 " vim: ts=18
|