Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
tcsh.vim257 linesDownload Raw Back to syntax
1" Vim syntax file2" Language:		tcsh scripts3" Maintainer:		Doug Kearns <dougkearns@gmail.com>4" Previous Maintainer:	Gautam Iyer <gi1242+vim@NoSpam.com> where NoSpam=gmail (Original Author)5" Last Change:		2026 Jan 166 7" Description: We break up each statement into a "command" and an "end" part.8" All groups are either a "command" or part of the "end" of a statement (ie9" everything after the "command"). This is because blindly highlighting tcsh10" statements as keywords caused way too many false positives. Eg:11"12" 	set history=20013"14" causes history to come up as a keyword, which we want to avoid.15 16" Quit when a syntax file was already loaded17if exists('b:current_syntax')18  finish19endif20 21let s:oldcpo = &cpo22set cpo&vim " Line continuation is used23 24syn iskeyword @,48-57,_,192-255,-25 26syn case match27 28" ----- Clusters ----- {{{129syn cluster tcshModifiers	contains=tcshModifier,tcshModifierError30syn cluster tcshQuoteList	contains=tcshDQuote,tcshSQuote,tcshBQuote31syn cluster tcshStatementEnds	contains=@tcshQuoteList,tcshComment,@tcshVarList,tcshRedir,tcshMeta,tcshHereDoc,tcshSpecial,tcshArgument32syn cluster tcshStatements	contains=tcshBuiltin,tcshCommands,tcshIf,tcshWhile33syn cluster tcshVarList		contains=tcshUsrVar,tcshArgv,tcshSubst34syn cluster tcshConditions	contains=tcshCmdSubst,tcshParenExpr,tcshOperator,tcshNumber,@tcshVarList35 36" ----- Errors ----- {{{137" Define first, so can be easily overridden.38syn match tcshError contained '\v\S.+'39 40" ----- Statements ----- {{{141" Tcsh commands: Any filename / modifiable variable (must be first!)42syn match tcshCommands	'\v[a-zA-Z0-9\\./_$:-]+' contains=tcshSpecial,tcshUsrVar,tcshArgv,tcshVarError nextgroup=tcshStatementEnd43 44" Builtin commands except those treated specially. Currently (un)set(env),45" (un)alias, if, while, else, bindkey46syn keyword tcshBuiltin nextgroup=tcshStatementEnd alloc bg break breaksw builtins bye case cd chdir complete continue default dirs echo echotc end endif endsw eval exec exit fg filetest foreach getspath getxvers glob goto hashstat history hup inlib jobs kill limit log login logout ls ls-F migrate newgrp nice nohup notify onintr popd printenv pushd rehash repeat rootnode sched setpath setspath settc setty setxvers shift source stop suspend switch telltc termname time umask uncomplete unhash universe unlimit ver wait warp watchlog where which47 48" StatementEnd is anything after a built-in / command till the lexical end of a49" statement (;, |, ||, |&, && or end of line)50syn region tcshStatementEnd	transparent contained matchgroup=tcshBuiltin start='' end='\v\\@<!(;|\|[|&]?|\&\&|$)' contains=@tcshStatementEnds51 52" set expressions (Contains shell variables)53syn keyword tcshShellVar contained addsuffix afsuser ampm anyerror argv autocorrect autoexpand autolist autologout autorehash backslash_quote catalog cdpath cdtohome color colorcat command compat_expr complete continue continue_args correct csubstnonl cwd dextract dirsfile dirstack dspmbyte dunique echo echo_style edit editors ellipsis euid euser fignore filec gid globdot globstar group highlight histchars histdup histfile histlit history home ignoreeof implicitcd inputmode killdup killring listflags listjobs listlinks listmax listmaxrows loginsh logout mail matchbeep nobeep noclobber noding noglob nokanji nonomatch nostat notify oid owd padhour parseoctal path printexitvalue prompt prompt2 prompt3 promptchars pushdtohome pushdsilent recexact recognize_only_executables rmstar rprompt savedirs savehist sched shell shlvl status symlinks tcsh term time tperiod tty uid user verbose version vimode visiblebell watch who wordchars54syn keyword tcshBuiltin	nextgroup=tcshSetEnd set unset55syn region  tcshSetEnd	contained transparent matchgroup=tcshBuiltin start='' skip='\\$' end='$\|;' contains=tcshShellVar,@tcshStatementEnds56 57" setenv expressions (Contains environment variables)58syn keyword tcshEnvVar contained AFSUSER COLUMNS DISPLAY EDITOR GROUP HOME HOST HOSTTYPE HPATH LANG LC_CTYPE LINES LS_COLORS MACHTYPE NOREBIND OSTYPE PATH PWD REMOTEHOST SHLVL SYSTYPE TERM TERMCAP USER VENDOR VISUAL59syn keyword tcshBuiltin	nextgroup=tcshEnvEnd setenv unsetenv60syn region  tcshEnvEnd	contained transparent matchgroup=tcshBuiltin start='' skip='\\$' end='$\|;' contains=tcshEnvVar,@tcshStatementEnds61 62" alias and unalias (contains special aliases)63syn keyword tcshAliases contained beepcmd cwdcmd jobcmd helpcommand periodic precmd postcmd shell64syn keyword tcshBuiltin	nextgroup=tcshAliCmd skipwhite alias unalias65syn match   tcshAliCmd	contained nextgroup=tcshAliEnd skipwhite '\v(\w|-)+' contains=tcshAliases66syn region  tcshAliEnd	contained transparent matchgroup=tcshBuiltin start='' skip='\\$' end='$\|;' contains=@tcshStatementEnds67 68" if statements69syn keyword tcshIf	nextgroup=tcshIfEnd skipwhite if70syn region  tcshIfEnd	contained start='\S' skip='\\$' matchgroup=tcshBuiltin end='\v<then>|$' contains=@tcshConditions,tcshSpecial,@tcshStatementEnds71syn region  tcshIfEnd	contained matchgroup=tcshBuiltin contains=@tcshConditions,tcshSpecial start='(' end='\v\)%(\s+then>)?' skipwhite nextgroup=@tcshStatementEnds 72syn region  tcshIfEnd	contained matchgroup=tcshBuiltin contains=tcshCommands,tcshSpecial start='\v\{\s+' end='\v\s+\}%(\s+then>)?' skipwhite nextgroup=@tcshStatementEnds keepend73 74" else statements75syn keyword tcshBuiltin	nextgroup=tcshIf skipwhite else76 77" while statements (contains expressions / operators)78syn keyword tcshBuiltin	nextgroup=@tcshConditions,tcshSpecial skipwhite while79 80" Conditions (for if and while)81syn region tcshParenExpr contained contains=@tcshConditions,tcshSpecial matchgroup=tcshBuiltin start='(' end=')'82syn region tcshCmdSubst  contained contains=tcshCommands matchgroup=tcshBuiltin start='\v\{\s+' end='\v\s+\}' keepend83 84" Bindkey. Internal editor functions85syn keyword tcshBindkeyFuncs contained backward-char backward-delete-char86	    \ backward-delete-word backward-kill-line backward-word87	    \ beginning-of-line capitalize-word change-case88	    \ change-till-end-of-line clear-screen complete-word89	    \ complete-word-fwd complete-word-back complete-word-raw90	    \ copy-prev-word copy-region-as-kill dabbrev-expand delete-char91	    \ delete-char-or-eof delete-char-or-list92	    \ delete-char-or-list-or-eof delete-word digit digit-argument93	    \ down-history downcase-word end-of-file end-of-line94	    \ exchange-point-and-mark expand-glob expand-history expand-line95	    \ expand-variables forward-char forward-word96	    \ gosmacs-transpose-chars history-search-backward97	    \ history-search-forward insert-last-word i-search-fwd98	    \ i-search-back keyboard-quit kill-line kill-region99	    \ kill-whole-line list-choices list-choices-raw list-glob100	    \ list-or-eof load-average magic-space newline newline-and-hold101	    \ newline-and-down-history normalize-path normalize-command102	    \ overwrite-mode prefix-meta quoted-insert redisplay103	    \ run-fg-editor run-help self-insert-command sequence-lead-in104	    \ set-mark-command spell-word spell-line stuff-char105	    \ toggle-literal-history transpose-chars transpose-gosling106	    \ tty-dsusp tty-flush-output tty-sigintr tty-sigquit tty-sigtsusp107	    \ tty-start-output tty-stop-output undefined-key108	    \ universal-argument up-history upcase-word109	    \ vi-beginning-of-next-word vi-add vi-add-at-eol vi-chg-case110	    \ vi-chg-meta vi-chg-to-eol vi-cmd-mode vi-cmd-mode-complete111	    \ vi-delprev vi-delmeta vi-endword vi-eword vi-char-back112	    \ vi-char-fwd vi-charto-back vi-charto-fwd vi-insert113	    \ vi-insert-at-bol vi-repeat-char-fwd vi-repeat-char-back114	    \ vi-repeat-search-fwd vi-repeat-search-back vi-replace-char115	    \ vi-replace-mode vi-search-back vi-search-fwd vi-substitute-char116	    \ vi-substitute-line vi-word-back vi-word-fwd vi-undo vi-zero117	    \ which-command yank yank-pop e_copy_to_clipboard118	    \ e_paste_from_clipboard e_dosify_next e_dosify_prev e_page_up119	    \ e_page_down120syn keyword tcshBuiltin nextgroup=tcshBindkeyEnd bindkey121syn region tcshBindkeyEnd contained transparent matchgroup=tcshBuiltin start='' skip='\\$' end='$' contains=@tcshQuoteList,tcshComment,@tcshVarList,tcshMeta,tcshSpecial,tcshArgument,tcshBindkeyFuncs122 123" Expressions start with @.124syn match tcshExprStart '\v\@\s+' nextgroup=tcshExprVar125syn match tcshExprVar	contained '\v\h\w*%(\[\d+\])?' contains=tcshShellVar,tcshEnvVar nextgroup=tcshExprOp126syn match tcshExprOp	contained '++\|--'127syn match tcshExprOp	contained '\v\s*\=' nextgroup=tcshExprEnd128syn match tcshExprEnd	contained '\v.*$'hs=e+1 contains=@tcshConditions129syn match tcshExprEnd	contained '\v.{-};'hs=e	contains=@tcshConditions130 131" ----- Comments: ----- {{{1132syn match tcshSharpBang '\%^#!.*$'133syn match tcshComment	'#.*' contains=tcshTodo,@Spell134syn match tcshTodo	contained '\v%(^\s*#\s*)@<=\c<%(TODO|FIXME|XXX)>'135 136" TODO: leading whitespace match is needed to prevent keyword matching137syn match tcshLabel     '^\s*\w\+:\ze\s*$'138 139" ----- Strings ----- {{{1140" Tcsh does not allow \" in strings unless the "backslash_quote" shell141" variable is set. Set the vim variable "tcsh_backslash_quote" to 0 if you142" want VIM to assume that no backslash quote constructs exist.143 144" Backquotes are treated as commands, and are not contained in anything145if get(g:, 'tcsh_backslash_quote', 1)146    syn region tcshSQuote	contained start="'" skip="\v\\\\|\\'" end="'"147    syn region tcshDQuote	contained start='"' end='"' contains=@tcshVarList,tcshSpecial,@Spell148    syn region tcshBQuote	keepend matchgroup=tcshBQuoteGrp start='`' skip='\v\\\\|\\`' end='`' contains=@tcshStatements149else150    syn region tcshSQuote	keepend contained start="'" end="'"151    syn region tcshDQuote	keepend contained start='"' end='"' contains=@tcshVarList,tcshSpecial,@Spell152    syn region tcshBQuote	keepend start='`' end='`' contains=@tcshStatements153endif154 155" ----- Variables ----- {{{1156" Variable Errors. Must come first! \$ constructs will be flagged by157" tcshSpecial, so we don't consider them here.158syn match tcshVarError	'\v\$\S*'	contained159 160" Modifiable Variables without {}.161syn match tcshUsrVar contained '\v\$\h\w*%(\[\d+%(-\d+)?\])?' nextgroup=@tcshModifiers contains=tcshShellVar,tcshEnvVar162syn match tcshArgv   contained '\v\$%(\d+|\*)' nextgroup=@tcshModifiers163 164" Modifiable Variables with {}.165syn match tcshUsrVar contained '\v\$\{\h\w*%(\[\d+%(-\d+)?\])?%(:\S*)?\}' contains=@tcshModifiers,tcshShellVar,tcshEnvVar166syn match tcshArgv   contained '\v\$\{%(\d+|\*)%(:\S*)?\}' contains=@tcshModifiers167 168" Un-modifiable Substitutions. Order is important here.169syn match tcshSubst contained	'\v\$[?#$!_<]' nextgroup=tcshModifierError170syn match tcshSubst contained	'\v\$[%#?]%(\h\w*|\d+)' nextgroup=tcshModifierError contains=tcshShellVar,tcshEnvVar171syn match tcshSubst contained	'\v\$\{[%#?]%(\h\w*|\d+)%(:\S*)?\}' contains=tcshModifierError contains=tcshShellVar,tcshEnvVar172 173" Variable Name Expansion Modifiers (order important)174syn match tcshModifierError	contained '\v:\S*'175syn match tcshModifier		contained '\v:[ag]?[htreuls&qx]' nextgroup=@tcshModifiers176 177" ----- Operators / Specials ----- {{{1178" Standard redirects (except <<) [<, >, >>, >>&, >>!, >>&!]179syn match tcshRedir contained	'\v\<|\>\>?\&?!?'180 181" Meta-chars182syn match tcshMeta  contained	'\v[]{}*?[]'183 184" Here documents (<<)185syn region tcshHereDoc contained matchgroup=tcshShellVar start='\v\<\<\s*\z(\h\w*)' end='^\z1$' contains=@tcshVarList,tcshSpecial fold186syn region tcshHereDoc contained matchgroup=tcshShellVar start="\v\<\<\s*'\z(\h\w*)'" start='\v\<\<\s*"\z(\h\w*)"$' start='\v\<\<\s*\\\z(\h\w*)$' end='^\z1$' fold187 188" Operators189syn match tcshOperator	contained '&&\|!\~\|!=\|<<\|<=\|==\|=\~\|>=\|>>\|\*\|\^\|\~\|||\|!\|%\|&\|+\|-\|/\|<\|>\||'190"syn match tcshOperator	contained '[(){}]'191 192" Numbers193syn match tcshNumber	contained '\v<-?\d+>'194 195" Arguments196syn match tcshArgument	contained '\v\s@<=-(\w|-)*'197 198" Special characters. \xxx, or backslashed characters.199"syn match tcshSpecial	contained '\v\\@<!\\(\d{3}|.)'200syn match tcshSpecial	contained '\v\\%([0-7]{3}|.)'201 202" ----- Synchronising ----- {{{1203if exists('tcsh_minlines')204    if tcsh_minlines == 'fromstart'205	syn sync fromstart206    else207	exec 'syn sync minlines=' . tcsh_minlines208    endif209else210    syn sync minlines=100	" Some completions can be quite long211endif212 213" ----- Highlighting ----- {{{1214" Define highlighting of syntax groups215hi def link tcshError		Error216hi def link tcshBuiltin		Statement217hi def link tcshShellVar	Preproc218hi def link tcshEnvVar		tcshShellVar219hi def link tcshAliases		tcshShellVar220hi def link tcshAliCmd		Identifier221hi def link tcshCommands	Identifier222hi def link tcshIf		tcshBuiltin223hi def link tcshWhile		tcshBuiltin224hi def link tcshBindkeyFuncs	Function225hi def link tcshExprStart	tcshBuiltin226hi def link tcshExprVar		tcshUsrVar227hi def link tcshExprOp		tcshOperator228hi def link tcshExprEnd		tcshOperator229hi def link tcshComment		Comment230hi def link tcshSharpBang	PreProc231hi def link tcshTodo		Todo232hi def link tcshSQuote		String233hi def link tcshDQuote		tcshSQuote234hi def link tcshBQuoteGrp	Include235hi def link tcshVarError	Error236hi def link tcshUsrVar		Type237hi def link tcshArgv		tcshUsrVar238hi def link tcshSubst		tcshUsrVar239hi def link tcshModifier	tcshArgument240hi def link tcshModifierError	tcshVarError241hi def link tcshMeta		tcshSubst242hi def link tcshRedir		tcshOperator243hi def link tcshHereDoc		tcshSQuote244hi def link tcshOperator	Operator245hi def link tcshNumber		Number246hi def link tcshArgument	Special247hi def link tcshSpecial		SpecialChar248hi def link tcshLabel		Label249" }}}250 251let &cpo = s:oldcpo252unlet s:oldcpo253 254let b:current_syntax = 'tcsh'255 256" vim: nowrap sw=2 sts=2 ts=8 noet fdm=marker:257 
codekingpro/portable-devtools · Team Ai