Merge pull request #13835 from saadparwaiz1/runtime/zsh

Update Runtime Files For Zsh
This commit is contained in:
Jan Edmund Lazo 2021-01-30 18:34:16 -05:00 committed by GitHub
commit 4e8a01a306
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 102 additions and 33 deletions

23
runtime/compiler/zsh.vim Normal file
View File

@ -0,0 +1,23 @@
" Vim compiler file
" Compiler: Zsh
" Maintainer: Doug Kearns <dougkearns@gmail.com>
" Last Change: 2020 Sep 6
if exists("current_compiler")
finish
endif
let current_compiler = "zsh"
if exists(":CompilerSet") != 2 " older Vim always used :setlocal
command -nargs=* CompilerSet setlocal <args>
endif
let s:cpo_save = &cpo
set cpo&vim
CompilerSet makeprg=zsh\ -n\ --\ %:S
CompilerSet errorformat=%f:\ line\ %l:\ %m,
\%-G%.%#
let &cpo = s:cpo_save
unlet s:cpo_save

View File

@ -2,7 +2,7 @@
" Language: Zsh shell script " Language: Zsh shell script
" Maintainer: Christian Brabandt <cb@256bit.org> " Maintainer: Christian Brabandt <cb@256bit.org>
" Previous Maintainer: Nikolai Weibull <now@bitwi.se> " Previous Maintainer: Nikolai Weibull <now@bitwi.se>
" Latest Revision: 2017-11-22 " Latest Revision: 2020-09-01
" License: Vim (see :h license) " License: Vim (see :h license)
" Repository: https://github.com/chrisbra/vim-zsh " Repository: https://github.com/chrisbra/vim-zsh
@ -14,11 +14,26 @@ let b:did_ftplugin = 1
let s:cpo_save = &cpo let s:cpo_save = &cpo
set cpo&vim set cpo&vim
let b:undo_ftplugin = "setl com< cms< fo<"
setlocal comments=:# commentstring=#\ %s formatoptions-=t formatoptions+=croql setlocal comments=:# commentstring=#\ %s formatoptions-=t formatoptions+=croql
let b:match_words = ',\<if\>:\<elif\>:\<else\>:\<fi\>' let b:undo_ftplugin = "setl com< cms< fo< "
if executable('zsh')
if !has('gui_running') && executable('less')
command! -buffer -nargs=1 RunHelp silent exe '!MANPAGER= zsh -ic "autoload -Uz run-help; run-help <args> 2>/dev/null | LESS= less"' | redraw!
elseif has('terminal')
command! -buffer -nargs=1 RunHelp silent exe ':term zsh -ic "autoload -Uz run-help; run-help <args>"'
else
command! -buffer -nargs=1 RunHelp echo system('zsh -ic "autoload -Uz run-help; run-help <args> 2>/dev/null"')
endif
if !exists('current_compiler')
compiler zsh
endif
setlocal keywordprg=:RunHelp
let b:undo_ftplugin .= 'keywordprg<'
endif
let b:match_words = '\<if\>:\<elif\>:\<else\>:\<fi\>'
\ . ',\<case\>:^\s*([^)]*):\<esac\>' \ . ',\<case\>:^\s*([^)]*):\<esac\>'
\ . ',\<\%(select\|while\|until\|repeat\|for\%(each\)\=\)\>:\<done\>' \ . ',\<\%(select\|while\|until\|repeat\|for\%(each\)\=\)\>:\<done\>'
let b:match_skip = 's:comment\|string\|heredoc\|subst' let b:match_skip = 's:comment\|string\|heredoc\|subst'

View File

