runtime/zsh: b17893aa940dc7d45421f875f5d90855880aad27

port zsh syntax file only
This commit is contained in:
Saad Parwaiz
2021-01-27 19:00:04 +00:00
parent 44802202be
commit d89cbb62ab

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-07-13 " Latest Revision: 2020-01-23
" 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,11 +13,30 @@ 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
" 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 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
@@ -32,13 +51,16 @@ syn region zshComment start='^\s*#' end='^\%(\s*#\)\@!'
syn match zshPreProc '^\%1l#\%(!\|compdef\|autoload\).*$' 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 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
@@ -342,22 +364,22 @@ 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\)'
@@ -367,6 +389,7 @@ 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