Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 1 | " Vim syntax file |
| 2 | " Language: C-shell (csh) |
Christian Brabandt | f9ca139 | 2024-02-19 20:37:11 +0100 | [diff] [blame] | 3 | " Maintainer: This runtime file is looking for a new maintainer. |
| 4 | " Former Maintainer: Charles E. Campbell |
Bram Moolenaar | f37506f | 2016-08-31 22:22:10 +0200 | [diff] [blame] | 5 | " Last Change: Aug 31, 2016 |
Bram Moolenaar | 1d9215b | 2020-01-25 13:27:42 +0100 | [diff] [blame] | 6 | " Version: 14 |
Christian Brabandt | f9ca139 | 2024-02-19 20:37:11 +0100 | [diff] [blame] | 7 | " Former URL: http://www.drchip.org/astronaut/vim/index.html#SYNTAX_CSH |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 8 | |
Bram Moolenaar | 89bcfda | 2016-08-30 23:26:57 +0200 | [diff] [blame] | 9 | " quit when a syntax file was already loaded |
| 10 | if exists("b:current_syntax") |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 11 | finish |
| 12 | endif |
| 13 | |
| 14 | " clusters: |
| 15 | syn cluster cshQuoteList contains=cshDblQuote,cshSnglQuote,cshBckQuote |
| 16 | syn cluster cshVarList contains=cshExtVar,cshSelector,cshQtyWord,cshArgv,cshSubst |
| 17 | |
| 18 | " Variables which affect the csh itself |
| 19 | syn match cshSetVariables contained "argv\|histchars\|ignoreeof\|noglob\|prompt\|status" |
| 20 | syn match cshSetVariables contained "cdpath\|history\|mail\|nonomatch\|savehist\|time" |
| 21 | syn match cshSetVariables contained "cwd\|home\|noclobber\|path\|shell\|verbose" |
| 22 | syn match cshSetVariables contained "echo" |
| 23 | |
| 24 | syn case ignore |
| 25 | syn keyword cshTodo contained todo |
| 26 | syn case match |
| 27 | |
| 28 | " Variable Name Expansion Modifiers |
| 29 | syn match cshModifier contained ":\(h\|t\|r\|q\|x\|gh\|gt\|gr\)" |
| 30 | |
| 31 | " Strings and Comments |
| 32 | syn match cshNoEndlineDQ contained "[^\"]\(\\\\\)*$" |
| 33 | syn match cshNoEndlineSQ contained "[^\']\(\\\\\)*$" |
| 34 | syn match cshNoEndlineBQ contained "[^\`]\(\\\\\)*$" |
| 35 | |
Bram Moolenaar | 9964e46 | 2007-05-05 17:54:07 +0000 | [diff] [blame] | 36 | syn region cshDblQuote start=+[^\\]"+lc=1 skip=+\\\\\|\\"+ end=+"+ contains=cshSpecial,cshShellVariables,cshExtVar,cshSelector,cshQtyWord,cshArgv,cshSubst,cshNoEndlineDQ,cshBckQuote,@Spell |
| 37 | syn region cshSnglQuote start=+[^\\]'+lc=1 skip=+\\\\\|\\'+ end=+'+ contains=cshNoEndlineSQ,@Spell |
| 38 | syn region cshBckQuote start=+[^\\]`+lc=1 skip=+\\\\\|\\`+ end=+`+ contains=cshNoEndlineBQ,@Spell |
| 39 | syn region cshDblQuote start=+^"+ skip=+\\\\\|\\"+ end=+"+ contains=cshSpecial,cshExtVar,cshSelector,cshQtyWord,cshArgv,cshSubst,cshNoEndlineDQ,@Spell |
| 40 | syn region cshSnglQuote start=+^'+ skip=+\\\\\|\\'+ end=+'+ contains=cshNoEndlineSQ,@Spell |
| 41 | syn region cshBckQuote start=+^`+ skip=+\\\\\|\\`+ end=+`+ contains=cshNoEndlineBQ,@Spell |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 42 | syn cluster cshCommentGroup contains=cshTodo,@Spell |
| 43 | syn match cshComment "#.*$" contains=@cshCommentGroup |
| 44 | |
| 45 | " A bunch of useful csh keywords |
| 46 | syn keyword cshStatement alias end history onintr setenv unalias |
| 47 | syn keyword cshStatement cd eval kill popd shift unhash |
| 48 | syn keyword cshStatement chdir exec login pushd source |
| 49 | syn keyword cshStatement continue exit logout rehash time unsetenv |
| 50 | syn keyword cshStatement dirs glob nice repeat umask wait |
| 51 | syn keyword cshStatement echo goto nohup |
| 52 | |
| 53 | syn keyword cshConditional break case else endsw switch |
| 54 | syn keyword cshConditional breaksw default endif |
| 55 | syn keyword cshRepeat foreach |
| 56 | |
| 57 | " Special environment variables |
| 58 | syn keyword cshShellVariables HOME LOGNAME PATH TERM USER |
| 59 | |
| 60 | " Modifiable Variables without {} |
| 61 | syn match cshExtVar "\$[a-zA-Z_][a-zA-Z0-9_]*\(:h\|:t\|:r\|:q\|:x\|:gh\|:gt\|:gr\)\=" contains=cshModifier |
| 62 | syn match cshSelector "\$[a-zA-Z_][a-zA-Z0-9_]*\[[a-zA-Z_]\+\]\(:h\|:t\|:r\|:q\|:x\|:gh\|:gt\|:gr\)\=" contains=cshModifier |
| 63 | syn match cshQtyWord "\$#[a-zA-Z_][a-zA-Z0-9_]*\(:h\|:t\|:r\|:q\|:x\|:gh\|:gt\|:gr\)\=" contains=cshModifier |
| 64 | syn match cshArgv "\$\d\+\(:h\|:t\|:r\|:q\|:x\|:gh\|:gt\|:gr\)\=" contains=cshModifier |
| 65 | syn match cshArgv "\$\*\(:h\|:t\|:r\|:q\|:x\|:gh\|:gt\|:gr\)\=" contains=cshModifier |
| 66 | |
| 67 | " Modifiable Variables with {} |
| 68 | syn match cshExtVar "\${[a-zA-Z_][a-zA-Z0-9_]*\(:h\|:t\|:r\|:q\|:x\|:gh\|:gt\|:gr\)\=}" contains=cshModifier |
| 69 | syn match cshSelector "\${[a-zA-Z_][a-zA-Z0-9_]*\[[a-zA-Z_]\+\]\(:h\|:t\|:r\|:q\|:x\|:gh\|:gt\|:gr\)\=}" contains=cshModifier |
| 70 | syn match cshQtyWord "\${#[a-zA-Z_][a-zA-Z0-9_]*\(:h\|:t\|:r\|:q\|:x\|:gh\|:gt\|:gr\)\=}" contains=cshModifier |
| 71 | syn match cshArgv "\${\d\+\(:h\|:t\|:r\|:q\|:x\|:gh\|:gt\|:gr\)\=}" contains=cshModifier |
| 72 | |
| 73 | " UnModifiable Substitutions |
| 74 | syn match cshSubstError "\$?[a-zA-Z_][a-zA-Z0-9_]*:\(h\|t\|r\|q\|x\|gh\|gt\|gr\)" |
| 75 | syn match cshSubstError "\${?[a-zA-Z_][a-zA-Z0-9_]*:\(h\|t\|r\|q\|x\|gh\|gt\|gr\)}" |
| 76 | syn match cshSubstError "\$?[0$<]:\(h\|t\|r\|q\|x\|gh\|gt\|gr\)" |
| 77 | syn match cshSubst "\$?[a-zA-Z_][a-zA-Z0-9_]*" |
| 78 | syn match cshSubst "\${?[a-zA-Z_][a-zA-Z0-9_]*}" |
| 79 | syn match cshSubst "\$?[0$<]" |
| 80 | |
| 81 | " I/O redirection |
| 82 | syn match cshRedir ">>&!\|>&!\|>>&\|>>!\|>&\|>!\|>>\|<<\|>\|<" |
| 83 | |
| 84 | " Handle set expressions |
| 85 | syn 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 "&&\|!\~\|!=\|<<\|<=\|==\|=\~\|>=\|>>\|\*\|\^\|\~\|||\|!\|\|%\|&\|+\|-\|/\|<\|>\||" |
| 89 | syn match cshOperator contained "&&\|!\~\|!=\|<<\|<=\|==\|=\~\|>=\|>>\|\*\|\^\|\~\|||\|!\|%\|&\|+\|-\|/\|<\|>\||" |
| 90 | syn match cshOperator contained "[(){}]" |
| 91 | syn 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 |
| 94 | syn match cshSpecial contained "\\\d\d\d\|\\[abcfnrtv\\]" |
| 95 | syn 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 Moolenaar | 89bcfda | 2016-08-30 23:26:57 +0200 | [diff] [blame] | 101 | syn region cshHereDoc matchgroup=cshRedir start="<<-\=\s*\**\z(\h\w*\)\**" matchgroup=cshRedir end="^\z1$" |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 102 | |
| 103 | " Define the default highlighting. |
Bram Moolenaar | f37506f | 2016-08-31 22:22:10 +0200 | [diff] [blame] | 104 | if !exists("skip_csh_syntax_inits") |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 105 | |
Bram Moolenaar | f37506f | 2016-08-31 22:22:10 +0200 | [diff] [blame] | 106 | 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 Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 121 | |
Bram Moolenaar | f37506f | 2016-08-31 22:22:10 +0200 | [diff] [blame] | 122 | 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 Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 139 | |
Bram Moolenaar | f37506f | 2016-08-31 22:22:10 +0200 | [diff] [blame] | 140 | endif |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 141 | |
| 142 | let b:current_syntax = "csh" |
| 143 | |
| 144 | " vim: ts=18 |