1
0
Fork 0
mirror of https://github.com/vim/vim synced 2025-03-16 06:47:52 +01:00
vim/runtime/syntax/tcsh.vim

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

256 lines
13 KiB
VimL
Raw Permalink Normal View History

2021-10-16 15:23:36 +01:00
" Vim syntax file
" Language: tcsh scripts
" Maintainer: Doug Kearns <dougkearns@gmail.com>
" Previous Maintainer: Gautam Iyer <gi1242+vim@NoSpam.com> where NoSpam=gmail (Original Author)
" Last Change: 2021 Oct 15
2004-06-13 20:20:40 +00:00
" Description: We break up each statement into a "command" and an "end" part.
" All groups are either a "command" or part of the "end" of a statement (ie
" everything after the "command"). This is because blindly highlighting tcsh
" statements as keywords caused way too many false positives. Eg:
"
2006-03-17 23:10:44 +00:00
" set history=200
2004-06-13 20:20:40 +00:00
"
" causes history to come up as a keyword, which we want to avoid.
" Quit when a syntax file was already loaded
2008-06-24 20:39:31 +00:00
if exists('b:current_syntax')
2004-06-13 20:20:40 +00:00
finish
endif
2008-06-24 20:39:31 +00:00
let s:oldcpo = &cpo
set cpo&vim " Line continuation is used
2021-10-16 15:23:36 +01:00
syn iskeyword @,48-57,_,192-255,-
2008-06-24 20:39:31 +00:00
2004-06-13 20:20:40 +00:00
syn case match
2021-10-16 15:23:36 +01:00
" ----- Clusters ----- {{{1
2004-06-13 20:20:40 +00:00
syn cluster tcshModifiers contains=tcshModifier,tcshModifierError
syn cluster tcshQuoteList contains=tcshDQuote,tcshSQuote,tcshBQuote
2021-10-16 15:23:36 +01:00
syn cluster tcshStatementEnds contains=@tcshQuoteList,tcshComment,@tcshVarList,tcshRedir,tcshMeta,tcshHereDoc,tcshSpecial,tcshArgument
2008-06-24 20:39:31 +00:00
syn cluster tcshStatements contains=tcshBuiltin,tcshCommands,tcshIf,tcshWhile
2004-06-13 20:20:40 +00:00
syn cluster tcshVarList contains=tcshUsrVar,tcshArgv,tcshSubst
2008-06-24 20:39:31 +00:00
syn cluster tcshConditions contains=tcshCmdSubst,tcshParenExpr,tcshOperator,tcshNumber,@tcshVarList
2021-10-16 15:23:36 +01:00
" ----- Errors ----- {{{1
2008-06-24 20:39:31 +00:00
" Define first, so can be easily overridden.
syn match tcshError contained '\v\S.+'
2004-06-13 20:20:40 +00:00
2021-10-16 15:23:36 +01:00
" ----- Statements ----- {{{1
2004-06-13 20:20:40 +00:00
" Tcsh commands: Any filename / modifiable variable (must be first!)
syn match tcshCommands '\v[a-zA-Z0-9\\./_$:-]+' contains=tcshSpecial,tcshUsrVar,tcshArgv,tcshVarError nextgroup=tcshStatementEnd
2008-06-24 20:39:31 +00:00
" Builtin commands except those treated specially. Currently (un)set(env),
" (un)alias, if, while, else, bindkey
2021-10-16 15:23:36 +01:00
syn 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 which
2004-06-13 20:20:40 +00:00
2008-06-24 20:39:31 +00:00
" StatementEnd is anything after a built-in / command till the lexical end of a
2004-06-13 20:20:40 +00:00
" statement (;, |, ||, |&, && or end of line)
2008-06-24 20:39:31 +00:00
syn region tcshStatementEnd transparent contained matchgroup=tcshBuiltin start='' end='\v\\@<!(;|\|[|&]?|\&\&|$)' contains=@tcshStatementEnds
2004-06-13 20:20:40 +00:00
" set expressions (Contains shell variables)
2021-10-16 15:23:36 +01:00
syn 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 wordchars
2008-06-24 20:39:31 +00:00
syn keyword tcshBuiltin nextgroup=tcshSetEnd set unset
syn region tcshSetEnd contained transparent matchgroup=tcshBuiltin start='' skip='\\$' end='$\|;' contains=tcshShellVar,@tcshStatementEnds
2004-06-13 20:20:40 +00:00
2008-06-24 20:39:31 +00:00
" setenv expressions (Contains environment variables)
2004-06-13 20:20:40 +00:00
syn 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 VISUAL
2008-06-24 20:39:31 +00:00
syn keyword tcshBuiltin nextgroup=tcshEnvEnd setenv unsetenv
syn region tcshEnvEnd contained transparent matchgroup=tcshBuiltin start='' skip='\\$' end='$\|;' contains=tcshEnvVar,@tcshStatementEnds
2004-06-13 20:20:40 +00:00
" alias and unalias (contains special aliases)
2007-05-05 17:54:07 +00:00
syn keyword tcshAliases contained beepcmd cwdcmd jobcmd helpcommand periodic precmd postcmd shell
2008-06-24 20:39:31 +00:00
syn keyword tcshBuiltin nextgroup=tcshAliCmd skipwhite alias unalias
2010-01-06 20:54:52 +01:00
syn match tcshAliCmd contained nextgroup=tcshAliEnd skipwhite '\v(\w|-)+' contains=tcshAliases
2008-06-24 20:39:31 +00:00
syn region tcshAliEnd contained transparent matchgroup=tcshBuiltin start='' skip='\\$' end='$\|;' contains=@tcshStatementEnds
2004-06-13 20:20:40 +00:00
2008-06-24 20:39:31 +00:00
" if statements
syn keyword tcshIf nextgroup=tcshIfEnd skipwhite if
syn region tcshIfEnd contained start='\S' skip='\\$' matchgroup=tcshBuiltin end='\v<then>|$' contains=@tcshConditions,tcshSpecial,@tcshStatementEnds
syn region tcshIfEnd contained matchgroup=tcshBuiltin contains=@tcshConditions,tcshSpecial start='(' end='\v\)%(\s+then>)?' skipwhite nextgroup=@tcshStatementEnds
syn region tcshIfEnd contained matchgroup=tcshBuiltin contains=tcshCommands,tcshSpecial start='\v\{\s+' end='\v\s+\}%(\s+then>)?' skipwhite nextgroup=@tcshStatementEnds keepend
2004-06-13 20:20:40 +00:00
2008-06-24 20:39:31 +00:00
" else statements
syn keyword tcshBuiltin nextgroup=tcshIf skipwhite else
2004-06-13 20:20:40 +00:00
" while statements (contains expressions / operators)
2008-06-24 20:39:31 +00:00
syn keyword tcshBuiltin nextgroup=@tcshConditions,tcshSpecial skipwhite while
" Conditions (for if and while)
syn region tcshParenExpr contained contains=@tcshConditions,tcshSpecial matchgroup=tcshBuiltin start='(' end=')'
syn region tcshCmdSubst contained contains=tcshCommands matchgroup=tcshBuiltin start='\v\{\s+' end='\v\s+\}' keepend
" Bindkey. Internal editor functions
syn keyword tcshBindkeyFuncs contained backward-char backward-delete-char
\ backward-delete-word backward-kill-line backward-word
\ beginning-of-line capitalize-word change-case
\ change-till-end-of-line clear-screen complete-word
\ complete-word-fwd complete-word-back complete-word-raw
\ copy-prev-word copy-region-as-kill dabbrev-expand delete-char
\ delete-char-or-eof delete-char-or-list
\ delete-char-or-list-or-eof delete-word digit digit-argument
\ down-history downcase-word end-of-file end-of-line
\ exchange-point-and-mark expand-glob expand-history expand-line
\ expand-variables forward-char forward-word
\ gosmacs-transpose-chars history-search-backward
\ history-search-forward insert-last-word i-search-fwd
\ i-search-back keyboard-quit kill-line kill-region
\ kill-whole-line list-choices list-choices-raw list-glob
2021-10-16 15:23:36 +01:00
\ list-or-eof load-average magic-space newline newline-and-hold
\ newline-and-down-history normalize-path normalize-command
\ overwrite-mode prefix-meta quoted-insert redisplay
\ run-fg-editor run-help self-insert-command sequence-lead-in
\ set-mark-command spell-word spell-line stuff-char
\ toggle-literal-history transpose-chars transpose-gosling
\ tty-dsusp tty-flush-output tty-sigintr tty-sigquit tty-sigtsusp
\ tty-start-output tty-stop-output undefined-key
\ universal-argument up-history upcase-word
2008-06-24 20:39:31 +00:00
\ vi-beginning-of-next-word vi-add vi-add-at-eol vi-chg-case
\ vi-chg-meta vi-chg-to-eol vi-cmd-mode vi-cmd-mode-complete
\ vi-delprev vi-delmeta vi-endword vi-eword vi-char-back
\ vi-char-fwd vi-charto-back vi-charto-fwd vi-insert
\ vi-insert-at-bol vi-repeat-char-fwd vi-repeat-char-back
\ vi-repeat-search-fwd vi-repeat-search-back vi-replace-char
\ vi-replace-mode vi-search-back vi-search-fwd vi-substitute-char
\ vi-substitute-line vi-word-back vi-word-fwd vi-undo vi-zero
\ which-command yank yank-pop e_copy_to_clipboard
\ e_paste_from_clipboard e_dosify_next e_dosify_prev e_page_up
\ e_page_down
syn keyword tcshBuiltin nextgroup=tcshBindkeyEnd bindkey
2021-10-16 15:23:36 +01:00
syn region tcshBindkeyEnd contained transparent matchgroup=tcshBuiltin start='' skip='\\$' end='$' contains=@tcshQuoteList,tcshComment,@tcshVarList,tcshMeta,tcshSpecial,tcshArgument,tcshBindkeyFuncs
2004-06-13 20:20:40 +00:00
" Expressions start with @.
2008-06-24 20:39:31 +00:00
syn match tcshExprStart '\v\@\s+' nextgroup=tcshExprVar
syn match tcshExprVar contained '\v\h\w*%(\[\d+\])?' contains=tcshShellVar,tcshEnvVar nextgroup=tcshExprOp
syn match tcshExprOp contained '++\|--'
syn match tcshExprOp contained '\v\s*\=' nextgroup=tcshExprEnd
syn match tcshExprEnd contained '\v.*$'hs=e+1 contains=@tcshConditions
syn match tcshExprEnd contained '\v.{-};'hs=e contains=@tcshConditions
2004-06-13 20:20:40 +00:00
2021-10-16 15:23:36 +01:00
" ----- Comments: ----- {{{1
2007-05-05 17:54:07 +00:00
syn match tcshComment '#\s.*' contains=tcshTodo,tcshCommentTi,@Spell
syn match tcshComment '\v#($|\S.*)' contains=tcshTodo,tcshCommentTi
syn match tcshSharpBang '^#! .*$'
2004-06-13 20:20:40 +00:00
syn match tcshCommentTi contained '\v#\s*\u\w*(\s+\u\w*)*:'hs=s+1 contains=tcshTodo
syn match tcshTodo contained '\v\c<todo>'
2021-10-16 15:23:36 +01:00
" ----- Strings ----- {{{1
2004-06-13 20:20:40 +00:00
" Tcsh does not allow \" in strings unless the "backslash_quote" shell
" variable is set. Set the vim variable "tcsh_backslash_quote" to 0 if you
" want VIM to assume that no backslash quote constructs exist.
" Backquotes are treated as commands, and are not contained in anything
2021-10-16 15:23:36 +01:00
if exists('tcsh_backslash_quote') && tcsh_backslash_quote == 0
2008-06-24 20:39:31 +00:00
syn region tcshSQuote keepend contained start="\v\\@<!'" end="'"
2004-06-13 20:20:40 +00:00
syn region tcshDQuote keepend contained start='\v\\@<!"' end='"' contains=@tcshVarList,tcshSpecial,@Spell
syn region tcshBQuote keepend start='\v\\@<!`' end='`' contains=@tcshStatements
else
2008-06-24 20:39:31 +00:00
syn region tcshSQuote contained start="\v\\@<!'" skip="\v\\\\|\\'" end="'"
2004-06-13 20:20:40 +00:00
syn region tcshDQuote contained start='\v\\@<!"' end='"' contains=@tcshVarList,tcshSpecial,@Spell
syn region tcshBQuote keepend matchgroup=tcshBQuoteGrp start='\v\\@<!`' skip='\v\\\\|\\`' end='`' contains=@tcshStatements
endif
2021-10-16 15:23:36 +01:00
" ----- Variables ----- {{{1
2004-06-13 20:20:40 +00:00
" Variable Errors. Must come first! \$ constructs will be flagged by
" tcshSpecial, so we don't consider them here.
syn match tcshVarError '\v\$\S*' contained
" Modifiable Variables without {}.
2008-06-24 20:39:31 +00:00
syn match tcshUsrVar contained '\v\$\h\w*%(\[\d+%(-\d+)?\])?' nextgroup=@tcshModifiers contains=tcshShellVar,tcshEnvVar
syn match tcshArgv contained '\v\$%(\d+|\*)' nextgroup=@tcshModifiers
2004-06-13 20:20:40 +00:00
" Modifiable Variables with {}.
2008-06-24 20:39:31 +00:00
syn match tcshUsrVar contained '\v\$\{\h\w*%(\[\d+%(-\d+)?\])?%(:\S*)?\}' contains=@tcshModifiers,tcshShellVar,tcshEnvVar
syn match tcshArgv contained '\v\$\{%(\d+|\*)%(:\S*)?\}' contains=@tcshModifiers
2004-06-13 20:20:40 +00:00
2008-06-24 20:39:31 +00:00
" Un-modifiable Substitutions. Order is important here.
syn match tcshSubst contained '\v\$[?#$!_<]' nextgroup=tcshModifierError
syn match tcshSubst contained '\v\$[%#?]%(\h\w*|\d+)' nextgroup=tcshModifierError contains=tcshShellVar,tcshEnvVar
syn match tcshSubst contained '\v\$\{[%#?]%(\h\w*|\d+)%(:\S*)?\}' contains=tcshModifierError contains=tcshShellVar,tcshEnvVar
2004-06-13 20:20:40 +00:00
" Variable Name Expansion Modifiers (order important)
syn match tcshModifierError contained '\v:\S*'
syn match tcshModifier contained '\v:[ag]?[htreuls&qx]' nextgroup=@tcshModifiers
2021-10-16 15:23:36 +01:00
" ----- Operators / Specials ----- {{{1
2004-06-13 20:20:40 +00:00
" Standard redirects (except <<) [<, >, >>, >>&, >>!, >>&!]
2008-06-24 20:39:31 +00:00
syn match tcshRedir contained '\v\<|\>\>?\&?!?'
2004-06-13 20:20:40 +00:00
2008-06-24 20:39:31 +00:00
" Meta-chars
syn match tcshMeta contained '\v[]{}*?[]'
2004-06-13 20:20:40 +00:00
2008-06-24 20:39:31 +00:00
" Here documents (<<)
syn region tcshHereDoc contained matchgroup=tcshShellVar start='\v\<\<\s*\z(\h\w*)' end='^\z1$' contains=@tcshVarList,tcshSpecial
syn 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$'
2004-06-13 20:20:40 +00:00
" Operators
2008-06-24 20:39:31 +00:00
syn match tcshOperator contained '&&\|!\~\|!=\|<<\|<=\|==\|=\~\|>=\|>>\|\*\|\^\|\~\|||\|!\|%\|&\|+\|-\|/\|<\|>\||'
"syn match tcshOperator contained '[(){}]'
2004-06-13 20:20:40 +00:00
" Numbers
2008-06-24 20:39:31 +00:00
syn match tcshNumber contained '\v<-?\d+>'
2004-06-13 20:20:40 +00:00
2008-06-24 20:39:31 +00:00
" Arguments
2021-10-16 15:23:36 +01:00
syn match tcshArgument contained '\v\s@<=-(\w|-)*'
2004-06-13 20:20:40 +00:00
2008-06-24 20:39:31 +00:00
" Special characters. \xxx, or backslashed characters.
"syn match tcshSpecial contained '\v\\@<!\\(\d{3}|.)'
syn match tcshSpecial contained '\v\\%([0-7]{3}|.)'
2004-06-13 20:20:40 +00:00
2021-10-16 15:23:36 +01:00
" ----- Synchronising ----- {{{1
2008-06-24 20:39:31 +00:00
if exists('tcsh_minlines')
2010-01-06 20:54:52 +01:00
if tcsh_minlines == 'fromstart'
syn sync fromstart
else
exec 'syn sync minlines=' . tcsh_minlines
endif
2004-06-13 20:20:40 +00:00
else
2008-06-24 20:39:31 +00:00
syn sync minlines=100 " Some completions can be quite long
2004-06-13 20:20:40 +00:00
endif
2021-10-16 15:23:36 +01:00
" ----- Highlighting ----- {{{1
2004-06-13 20:20:40 +00:00
" Define highlighting of syntax groups
2008-06-24 20:39:31 +00:00
hi def link tcshError Error
hi def link tcshBuiltin Statement
hi def link tcshShellVar Preproc
2004-06-13 20:20:40 +00:00
hi def link tcshEnvVar tcshShellVar
hi def link tcshAliases tcshShellVar
2008-06-24 20:39:31 +00:00
hi def link tcshAliCmd Identifier
hi def link tcshCommands Identifier
hi def link tcshIf tcshBuiltin
hi def link tcshWhile tcshBuiltin
hi def link tcshBindkeyFuncs Function
hi def link tcshExprStart tcshBuiltin
2004-06-13 20:20:40 +00:00
hi def link tcshExprVar tcshUsrVar
hi def link tcshExprOp tcshOperator
hi def link tcshExprEnd tcshOperator
2008-06-24 20:39:31 +00:00
hi def link tcshComment Comment
hi def link tcshCommentTi Preproc
2006-03-17 23:10:44 +00:00
hi def link tcshSharpBang tcshCommentTi
2008-06-24 20:39:31 +00:00
hi def link tcshTodo Todo
hi def link tcshSQuote Constant
2004-06-13 20:20:40 +00:00
hi def link tcshDQuote tcshSQuote
2008-06-24 20:39:31 +00:00
hi def link tcshBQuoteGrp Include
hi def link tcshVarError Error
hi def link tcshUsrVar Type
2004-06-13 20:20:40 +00:00
hi def link tcshArgv tcshUsrVar
hi def link tcshSubst tcshUsrVar
2021-10-16 15:23:36 +01:00
hi def link tcshModifier tcshArgument
2004-06-13 20:20:40 +00:00
hi def link tcshModifierError tcshVarError
hi def link tcshMeta tcshSubst
hi def link tcshRedir tcshOperator
hi def link tcshHereDoc tcshSQuote
2008-06-24 20:39:31 +00:00
hi def link tcshOperator Operator
hi def link tcshNumber Number
2021-10-16 15:23:36 +01:00
hi def link tcshArgument Special
2008-06-24 20:39:31 +00:00
hi def link tcshSpecial SpecialChar
2021-10-16 15:23:36 +01:00
" }}}
2008-06-24 20:39:31 +00:00
let &cpo = s:oldcpo
unlet s:oldcpo
2004-06-13 20:20:40 +00:00
2008-06-24 20:39:31 +00:00
let b:current_syntax = 'tcsh'
2021-10-16 15:23:36 +01:00
" vim: nowrap sw=2 sts=2 ts=8 noet fdm=marker: