blob: c134aa7ef399e42541913160a71df3a278438724 [file] [log] [blame]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001" Vim syntax file
2" Language: C-shell (csh)
Bram Moolenaare2719092015-01-10 15:09:25 +01003" Maintainer: Charles E. Campbell <NdrOchipS@PcampbellAfamily.Mbiz>
Bram Moolenaarf37506f2016-08-31 22:22:10 +02004" Last Change: Aug 31, 2016
5" Version: 13
Bram Moolenaare2719092015-01-10 15:09:25 +01006" URL: http://www.drchip.org/astronaut/vim/index.html#SYNTAX_CSH
Bram Moolenaar071d4272004-06-13 20:20:40 +00007
Bram Moolenaar89bcfda2016-08-30 23:26:57 +02008" quit when a syntax file was already loaded
9if exists("b:current_syntax")
Bram Moolenaar071d4272004-06-13 20:20:40 +000010 finish
11endif
12
13" clusters:
14syn cluster cshQuoteList contains=cshDblQuote,cshSnglQuote,cshBckQuote
15syn cluster cshVarList contains=cshExtVar,cshSelector,cshQtyWord,cshArgv,cshSubst
16
17" Variables which affect the csh itself
18syn match cshSetVariables contained "argv\|histchars\|ignoreeof\|noglob\|prompt\|status"
19syn match cshSetVariables contained "cdpath\|history\|mail\|nonomatch\|savehist\|time"
20syn match cshSetVariables contained "cwd\|home\|noclobber\|path\|shell\|verbose"
21syn match cshSetVariables contained "echo"
22
23syn case ignore
24syn keyword cshTodo contained todo
25syn case match
26
27" Variable Name Expansion Modifiers
28syn match cshModifier contained ":\(h\|t\|r\|q\|x\|gh\|gt\|gr\)"
29
30" Strings and Comments
31syn match cshNoEndlineDQ contained "[^\"]\(\\\\\)*$"
32syn match cshNoEndlineSQ contained "[^\']\(\\\\\)*$"
33syn match cshNoEndlineBQ contained "[^\`]\(\\\\\)*$"
34
Bram Moolenaar9964e462007-05-05 17:54:07 +000035syn region cshDblQuote start=+[^\\]"+lc=1 skip=+\\\\\|\\"+ end=+"+ contains=cshSpecial,cshShellVariables,cshExtVar,cshSelector,cshQtyWord,cshArgv,cshSubst,cshNoEndlineDQ,cshBckQuote,@Spell
36syn region cshSnglQuote start=+[^\\]'+lc=1 skip=+\\\\\|\\'+ end=+'+ contains=cshNoEndlineSQ,@Spell
37syn region cshBckQuote start=+[^\\]`+lc=1 skip=+\\\\\|\\`+ end=+`+ contains=cshNoEndlineBQ,@Spell
38syn region cshDblQuote start=+^"+ skip=+\\\\\|\\"+ end=+"+ contains=cshSpecial,cshExtVar,cshSelector,cshQtyWord,cshArgv,cshSubst,cshNoEndlineDQ,@Spell
39syn region cshSnglQuote start=+^'+ skip=+\\\\\|\\'+ end=+'+ contains=cshNoEndlineSQ,@Spell
40syn region cshBckQuote start=+^`+ skip=+\\\\\|\\`+ end=+`+ contains=cshNoEndlineBQ,@Spell
Bram Moolenaar071d4272004-06-13 20:20:40 +000041syn cluster cshCommentGroup contains=cshTodo,@Spell
42syn match cshComment "#.*$" contains=@cshCommentGroup
43
44" A bunch of useful csh keywords
45syn keyword cshStatement alias end history onintr setenv unalias
46syn keyword cshStatement cd eval kill popd shift unhash
47syn keyword cshStatement chdir exec login pushd source
48syn keyword cshStatement continue exit logout rehash time unsetenv
49syn keyword cshStatement dirs glob nice repeat umask wait
50syn keyword cshStatement echo goto nohup
51
52syn keyword cshConditional break case else endsw switch
53syn keyword cshConditional breaksw default endif
54syn keyword cshRepeat foreach
55
56" Special environment variables
57syn keyword cshShellVariables HOME LOGNAME PATH TERM USER
58
59" Modifiable Variables without {}
60syn match cshExtVar "\$[a-zA-Z_][a-zA-Z0-9_]*\(:h\|:t\|:r\|:q\|:x\|:gh\|:gt\|:gr\)\=" contains=cshModifier
61syn match cshSelector "\$[a-zA-Z_][a-zA-Z0-9_]*\[[a-zA-Z_]\+\]\(:h\|:t\|:r\|:q\|:x\|:gh\|:gt\|:gr\)\=" contains=cshModifier
62syn match cshQtyWord "\$#[a-zA-Z_][a-zA-Z0-9_]*\(:h\|:t\|:r\|:q\|:x\|:gh\|:gt\|:gr\)\=" contains=cshModifier
63syn match cshArgv "\$\d\+\(:h\|:t\|:r\|:q\|:x\|:gh\|:gt\|:gr\)\=" contains=cshModifier
64syn match cshArgv "\$\*\(:h\|:t\|:r\|:q\|:x\|:gh\|:gt\|:gr\)\=" contains=cshModifier
65
66" Modifiable Variables with {}
67syn match cshExtVar "\${[a-zA-Z_][a-zA-Z0-9_]*\(:h\|:t\|:r\|:q\|:x\|:gh\|:gt\|:gr\)\=}" contains=cshModifier
68syn match cshSelector "\${[a-zA-Z_][a-zA-Z0-9_]*\[[a-zA-Z_]\+\]\(:h\|:t\|:r\|:q\|:x\|:gh\|:gt\|:gr\)\=}" contains=cshModifier
69syn match cshQtyWord "\${#[a-zA-Z_][a-zA-Z0-9_]*\(:h\|:t\|:r\|:q\|:x\|:gh\|:gt\|:gr\)\=}" contains=cshModifier
70syn match cshArgv "\${\d\+\(:h\|:t\|:r\|:q\|:x\|:gh\|:gt\|:gr\)\=}" contains=cshModifier
71
72" UnModifiable Substitutions
73syn match cshSubstError "\$?[a-zA-Z_][a-zA-Z0-9_]*:\(h\|t\|r\|q\|x\|gh\|gt\|gr\)"
74syn match cshSubstError "\${?[a-zA-Z_][a-zA-Z0-9_]*:\(h\|t\|r\|q\|x\|gh\|gt\|gr\)}"
75syn match cshSubstError "\$?[0$<]:\(h\|t\|r\|q\|x\|gh\|gt\|gr\)"
76syn match cshSubst "\$?[a-zA-Z_][a-zA-Z0-9_]*"
77syn match cshSubst "\${?[a-zA-Z_][a-zA-Z0-9_]*}"
78syn match cshSubst "\$?[0$<]"
79
80" I/O redirection
81syn match cshRedir ">>&!\|>&!\|>>&\|>>!\|>&\|>!\|>>\|<<\|>\|<"
82
83" Handle set expressions
84syn region cshSetExpr matchgroup=cshSetStmt start="\<set\>\|\<unset\>" end="$\|;" contains=cshComment,cshSetStmt,cshSetVariables,@cshQuoteList
85
86" Operators and Expression-Using constructs
87"syn match cshOperator contained "&&\|!\~\|!=\|<<\|<=\|==\|=\~\|>=\|>>\|\*\|\^\|\~\|||\|!\|\|%\|&\|+\|-\|/\|<\|>\||"
88syn match cshOperator contained "&&\|!\~\|!=\|<<\|<=\|==\|=\~\|>=\|>>\|\*\|\^\|\~\|||\|!\|%\|&\|+\|-\|/\|<\|>\||"
89syn match cshOperator contained "[(){}]"
90syn region cshTest matchgroup=cshStatement start="\<if\>\|\<while\>" skip="\\$" matchgroup=cshStatement end="\<then\>\|$" contains=cshComment,cshOperator,@cshQuoteList,@cshVarLIst
91
92" Highlight special characters (those which have a backslash) differently
93syn match cshSpecial contained "\\\d\d\d\|\\[abcfnrtv\\]"
94syn match cshNumber "-\=\<\d\+\>"
95
96" All other identifiers
97"syn match cshIdentifier "\<[a-zA-Z._][a-zA-Z0-9._]*\>"
98
99" Shell Input Redirection (Here Documents)
Bram Moolenaar89bcfda2016-08-30 23:26:57 +0200100syn region cshHereDoc matchgroup=cshRedir start="<<-\=\s*\**\z(\h\w*\)\**" matchgroup=cshRedir end="^\z1$"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000101
102" Define the default highlighting.
Bram Moolenaarf37506f2016-08-31 22:22:10 +0200103if !exists("skip_csh_syntax_inits")
Bram Moolenaar071d4272004-06-13 20:20:40 +0000104
Bram Moolenaarf37506f2016-08-31 22:22:10 +0200105 hi def link cshArgv cshVariables
106 hi def link cshBckQuote cshCommand
107 hi def link cshDblQuote cshString
108 hi def link cshExtVar cshVariables
109 hi def link cshHereDoc cshString
110 hi def link cshNoEndlineBQ cshNoEndline
111 hi def link cshNoEndlineDQ cshNoEndline
112 hi def link cshNoEndlineSQ cshNoEndline
113 hi def link cshQtyWord cshVariables
114 hi def link cshRedir cshOperator
115 hi def link cshSelector cshVariables
116 hi def link cshSetStmt cshStatement
117 hi def link cshSetVariables cshVariables
118 hi def link cshSnglQuote cshString
119 hi def link cshSubst cshVariables
Bram Moolenaar071d4272004-06-13 20:20:40 +0000120
Bram Moolenaarf37506f2016-08-31 22:22:10 +0200121 hi def link cshCommand Statement
122 hi def link cshComment Comment
123 hi def link cshConditional Conditional
124 hi def link cshIdentifier Error
125 hi def link cshModifier Special
126 hi def link cshNoEndline Error
127 hi def link cshNumber Number
128 hi def link cshOperator Operator
129 hi def link cshRedir Statement
130 hi def link cshRepeat Repeat
131 hi def link cshShellVariables Special
132 hi def link cshSpecial Special
133 hi def link cshStatement Statement
134 hi def link cshString String
135 hi def link cshSubstError Error
136 hi def link cshTodo Todo
137 hi def link cshVariables Type
Bram Moolenaar071d4272004-06-13 20:20:40 +0000138
Bram Moolenaarf37506f2016-08-31 22:22:10 +0200139endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000140
141let b:current_syntax = "csh"
142
143" vim: ts=18