Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 1 | " Vim syntax file |
| 2 | " Language: C-shell (csh) |
Bram Moolenaar | e271909 | 2015-01-10 15:09:25 +0100 | [diff] [blame] | 3 | " Maintainer: Charles E. Campbell <NdrOchipS@PcampbellAfamily.Mbiz> |
Bram Moolenaar | e271909 | 2015-01-10 15:09:25 +0100 | [diff] [blame] | 4 | " Last Change: Oct 23, 2014 |
Bram Moolenaar | 83d1b19 | 2015-04-13 14:22:40 +0200 | [diff] [blame] | 5 | " Version: 11 |
Bram Moolenaar | e271909 | 2015-01-10 15:09:25 +0100 | [diff] [blame] | 6 | " URL: http://www.drchip.org/astronaut/vim/index.html#SYNTAX_CSH |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 7 | |
Bram Moolenaar | 89bcfda | 2016-08-30 23:26:57 +0200 | [diff] [blame] | 8 | " quit when a syntax file was already loaded |
| 9 | if exists("b:current_syntax") |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 10 | finish |
| 11 | endif |
| 12 | |
| 13 | " clusters: |
| 14 | syn cluster cshQuoteList contains=cshDblQuote,cshSnglQuote,cshBckQuote |
| 15 | syn cluster cshVarList contains=cshExtVar,cshSelector,cshQtyWord,cshArgv,cshSubst |
| 16 | |
| 17 | " Variables which affect the csh itself |
| 18 | syn match cshSetVariables contained "argv\|histchars\|ignoreeof\|noglob\|prompt\|status" |
| 19 | syn match cshSetVariables contained "cdpath\|history\|mail\|nonomatch\|savehist\|time" |
| 20 | syn match cshSetVariables contained "cwd\|home\|noclobber\|path\|shell\|verbose" |
| 21 | syn match cshSetVariables contained "echo" |
| 22 | |
| 23 | syn case ignore |
| 24 | syn keyword cshTodo contained todo |
| 25 | syn case match |
| 26 | |
| 27 | " Variable Name Expansion Modifiers |
| 28 | syn match cshModifier contained ":\(h\|t\|r\|q\|x\|gh\|gt\|gr\)" |
| 29 | |
| 30 | " Strings and Comments |
| 31 | syn match cshNoEndlineDQ contained "[^\"]\(\\\\\)*$" |
| 32 | syn match cshNoEndlineSQ contained "[^\']\(\\\\\)*$" |
| 33 | syn match cshNoEndlineBQ contained "[^\`]\(\\\\\)*$" |
| 34 | |
Bram Moolenaar | 9964e46 | 2007-05-05 17:54:07 +0000 | [diff] [blame] | 35 | syn region cshDblQuote start=+[^\\]"+lc=1 skip=+\\\\\|\\"+ end=+"+ contains=cshSpecial,cshShellVariables,cshExtVar,cshSelector,cshQtyWord,cshArgv,cshSubst,cshNoEndlineDQ,cshBckQuote,@Spell |
| 36 | syn region cshSnglQuote start=+[^\\]'+lc=1 skip=+\\\\\|\\'+ end=+'+ contains=cshNoEndlineSQ,@Spell |
| 37 | syn region cshBckQuote start=+[^\\]`+lc=1 skip=+\\\\\|\\`+ end=+`+ contains=cshNoEndlineBQ,@Spell |
| 38 | syn region cshDblQuote start=+^"+ skip=+\\\\\|\\"+ end=+"+ contains=cshSpecial,cshExtVar,cshSelector,cshQtyWord,cshArgv,cshSubst,cshNoEndlineDQ,@Spell |
| 39 | syn region cshSnglQuote start=+^'+ skip=+\\\\\|\\'+ end=+'+ contains=cshNoEndlineSQ,@Spell |
| 40 | syn region cshBckQuote start=+^`+ skip=+\\\\\|\\`+ end=+`+ contains=cshNoEndlineBQ,@Spell |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 41 | syn cluster cshCommentGroup contains=cshTodo,@Spell |
| 42 | syn match cshComment "#.*$" contains=@cshCommentGroup |
| 43 | |
| 44 | " A bunch of useful csh keywords |
| 45 | syn keyword cshStatement alias end history onintr setenv unalias |
| 46 | syn keyword cshStatement cd eval kill popd shift unhash |
| 47 | syn keyword cshStatement chdir exec login pushd source |
| 48 | syn keyword cshStatement continue exit logout rehash time unsetenv |
| 49 | syn keyword cshStatement dirs glob nice repeat umask wait |
| 50 | syn keyword cshStatement echo goto nohup |
| 51 | |
| 52 | syn keyword cshConditional break case else endsw switch |
| 53 | syn keyword cshConditional breaksw default endif |
| 54 | syn keyword cshRepeat foreach |
| 55 | |
| 56 | " Special environment variables |
| 57 | syn keyword cshShellVariables HOME LOGNAME PATH TERM USER |
| 58 | |
| 59 | " Modifiable Variables without {} |
| 60 | syn match cshExtVar "\$[a-zA-Z_][a-zA-Z0-9_]*\(:h\|:t\|:r\|:q\|:x\|:gh\|:gt\|:gr\)\=" contains=cshModifier |
| 61 | syn match cshSelector "\$[a-zA-Z_][a-zA-Z0-9_]*\[[a-zA-Z_]\+\]\(:h\|:t\|:r\|:q\|:x\|:gh\|:gt\|:gr\)\=" contains=cshModifier |
| 62 | syn match cshQtyWord "\$#[a-zA-Z_][a-zA-Z0-9_]*\(:h\|:t\|:r\|:q\|:x\|:gh\|:gt\|:gr\)\=" contains=cshModifier |
| 63 | syn match cshArgv "\$\d\+\(:h\|:t\|:r\|:q\|:x\|:gh\|:gt\|:gr\)\=" contains=cshModifier |
| 64 | syn match cshArgv "\$\*\(:h\|:t\|:r\|:q\|:x\|:gh\|:gt\|:gr\)\=" contains=cshModifier |
| 65 | |
| 66 | " Modifiable Variables with {} |
| 67 | syn match cshExtVar "\${[a-zA-Z_][a-zA-Z0-9_]*\(:h\|:t\|:r\|:q\|:x\|:gh\|:gt\|:gr\)\=}" contains=cshModifier |
| 68 | syn match cshSelector "\${[a-zA-Z_][a-zA-Z0-9_]*\[[a-zA-Z_]\+\]\(:h\|:t\|:r\|:q\|:x\|:gh\|:gt\|:gr\)\=}" contains=cshModifier |
| 69 | syn match cshQtyWord "\${#[a-zA-Z_][a-zA-Z0-9_]*\(:h\|:t\|:r\|:q\|:x\|:gh\|:gt\|:gr\)\=}" contains=cshModifier |
| 70 | syn match cshArgv "\${\d\+\(:h\|:t\|:r\|:q\|:x\|:gh\|:gt\|:gr\)\=}" contains=cshModifier |
| 71 | |
| 72 | " UnModifiable Substitutions |
| 73 | syn match cshSubstError "\$?[a-zA-Z_][a-zA-Z0-9_]*:\(h\|t\|r\|q\|x\|gh\|gt\|gr\)" |
| 74 | syn match cshSubstError "\${?[a-zA-Z_][a-zA-Z0-9_]*:\(h\|t\|r\|q\|x\|gh\|gt\|gr\)}" |
| 75 | syn match cshSubstError "\$?[0$<]:\(h\|t\|r\|q\|x\|gh\|gt\|gr\)" |
| 76 | syn match cshSubst "\$?[a-zA-Z_][a-zA-Z0-9_]*" |
| 77 | syn match cshSubst "\${?[a-zA-Z_][a-zA-Z0-9_]*}" |
| 78 | syn match cshSubst "\$?[0$<]" |
| 79 | |
| 80 | " I/O redirection |
| 81 | syn match cshRedir ">>&!\|>&!\|>>&\|>>!\|>&\|>!\|>>\|<<\|>\|<" |
| 82 | |
| 83 | " Handle set expressions |
| 84 | syn 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 "&&\|!\~\|!=\|<<\|<=\|==\|=\~\|>=\|>>\|\*\|\^\|\~\|||\|!\|\|%\|&\|+\|-\|/\|<\|>\||" |
| 88 | syn match cshOperator contained "&&\|!\~\|!=\|<<\|<=\|==\|=\~\|>=\|>>\|\*\|\^\|\~\|||\|!\|%\|&\|+\|-\|/\|<\|>\||" |
| 89 | syn match cshOperator contained "[(){}]" |
| 90 | syn 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 |
| 93 | syn match cshSpecial contained "\\\d\d\d\|\\[abcfnrtv\\]" |
| 94 | syn 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 Moolenaar | 89bcfda | 2016-08-30 23:26:57 +0200 | [diff] [blame] | 100 | 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] | 101 | |
| 102 | " Define the default highlighting. |
Bram Moolenaar | 89bcfda | 2016-08-30 23:26:57 +0200 | [diff] [blame] | 103 | " Only when an item doesn't have highlighting yet |
| 104 | command -nargs=+ HiLink hi def link <args> |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 105 | |
Bram Moolenaar | 89bcfda | 2016-08-30 23:26:57 +0200 | [diff] [blame] | 106 | HiLink cshArgv cshVariables |
| 107 | HiLink cshBckQuote cshCommand |
| 108 | HiLink cshDblQuote cshString |
| 109 | HiLink cshExtVar cshVariables |
| 110 | HiLink cshHereDoc cshString |
| 111 | HiLink cshNoEndlineBQ cshNoEndline |
| 112 | HiLink cshNoEndlineDQ cshNoEndline |
| 113 | HiLink cshNoEndlineSQ cshNoEndline |
| 114 | HiLink cshQtyWord cshVariables |
| 115 | HiLink cshRedir cshOperator |
| 116 | HiLink cshSelector cshVariables |
| 117 | HiLink cshSetStmt cshStatement |
| 118 | HiLink cshSetVariables cshVariables |
| 119 | HiLink cshSnglQuote cshString |
| 120 | HiLink cshSubst cshVariables |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 121 | |
Bram Moolenaar | 89bcfda | 2016-08-30 23:26:57 +0200 | [diff] [blame] | 122 | HiLink cshCommand Statement |
| 123 | HiLink cshComment Comment |
| 124 | HiLink cshConditional Conditional |
| 125 | HiLink cshIdentifier Error |
| 126 | HiLink cshModifier Special |
| 127 | HiLink cshNoEndline Error |
| 128 | HiLink cshNumber Number |
| 129 | HiLink cshOperator Operator |
| 130 | HiLink cshRedir Statement |
| 131 | HiLink cshRepeat Repeat |
| 132 | HiLink cshShellVariables Special |
| 133 | HiLink cshSpecial Special |
| 134 | HiLink cshStatement Statement |
| 135 | HiLink cshString String |
| 136 | HiLink cshSubstError Error |
| 137 | HiLink cshTodo Todo |
| 138 | HiLink cshVariables Type |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 139 | |
Bram Moolenaar | 89bcfda | 2016-08-30 23:26:57 +0200 | [diff] [blame] | 140 | delcommand HiLink |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 141 | |
| 142 | let b:current_syntax = "csh" |
| 143 | |
| 144 | " vim: ts=18 |