diff --git a/runtime/doc/vim9.txt b/runtime/doc/vim9.txt index 3de4a75e9b..70c8cdb32d 100644 --- a/runtime/doc/vim9.txt +++ b/runtime/doc/vim9.txt @@ -1,4 +1,4 @@ -*vim9.txt* For Vim version 9.1. Last change: 2025 Aug 27 +*vim9.txt* For Vim version 9.1. Last change: 2025 Sep 30 VIM REFERENCE MANUAL by Bram Moolenaar @@ -2083,14 +2083,16 @@ original value to get the same effect. The order of flags may change. In the |vimrc| file sourced on startup this does not happen. *vim9-mix* -There is one way to use both legacy and Vim9 syntax in one script file: > - " comments may go here +There is one way to use both legacy and Vim9 syntax in one script file: >vim9 + + " legacy Vim script comments may go here if !has('vim9script') - " legacy script commands go here + " legacy Vim script commands go here finish endif vim9script # Vim9 script commands go here + This allows for writing a script that takes advantage of the Vim9 script syntax if possible, but will also work on a Vim version without it. diff --git a/runtime/syntax/help.vim b/runtime/syntax/help.vim index 35b4572bfa..2d07b7018f 100644 --- a/runtime/syntax/help.vim +++ b/runtime/syntax/help.vim @@ -1,7 +1,7 @@ " Vim syntax file " Language: Vim help file " Maintainer: Doug Kearns -" Last Change: 2025 Sep 27 +" Last Change: 2025 Sep 29 " Former Maintainer: Bram Moolenaar " Quit when a (custom) syntax file was already loaded @@ -53,6 +53,15 @@ for [s:lang, s:syntax] in g:help_example_languages->items() endfor unlet! s:lang s:syntax +if has_key(g:help_example_languages, "vim9") + " for example at :help vim9-mix + syn region vim9LegacyHeader_HelpExample + \ start=+" legacy Vim script comments may go here+ + \ end="^\ze\s*vim9s\%[cript]\>" + \ contains=@vimLegacyTop,vimComment,vimLineComment + syn cluster helpExampleHighlight_vim9 add=vim9LegacyHeader_HelpExample +endif + if has("ebcdic") syn match helpHyperTextJump "\\\@v|i|m|:| |s|e|t| |f|t|=|h|e|l|p|:| @57 -|~+0#4040ff13&| @73 -|~| @73 -|~| @73 -|~| @73 -|~| @73 -|~| @73 -|~| @73 -|~| @73 -|~| @73 -|~| @73 -|~| @73 -|~| @73 -|~| @73 -|~| @73 -| +0#0000000&@56|3@1|,|1| @9|B|o|t| +@75 +>E+0#e000e06&|X|A|M|P|L|E| |L|A|N|G|U|A|G|E|S|~+0#ffffff16&| +0#0000000&@56 +@56|*+0#ffffff16&|v+0#e000002&|i|m|9|-|m|i|x|*+0#ffffff16&| +0#0000000&@8 +|T|h|e|r|e| |i|s| |o|n|e| |w|a|y| |t|o| |u|s|e| |b|o|t|h| |l|e|g|a|c|y| |a|n|d| |V|i|m|9| |s|y|n|t|a|x| |i|n| |o|n|e| |s|c|r|i|p|t| |f|i|l|e|:| +0#ffffff16&|>|v|i +|m|9| +0#0000000&@72 +@75 +@8|"+0#0000e05&| |l|e|g|a|c|y| |V|i|m| |s|c|r|i|p|t| |c|o|m@1|e|n|t|s| |m|a|y| |g|o| |h|e|r|e| +0#0000000&@26 +@8|i+0#af5f00255&|f| +0#0000000&|!+0#af5f00255&|h+0#00e0e07&|a|s|(+0#e000e06&|'+0#e000002&|v|i|m|9|s|c|r|i|p|t|'|)+0#e000e06&| +0#0000000&@45 +@11|"+0#0000e05&| |l|e|g|a|c|y| |V|i|m| |s|c|r|i|p|t| |c|o|m@1|a|n|d|s| |g|o| |h|e|r|e| +0#0000000&@27 +@11|f+0#af5f00255&|i|n|i|s|h| +0#0000000&@57 +@8|e+0#af5f00255&|n|d|i|f| +0#0000000&@61 +@8|v+0#af5f00255&|i|m|9|s|c|r|i|p|t| +0#0000000&@56 +@8|#+0#0000e05&| |V|i|m|9| |s|c|r|i|p|t| |c|o|m@1|a|n|d|s| |g|o| |h|e|r|e| +0#0000000&@36 +@75 +|T|h|i|s| |a|l@1|o|w|s| |f|o|r| |w|r|i|t|i|n|g| |a| |s|c|r|i|p|t| |t|h|a|t| |t|a|k|e|s| |a|d|v|a|n|t|a|g|e| |o|f| |t|h|e| |V|i|m|9| |s|c|r|i|p|t| @2 +@57|3|4|,|1| @9|9|0|%| diff --git a/runtime/syntax/testdir/dumps/help_03.dump b/runtime/syntax/testdir/dumps/help_03.dump new file mode 100644 index 0000000000..f403f1cebc --- /dev/null +++ b/runtime/syntax/testdir/dumps/help_03.dump @@ -0,0 +1,20 @@ +|T+0&#ffffff0|h|i|s| |a|l@1|o|w|s| |f|o|r| |w|r|i|t|i|n|g| |a| |s|c|r|i|p|t| |t|h|a|t| |t|a|k|e|s| |a|d|v|a|n|t|a|g|e| |o|f| |t|h|e| |V|i|m|9| |s|c|r|i|p|t| @2 +|s|y|n|t|a|x| |i|f| |p|o|s@1|i|b|l|e|,| |b|u|t| |w|i|l@1| |a|l|s|o| |w|o|r|k| |o|n| |a| |V|i|m| |v|e|r|s|i|o|n| |w|i|t|h|o|u|t| |i|t|.| @7 +@75 +@1>v|i|m|:|t|w|=|7|8|:|t|s|=|8|:|n|o|e|t|:|f|t|=|h|e|l|p|:|n|o|r|l|:| @40 +|~+0#4040ff13&| @73 +|~| @73 +|~| @73 +|~| @73 +|~| @73 +|~| @73 +|~| @73 +|~| @73 +|~| @73 +|~| @73 +|~| @73 +|~| @73 +|~| @73 +|~| @73 +|~| @73 +| +0#0000000&@56|4|9|,|2| @9|B|o|t| diff --git a/runtime/syntax/testdir/input/help.txt b/runtime/syntax/testdir/input/help.txt index 37f34a9340..fd56f9cd0d 100644 --- a/runtime/syntax/testdir/input/help.txt +++ b/runtime/syntax/testdir/input/help.txt @@ -30,4 +30,20 @@ however, that any long directory names will appear in their short (MS-DOS) form on some Windows versions. This is a limitation of the Windows "Send To" mechanism. -vim: set ft=help: + +EXAMPLE LANGUAGES~ + *vim9-mix* +There is one way to use both legacy and Vim9 syntax in one script file: >vim9 + + " legacy Vim script comments may go here + if !has('vim9script') + " legacy Vim script commands go here + finish + endif + vim9script + # Vim9 script commands go here + +This allows for writing a script that takes advantage of the Vim9 script +syntax if possible, but will also work on a Vim version without it. + + vim:tw=78:ts=8:noet:ft=help:norl: