]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
runtime(help): Add Vim lang annotation support for codeblocks
authorShougo Matsushita <Shougo.Matsu@gmail.com>
Sun, 15 Dec 2024 19:47:37 +0000 (20:47 +0100)
committerChristian Brabandt <cb@256bit.org>
Sun, 15 Dec 2024 19:52:45 +0000 (20:52 +0100)
closes: #16215

Co-authored-by: zeertzjq <zeertzjq@outlook.com>
Signed-off-by: Shougo Matsushita <Shougo.Matsu@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
runtime/doc/helphelp.txt
runtime/syntax/help.vim

index 3da38ecc516e044dc3b507dce7c23a2ab092e4ba..948ef724889d8cfbc807b3ad336997c8cabf0f18 100644 (file)
@@ -1,4 +1,4 @@
-*helphelp.txt* For Vim version 9.1.  Last change: 2024 Nov 19
+*helphelp.txt* For Vim version 9.1.  Last change: 2024 Dec 15
 
 
                  VIM REFERENCE MANUAL    by Bram Moolenaar
@@ -437,7 +437,13 @@ also implicitly stops the block of ex-commands before it.  E.g. >
        echo "Example"
     endfunction
 <
-
+It's possible to add Vim syntax highlighting support to code examples.  This
+can be done by adding "vim" after the greater than (>) character (">vim").
+E.g: >vim
+    function Example_Func()
+       echo "Example"
+    endfunction
+<
 The following are highlighted differently in a Vim help file:
   - a special key name expressed either in <> notation as in <PageDown>, or
     as a Ctrl character as in CTRL-X
index ae7e3bc6a7c08629d6a4077317aecf4d6b94ddd8..3886164b334a62490787cb1ef02f1193273e9c7f 100644 (file)
@@ -1,7 +1,7 @@
 " Vim syntax file
 " Language:    Vim help file
 " Maintainer:  The Vim Project <https://github.com/vim/vim>
-" Last Change: 2024 Oct 16
+" Last Change: 2024 Dec 15
 " Former Maintainer:   Bram Moolenaar <Bram@vim.org>
 
 " Quit when a (custom) syntax file was already loaded
@@ -15,10 +15,22 @@ set cpo&vim
 syn match helpHeadline         "^[A-Z.][-A-Z0-9 .,()_']*?\=\ze\(\s\+\*\|$\)"
 syn match helpSectionDelim     "^===.*===$"
 syn match helpSectionDelim     "^---.*--$"
+
+unlet! b:current_syntax
+" sil! to prevent E403
+silent! syntax include @VimScript syntax/vim.vim
 if has("conceal")
   syn region helpExample       matchgroup=helpIgnore start=" >$" start="^>$" end="^[^ \t]"me=e-1 end="^<" concealends
-else
-  syn region helpExample       matchgroup=helpIgnore start=" >$" start="^>$" end="^[^ \t]"me=e-1 end="^<"
+  syn region helpExampleVimScript matchgroup=helpIgnore
+        \ start=/^>vim$/ start=/ >vim$/
+        \ end=/^[^ \t]/me=e-1 end=/^</ concealends
+        \ contains=@VimScript keepend
+ else
+   syn region helpExample      matchgroup=helpIgnore start=" >$" start="^>$" end="^[^ \t]"me=e-1 end="^<"
+   syn region helpExampleVimScript matchgroup=helpIgnore
+         \ start=/^>vim$/ start=/ >vim$/
+         \ end=/^[^ \t]/me=e-1 end=/^</
+         \ contains=@VimScript keepend
 endif
 if has("ebcdic")
   syn match helpHyperTextJump  "\\\@<!|[^"*|]\+|" contains=helpBar