comparison runtime/syntax/zsh.vim @ 19646:847a300aa244

Update runtime files Commit: https://github.com/vim/vim/commit/b17893aa940dc7d45421f875f5d90855880aad27 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Mar 14 08:19:51 2020 +0100 Update runtime files
author Bram Moolenaar <Bram@vim.org>
date Sat, 14 Mar 2020 08:30:08 +0100
parents 6d11fc4aa683
children 29c5f168c6fd
comparison
equal deleted inserted replaced
19645:c4e27eead327 19646:847a300aa244
1 " Vim syntax file 1 " Vim syntax file
2 " Language: Zsh shell script 2 " Language: Zsh shell script
3 " Maintainer: Christian Brabandt <cb@256bit.org> 3 " Maintainer: Christian Brabandt <cb@256bit.org>
4 " Previous Maintainer: Nikolai Weibull <now@bitwi.se> 4 " Previous Maintainer: Nikolai Weibull <now@bitwi.se>
5 " Latest Revision: 2018-07-13 5 " Latest Revision: 2020-01-23
6 " License: Vim (see :h license) 6 " License: Vim (see :h license)
7 " Repository: https://github.com/chrisbra/vim-zsh 7 " Repository: https://github.com/chrisbra/vim-zsh
8 8
9 if exists("b:current_syntax") 9 if exists("b:current_syntax")
10 finish 10 finish
11 endif 11 endif
12 12
13 let s:cpo_save = &cpo 13 let s:cpo_save = &cpo
14 set cpo&vim 14 set cpo&vim
15 15
16 if v:version > 704 || (v:version == 704 && has("patch1142")) 16 function! s:ContainedGroup()
17 syn iskeyword @,48-57,_,192-255,#,- 17 " needs 7.4.2008 for execute() function
18 else 18 let result='TOP'
19 setlocal iskeyword+=- 19 " vim-pandoc syntax defines the @langname cluster for embedded syntax languages
20 endif 20 " However, if no syntax is defined yet, `syn list @zsh` will return
21 " "No syntax items defined", so make sure the result is actually a valid syn cluster
22 for cluster in ['markdownHighlightzsh', 'zsh']
23 try
24 " markdown syntax defines embedded clusters as @markdownhighlight<lang>,
25 " pandoc just uses @<lang>, so check both for both clusters
26 let a=split(execute('syn list @'. cluster), "\n")
27 if len(a) == 2 && a[0] =~# '^---' && a[1] =~? cluster
28 return '@'. cluster
29 endif
30 catch /E392/
31 " ignore
32 endtry
33 endfor
34 return result
35 endfunction
36
37 let s:contained=s:ContainedGroup()
38
39 syn iskeyword @,48-57,_,192-255,#,-
21 if get(g:, 'zsh_fold_enable', 0) 40 if get(g:, 'zsh_fold_enable', 0)
22 setlocal foldmethod=syntax 41 setlocal foldmethod=syntax
23 endif 42 endif
24 43
25 syn keyword zshTodo contained TODO FIXME XXX NOTE 44 syn keyword zshTodo contained TODO FIXME XXX NOTE
30 syn region zshComment start='^\s*#' end='^\%(\s*#\)\@!' 49 syn region zshComment start='^\s*#' end='^\%(\s*#\)\@!'
31 \ contains=zshTodo,@Spell fold 50 \ contains=zshTodo,@Spell fold
32 51
33 syn match zshPreProc '^\%1l#\%(!\|compdef\|autoload\).*$' 52 syn match zshPreProc '^\%1l#\%(!\|compdef\|autoload\).*$'
34 53
54 syn match zshPOSIXQuoted '\\[xX][0-9a-fA-F]\{1,2}'
55 syn match zshPOSIXQuoted '\\[0-7]\{1,3}'
56 syn match zshPOSIXQuoted '\\u[0-9a-fA-F]\{1,4}'
57 syn match zshPOSIXQuoted '\\U[1-9a-fA-F]\{1,8}'
35 syn match zshQuoted '\\.' 58 syn match zshQuoted '\\.'
36 syn region zshString matchgroup=zshStringDelimiter start=+"+ end=+"+ 59 syn region zshString matchgroup=zshStringDelimiter start=+"+ end=+"+
37 \ contains=zshQuoted,@zshDerefs,@zshSubst fold 60 \ contains=zshQuoted,@zshDerefs,@zshSubst fold
38 syn region zshString matchgroup=zshStringDelimiter start=+'+ end=+'+ fold 61 syn region zshString matchgroup=zshStringDelimiter start=+'+ end=+'+ fold
39 " XXX: This should probably be more precise, but Zsh seems a bit confused about it itself
40 syn region zshPOSIXString matchgroup=zshStringDelimiter start=+\$'+ 62 syn region zshPOSIXString matchgroup=zshStringDelimiter start=+\$'+
41 \ end=+'+ contains=zshQuoted 63 \ skip=+\\[\\']+ end=+'+ contains=zshPOSIXQuoted,zshQuoted
42 syn match zshJobSpec '%\(\d\+\|?\=\w\+\|[%+-]\)' 64 syn match zshJobSpec '%\(\d\+\|?\=\w\+\|[%+-]\)'
43 65
44 syn keyword zshPrecommand noglob nocorrect exec command builtin - time 66 syn keyword zshPrecommand noglob nocorrect exec command builtin - time
45 67
46 syn keyword zshDelimiter do done end 68 syn keyword zshDelimiter do done end
340 syn match zshNumber '[+-]\=\d\+#[-+]\=\w\+\>' 362 syn match zshNumber '[+-]\=\d\+#[-+]\=\w\+\>'
341 syn match zshNumber '[+-]\=\d\+\.\d\+\>' 363 syn match zshNumber '[+-]\=\d\+\.\d\+\>'
342 364
343 " TODO: $[...] is the same as $((...)), so add that as well. 365 " TODO: $[...] is the same as $((...)), so add that as well.
344 syn cluster zshSubst contains=zshSubst,zshOldSubst,zshMathSubst 366 syn cluster zshSubst contains=zshSubst,zshOldSubst,zshMathSubst
345 syn region zshSubst matchgroup=zshSubstDelim transparent 367 exe 'syn region zshSubst matchgroup=zshSubstDelim transparent start=/\$(/ skip=/\\)/ end=/)/ contains='.s:contained. ' fold'
346 \ start='\$(' skip='\\)' end=')' contains=TOP fold
347 syn region zshParentheses transparent start='(' skip='\\)' end=')' fold 368 syn region zshParentheses transparent start='(' skip='\\)' end=')' fold
348 syn region zshGlob start='(#' end=')' 369 syn region zshGlob start='(#' end=')'
349 syn region zshMathSubst matchgroup=zshSubstDelim transparent 370 syn region zshMathSubst matchgroup=zshSubstDelim transparent
350 \ start='\$((' skip='\\)' end='))' 371 \ start='\$((' skip='\\)' end='))'
351 \ contains=zshParentheses,@zshSubst,zshNumber, 372 \ contains=zshParentheses,@zshSubst,zshNumber,
352 \ @zshDerefs,zshString keepend fold 373 \ @zshDerefs,zshString keepend fold
353 syn region zshBrackets contained transparent start='{' skip='\\}' 374 " The ms=s+1 prevents matching zshBrackets several times on opening brackets
375 " (see https://github.com/chrisbra/vim-zsh/issues/21#issuecomment-576330348)
376 syn region zshBrackets contained transparent start='{'ms=s+1 skip='\\}'
354 \ end='}' fold 377 \ end='}' fold
355 syn region zshBrackets transparent start='{' skip='\\}' 378 exe 'syn region zshBrackets transparent start=/{/ms=s+1 skip=/\\}/ end=/}/ contains='.s:contained. ' fold'
356 \ end='}' contains=TOP fold 379
357 syn region zshSubst matchgroup=zshSubstDelim start='\${' skip='\\}' 380 syn region zshSubst matchgroup=zshSubstDelim start='\${' skip='\\}'
358 \ end='}' contains=@zshSubst,zshBrackets,zshQuoted,zshString fold 381 \ end='}' contains=@zshSubst,zshBrackets,zshQuoted,zshString fold
359 syn region zshOldSubst matchgroup=zshSubstDelim start=+`+ skip=+\\`+ 382 exe 'syn region zshOldSubst matchgroup=zshSubstDelim start=/`/ skip=/\\[\\`]/ end=/`/ contains='.s:contained. ',zshOldSubst fold'
360 \ end=+`+ contains=TOP,zshOldSubst fold
361 383
362 syn sync minlines=50 maxlines=90 384 syn sync minlines=50 maxlines=90
363 syn sync match zshHereDocSync grouphere NONE '<<-\=\s*\%(\\\=\S\+\|\(["']\)\S\+\1\)' 385 syn sync match zshHereDocSync grouphere NONE '<<-\=\s*\%(\\\=\S\+\|\(["']\)\S\+\1\)'
364 syn sync match zshHereDocEndSync groupthere NONE '^\s*EO\a\+\>' 386 syn sync match zshHereDocEndSync groupthere NONE '^\s*EO\a\+\>'
365 387
366 hi def link zshTodo Todo 388 hi def link zshTodo Todo
367 hi def link zshComment Comment 389 hi def link zshComment Comment
368 hi def link zshPreProc PreProc 390 hi def link zshPreProc PreProc
369 hi def link zshQuoted SpecialChar 391 hi def link zshQuoted SpecialChar
392 hi def link zshPOSIXQuoted SpecialChar
370 hi def link zshString String 393 hi def link zshString String
371 hi def link zshStringDelimiter zshString 394 hi def link zshStringDelimiter zshString
372 hi def link zshPOSIXString zshString 395 hi def link zshPOSIXString zshString
373 hi def link zshJobSpec Special 396 hi def link zshJobSpec Special
374 hi def link zshPrecommand Special 397 hi def link zshPrecommand Special