From: Doug Kearns Date: Sun, 28 Jun 2026 17:22:16 +0000 (+0000) Subject: runtime(vim): Fix heredoc triggering misidentifcation of Vim9 script X-Git-Tag: v9.2.0743~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9a899af7e8e74bb094cfdfda857580b2e8ddf840;p=thirdparty%2Fvim.git runtime(vim): Fix heredoc triggering misidentifcation of Vim9 script The following let-heredoc can cause legacy scripts to be misidentified as Vim9 script if it appears early in the file. Only match :vim9script at the start of a line where it sensibly belongs. let x =<< trim LINES vim9script ... LINES fixes: #20647 (reported by Maxim Kim). closes: #20654 Signed-off-by: Doug Kearns Signed-off-by: Christian Brabandt --- diff --git a/runtime/ftplugin/vim.vim b/runtime/ftplugin/vim.vim index 21ca040fa6..b54cb48f02 100644 --- a/runtime/ftplugin/vim.vim +++ b/runtime/ftplugin/vim.vim @@ -6,7 +6,7 @@ " @Konfekt " @tpope (s:Help()) " @lacygoill -" Last Change: 2026 May 31 +" Last Change: 2026 Jun 27 " Only do this when not done yet for this buffer if exists("b:did_ftplugin") @@ -107,7 +107,7 @@ command! -buffer -nargs=1 VimKeywordPrg :exe 'help' s:Help() setlocal keywordprg=:VimKeywordPrg " Comments starts with # in Vim9 script. We have to guess which one to use. -if "\n" .. getline(1, 32)->join("\n") =~# '\n\s*vim9\%[script]\>' +if "\n" .. getline(1, 32)->join("\n") =~# '\nvim9s\%[cript]\>' setlocal commentstring=#\ %s " Set 'comments' to format dashed lists in comments, for Vim9 script. setlocal com=sO:#\ -,mO:#\ \ ,eO:##,:#\\\ ,:# diff --git a/runtime/syntax/generator/vim.vim.base b/runtime/syntax/generator/vim.vim.base index 309ef2a9ba..5b20d1ddff 100644 --- a/runtime/syntax/generator/vim.vim.base +++ b/runtime/syntax/generator/vim.vim.base @@ -2,7 +2,7 @@ " Language: Vim script " Maintainer: Hirohito Higashi " Doug Kearns -" Last Change: 2026 Jun 12 +" Last Change: 2026 Jun 27 " Former Maintainer: Charles E. Campbell " DO NOT CHANGE DIRECTLY. @@ -19,7 +19,7 @@ set cpo&vim " Feature testing {{{1 " NOTE: vimsyn_force_vim9 for internal use only -let s:vim9script = get(b:, "vimsyn_force_vim9", v:false) || "\n" .. getline(1, 32)->join("\n") =~# '\n\s*vim9\%[script]\>' +let s:vim9script = get(b:, "vimsyn_force_vim9", v:false) || "\n" .. getline(1, 32)->join("\n") =~# '\nvim9s\%[cript]\>' function s:has(feature) return has(a:feature) || index(get(g:, "vimsyn_vim_features", []), a:feature) != -1 diff --git a/runtime/syntax/vim.vim b/runtime/syntax/vim.vim index 08d2a2b85b..60e584dccb 100644 --- a/runtime/syntax/vim.vim +++ b/runtime/syntax/vim.vim @@ -2,7 +2,7 @@ " Language: Vim script " Maintainer: Hirohito Higashi " Doug Kearns -" Last Change: 2026 Jun 12 +" Last Change: 2026 Jun 27 " Former Maintainer: Charles E. Campbell " DO NOT CHANGE DIRECTLY. @@ -19,7 +19,7 @@ set cpo&vim " Feature testing {{{1 " NOTE: vimsyn_force_vim9 for internal use only -let s:vim9script = get(b:, "vimsyn_force_vim9", v:false) || "\n" .. getline(1, 32)->join("\n") =~# '\n\s*vim9\%[script]\>' +let s:vim9script = get(b:, "vimsyn_force_vim9", v:false) || "\n" .. getline(1, 32)->join("\n") =~# '\nvim9s\%[cript]\>' function s:has(feature) return has(a:feature) || index(get(g:, "vimsyn_vim_features", []), a:feature) != -1