xref: /vim-8.2.3635/runtime/syntax/zsh.vim (revision 0fa313a7)
1" Vim syntax file
2" Language:	Z shell (zsh)
3" Maintainer:	Felix von Leitner <[email protected]>
4" Heavily based on sh.vim by Lennart Schultz
5" Last Change:	2003 May 11
6
7" For version 5.x: Clear all syntax items
8" For version 6.x: Quit when a syntax file was already loaded
9if version < 600
10  syntax clear
11elseif exists("b:current_syntax")
12  finish
13endif
14
15" String and Character contstants
16" Highlight special characters (those which have a backslash) differently
17syn match   zshSpecial	"\\\d\d\d\|\\[abcfnrtv\\']"
18syn region	zshSinglequote	start=+'+ skip=+\\'+ end=+'+
19" A bunch of useful zsh keywords
20" syn keyword	zshFunction	function
21syn keyword	zshStatement	bg break cd chdir continue echo eval exec
22syn keyword	zshStatement	exit export fg getopts hash jobs kill
23syn keyword	zshStatement	pwd read readonly return set zshift function
24syn keyword	zshStatement	stop suspend test times trap type ulimit
25syn keyword	zshStatement	umask unset wait setopt compctl source
26syn keyword	zshStatement	whence disown shift which unhash unalias
27syn keyword	zshStatement	alias functions unfunction getln disable
28syn keyword	zshStatement	vared getopt enable unsetopt autoload
29syn keyword	zshStatement	bindkey pushln command limit unlimit fc
30syn keyword	zshStatement	print builtin noglob sched r time
31syn keyword	zshStatement	typeset declare local integer
32
33syn keyword	zshConditional	if else esac case then elif fi in
34syn keyword	zshRepeat	while for do done
35
36" Following is worth to notice: command substitution, file redirection and functions (so these features turns red)
37syn match	zshFunctionName	"\h\w*\s*()"
38syn region	zshCommandSub	start=+`+ skip=+\\`+ end=+`+
39" contains=ALLBUT,zshFunction
40syn match	zshRedir	"\d\=\(<\|<<\|>\|>>\)\(|\|&\d\)\="
41
42syn keyword	zshTodo contained TODO
43
44syn keyword	zshShellVariables	USER LOGNAME HOME PATH CDPATH SHELL
45syn keyword	zshShellVariables	LC_TYPE LC_MESSAGE MAIL MAILCHECK
46syn keyword	zshShellVariables	PS1 PS2 IFS EGID EUID ERRNO GID UID
47syn keyword	zshShellVariables	HOST LINENO MACHTYPE OLDPWD OPTARG
48syn keyword	zshShellVariables	OPTIND OSTYPE PPID PWD RANDOM SECONDS
49syn keyword	zshShellVariables	SHLVL TTY signals TTYIDLE USERNAME
50syn keyword	zshShellVariables	VENDOR ZSH_NAME ZSH_VERSION ARGV0
51syn keyword	zshShellVariables	BAUD COLUMNS cdpath DIRSTACKSIZE
52syn keyword	zshShellVariables	FCEDIT fignore fpath histchars HISTCHARS
53syn keyword	zshShellVariables	HISTFILE HISTSIZE KEYTIMEOUT LANG
54syn keyword	zshShellVariables	LC_ALL LC_COLLATE LC_CTYPE LC_MESSAGES
55syn keyword	zshShellVariables	LC_TIME LINES LISTMAX LOGCHECK mailpath
56syn keyword	zshShellVariables	MAILPATH MANPATH manpath module_path
57syn keyword	zshShellVariables	MODULE_PATH NULLCMD path POSTEDIT
58syn keyword	zshShellVariables	PS3 PS4 PROMPT PROMPT2 PROMPT3 PROMPT4
59syn keyword	zshShellVariables	psvar PSVAR prompt READNULLCMD
60syn keyword	zshShellVariables	REPORTTIME RPROMPT RPS1 SAVEHIST
61syn keyword	zshShellVariables	SPROMPT STTY TIMEFMT TMOUT TMPPREFIX
62syn keyword	zshShellVariables	watch WATCH WATCHFMT WORDCHARS ZDOTDIR
63syn match	zshSpecialShellVar	"\$[-#@*$?!0-9]"
64syn keyword	zshSetVariables		ignoreeof noclobber
65syn region	zshDerefOpr	start="\${" end="}" contains=zshShellVariables
66syn match	zshDerefIdentifier	"\$[a-zA-Z_][a-zA-Z0-9_]*\>"
67syn match	zshOperator		"[][}{&;|)(]"
68
69
70
71syn match  zshNumber		"-\=\<\d\+\>"
72syn match  zshComment	"#.*$" contains=zshNumber,zshTodo
73
74
75syn match zshTestOpr	"-\<[oeaznlg][tfqet]\=\>\|!\==\|-\<[b-gkLprsStuwjxOG]\>"
76"syn region zshTest	      start="\[" skip="\\$" end="\]" contains=zshString,zshTestOpr,zshDerefIdentifier,zshDerefOpr
77syn region  zshString	start=+"+  skip=+\\"+  end=+"+  contains=zshSpecial,zshOperator,zshDerefIdentifier,zshDerefOpr,zshSpecialShellVar,zshSinglequote,zshCommandSub
78
79" Define the default highlighting.
80" For version 5.7 and earlier: only when not done already
81" For version 5.8 and later: only when an item doesn't have highlighting yet
82if version >= 508 || !exists("did_zsh_syntax_inits")
83  if version < 508
84    let did_zsh_syntax_inits = 1
85    command -nargs=+ HiLink hi link <args>
86  else
87    command -nargs=+ HiLink hi def link <args>
88  endif
89
90  HiLink zshSinglequote		zshString
91  HiLink zshConditional		zshStatement
92  HiLink zshRepeat		zshStatement
93  HiLink zshFunctionName	zshFunction
94  HiLink zshCommandSub		zshOperator
95  HiLink zshRedir		zshOperator
96  HiLink zshSetVariables	zshShellVariables
97  HiLink zshSpecialShellVar	zshShellVariables
98  HiLink zshTestOpr		zshOperator
99  HiLink zshDerefOpr		zshSpecial
100  HiLink zshDerefIdentifier	zshShellVariables
101  HiLink zshOperator		Operator
102  HiLink zshStatement		Statement
103  HiLink zshNumber		Number
104  HiLink zshString		String
105  HiLink zshComment		Comment
106  HiLink zshSpecial		Special
107  HiLink zshTodo		Todo
108  HiLink zshShellVariables	Special
109"  hi zshOperator		term=underline ctermfg=6 guifg=Purple gui=bold
110"  hi zshShellVariables	term=underline ctermfg=2 guifg=SeaGreen gui=bold
111"  hi zshFunction		term=bold ctermbg=1 guifg=Red
112
113  delcommand HiLink
114endif
115
116let b:current_syntax = "zsh"
117
118" vim: ts=8
119