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