[vim/vim] Add g:help_example_languages to support language annotation highlighting (PR #16238)

43 views
Skip to first unread message

Shougo

unread,
Dec 17, 2024, 6:29:53 AM12/17/24
to vim/vim, Subscribed

Continues of #16215

I have added g:help_example_languages variable to support language annotation highlighting.
Because markdown has similar feature by g:markdown_fenced_languages.

Before:

2024-12-17_17-52.png (view on web)

After:

2024-12-17_17-55.png (view on web)


You can view, comment on, or merge this pull request online at:

  https://github.com/vim/vim/pull/16238

Commit Summary

  • 8fe8ec9 Add g:help_example_languages to support language annotation highlighting

File Changes

(4 files)

Patch Links:


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/16238@github.com>

Shougo

unread,
Dec 17, 2024, 6:44:44 AM12/17/24
to vim/vim, Push

@Shougo pushed 1 commit.

  • 242dbef Add g:help_example_languages to support language annotation highlighting


View it on GitHub or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/16238/before/8fe8ec97db410ea519c12c0d3d9ca931e7680bcd/after/242dbef1d007219f6e7f76059225852b3be61c92@github.com>

mityu

unread,
Dec 17, 2024, 9:04:53 AM12/17/24
to vim/vim, Subscribed

@mityu commented on this pull request.


In runtime/syntax/help.vim:

>  endif
+
+for [s:lang, s:syntax] in g:help_example_languages->items()
+  unlet! b:current_syntax
+  " silent! to prevent E403
+  execute 'silent! syntax include' $'@Example{s:lang}' $'syntax/{s:syntax}.vim'
+
+  execute $'syn region helpExample{s:lang} matchgroup=helpIgnore'
+        \ $'start=/^>{s:lang}$/ start=/ >{s:lang}$/'
+        \ 'end=/^[^ \t]/me=e-1 end=/^</'
+        \ (has("conceal") ? 'concealends' : '')
+        \ $'contains=@Example{s:lang} keepend'
+endfor
+

How about to unlet s:lang and s:syntax here?


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/16238/review/2508978102@github.com>

h_east

unread,
Dec 17, 2024, 1:16:33 PM12/17/24
to vim/vim, Subscribed

Ummm... I feel like there's something really bothering me, though...

Maybe the match condition ( >[a-z0-9]*$ or ^>[a-z0-9]*$) is too simple.
Is it okay if it's " >|[a-z0-9]+|$", "^>|[a-z0-9]+|$" or " >:[a-z0-9]+:$", "^>:[a-z0-9]+:$"?

Example1: >|vim|
    code1
>

Obviously, the following is the same highlighting as before.

Example2: >
    code2
>


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/16238/c2549245368@github.com>

Christian Clason

unread,
Dec 17, 2024, 1:30:09 PM12/17/24
to vim/vim, Subscribed

You do what works best for you, of course, but Neovim already uses >foo for code block annotations. It would be really nice if plugins could support both editors in their documentation.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/16238/c2549282008@github.com>

Christian Brabandt

unread,
Dec 17, 2024, 2:46:23 PM12/17/24
to vim/vim, Subscribed

@chrisbra commented on this pull request.


In runtime/doc/helphelp.txt:

> @@ -433,17 +433,27 @@ To quote a block of ex-commands verbatim, place a greater than (>) character
 at the end of the line before the block and a less than (<) character as the
 first non-blank on a line following the block.  Any line starting in column 1
 also implicitly stops the block of ex-commands before it.  E.g. >
-    function Example_Func()
-	echo "Example"
-    endfunction
+	function Example_Func()
+	  echo "Example"
+	endfunction

why the indentation change?


In runtime/doc/helphelp.txt:

>  <
-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
+
+To add annotation in the block, place the annotation (ex: "lua") after a
+greater than (>) character.  E.g: >lua
+	print("hello")
+<
⬇️ Suggested change
-<
+<
+Note: uses lua syntax highlighting, if "lua" is in |g:help_example_languages|.

In runtime/doc/helphelp.txt:

>  <
-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
+
+To add annotation in the block, place the annotation (ex: "lua") after a
+greater than (>) character.  E.g: >lua
+	print("hello")
+<
+In default, it's possible to add Vim syntax highlighting support to code
⬇️ Suggested change
-In default, it's possible to add Vim syntax highlighting support to code
+It's possible to add Vim syntax highlighting support to code

In runtime/doc/helphelp.txt:

>  <
+						 *g:help_example_languages*
+If you want to change the syntax highlighting in the block, you can
+change it like this: >
+	:let g:help_example_languages = #{ vim: 'vim', sh: 'bash' }
+The key is language annotation and the value is syntax name.
+

When not configured, help files support Vim script highlighting only.


In runtime/doc/helphelp.txt:

>  <
+						 *g:help_example_languages*
+If you want to change the syntax highlighting in the block, you can
+change it like this: >
+	:let g:help_example_languages = #{ vim: 'vim', sh: 'bash' }

Perhaps it should be named: g:help_import_languages ?


In runtime/doc/helphelp.txt:

>  <
+						 *g:help_example_languages*
+If you want to change the syntax highlighting in the block, you can
+change it like this: >
+	:let g:help_example_languages = #{ vim: 'vim', sh: 'bash' }
+The key is language annotation and the value is syntax name.
⬇️ Suggested change
-The key is language annotation and the value is syntax name.
+The key is the annotation marker and the value is the 'syntax' name.


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/16238/review/2509920587@github.com>

Shougo

unread,
Dec 17, 2024, 7:20:18 PM12/17/24
to vim/vim, Subscribed

@Shougo commented on this pull request.


In runtime/doc/helphelp.txt:

> @@ -433,17 +433,27 @@ To quote a block of ex-commands verbatim, place a greater than (>) character
 at the end of the line before the block and a less than (<) character as the
 first non-blank on a line following the block.  Any line starting in column 1
 also implicitly stops the block of ex-commands before it.  E.g. >
-    function Example_Func()
-	echo "Example"
-    endfunction
+	function Example_Func()
+	  echo "Example"
+	endfunction

I have read the other example indentation.

It seems indented by tab.


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/16238/review/2510460335@github.com>

Shougo

unread,
Dec 17, 2024, 7:20:30 PM12/17/24
to vim/vim, Push

@Shougo pushed 1 commit.

  • 28fc79a Update runtime/doc/helphelp.txt

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/16238/before/242dbef1d007219f6e7f76059225852b3be61c92/after/28fc79af9fd7515f30cd5d6aba3139c070320adf@github.com>

Shougo

unread,
Dec 17, 2024, 7:22:19 PM12/17/24
to vim/vim, Push

@Shougo pushed 1 commit.

  • e2c368e Update runtime/doc/helphelp.txt

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/16238/before/28fc79af9fd7515f30cd5d6aba3139c070320adf/after/e2c368e69b971e4be8832023c991f031950d6c55@github.com>

Shougo

unread,
Dec 17, 2024, 7:25:29 PM12/17/24
to vim/vim, Subscribed

@Shougo commented on this pull request.


In runtime/doc/helphelp.txt:

>  <
+						 *g:help_example_languages*
+If you want to change the syntax highlighting in the block, you can
+change it like this: >
+	:let g:help_example_languages = #{ vim: 'vim', sh: 'bash' }

Hm... It seems from implementation name.
help_example_languages means it describes the example languages.


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/16238/review/2510466731@github.com>

Shougo

unread,
Dec 17, 2024, 7:25:39 PM12/17/24
to vim/vim, Subscribed

@Shougo commented on this pull request.


In runtime/doc/helphelp.txt:

>  <
+						 *g:help_example_languages*
+If you want to change the syntax highlighting in the block, you can
+change it like this: >
+	:let g:help_example_languages = #{ vim: 'vim', sh: 'bash' }
+The key is language annotation and the value is syntax name.
+

OK.


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/16238/review/2510466871@github.com>

Shougo

unread,
Dec 17, 2024, 7:26:25 PM12/17/24
to vim/vim, Push

@Shougo pushed 1 commit.

  • a5dc2dd Update runtime/doc/helphelp.txt

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/16238/before/e2c368e69b971e4be8832023c991f031950d6c55/after/a5dc2dd5b8ed6a0259dfaac1dfb45ed0051160a3@github.com>

Shougo

unread,
Dec 17, 2024, 7:27:54 PM12/17/24
to vim/vim, Subscribed

@Shougo commented on this pull request.


In runtime/syntax/help.vim:

>  endif
+
+for [s:lang, s:syntax] in g:help_example_languages->items()
+  unlet! b:current_syntax
+  " silent! to prevent E403
+  execute 'silent! syntax include' $'@Example{s:lang}' $'syntax/{s:syntax}.vim'
+
+  execute $'syn region helpExample{s:lang} matchgroup=helpIgnore'
+        \ $'start=/^>{s:lang}$/ start=/ >{s:lang}$/'
+        \ 'end=/^[^ \t]/me=e-1 end=/^</'
+        \ (has("conceal") ? 'concealends' : '')
+        \ $'contains=@Example{s:lang} keepend'
+endfor
+

OK.


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/16238/review/2510469846@github.com>

Shougo

unread,
Dec 17, 2024, 7:34:14 PM12/17/24
to vim/vim, Subscribed

Maybe the match condition ((^| )>[a-z0-9]*$) is too simple.
Is it okay if it's (^| )>|[a-z0-9]+|$ or (^| )>:[a-z0-9]+:$ ?
(Enclose the language name in symbols)

It may be too simple. But markdown syntax uses similar markup like this.

```vim


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/16238/c2549991428@github.com>

Shougo

unread,
Dec 17, 2024, 7:39:41 PM12/17/24
to vim/vim, Push

@Shougo pushed 2 commits.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/16238/before/a5dc2dd5b8ed6a0259dfaac1dfb45ed0051160a3/after/36374d6fc8f4721fc8f52f9cfb070066374baf0e@github.com>

Shougo

unread,
Dec 17, 2024, 7:40:12 PM12/17/24
to vim/vim, Subscribed

I have updated the syntax file.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/16238/c2550003296@github.com>

Shougo

unread,
Dec 17, 2024, 7:45:47 PM12/17/24
to vim/vim, Push

@Shougo pushed 6 commits.

  • ddbfdc1 Add g:help_example_languages to support language annotation highlighting
  • d53c2a2 Update runtime/doc/helphelp.txt
  • 9104ae2 Update runtime/doc/helphelp.txt
  • ef513ac Update runtime/doc/helphelp.txt
  • 1c35613 Fix for reviews
  • 24b1cb0 Improve syntax file

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/16238/before/36374d6fc8f4721fc8f52f9cfb070066374baf0e/after/24b1cb0b81d962ea238881ecff7a770c67850727@github.com>

Shougo

unread,
Dec 17, 2024, 8:24:00 PM12/17/24
to vim/vim, Subscribed

Hm... Why the tests are failed?


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/16238/c2550071305@github.com>

Shougo

unread,
Dec 17, 2024, 8:25:27 PM12/17/24
to vim/vim, Subscribed

@Shougo commented on this pull request.


In runtime/syntax/help.vim:

>  endif
+
+for [s:lang, s:syntax] in g:help_example_languages->items()
+  unlet! b:current_syntax
+  " silent! to prevent E403
+  execute 'silent! syntax include' $'@Example{s:lang}' $'syntax/{s:syntax}.vim'
+
+  execute $'syn region helpExample{s:lang} matchgroup=helpIgnore'
+        \ $'start=/^>{s:lang}$/ start=/ >{s:lang}$/'
+        \ 'end=/^[^ \t]/me=e-1 end=/^</'
+        \ (has("conceal") ? 'concealends' : '')
+        \ $'contains=@Example{s:lang} keepend'
+endfor
+

Fixed.


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/16238/review/2510552295@github.com>

h_east

unread,
Dec 18, 2024, 4:12:32 AM12/18/24
to vim/vim, Subscribed

It may be too simple. But markdown syntax uses similar markup like this.

The "simple" here means that there is a high probability that the pattern will match unintentionally in the help text.
That actually existed, right? (Well, it was a bit subtle) --> #16215 (comment)

In that sense, markdown syntax is NOT "simple".

However, the original >$ itself is simple, so I guess it's okay.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/16238/c2550767379@github.com>

zeertzjq

unread,
Dec 18, 2024, 4:18:24 AM12/18/24
to vim/vim, Subscribed

Maybe the pattern can be added only for every language in the list instead of [a-z]* to avoid false positives?


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/16238/c2550790663@github.com>

h_east

unread,
Dec 18, 2024, 4:36:21 AM12/18/24
to vim/vim, Subscribed

@h-east commented on this pull request.


In runtime/syntax/help.vim:

>  endif
+
+for [s:lang, s:syntax] in g:help_example_languages->items()
+  unlet! b:current_syntax
+  " silent! to prevent E403
+  execute 'silent! syn include' $'@helpExampleHighlight_{s:lang}'
+        \ $'syntax/{s:syntax}.vim'
+
+  execute $'syn region helpExampleHighlight_{s:lang} matchgroup=helpIgnore'
+        \ $'start=/^>{s:lang}$/ start=/ >{s:lang}$/'

This also inspires me 😜

⬇️ Suggested change
-        \ $'start=/^>{s:lang}$/ start=/ >{s:lang}$/'
+        \ $'start=/\%(^\| \)>{s:lang}$/'


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/16238/review/2511294465@github.com>

h_east

unread,
Dec 18, 2024, 4:47:30 AM12/18/24
to vim/vim, Subscribed

Maybe the pattern can be added only for every language in the list instead of [a-z]* to avoid false positives?

If we do that, I feel like examples in languages not specified in g:help_example_languages will no longer be highlighted with helpExample. Is that okay?


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/16238/c2550858086@github.com>

Shougo

unread,
Dec 18, 2024, 5:05:30 AM12/18/24
to vim/vim, Push

@Shougo pushed 1 commit.

  • d23ccff Update runtime/syntax/help.vim

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/16238/before/24b1cb0b81d962ea238881ecff7a770c67850727/after/d23ccff78b04ca2ee36c5e3f0461dd0d5d20ac0e@github.com>

Shougo

unread,
Dec 18, 2024, 5:11:35 AM12/18/24
to vim/vim, Subscribed

The "simple" here means that there is a high probability that the pattern will match unintentionally in the help text.
That actually existed, right? (Well, it was a bit subtle) --> #16215 (comment)

It might unintentionally conflict with the existing description.
In such cases, it is likely that the markup is not done correctly.

Maybe the pattern can be added only for every language in the list instead of [a-z]* to avoid false positives?

It is possible but ...

If we do that, I feel like examples in languages not specified in g:help_example_languages will no longer be highlighted with helpExample. Is that okay?

Yes. I think it is problem. Even if the unspecified language is not syntax highlighted, I would like to keep the example highlighting.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/16238/c2550914166@github.com>

h_east

unread,
Dec 18, 2024, 9:04:49 AM12/18/24
to vim/vim, Subscribed

@h-east commented on this pull request.

Wouldn't it be better if vim highlighting was always enabled?
I think it would be less confusing if it was always enabled internally, without the need to set it in g:help_example_languages.


In runtime/syntax/help.vim:

> +unlet s:lang
+unlet s:syntax

Error with let g:help_example_languages = {}

line   43:
E108: No such variable: "s:lang"
line   44:
E108: No such variable: "s:syntax"
Press ENTER or type command to continu
⬇️ Suggested change
-unlet s:lang
-unlet s:syntax
+unlet! s:lang
+unlet! s:syntax


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/16238/review/2511935395@github.com>

Aliaksei Budavei

unread,
Dec 18, 2024, 2:13:26 PM12/18/24
to vim/vim, Subscribed

Syntax file maintainers will justifiably balk at rewriting
parts of their files to accommodate arbitrary inclusion.

Currently, they can manage the context of syntax items by
choosing :syn-contained for some and omitting it for other,
and establish :syn-priority among the same scope items by
moving them up and down a file. As soon as their files are
:syn-included, ALL is :syn-contained, with :syn-priority
revised without their consulting!

https://github.com/vim/vim/blob/21c37d7f695077efe6df57806ff35da79adce1d5/runtime/doc/syntax.txt#L5068-L5073

There is already one discrepancy spotted, e.g.:

Head section.
>vim
	if 1
	elseif 0
	else " endif
	endif

	if 1 | elseif 0 | else | endif " endif

	while 0
	endwhile

	while 0 | endwhile " endwhile
 
	print

Tail section.

Well, a naïve fix is as follows:

diff --git a/runtime/syntax/generator/vim.vim.base b/runtime/syntax/generator/vim.vim.base
index 6d67d7b93..81e01a0c5 100644
--- a/runtime/syntax/generator/vim.vim.base
+++ b/runtime/syntax/generator/vim.vim.base
@@ -205,13 +205,13 @@ syn case match
 syn cluster vimCmdList	contains=vimAbb,vimAddress,vimAutoCmd,vimAugroup,vimBehave,vimCall,vimCatch,vimConst,vimDef,vimDefFold,vimDelcommand,@vimEcho,vimEnddef,vimEndfunction,vimExecute,vimIsCommand,vimExtCmd,vimFor,vimFunction,vimFuncFold,vimGlobal,vimHighlight,vimLet,vimLoadkeymap,vimMap,vimMark,vimMatch,vimNotFunc,vimNormal,vimSet,vimSleep,vimSyntax,vimThrow,vimUnlet,vimUnmap,vimUserCmd,vimMenu,vimMenutranslate,@vim9CmdList
 syn cluster vim9CmdList	contains=vim9Class,vim9Const,vim9Enum,vim9Export,vim9Final,vim9For,vim9Interface,vim9Type,vim9Var
 syn match vimCmdSep	"[:|]\+"	skipwhite nextgroup=@vimCmdList,vimSubst1
-syn match vimIsCommand	"\<\%(\h\w*\|[23]mat\%[ch]\)\>"	contains=vimCommand
 syn match vimBang	      contained	"!"
 syn match vimVar	      contained	"\<\h[a-zA-Z0-9#_]*\>"
 syn match vimVar		"\<[bwglstav]:\h[a-zA-Z0-9#_]*\>"
 syn match vimVar	      	"\s\zs&\%([lg]:\)\=\a\+\>"
 syn match vimVar		"\s\zs&t_\S[a-zA-Z0-9]\>"
 syn match vimVar        	"\s\zs&t_k;"
+syn match vimIsCommand	"\<\%(\h\w*\|[23]mat\%[ch]\)\>"	contains=vimCommand
 syn match vimFBVar      contained   "\<[bwglstav]:\h[a-zA-Z0-9#_]*\>"
 syn keyword vimCommand  contained	in
 syn match vimBang	      contained	"!"

BUT, it breaks a test (vim9_ex_loadkeymap), @dkearns.


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/16238/c2552080842@github.com>

Shougo

unread,
Dec 18, 2024, 7:15:31 PM12/18/24
to vim/vim, Push

@Shougo pushed 1 commit.

  • f7e4d2e Update runtime/syntax/help.vim


View it on GitHub or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/16238/before/d23ccff78b04ca2ee36c5e3f0461dd0d5d20ac0e/after/f7e4d2e1026f105b590791bf7ce3d4cecd19ab7e@github.com>

Shougo

unread,
Dec 18, 2024, 7:23:32 PM12/18/24
to vim/vim, Subscribed

Wouldn't it be better if vim highlighting was always enabled?
I think it would be less confusing if it was always enabled internally, without the need to set it in >g:help_example_languages.

The change is possible, but I would like to keep it configurable, including Vim script syntax highlighting.


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/16238/c2552518871@github.com>

Shougo

unread,
Dec 18, 2024, 7:24:05 PM12/18/24
to vim/vim, Push

@Shougo pushed 7 commits.

  • ceb407e Add g:help_example_languages to support language annotation highlighting
  • de0b90b Update runtime/doc/helphelp.txt
  • 567b20b Update runtime/doc/helphelp.txt
  • 11bb2a7 Update runtime/doc/helphelp.txt
  • 8ad76a0 Fix for reviews
  • bc0c786 Improve syntax file
  • bfa123b Update runtime/syntax/help.vim

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/16238/before/f7e4d2e1026f105b590791bf7ce3d4cecd19ab7e/after/bfa123b050eee03af74173190c3bb122c3ad5cc4@github.com>

h_east

unread,
Dec 18, 2024, 8:11:28 PM12/18/24
to vim/vim, Subscribed

Then, add to the documentation the behavior when g:help_example_languages is not defined and the precautions when setting g:help_example_languages.
Current documentation will confuse everyone regarding Vim script highlighting.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/16238/c2552568087@github.com>

Shougo

unread,
Dec 18, 2024, 8:44:28 PM12/18/24
to vim/vim, Subscribed

						 *g:help_example_languages*
If you want to change the syntax highlighting in the block, you can
change it like this: >
	:let g:help_example_languages = #{ vim: 'vim', sh: 'bash' }
The key is the annotation marker name and the value is the 'syntax' name.
When not configured, help files support Vim script highlighting only.

Then, add to the documentation the behavior when g:help_example_languages is not defined and the precautions when setting g:help_example_languages.
Current documentation will confuse everyone regarding Vim script highlighting.

Could you please specify what kind of precautions are necessary?
Could you provide some suggestions?


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/16238/c2552600098@github.com>

h_east

unread,
Dec 18, 2024, 8:58:25 PM12/18/24
to vim/vim, Subscribed

@h-east commented on this pull request.


In runtime/syntax/help.vim:

> +if !exists('g:help_example_languages')
+  let g:help_example_languages = #{ vim: 'vim' }
+endif

Document this.
And, when setting g:help_example_languages, if you do not add vim, vim script syntax highlighting will not be available.


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/16238/review/2513170400@github.com>

Shougo

unread,
Dec 18, 2024, 9:18:03 PM12/18/24
to vim/vim, Subscribed

@Shougo commented on this pull request.


In runtime/syntax/help.vim:

> +if !exists('g:help_example_languages')
+  let g:help_example_languages = #{ vim: 'vim' }
+endif

And, when setting g:help_example_languages, if you do not add vim, vim script syntax highlighting will not be available.

OK. I will add it.

Document this.

I think it is documented by When not configured, help files support Vim script highlighting only.


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/16238/review/2513185652@github.com>

Shougo

unread,
Dec 18, 2024, 11:25:05 PM12/18/24
to vim/vim, Push

@Shougo pushed 1 commit.


View it on GitHub or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/16238/before/bfa123b050eee03af74173190c3bb122c3ad5cc4/after/c5c5345e20357e9dda525cdd23969b94d408ff80@github.com>

Christian Brabandt

unread,
Dec 19, 2024, 2:30:50 PM12/19/24
to vim/vim, Subscribed

@chrisbra commented on this pull request.


In runtime/syntax/help.vim:

> +if !exists('g:help_example_languages')
+  let g:help_example_languages = #{ vim: 'vim' }
+endif

yes should be fine


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/16238/review/2516009252@github.com>

Christian Brabandt

unread,
Dec 19, 2024, 2:31:01 PM12/19/24
to vim/vim, Subscribed

@chrisbra commented on this pull request.


In runtime/doc/helphelp.txt:

>  <
+						 *g:help_example_languages*
+If you want to change the syntax highlighting in the block, you can
+change it like this: >
+	:let g:help_example_languages = #{ vim: 'vim', sh: 'bash' }
+The key is the annotation marker name and the value is the 'syntax' name.
+When not configured, help files support Vim script highlighting only.
+Note: When setting "g:help_example_languages", if you do not add "vim", Vim
+script syntax highlighting will not be available.
⬇️ Suggested change
-script syntax highlighting will not be available.
+When setting "g:help_example_languages" to an empty value, syntax highlighting for embedded languages will be disabled.


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/16238/review/2516009445@github.com>

Christian Brabandt

unread,
Dec 19, 2024, 2:32:08 PM12/19/24
to vim/vim, Subscribed

I am undecided mainly because of the issue mentioned by @zzzyxwvut

@dkearns your opinion please to include further languages?


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/16238/c2555623255@github.com>

Shougo

unread,
Dec 19, 2024, 6:57:08 PM12/19/24
to vim/vim, Push

@Shougo pushed 1 commit.

  • 83ebb78 Update runtime/doc/helphelp.txt

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/16238/before/c5c5345e20357e9dda525cdd23969b94d408ff80/after/83ebb78ef7571127208ca87ffa1d6748891069ca@github.com>

h_east

unread,
Dec 20, 2024, 5:08:18 AM12/20/24
to vim/vim, Subscribed

@h-east commented on this pull request.


In runtime/doc/helphelp.txt:

>  <
+						 *g:help_example_languages*
+If you want to change the syntax highlighting in the block, you can
+change it like this: >
+	:let g:help_example_languages = #{ vim: 'vim', sh: 'bash' }
+The key is language annotation and the value is syntax name.
+
  • The flow from the previous line seems strange.
  • Exceeds 80 characters.


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/16238/review/2517208480@github.com>

h_east

unread,
Dec 20, 2024, 12:49:36 PM12/20/24
to vim/vim, Subscribed

@h-east commented on this pull request.


In runtime/doc/helphelp.txt:

>  <
+						 *g:help_example_languages*
+If you want to change the syntax highlighting in the block, you can
+change it like this: >
+	:let g:help_example_languages = #{ vim: 'vim', sh: 'bash' }
+The key is the annotation marker name and the value is the 'syntax' name.
+When not configured, help files support Vim script highlighting only.
+Note: When setting "g:help_example_languages", if you do not add "vim", Vim
+When setting "g:help_example_languages" to an empty value, syntax highlighting for embedded languages will be disabled.

This was posted to vim_dev, but it doesn't seem to be reflected on GitHub, so I'm rewriting it.

    • The flow from the previous line seems strange.
    • Exceeds 80 columns.


    Reply to this email directly, view it on GitHub, or unsubscribe.

    You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/16238/review/2518050099@github.com>

    Shougo

    unread,
    Dec 20, 2024, 6:25:50 PM12/20/24
    to vim/vim, Subscribed

    @Shougo commented on this pull request.


    In runtime/doc/helphelp.txt:

    >  <
    +						 *g:help_example_languages*
    +If you want to change the syntax highlighting in the block, you can
    +change it like this: >
    +	:let g:help_example_languages = #{ vim: 'vim', sh: 'bash' }
    +The key is the annotation marker name and the value is the 'syntax' name.
    +When not configured, help files support Vim script highlighting only.
    +Note: When setting "g:help_example_languages", if you do not add "vim", Vim
    +When setting "g:help_example_languages" to an empty value, syntax highlighting for embedded languages will be disabled.
    

    Exceeds 80 columns.

    Thanks.


    Reply to this email directly, view it on GitHub, or unsubscribe.

    You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/16238/review/2518500722@github.com>

    Shougo

    unread,
    Dec 20, 2024, 6:29:56 PM12/20/24
    to vim/vim, Push

    @Shougo pushed 1 commit.

    • 126077a Improve the documentation


    View it on GitHub or unsubscribe.
    You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/16238/before/83ebb78ef7571127208ca87ffa1d6748891069ca/after/126077af3552f25b45f970d0ec5cca64d9c0454b@github.com>

    Shougo

    unread,
    Dec 20, 2024, 6:30:26 PM12/20/24
    to vim/vim, Subscribed

    @Shougo commented on this pull request.


    In runtime/doc/helphelp.txt:

    >  <
    +						 *g:help_example_languages*
    +If you want to change the syntax highlighting in the block, you can
    +change it like this: >
    +	:let g:help_example_languages = #{ vim: 'vim', sh: 'bash' }
    +The key is the annotation marker name and the value is the 'syntax' name.
    +When not configured, help files support Vim script highlighting only.
    +Note: When setting "g:help_example_languages", if you do not add "vim", Vim
    +When setting "g:help_example_languages" to an empty value, syntax highlighting for embedded languages will be disabled.
    

    The flow from the previous line seems strange.

    I have updated the documentation.


    Reply to this email directly, view it on GitHub, or unsubscribe.
    You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/16238/review/2518507469@github.com>

    Christian Brabandt

    unread,
    Dec 25, 2024, 4:45:58 AM12/25/24
    to vim/vim, Subscribed

    Okay, I include it and add a note, that for proper support included syntax highlighting needs to be accounted for, it may not always work perfectly otherwise.


    Reply to this email directly, view it on GitHub.
    You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/16238/c2561757438@github.com>

    Christian Brabandt

    unread,
    Dec 25, 2024, 4:57:50 AM12/25/24
    to vim/vim, Subscribed

    Closed #16238 via 5ddcecf.


    Reply to this email directly, view it on GitHub.

    You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/16238/issue_event/15760929295@github.com>

    dkearns

    unread,
    Jul 12, 2025, 12:56:50 PMJul 12
    to vim/vim, Subscribed
    dkearns left a comment (vim/vim#16238)

    Sorry, I completely missed this when it was included. Too much Xmas cheer?

    As @zzzyxwvut points out, supporting this sort of inclusion can be difficult but I'll see what I can do.


    Reply to this email directly, view it on GitHub.

    You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/16238/c3065866248@github.com>

    Reply all
    Reply to author
    Forward
    0 new messages