neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

csh.vim (6403B)


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