vim-patch:1341176: runtime(vim): Update help syntax file, improve highlighting of included Vim examples (#34924)

- Take over as file maintainer.
- Improve highlighting of legacy script examples by using :syn-iskeyword
  with the default 'iskeyword' value. Vim9 script examples are not
  supported yet.
- Match admonition labels in more contexts.
- Match URLs in more contexts.

fixes vim/vim#17721
closes: vim/vim#17731

1341176e7b

Co-authored-by: Doug Kearns <dougkearns@gmail.com>
This commit is contained in:
zeertzjq
2025-07-14 07:11:22 +08:00
committed by GitHub
parent f487ae90cf
commit 9f16b598f9
2 changed files with 26 additions and 15 deletions

View File

@ -200,7 +200,7 @@ command: >vim
Or put this line in your |vimrc|: >vim Or put this line in your |vimrc|: >vim
packadd! justify :packadd! justify
This Vim script file defines a new visual command "_j". To justify a block of This Vim script file defines a new visual command "_j". To justify a block of
text, highlight the text in Visual mode and then execute "_j". text, highlight the text in Visual mode and then execute "_j".

View File

@ -1,7 +1,7 @@
" Vim syntax file " Vim syntax file
" Language: Vim help file " Language: Vim help file
" Maintainer: The Vim Project <https://github.com/vim/vim> " Maintainer: Doug Kearns <dougkearns@gmail.com>
" Last Change: 2024 Dec 15 " Last Change: 2025 Jul 12
" Former Maintainer: Bram Moolenaar <Bram@vim.org> " Former Maintainer: Bram Moolenaar <Bram@vim.org>
" Quit when a (custom) syntax file was already loaded " Quit when a (custom) syntax file was already loaded
@ -12,6 +12,8 @@ endif
let s:cpo_save = &cpo let s:cpo_save = &cpo
set cpo&vim set cpo&vim
syn iskeyword @,48-57,_,192-255
if !exists('g:help_example_languages') if !exists('g:help_example_languages')
let g:help_example_languages = #{ vim: 'vim' } let g:help_example_languages = #{ vim: 'vim' }
endif endif
@ -73,24 +75,32 @@ if has("conceal")
else else
syn match helpIgnore "." contained syn match helpIgnore "." contained
endif endif
syn keyword helpNote note Note NOTE note: Note: NOTE: Notes Notes:
syn match helpNote "\c(note\(:\|\>\)"ms=s+1
syn keyword helpWarning WARNING WARNING: Warning:
syn keyword helpDeprecated DEPRECATED DEPRECATED: Deprecated:
syn match helpSpecial "\<N\>"
syn match helpSpecial "\<N\.$"me=e-1
syn match helpSpecial "\<N\.\s"me=e-2
syn match helpSpecial "(N\>"ms=s+1
" match 'iskeyword' word boundaries, '!-~,^*,^|,^",192-255'
let s:iskeyword = '!#-)+-{}~\d192-\d255'
let s:start_word = $'\%(^\|[^{s:iskeyword}]\)\@1<='
let s:end_word = $'\%([^{s:iskeyword}]\|$\)\@='
exec $'syn match helpNote "{s:start_word}\%(note\|Note\|NOTE\|Notes\):\={s:end_word}"'
exec $'syn match helpNote "\c[[(]note\%(:\|{s:end_word}\)"ms=s+1'
exec $'syn match helpWarning "{s:start_word}\%(WARNING:\=\|Warning:\){s:end_word}"'
exec $'syn match helpDeprecated "{s:start_word}\%(DEPRECATED:\=\|Deprecated:\){s:end_word}"'
exec $'syn match helpSpecial "{s:start_word}N{s:end_word}"'
exec $'syn match helpSpecial "{s:start_word}N\.$"me=e-1'
exec $'syn match helpSpecial "{s:start_word}N\.\s"me=e-2'
exec $'syn match helpSpecial "(N{s:end_word}"ms=s+1'
syn match helpSpecial "\[N]" syn match helpSpecial "\[N]"
" avoid highlighting N N in quickref.txt " avoid highlighting N N in quickref.txt
syn match helpSpecial "N N"he=s+1 syn match helpSpecial "N N"he=s+1
syn match helpSpecial "Nth"me=e-2 syn match helpSpecial "Nth"me=e-2
syn match helpSpecial "N-1"me=e-2 syn match helpSpecial "N-1"me=e-2
" highlighting N for :resize in windows.txt " highlighting N for :resize in windows.txt
syn match helpSpecial "] -N\>"ms=s+3 exec $'syn match helpSpecial "] -N{s:end_word}"ms=s+3'
syn match helpSpecial "+N\>"ms=s+1 exec $'syn match helpSpecial "+N{s:end_word}"ms=s+1'
syn match helpSpecial "\[+-]N\>"ms=s+4 exec $'syn match helpSpecial "\[+-]N{s:end_word}"ms=s+4'
unlet s:iskeyword s:start_word s:end_word
" highlighting N of cinoptions-values in indent.txt " highlighting N of cinoptions-values in indent.txt
syn match helpSpecial "^\t-\?\zsNs\?\s"me=s+1 syn match helpSpecial "^\t-\?\zsNs\?\s"me=s+1
" highlighting N of cinoptions-values in indent.txt " highlighting N of cinoptions-values in indent.txt
@ -177,6 +187,7 @@ let s:i = match(expand("%"), '\.\a\ax$')
if s:i > 0 if s:i > 0
exe "runtime syntax/help_" . strpart(expand("%"), s:i + 1, 2) . ".vim" exe "runtime syntax/help_" . strpart(expand("%"), s:i + 1, 2) . ".vim"
endif endif
unlet s:i
syn sync minlines=40 syn sync minlines=40