From 44802202be0a3e803e88a2c65abafa6a1a05d7f2 Mon Sep 17 00:00:00 2001 From: Saad Parwaiz Date: Wed, 27 Jan 2021 18:56:31 +0000 Subject: [PATCH 1/6] runtime/zsh: 96f45c0b6fc9e9d404e6805593ed1e0e6795e470 Port zsh syntax file only --- runtime/syntax/zsh.vim | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/runtime/syntax/zsh.vim b/runtime/syntax/zsh.vim index 3eba438aa7..1e947671a9 100644 --- a/runtime/syntax/zsh.vim +++ b/runtime/syntax/zsh.vim @@ -2,7 +2,7 @@ " Language: Zsh shell script " Maintainer: Christian Brabandt " Previous Maintainer: Nikolai Weibull -" Latest Revision: 2018-05-12 +" Latest Revision: 2018-07-13 " License: Vim (see :h license) " Repository: https://github.com/chrisbra/vim-zsh @@ -112,7 +112,7 @@ syn keyword zshCommands alias autoload bg bindkey break bye cap cd \ enable eval exec exit export false fc fg \ functions getcap getln getopts hash history \ 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 \ source stat suspend test times trap true \ ttyctl type ulimit umask unalias unfunction @@ -125,7 +125,7 @@ syn keyword zshCommands alias autoload bg bindkey break bye cap cd " Create a list of option names from zsh source dir: " #!/bin/zsh " 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 " do " echo ${${(L)opt#pindex\(}%\)} @@ -136,6 +136,7 @@ syn case ignore syn match zshOptStart /^\s*\%(\%(\%(un\)\?setopt\)\|set\s+[-+]o\)/ nextgroup=zshOption skipwhite syn match zshOption / \ \%(\%(\\)\| + \ \%(\%(\\)\|\%(\%(no_\?\)\?alias_func_def\>\)\| \ \%(\%(\\)\|\%(\%(no_\?\)\?all_export\>\)\| \ \%(\%(\\)\|\%(\%(no_\?\)\?always_last_prompt\>\)\|\%(\%(no_\?\)\?always_lastprompt\>\)\| \ \%(\%(\\)\|\%(\%(no_\?\)\?always_to_end\>\)\| @@ -168,6 +169,7 @@ syn match zshOption / \ \%(\%(\\)\|\%(\%(no_\?\)\?chase_dots\>\)\| \ \%(\%(\\)\|\%(\%(no_\?\)\?chase_links\>\)\| \ \%(\%(\\)\|\%(\%(no_\?\)\?check_jobs\>\)\| + \ \%(\%(\\)\|\%(\%(no_\?\)\?check_running_jobs\>\)\| \ \%(\%(\\)\| \ \%(\%(\\)\|\%(\%(no_\?\)\?combining_chars\>\)\| \ \%(\%(\\)\|\%(\%(no_\?\)\?complete_aliases\>\)\| @@ -188,7 +190,7 @@ syn match zshOption / \ \%(\%(\\)\| \ \%(\%(\\)\|\%(\%(no_\?\)\?err_exit\>\)\| \ \%(\%(\\)\|\%(\%(no_\?\)\?err_return\>\)\| - \ \%(\%(\\)\|\%(\%(no_\?\)\?eval_lineno\>\)\| \ \%(\%(\\)\| \ \%(\%(\\)\|\%(\%(no_\?\)\?extended_glob\>\)\| \ \%(\%(\\)\|\%(\%(no_\?\)\?extended_history\>\)\| @@ -322,6 +324,7 @@ syn match zshOption / \ \%(\%(\\)\| \ \%(\%(\\)\| \ \%(\%(\\)\| + \ \%(\%(\\)\|\%(\%(no_\?\)\?warn_nested_var\>\)\| \ \%(\%(\\)\|\%(\%(no_\?\)\?warn_create_global\>\)\| \ \%(\%(\\)\| \ \%(\%(\\)/ nextgroup=zshOption,zshComment skipwhite contained From d89cbb62ab97bf3b349e18c3348a4d32ce12d0f7 Mon Sep 17 00:00:00 2001 From: Saad Parwaiz Date: Wed, 27 Jan 2021 19:00:04 +0000 Subject: [PATCH 2/6] runtime/zsh: b17893aa940dc7d45421f875f5d90855880aad27 port zsh syntax file only --- runtime/syntax/zsh.vim | 53 ++++++++++++++++++++++++++++++------------ 1 file changed, 38 insertions(+), 15 deletions(-) diff --git a/runtime/syntax/zsh.vim b/runtime/syntax/zsh.vim index 1e947671a9..ddb19b5800 100644 --- a/runtime/syntax/zsh.vim +++ b/runtime/syntax/zsh.vim @@ -2,7 +2,7 @@ " Language: Zsh shell script " Maintainer: Christian Brabandt " Previous Maintainer: Nikolai Weibull -" Latest Revision: 2018-07-13 +" Latest Revision: 2020-01-23 " License: Vim (see :h license) " Repository: https://github.com/chrisbra/vim-zsh @@ -13,11 +13,30 @@ endif let s:cpo_save = &cpo set cpo&vim -if v:version > 704 || (v:version == 704 && has("patch1142")) - syn iskeyword @,48-57,_,192-255,#,- -else - setlocal iskeyword+=- -endif +function! s:ContainedGroup() + " needs 7.4.2008 for execute() function + let result='TOP' + " vim-pandoc syntax defines the @langname cluster for embedded syntax languages + " 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, + " pandoc just uses @, 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) setlocal foldmethod=syntax endif @@ -32,13 +51,16 @@ syn region zshComment start='^\s*#' end='^\%(\s*#\)\@!' syn match zshPreProc '^\%1l#\%(!\|compdef\|autoload\).*$' +syn match zshPOSIXQuoted '\\[xX][0-9a-fA-F]\{1,2}' +syn match zshPOSIXQuoted '\\[0-7]\{1,3}' +syn match zshPOSIXQuoted '\\u[0-9a-fA-F]\{1,4}' +syn match zshPOSIXQuoted '\\U[1-9a-fA-F]\{1,8}' syn match zshQuoted '\\.' syn region zshString matchgroup=zshStringDelimiter start=+"+ end=+"+ \ contains=zshQuoted,@zshDerefs,@zshSubst 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=+\$'+ - \ end=+'+ contains=zshQuoted + \ skip=+\\[\\']+ end=+'+ contains=zshPOSIXQuoted,zshQuoted syn match zshJobSpec '%\(\d\+\|?\=\w\+\|[%+-]\)' syn keyword zshPrecommand noglob nocorrect exec command builtin - time @@ -342,22 +364,22 @@ syn match zshNumber '[+-]\=\d\+\.\d\+\>' " TODO: $[...] is the same as $((...)), so add that as well. syn cluster zshSubst contains=zshSubst,zshOldSubst,zshMathSubst -syn region zshSubst matchgroup=zshSubstDelim transparent - \ start='\$(' skip='\\)' end=')' contains=TOP fold +exe 'syn region zshSubst matchgroup=zshSubstDelim transparent start=/\$(/ skip=/\\)/ end=/)/ contains='.s:contained. ' fold' syn region zshParentheses transparent start='(' skip='\\)' end=')' fold syn region zshGlob start='(#' end=')' syn region zshMathSubst matchgroup=zshSubstDelim transparent \ start='\$((' skip='\\)' end='))' \ contains=zshParentheses,@zshSubst,zshNumber, \ @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 -syn region zshBrackets transparent start='{' skip='\\}' - \ end='}' contains=TOP fold +exe 'syn region zshBrackets transparent start=/{/ms=s+1 skip=/\\}/ end=/}/ contains='.s:contained. ' fold' + syn region zshSubst matchgroup=zshSubstDelim start='\${' skip='\\}' \ end='}' contains=@zshSubst,zshBrackets,zshQuoted,zshString fold -syn region zshOldSubst matchgroup=zshSubstDelim start=+`+ skip=+\\`+ - \ end=+`+ contains=TOP,zshOldSubst fold +exe 'syn region zshOldSubst matchgroup=zshSubstDelim start=/`/ skip=/\\[\\`]/ end=/`/ contains='.s:contained. ',zshOldSubst fold' syn sync minlines=50 maxlines=90 syn sync match zshHereDocSync grouphere NONE '<<-\=\s*\%(\\\=\S\+\|\(["']\)\S\+\1\)' @@ -367,6 +389,7 @@ hi def link zshTodo Todo hi def link zshComment Comment hi def link zshPreProc PreProc hi def link zshQuoted SpecialChar +hi def link zshPOSIXQuoted SpecialChar hi def link zshString String hi def link zshStringDelimiter zshString hi def link zshPOSIXString zshString From da61cca9f79546dd9c947b1d4cbeefa1d3a32dc5 Mon Sep 17 00:00:00 2001 From: Saad Parwaiz Date: Wed, 27 Jan 2021 19:01:28 +0000 Subject: [PATCH 3/6] runtime/zsh: 23515b4ef7580af8b9d3b964a558ab2007cacda5 port zsh syntax file only --- runtime/syntax/zsh.vim | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/runtime/syntax/zsh.vim b/runtime/syntax/zsh.vim index ddb19b5800..819c419228 100644 --- a/runtime/syntax/zsh.vim +++ b/runtime/syntax/zsh.vim @@ -2,7 +2,7 @@ " Language: Zsh shell script " Maintainer: Christian Brabandt " Previous Maintainer: Nikolai Weibull -" Latest Revision: 2020-01-23 +" Latest Revision: 2020-11-21 " License: Vim (see :h license) " Repository: https://github.com/chrisbra/vim-zsh @@ -14,7 +14,7 @@ let s:cpo_save = &cpo set cpo&vim function! s:ContainedGroup() - " needs 7.4.2008 for execute() function + " needs 7.4.2008 for execute() function let result='TOP' " vim-pandoc syntax defines the @langname cluster for embedded syntax languages " However, if no syntax is defined yet, `syn list @zsh` will return @@ -41,16 +41,6 @@ if get(g:, 'zsh_fold_enable', 0) setlocal foldmethod=syntax endif -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\).*$' - syn match zshPOSIXQuoted '\\[xX][0-9a-fA-F]\{1,2}' syn match zshPOSIXQuoted '\\[0-7]\{1,3}' syn match zshPOSIXQuoted '\\u[0-9a-fA-F]\{1,4}' @@ -188,11 +178,13 @@ syn match zshOption / \ \%(\%(\\)\|\%(\%(no_\?\)\?case_match\>\)\| \ \%(\%(\\)\|\%(\%(no_\?\)\?c_bases\>\)\| \ \%(\%(\\)\|\%(\%(no_\?\)\?cdable_vars\>\)\|\%(\%(no_\?\)\?cd_able_vars\>\)\| + \ \%(\%(\\)\|\%(\%(no_\?\)\?cd_silent\>\)\|\%(\%(no_\?\)\?cd_silent\>\)\| \ \%(\%(\\)\|\%(\%(no_\?\)\?chase_dots\>\)\| \ \%(\%(\\)\|\%(\%(no_\?\)\?chase_links\>\)\| \ \%(\%(\\)\|\%(\%(no_\?\)\?check_jobs\>\)\| \ \%(\%(\\)\|\%(\%(no_\?\)\?check_running_jobs\>\)\| \ \%(\%(\\)\| + \ \%(\%(\\)\|\%(\%(no_\?\)\?clobber_empty\>\)\| \ \%(\%(\\)\|\%(\%(no_\?\)\?combining_chars\>\)\| \ \%(\%(\\)\|\%(\%(no_\?\)\?complete_aliases\>\)\| \ \%(\%(\\)\|\%(\%(no_\?\)\?complete_in_word\>\)\| @@ -333,6 +325,7 @@ syn match zshOption / \ \%(\%(\\)\|\%(\%(no_\?\)\?sh_nullcmd\>\)\| \ \%(\%(\\)\|\%(\%(no_\?\)\?sh_option_letters\>\)\| \ \%(\%(\\)\|\%(\%(no_\?\)\?short_loops\>\)\| + \ \%(\%(\\)\|\%(\%(no_\?\)\?short_repeat\>\)\| \ \%(\%(\\)\|\%(\%(no_\?\)\?sh_word_split\>\)\| \ \%(\%(\\)\|\%(\%(no_\?\)\?single_command\>\)\| \ \%(\%(\\)\|\%(\%(no_\?\)\?single_line_zle\>\)\| @@ -351,6 +344,8 @@ syn match zshOption / \ \%(\%(\\)\| \ \%(\%(\\)/ nextgroup=zshOption,zshComment skipwhite contained +syn case match + syn keyword zshTypes float integer local typeset declare private readonly " XXX: this may be too much @@ -368,7 +363,7 @@ exe 'syn region zshSubst matchgroup=zshSubstDelim transparent start=/\$(/ syn region zshParentheses transparent start='(' skip='\\)' end=')' fold syn region zshGlob start='(#' end=')' syn region zshMathSubst matchgroup=zshSubstDelim transparent - \ start='\$((' skip='\\)' end='))' + \ start='\%(\$\?\)[<=>]\@' +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 zshComment Comment hi def link zshPreProc PreProc From 7722eb09534054613016e0dd61bf56a5dc8a916c Mon Sep 17 00:00:00 2001 From: Saad Parwaiz Date: Wed, 27 Jan 2021 19:05:25 +0000 Subject: [PATCH 4/6] runtime/zsh: b17893aa940dc7d45421f875f5d90855880aad27 port zsh ftplugin only --- runtime/ftplugin/zsh.vim | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/runtime/ftplugin/zsh.vim b/runtime/ftplugin/zsh.vim index fe8efc59ab..741f31b42c 100644 --- a/runtime/ftplugin/zsh.vim +++ b/runtime/ftplugin/zsh.vim @@ -2,7 +2,7 @@ " Language: Zsh shell script " Maintainer: Christian Brabandt " Previous Maintainer: Nikolai Weibull -" Latest Revision: 2017-11-22 +" Latest Revision: 2020-01-10 " License: Vim (see :h license) " Repository: https://github.com/chrisbra/vim-zsh @@ -14,10 +14,24 @@ let b:did_ftplugin = 1 let s:cpo_save = &cpo set cpo&vim -let b:undo_ftplugin = "setl com< cms< fo<" - setlocal comments=:# commentstring=#\ %s formatoptions-=t formatoptions+=croql +let b:undo_ftplugin = "setl com< cms< fo< " + +if executable('zsh') + if !has('gui_running') && executable('less') + command! -buffer -nargs=1 RunHelp silent exe '!zsh -ic "autoload -Uz run-help; run-help 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 "' + else + command! -buffer -nargs=1 RunHelp echo system('zsh -ic "autoload -Uz run-help; run-help 2>/dev/null"') + endif + setlocal keywordprg=:RunHelp + setlocal makeprg=zsh\ -n\ --\ %:S + setlocal errorformat=%f:\ line\ %l:\ %m + let b:undo_ftplugin .= 'keywordprg< errorformat< makeprg<' +endif + let b:match_words = ',\:\:\:\' \ . ',\:^\s*([^)]*):\' \ . ',\<\%(select\|while\|until\|repeat\|for\%(each\)\=\)\>:\' From bf1da7424d5597f5de47d8dc7aad3a0b2ba42064 Mon Sep 17 00:00:00 2001 From: Saad Parwaiz Date: Wed, 27 Jan 2021 19:08:54 +0000 Subject: [PATCH 5/6] runtime/zsh: 23515b4ef7580af8b9d3b964a558ab2007cacda5 port zsh ftplugin only. --- runtime/ftplugin/zsh.vim | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/runtime/ftplugin/zsh.vim b/runtime/ftplugin/zsh.vim index 741f31b42c..53ce1417dd 100644 --- a/runtime/ftplugin/zsh.vim +++ b/runtime/ftplugin/zsh.vim @@ -2,7 +2,7 @@ " Language: Zsh shell script " Maintainer: Christian Brabandt " Previous Maintainer: Nikolai Weibull -" Latest Revision: 2020-01-10 +" Latest Revision: 2020-09-01 " License: Vim (see :h license) " Repository: https://github.com/chrisbra/vim-zsh @@ -19,20 +19,21 @@ setlocal comments=:# commentstring=#\ %s formatoptions-=t formatoptions+=croql let b:undo_ftplugin = "setl com< cms< fo< " if executable('zsh') - if !has('gui_running') && executable('less') - command! -buffer -nargs=1 RunHelp silent exe '!zsh -ic "autoload -Uz run-help; run-help 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 "' - else - command! -buffer -nargs=1 RunHelp echo system('zsh -ic "autoload -Uz run-help; run-help 2>/dev/null"') - endif + if !has('gui_running') && executable('less') + command! -buffer -nargs=1 RunHelp silent exe '!MANPAGER= zsh -ic "autoload -Uz run-help; run-help 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 "' + else + command! -buffer -nargs=1 RunHelp echo system('zsh -ic "autoload -Uz run-help; run-help 2>/dev/null"') + endif + if !exists('current_compiler') + compiler zsh + endif setlocal keywordprg=:RunHelp - setlocal makeprg=zsh\ -n\ --\ %:S - setlocal errorformat=%f:\ line\ %l:\ %m - let b:undo_ftplugin .= 'keywordprg< errorformat< makeprg<' + let b:undo_ftplugin .= 'keywordprg<' endif -let b:match_words = ',\:\:\:\' +let b:match_words = '\:\:\:\' \ . ',\:^\s*([^)]*):\' \ . ',\<\%(select\|while\|until\|repeat\|for\%(each\)\=\)\>:\' let b:match_skip = 's:comment\|string\|heredoc\|subst' From 55fed9a2b0f33b2d86d45718c5c235ce62de05fa Mon Sep 17 00:00:00 2001 From: Saad Parwaiz Date: Wed, 27 Jan 2021 19:56:26 +0000 Subject: [PATCH 6/6] runtime/zsh: 23515b4ef7580af8b9d3b964a558ab2007cacda5 port zsh compiler only --- runtime/compiler/zsh.vim | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 runtime/compiler/zsh.vim diff --git a/runtime/compiler/zsh.vim b/runtime/compiler/zsh.vim new file mode 100644 index 0000000000..5703c1fc44 --- /dev/null +++ b/runtime/compiler/zsh.vim @@ -0,0 +1,23 @@ +" Vim compiler file +" Compiler: Zsh +" Maintainer: Doug Kearns +" 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 +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