0
0
mirror of https://github.com/vim/vim.git synced 2025-09-23 03:43:49 -04:00

runtime(vim): Update base-syntax, improve :let-heredoc highlighting

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: #15511

Signed-off-by: Doug Kearns <dougkearns@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
Doug Kearns
2024-08-16 21:07:15 +02:00
committed by Christian Brabandt
parent 8f3f78546f
commit d164f2a521
15 changed files with 280 additions and 12 deletions

View File

@@ -3,7 +3,7 @@
" Maintainer: Hirohito Higashi <h.east.727 ATMARK gmail.com>
" Doug Kearns <dougkearns@gmail.com>
" URL: https://github.com/vim-jp/syntax-vim-ex
" Last Change: 2024 Jul 23
" Last Change: 2024 Aug 16
" Former Maintainer: Charles E. Campbell
" DO NOT CHANGE DIRECTLY.
@@ -480,11 +480,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
" =============
@@ -564,7 +565,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