runtime(help): Update syntax, add vim9 example language

"vim9" is Vim9 script and "vim" is legacy script.

See: https://github.com/vim/vim/pull/18350#discussion_r2372462539

closes: #18407

Signed-off-by: Doug Kearns <dougkearns@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
Doug Kearns
2025-09-28 18:06:04 +00:00
committed by Christian Brabandt
parent ae20d732ae
commit 3a56139398
6 changed files with 24 additions and 9 deletions

View File

@ -18,7 +18,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") =~# '\n\s*vim9\%[script]\>'
function s:has(feature)
return has(a:feature) || index(get(g:, "vimsyn_vim_features", []), a:feature) != -1

View File

@ -1,7 +1,7 @@
" Vim syntax file
" Language: Vim help file
" Maintainer: Doug Kearns <dougkearns@gmail.com>
" Last Change: 2025 Jul 20
" Last Change: 2025 Sep 27
" Former Maintainer: Bram Moolenaar <Bram@vim.org>
" Quit when a (custom) syntax file was already loaded
@ -15,7 +15,7 @@ set cpo&vim
syn iskeyword @,48-57,_,192-255
if !exists('g:help_example_languages')
let g:help_example_languages = #{ vim: 'vim' }
let g:help_example_languages = #{ vim: 'vim', vim9: 'vim' }
endif
syn match helpHeadline "^[A-Z.][-A-Z0-9 .,()_']*?\=\ze\(\s\+\*\|$\)"
@ -32,10 +32,19 @@ endif
for [s:lang, s:syntax] in g:help_example_languages->items()
unlet! b:current_syntax
if s:lang == "vim9"
let b:vimsyn_force_vim9 = v:true
endif
" silent! to prevent E403
execute 'silent! syn include' $'@helpExampleHighlight_{s:lang}'
\ $'syntax/{s:syntax}.vim'
if s:lang == "vim9"
unlet b:vimsyn_force_vim9
endif
execute $'syn region helpExampleHighlight_{s:lang} matchgroup=helpIgnore'
\ $'start=/\%(^\| \)>{s:lang}$/'
\ 'end=/^[^ \t]/me=e-1 end=/^</'

View File

@ -18,7 +18,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") =~# '\n\s*vim9\%[script]\>'
function s:has(feature)
return has(a:feature) || index(get(g:, "vimsyn_vim_features", []), a:feature) != -1