vim-patch:d164f2a: runtime(vim): Update base-syntax, improve :let-heredoc highlighting (#30069)

The end marker must appear on line of its own without any trailing
whitespace.

Whitespace is incorrectly allowed before all end markers.  Limiting this
only to heredocs where "trim" was specified, and with the correct
indent, is currently an intractable problem given that contained syntax
groups (in this case :let) cannot be limited to start patterns.

Highlight interpolated expressions when "eval" is specified.

cloess: vim/vim#15511

d164f2a521

Co-authored-by: Doug Kearns <dougkearns@gmail.com>
This commit is contained in:
zeertzjq 2024-08-17 07:09:39 +08:00 committed by GitHub
parent d698b3acca
commit 172cc23d88
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -433,11 +433,12 @@ syn match vimEscape contained "\\\o\{1,3}\|\\[xX]\x\{1,2}\|\\u\x\{1,4}\|\\U\x\{1
syn match vimEscape contained "\\<" contains=vimNotation
syn match vimEscape contained "\\<\*[^>]*>\=>"
syn region vimString oneline start=+$'+ skip=+''+ end=+'+ contains=vimStringInterpolationBrace,vimStringInterpolationExpr
syn region vimString oneline start=+$"+ end=+"+ contains=@vimStringGroup,vimStringInterpolationBrace,vimStringInterpolationExpr
syn region vimString oneline start=+$'+ skip=+''+ end=+'+ contains=@vimStringInterpolation
syn region vimString oneline start=+$"+ end=+"+ contains=@vimStringGroup,@vimStringInterpolation
syn region vimStringInterpolationExpr oneline contained matchgroup=vimSep start=+{+ end=+}+ contains=@vimExprList
syn match vimStringInterpolationBrace contained "{{"
syn match vimStringInterpolationBrace contained "}}"
syn cluster vimStringInterpolation contains=vimStringInterpolationExpr,vimStringInterpolationBrace
" Substitutions: {{{2
" =============
@ -517,7 +518,13 @@ VimL syn keyword vimUnlet unl[et] skipwhite nextgroup=vimUnletBang,vimUnletVars
syn match vimUnletBang contained "!" skipwhite nextgroup=vimUnletVars
syn region vimUnletVars contained start="$\I\|\h" skip="\n\s*\\" end="$" end="|" contains=vimVar,vimEnvvar,vimContinue,vimString,vimNumber
VimFoldh syn region vimLetHereDoc matchgroup=vimLetHereDocStart start='=<<\s*\%(trim\s\+\%(eval\s\+\)\=\|eval\s\+\%(trim\s\+\)\=\)\=\z(\L\S*\)' matchgroup=vimLetHereDocStop end='^\s*\z1\s*$' extend
" Note: This incorrectly matches end markers with leading whitespace even if
" "trim" was not specified. Matching :let indent for "trim" indented
" end markers would require a contained :let that cannot be restricted
" to the start pattern. A common internal testing use of heredocs is to
" specify code blocks where :let commonly appears in the heredoc text.
VimFoldh syn region vimLetHereDoc matchgroup=vimLetHereDocStart start='=<<\s*\%(trim\s\+\)\=\z(\L\S*\)' matchgroup=vimLetHereDocStop end='^\s*\z1$' extend
VimFoldh syn region vimLetHereDoc matchgroup=vimLetHereDocStart start='=<<\s*\%(\%(trim\s\+\)\=eval\s\+\|eval\s\+\%(trim\s\+\)\=\)\z(\L\S*\)' matchgroup=vimLetHereDocStop end='^\s*\z1$' contains=@vimStringInterpolation extend
Vim9 syn keyword vim9Const const skipwhite nextgroup=vim9Variable,vim9VariableList
Vim9 syn keyword vim9Final final skipwhite nextgroup=vim9Variable,vim9VariableList