mirror of
https://github.com/neovim/neovim.git
synced 2026-08-29 18:41:48 +00:00
vim-patch:9a899af: 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: vim/vim#20647 (reported by Maxim Kim).
closes: vim/vim#20654
9a899af7e8
Co-authored-by: Doug Kearns <dougkearns@gmail.com>
This commit is contained in:
@@ -5,7 +5,8 @@
|
||||
" Contributors: Riley Bruins <ribru17@gmail.com> ('commentstring')
|
||||
" @Konfekt
|
||||
" @tpope (s:Help())
|
||||
" Last Change: 2026 May 31
|
||||
" @lacygoill
|
||||
" Last Change: 2026 Jun 27
|
||||
|
||||
" Only do this when not done yet for this buffer
|
||||
if exists("b:did_ftplugin")
|
||||
@@ -103,7 +104,7 @@ command! -buffer -nargs=1 VimKeywordPrg :exe 'help' s:Help(<q-args>)
|
||||
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:##,:#\\\ ,:#
|
||||
|
||||
@@ -17,7 +17,8 @@ set cpo&vim
|
||||
|
||||
" Feature testing {{{1
|
||||
|
||||
let s:vim9script = "\n" .. getline(1, 32)->join("\n") =~# '\n\s*vim9\%[script]\>'
|
||||
" NOTE: vimsyn_force_vim9 for internal use only
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user