@ -2,7 +2,7 @@
" Language: Zsh shell script " Language: Zsh shell script
" Maintainer: Christian Brabandt <cb@256bit.org> " Maintainer: Christian Brabandt <cb@256bit.org>
" Previous Maintainer: Nikolai Weibull <now@bitwi.se> " Previous Maintainer: Nikolai Weibull <now@bitwi.se>
" Latest Revision: 2018-05-12 " Latest Revision: 2020-11-21
" License: Vim (see :h license) " License: Vim (see :h license)
" Repository: https://github.com/chrisbra/vim-zsh " Repository: https://github.com/chrisbra/vim-zsh
@ -13,32 +13,44 @@ endif
let s:cpo_save = &cpo let s:cpo_save = &cpo
set cpo&vim set cpo&vim
if v:version > 704 || (v:version == 704 && has("patch1142")) function! s:ContainedGroup()
syn iskeyword @,48-57,_,192-255,#,- " needs 7.4.2008 for execute() function
else let result='TOP'
setlocal iskeyword+=- " vim-pandoc syntax defines the @langname cluster for embedded syntax languages
endif " However, if no syntax is defined yet, `syn list @zsh` will return
" "No syntax items defined", so make sure the result is actually a valid syn cluster
for cluster in ['markdownHighlightzsh', 'zsh']
try
" markdown syntax defines embedded clusters as @markdownhighlight<lang>,
" pandoc just uses @<lang>, so check both for both clusters
let a=split(execute('syn list @'. cluster), "\n")
if len(a) == 2 && a[0] =~# '^---' && a[1] =~? cluster
return '@'. cluster
endif
catch /E392/
" ignore
endtry
endfor
return result
endfunction
let s:contained=s:ContainedGroup()
syn iskeyword @,48-57,_,192-255,#,-
if get(g:, 'zsh_fold_enable', 0) if get(g:, 'zsh_fold_enable', 0)
setlocal foldmethod=syntax setlocal foldmethod=syntax
endif endif
syn keyword zshTodo contained TODO FIXME XXX NOTE syn match zshPOSIXQuoted '\\[xX][0-9a-fA-F]\{1,2}'
syn match zshPOSIXQuoted '\\[0-7]\{1,3}'
syn region zshComment oneline start='\%(^\|\s\+\)#' end='$' syn match zshPOSIXQuoted '\\u[0-9a-fA-F]\{1,4}'
\ contains=zshTodo,@Spell fold syn match zshPOSIXQuoted '\\U[1-9a-fA-F]\{1,8}'
syn region zshComment start='^\s*#' end='^\%(\s*#\)\@!'
\ contains=zshTodo,@Spell fold
syn match zshPreProc '^\%1l#\%(!\|compdef\|autoload\).*$'
syn match zshQuoted '\\.' syn match zshQuoted '\\.'
syn region zshString matchgroup=zshStringDelimiter start=+"+ end=+"+ syn region zshString matchgroup=zshStringDelimiter start=+"+ end=+"+
\ contains=zshQuoted,@zshDerefs,@zshSubst fold \ contains=zshQuoted,@zshDerefs,@zshSubst fold
syn region zshString matchgroup=zshStringDelimiter start=+'+ end=+'+ fold syn region zshString matchgroup=zshStringDelimiter start=+'+ end=+'+ fold
" XXX: This should probably be more precise, but Zsh seems a bit confused about it itself
syn region zshPOSIXString matchgroup=zshStringDelimiter start=+\$'+ syn region zshPOSIXString matchgroup=zshStringDelimiter start=+\$'+
\ end=+'+ contains=zshQuoted \ skip=+\\[\\']+ end=+'+ contains=zshPOSIXQuoted,zshQuoted
syn match zshJobSpec '%\(\d\+\|?\=\w\+\|[%+-]\)' syn match zshJobSpec '%\(\d\+\|?\=\w\+\|[%+-]\)'
syn keyword zshPrecommand noglob nocorrect exec command builtin - time syn keyword zshPrecommand noglob nocorrect exec command builtin - time
@ -112,7 +124,7 @@ syn keyword zshCommands alias autoload bg bindkey break bye cap cd
\ enable eval exec exit export false fc fg \ enable eval exec exit export false fc fg
\ functions getcap getln getopts hash history \ functions getcap getln getopts hash history
\ jobs kill let limit log logout popd print \ jobs kill let limit log logout popd print
\ printf pushd pushln pwd r read readonly \ printf pushd pushln pwd r read
\ rehash return sched set setcap shift \ rehash return sched set setcap shift
\ source stat suspend test times trap true \ source stat suspend test times trap true
\ ttyctl type ulimit umask unalias unfunction \ ttyctl type ulimit umask unalias unfunction
@ -125,7 +137,7 @@ syn keyword zshCommands alias autoload bg bindkey break bye cap cd
" Create a list of option names from zsh source dir: " Create a list of option names from zsh source dir:
" #!/bin/zsh " #!/bin/zsh
" topdir=/path/to/zsh-xxx " topdir=/path/to/zsh-xxx
" grep '^pindex([A-Za-z_]*)$' $topdir/Src/Doc/Zsh/optionsyo | " grep '^pindex([A-Za-z_]*)$' $topdir/Doc/Zsh/options.yo |
" while read opt " while read opt
" do " do
" echo ${${(L)opt#pindex\(}%\)} " echo ${${(L)opt#pindex\(}%\)}
@ -136,6 +148,7 @@ syn case ignore
syn match zshOptStart /^\s*\%(\%(\%(un\)\?setopt\)\|set\s+[-+]o\)/ nextgroup=zshOption skipwhite syn match zshOptStart /^\s*\%(\%(\%(un\)\?setopt\)\|set\s+[-+]o\)/ nextgroup=zshOption skipwhite
syn match zshOption / syn match zshOption /
\ \%(\%(\<no_\?\)\?aliases\>\)\| \ \%(\%(\<no_\?\)\?aliases\>\)\|
\ \%(\%(\<no_\?\)\?aliasfuncdef\>\)\|\%(\%(no_\?\)\?alias_func_def\>\)\|
\ \%(\%(\<no_\?\)\?allexport\>\)\|\%(\%(no_\?\)\?all_export\>\)\| \ \%(\%(\<no_\?\)\?allexport\>\)\|\%(\%(no_\?\)\?all_export\>\)\|
\ \%(\%(\<no_\?\)\?alwayslastprompt\>\)\|\%(\%(no_\?\)\?always_last_prompt\>\)\|\%(\%(no_\?\)\?always_lastprompt\>\)\| \ \%(\%(\<no_\?\)\?alwayslastprompt\>\)\|\%(\%(no_\?\)\?always_last_prompt\>\)\|\%(\%(no_\?\)\?always_lastprompt\>\)\|
\ \%(\%(\<no_\?\)\?alwaystoend\>\)\|\%(\%(no_\?\)\?always_to_end\>\)\| \ \%(\%(\<no_\?\)\?alwaystoend\>\)\|\%(\%(no_\?\)\?always_to_end\>\)\|
@ -165,10 +178,13 @@ syn match zshOption /
\ \%(\%(\<no_\?\)\?casematch\>\)\|\%(\%(no_\?\)\?case_match\>\)\| \ \%(\%(\<no_\?\)\?casematch\>\)\|\%(\%(no_\?\)\?case_match\>\)\|
\ \%(\%(\<no_\?\)\?cbases\>\)\|\%(\%(no_\?\)\?c_bases\>\)\| \ \%(\%(\<no_\?\)\?cbases\>\)\|\%(\%(no_\?\)\?c_bases\>\)\|
\ \%(\%(\<no_\?\)\?cdablevars\>\)\|\%(\%(no_\?\)\?cdable_vars\>\)\|\%(\%(no_\?\)\?cd_able_vars\>\)\| \ \%(\%(\<no_\?\)\?cdablevars\>\)\|\%(\%(no_\?\)\?cdable_vars\>\)\|\%(\%(no_\?\)\?cd_able_vars\>\)\|
\ \%(\%(\<no_\?\)\?cdsilent\>\)\|\%(\%(no_\?\)\?cd_silent\>\)\|\%(\%(no_\?\)\?cd_silent\>\)\|
\ \%(\%(\<no_\?\)\?chasedots\>\)\|\%(\%(no_\?\)\?chase_dots\>\)\| \ \%(\%(\<no_\?\)\?chasedots\>\)\|\%(\%(no_\?\)\?chase_dots\>\)\|
\ \%(\%(\<no_\?\)\?chaselinks\>\)\|\%(\%(no_\?\)\?chase_links\>\)\| \ \%(\%(\<no_\?\)\?chaselinks\>\)\|\%(\%(no_\?\)\?chase_links\>\)\|
\ \%(\%(\<no_\?\)\?checkjobs\>\)\|\%(\%(no_\?\)\?check_jobs\>\)\| \ \%(\%(\<no_\?\)\?checkjobs\>\)\|\%(\%(no_\?\)\?check_jobs\>\)\|
\ \%(\%(\<no_\?\)\?checkrunningjobs\>\)\|\%(\%(no_\?\)\?check_running_jobs\>\)\|
\ \%(\%(\<no_\?\)\?clobber\>\)\| \ \%(\%(\<no_\?\)\?clobber\>\)\|
\ \%(\%(\<no_\?\)\?clobberempty\>\)\|\%(\%(no_\?\)\?clobber_empty\>\)\|
\ \%(\%(\<no_\?\)\?combiningchars\>\)\|\%(\%(no_\?\)\?combining_chars\>\)\| \ \%(\%(\<no_\?\)\?combiningchars\>\)\|\%(\%(no_\?\)\?combining_chars\>\)\|
\ \%(\%(\<no_\?\)\?completealiases\>\)\|\%(\%(no_\?\)\?complete_aliases\>\)\| \ \%(\%(\<no_\?\)\?completealiases\>\)\|\%(\%(no_\?\)\?complete_aliases\>\)\|
\ \%(\%(\<no_\?\)\?completeinword\>\)\|\%(\%(no_\?\)\?complete_in_word\>\)\| \ \%(\%(\<no_\?\)\?completeinword\>\)\|\%(\%(no_\?\)\?complete_in_word\>\)\|
@ -188,7 +204,7 @@ syn match zshOption /
\ \%(\%(\<no_\?\)\?equals\>\)\| \ \%(\%(\<no_\?\)\?equals\>\)\|
\ \%(\%(\<no_\?\)\?errexit\>\)\|\%(\%(no_\?\)\?err_exit\>\)\| \ \%(\%(\<no_\?\)\?errexit\>\)\|\%(\%(no_\?\)\?err_exit\>\)\|
\ \%(\%(\<no_\?\)\?errreturn\>\)\|\%(\%(no_\?\)\?err_return\>\)\| \ \%(\%(\<no_\?\)\?errreturn\>\)\|\%(\%(no_\?\)\?err_return\>\)\|
\ \%(\%(\<no_\?\)\?evallineno_\?\)\|\%(\%(no_\?\)\?eval_lineno_\?\)\| \ \%(\%(\<no_\?\)\?evallineno\>\)\|\%(\%(no_\?\)\?eval_lineno\>\)\|
\ \%(\%(\<no_\?\)\?exec\>\)\| \ \%(\%(\<no_\?\)\?exec\>\)\|
\ \%(\%(\<no_\?\)\?extendedglob\>\)\|\%(\%(no_\?\)\?extended_glob\>\)\| \ \%(\%(\<no_\?\)\?extendedglob\>\)\|\%(\%(no_\?\)\?extended_glob\>\)\|
\ \%(\%(\<no_\?\)\?extendedhistory\>\)\|\%(\%(no_\?\)\?extended_history\>\)\| \ \%(\%(\<no_\?\)\?extendedhistory\>\)\|\%(\%(no_\?\)\?extended_history\>\)\|
@ -309,6 +325,7 @@ syn match zshOption /
\ \%(\%(\<no_\?\)\?shnullcmd\>\)\|\%(\%(no_\?\)\?sh_nullcmd\>\)\| \ \%(\%(\<no_\?\)\?shnullcmd\>\)\|\%(\%(no_\?\)\?sh_nullcmd\>\)\|
\ \%(\%(\<no_\?\)\?shoptionletters\>\)\|\%(\%(no_\?\)\?sh_option_letters\>\)\| \ \%(\%(\<no_\?\)\?shoptionletters\>\)\|\%(\%(no_\?\)\?sh_option_letters\>\)\|
\ \%(\%(\<no_\?\)\?shortloops\>\)\|\%(\%(no_\?\)\?short_loops\>\)\| \ \%(\%(\<no_\?\)\?shortloops\>\)\|\%(\%(no_\?\)\?short_loops\>\)\|
\ \%(\%(\<no_\?\)\?shortrepeat\>\)\|\%(\%(no_\?\)\?short_repeat\>\)\|
\ \%(\%(\<no_\?\)\?shwordsplit\>\)\|\%(\%(no_\?\)\?sh_word_split\>\)\| \ \%(\%(\<no_\?\)\?shwordsplit\>\)\|\%(\%(no_\?\)\?sh_word_split\>\)\|
\ \%(\%(\<no_\?\)\?singlecommand\>\)\|\%(\%(no_\?\)\?single_command\>\)\| \ \%(\%(\<no_\?\)\?singlecommand\>\)\|\%(\%(no_\?\)\?single_command\>\)\|
\ \%(\%(\<no_\?\)\?singlelinezle\>\)\|\%(\%(no_\?\)\?single_line_zle\>\)\| \ \%(\%(\<no_\?\)\?singlelinezle\>\)\|\%(\%(no_\?\)\?single_line_zle\>\)\|
@ -322,10 +339,13 @@ syn match zshOption /
\ \%(\%(\<no_\?\)\?unset\>\)\| \ \%(\%(\<no_\?\)\?unset\>\)\|
\ \%(\%(\<no_\?\)\?verbose\>\)\| \ \%(\%(\<no_\?\)\?verbose\>\)\|
\ \%(\%(\<no_\?\)\?vi\>\)\| \ \%(\%(\<no_\?\)\?vi\>\)\|
\ \%(\%(\<no_\?\)\?warnnestedvar\>\)\|\%(\%(no_\?\)\?warn_nested_var\>\)\|
\ \%(\%(\<no_\?\)\?warncreateglobal\>\)\|\%(\%(no_\?\)\?warn_create_global\>\)\| \ \%(\%(\<no_\?\)\?warncreateglobal\>\)\|\%(\%(no_\?\)\?warn_create_global\>\)\|
\ \%(\%(\<no_\?\)\?xtrace\>\)\| \ \%(\%(\<no_\?\)\?xtrace\>\)\|
\ \%(\%(\<no_\?\)\?zle\>\)/ nextgroup=zshOption,zshComment skipwhite contained \ \%(\%(\<no_\?\)\?zle\>\)/ nextgroup=zshOption,zshComment skipwhite contained
syn case match
syn keyword zshTypes float integer local typeset declare private readonly syn keyword zshTypes float integer local typeset declare private readonly
" XXX: this may be too much " XXX: this may be too much
@ -339,31 +359,42 @@ syn match zshNumber '[+-]\=\d\+\.\d\+\>'
" TODO: $[...] is the same as $((...)), so add that as well. " TODO: $[...] is the same as $((...)), so add that as well.
syn cluster zshSubst contains=zshSubst,zshOldSubst,zshMathSubst syn cluster zshSubst contains=zshSubst,zshOldSubst,zshMathSubst
syn region zshSubst matchgroup=zshSubstDelim transparent exe 'syn region zshSubst matchgroup=zshSubstDelim transparent start=/\$(/ skip=/\\)/ end=/)/ contains='.s:contained. ' fold'
\ start='\$(' skip='\\)' end=')' contains=TOP fold
syn region zshParentheses transparent start='(' skip='\\)' end=')' fold syn region zshParentheses transparent start='(' skip='\\)' end=')' fold
syn region zshGlob start='(#' end=')' syn region zshGlob start='(#' end=')'
syn region zshMathSubst matchgroup=zshSubstDelim transparent syn region zshMathSubst matchgroup=zshSubstDelim transparent
\ start='\$((' skip='\\)' end='))' \ start='\%(\$\?\)[<=>]\@<!((' skip='\\)' end='))'
\ contains=zshParentheses,@zshSubst,zshNumber, \ contains=zshParentheses,@zshSubst,zshNumber,
\ @zshDerefs,zshString keepend fold \ @zshDerefs,zshString keepend fold
syn region zshBrackets contained transparent start='{' skip='\\}' " The ms=s+1 prevents matching zshBrackets several times on opening brackets
" (see https://github.com/chrisbra/vim-zsh/issues/21#issuecomment-576330348)
syn region zshBrackets contained transparent start='{'ms=s+1 skip='\\}'
\ end='}' fold \ end='}' fold
syn region zshBrackets transparent start='{' skip='\\}' exe 'syn region zshBrackets transparent start=/{/ms=s+1 skip=/\\}/ end=/}/ contains='.s:contained. ' fold'
\ end='}' contains=TOP fold
syn region zshSubst matchgroup=zshSubstDelim start='\${' skip='\\}' syn region zshSubst matchgroup=zshSubstDelim start='\${' skip='\\}'
\ end='}' contains=@zshSubst,zshBrackets,zshQuoted,zshString fold \ end='}' contains=@zshSubst,zshBrackets,zshQuoted,zshString fold
syn region zshOldSubst matchgroup=zshSubstDelim start=+`+ skip=+\\`+ exe 'syn region zshOldSubst matchgroup=zshSubstDelim start=/`/ skip=/\\[\\`]/ end=/`/ contains='.s:contained. ',zshOldSubst fold'
\ end=+`+ contains=TOP,zshOldSubst fold
syn sync minlines=50 maxlines=90 syn sync minlines=50 maxlines=90
syn sync match zshHereDocSync grouphere NONE '<<-\=\s*\%(\\\=\S\+\|\(["']\)\S\+\1\)' syn sync match zshHereDocSync grouphere NONE '<<-\=\s*\%(\\\=\S\+\|\(["']\)\S\+\1\)'
syn sync match zshHereDocEndSync groupthere NONE '^\s*EO\a\+\>' syn sync match zshHereDocEndSync groupthere NONE '^\s*EO\a\+\>'
syn keyword zshTodo contained TODO FIXME XXX NOTE
syn region zshComment oneline start='\%(^\|\s\+\)#' end='$'
\ contains=zshTodo,@Spell fold
syn region zshComment start='^\s*#' end='^\%(\s*#\)\@!'
\ contains=zshTodo,@Spell fold
syn match zshPreProc '^\%1l#\%(!\|compdef\|autoload\).*$'
hi def link zshTodo Todo hi def link zshTodo Todo
hi def link zshComment Comment hi def link zshComment Comment
hi def link zshPreProc PreProc hi def link zshPreProc PreProc
hi def link zshQuoted SpecialChar hi def link zshQuoted SpecialChar
hi def link zshPOSIXQuoted SpecialChar
hi def link zshString String hi def link zshString String
hi def link zshStringDelimiter zshString hi def link zshStringDelimiter zshString
hi def link zshPOSIXString zshString hi def link zshPOSIXString zshString