From 0977c8b03e7eca56bb640acd2fd1c6f5fc825899 Mon Sep 17 00:00:00 2001 From: Doug Kearns Date: Wed, 1 Oct 2025 21:03:22 +0000 Subject: [PATCH] runtime(vim): Update base syntax, contain user command replacement text Ensure that :command replacement text terminates at the end of the logical line. Add :command to the generator exclusion list. fixes: #18414 (@Dougaak) fixes: #18448 (Maxim Kim) closes: #18415 Signed-off-by: Doug Kearns Signed-off-by: Christian Brabandt --- runtime/syntax/generator/gen_syntax_vim.vim | 3 +- runtime/syntax/generator/vim.vim.base | 1 + .../testdir/dumps/vim_ex_command_01.dump | 2 +- .../testdir/dumps/vim_ex_command_02.dump | 2 +- .../testdir/dumps/vim_ex_command_03.dump | 2 +- .../testdir/dumps/vim_ex_command_04.dump | 2 +- .../testdir/dumps/vim_ex_command_05.dump | 2 +- .../testdir/dumps/vim_ex_command_06.dump | 2 +- .../testdir/dumps/vim_ex_command_07.dump | 2 +- .../testdir/dumps/vim_ex_command_08.dump | 2 +- .../testdir/dumps/vim_ex_command_09.dump | 4 +- .../testdir/dumps/vim_ex_command_10.dump | 38 +++++++++---------- .../testdir/dumps/vim_ex_command_11.dump | 20 ++++++++++ .../syntax/testdir/input/vim_ex_command.vim | 26 +++++++++++++ runtime/syntax/vim.vim | 1 + 15 files changed, 79 insertions(+), 30 deletions(-) create mode 100644 runtime/syntax/testdir/dumps/vim_ex_command_11.dump diff --git a/runtime/syntax/generator/gen_syntax_vim.vim b/runtime/syntax/generator/gen_syntax_vim.vim index 9e45b97f1d..9ecab6e7ea 100644 --- a/runtime/syntax/generator/gen_syntax_vim.vim +++ b/runtime/syntax/generator/gen_syntax_vim.vim @@ -1,7 +1,7 @@ " Vim syntax file generator " Language: Vim script " Maintainer: Hirohito Higashi (h_east) -" Last Change: 2025 Sep 23 +" Last Change: 2025 Sep 27 let s:keepcpo= &cpo set cpo&vim @@ -307,6 +307,7 @@ function s:get_vim_command_type(cmd_name) catch chdir class + command copy debuggreedy def diff --git a/runtime/syntax/generator/vim.vim.base b/runtime/syntax/generator/vim.vim.base index fbca93451d..3f983e71a8 100644 --- a/runtime/syntax/generator/vim.vim.base +++ b/runtime/syntax/generator/vim.vim.base @@ -863,6 +863,7 @@ syn region vimUserCmdReplacement contained \ skip=+\n\s*\%(\\\|["#]\\ \)+ \ end="$" \ contains=@vimContinue,@vimUserCmdList,vimComFilter + \ keepend syn region vimUserCmdBlock contained \ matchgroup=vimSep \ start="{" diff --git a/runtime/syntax/testdir/dumps/vim_ex_command_01.dump b/runtime/syntax/testdir/dumps/vim_ex_command_01.dump index bbe9104e21..78492c7f3d 100644 --- a/runtime/syntax/testdir/dumps/vim_ex_command_01.dump +++ b/runtime/syntax/testdir/dumps/vim_ex_command_01.dump @@ -17,4 +17,4 @@ @6|\+0#e000e06&| +0#0000000&|e+0#af5f00255&|c|h|o| +0#0000000&|"+0#e000002&|F|o@1|"| +0#0000000&@56 @75 |c+0#af5f00255&|o|m@1|a|n|d|!| +0#0000000&|-+0#e000e06&|a|d@1|r|=|a+0#00e0003&|r|g|u|m|e|n|t|s| +0#0000000&|-+0#e000e06&|b|a|n|g| +0#0000000&|-+0#e000e06&|b|a|r| +0#0000000&|-+0#e000e06&|b|u|f@1|e|r| +0#0000000&|-+0#e000e06&|c|o|m|p|l|e|t|e|=|a+0#00e0003&|r|g|l|i|s|t| +0#0000000&|-+0#e000e06&|c|o|u|n|t|=|1+0#e000002&| +0#0000000&|-+0#e000e06&|@+0#4040ff13&@2 -| +0#0000000&@56|1|9|,|1| @10|8|%| +| +0#0000000&@56|1|9|,|1| @10|7|%| diff --git a/runtime/syntax/testdir/dumps/vim_ex_command_02.dump b/runtime/syntax/testdir/dumps/vim_ex_command_02.dump index 86712c1e81..dd95498f4e 100644 --- a/runtime/syntax/testdir/dumps/vim_ex_command_02.dump +++ b/runtime/syntax/testdir/dumps/vim_ex_command_02.dump @@ -17,4 +17,4 @@ @75 |c+0#af5f00255&|o|m@1|a|n|d|!| +0#0000000&|-+0#e000e06&|c|o|m|p|l|e|t|e|=|c+0#00e0003&|u|s|t|o|m|,+0#0000000&|s+0#00e0e07&|:|C|o|m|p|l|e|t|e|r|1| +0#0000000&|F+0#0000001#ffff4012|o@1| +0#0000000#ffffff0|e+0#af5f00255&|c|h|o| +0#0000000&|"+0#e000002&|F|o@1|"| +0#0000000&@21 |c+0#af5f00255&|o|m@1|a|n|d|!| +0#0000000&|-+0#e000e06&|c|o|m|p|l|e|t|e|=|c+0#00e0003&|u|s|t|o|m|l|i|s|t|,+0#0000000&|s+0#00e0e07&|:|C|o|m|p|l|e|t|e|r|2| +0#0000000&|F+0#0000001#ffff4012|o@1| +0#0000000#ffffff0|e+0#af5f00255&|c|h|o| +0#0000000&|"+0#e000002&|F|o@1|"| +0#0000000&@17 -@57|3|4|,|1| @9|1|8|%| +@57|3|4|,|1| @9|1|6|%| diff --git a/runtime/syntax/testdir/dumps/vim_ex_command_03.dump b/runtime/syntax/testdir/dumps/vim_ex_command_03.dump index 3502efb843..aa0e2f0c32 100644 --- a/runtime/syntax/testdir/dumps/vim_ex_command_03.dump +++ b/runtime/syntax/testdir/dumps/vim_ex_command_03.dump @@ -17,4 +17,4 @@ @6|\+0#e000e06&| +0#0000000&|-+0#e000e06&|b|u|f@1|e|r| +0#0000000&@59 @6|\+0#e000e06&| +0#0000000&|-+0#e000e06&|c|o|m|p|l|e|t|e|=|b+0#00e0003&|u|f@1|e|r| +0#0000000&@50 @6|\+0#e000e06&| +0#0000000&|-+0#e000e06&|c|o|u|n|t| +0#0000000&@60 -@57|5|0|,|0|-|1| @7|2|9|%| +@57|5|0|,|0|-|1| @7|2|4|%| diff --git a/runtime/syntax/testdir/dumps/vim_ex_command_04.dump b/runtime/syntax/testdir/dumps/vim_ex_command_04.dump index 8827d57081..c819f228cd 100644 --- a/runtime/syntax/testdir/dumps/vim_ex_command_04.dump +++ b/runtime/syntax/testdir/dumps/vim_ex_command_04.dump @@ -17,4 +17,4 @@ @6|\+0#e000e06&| +0#0000000&|-+0#e000e06&|n|a|r|g|s|=|*+0#00e0003&| +0#0000000&@58 @6|\+0#e000e06&| +0#0000000&|-+0#e000e06&|r|a|n|g|e| +0#0000000&@60 @6|\+0#e000e06&| +0#0000000&|-+0#e000e06&|r|e|g|i|s|t|e|r| +0#0000000&@57 -@57|6|8|,|7| @9|4|1|%| +@57|6|8|,|7| @9|3|5|%| diff --git a/runtime/syntax/testdir/dumps/vim_ex_command_05.dump b/runtime/syntax/testdir/dumps/vim_ex_command_05.dump index 21edaa64bc..d5cccc3289 100644 --- a/runtime/syntax/testdir/dumps/vim_ex_command_05.dump +++ b/runtime/syntax/testdir/dumps/vim_ex_command_05.dump @@ -17,4 +17,4 @@ @6|"+0#0000e05&|\| |c|o|m@1|e|n|t| +0#0000000&@58 @6|\+0#e000e06&| +0#0000000&|-+0#e000e06&|c|o|u|n|t| +0#0000000&@60 @6|"+0#0000e05&|\| |c|o|m@1|e|n|t| +0#0000000&@58 -@57|8|6|,|0|-|1| @7|5|2|%| +@57|8|6|,|0|-|1| @7|4|5|%| diff --git a/runtime/syntax/testdir/dumps/vim_ex_command_06.dump b/runtime/syntax/testdir/dumps/vim_ex_command_06.dump index 766150a820..ce8e796578 100644 --- a/runtime/syntax/testdir/dumps/vim_ex_command_06.dump +++ b/runtime/syntax/testdir/dumps/vim_ex_command_06.dump @@ -17,4 +17,4 @@ |"+0#0000e05&| |E|r@1|o|r|s| +0#0000000&@66 @75 |c+0#af5f00255&|o|m@1|a|n|d|!| +0#0000000&|-+0#ffffff16#ff404010|b|a|d|a|t@1|r|=+0#0000000#ffffff0|a|r|g|u|m|e|n|t|s| |-+0#e000e06&|b|a|n|g| +0#0000000&|-+0#ffffff16#ff404010|b|a|d|a|t@1|r| +0#0000000#ffffff0|-+0#e000e06&|n|a|r|g|s|=|*+0#00e0003&| +0#0000000&|F+0#0000001#ffff4012|o@1| +0#0000000#ffffff0|e+0#af5f00255&|c|h|o| +0#0000000&|"+0#e000002&|F|o@1|"| +0#0000000&@8 -@57|1|0|4|,|7| @8|6|4|%| +@57|1|0|4|,|7| @8|5@1|%| diff --git a/runtime/syntax/testdir/dumps/vim_ex_command_07.dump b/runtime/syntax/testdir/dumps/vim_ex_command_07.dump index f63dbd998f..e88760eaa3 100644 --- a/runtime/syntax/testdir/dumps/vim_ex_command_07.dump +++ b/runtime/syntax/testdir/dumps/vim_ex_command_07.dump @@ -17,4 +17,4 @@ |c+0#af5f00255&|o|m|c|l|e|a|r| +0#0000000&||| |e+0#af5f00255&|c|h|o| +0#0000000&|"+0#e000002&|F|o@1|"| +0#0000000&@53 @75 @75 -@57|1|2@1|,|1| @8|7|6|%| +@57|1|2@1|,|1| @8|6|5|%| diff --git a/runtime/syntax/testdir/dumps/vim_ex_command_08.dump b/runtime/syntax/testdir/dumps/vim_ex_command_08.dump index e6792e6a90..63a768760d 100644 --- a/runtime/syntax/testdir/dumps/vim_ex_command_08.dump +++ b/runtime/syntax/testdir/dumps/vim_ex_command_08.dump @@ -17,4 +17,4 @@ |"|•|"|,| |"|g|"|)|/+0#e000e06&|g|e| +0#0000000&@62 @4|e+0#af5f00255&|n|d|i|f| +0#0000000&@65 @4|i+0#af5f00255&|f| +0#0000000&|"+0#e000002&|<|a|r|g|s|>|"| +0#0000000&|=+0#af5f00255&@1| +0#0000000&|"+0#e000002&@1| +0#0000000&@53 -@57|1|4|0|,|0|-|1| @6|8@1|%| +@57|1|4|0|,|0|-|1| @6|7|5|%| diff --git a/runtime/syntax/testdir/dumps/vim_ex_command_09.dump b/runtime/syntax/testdir/dumps/vim_ex_command_09.dump index 7b81de09ce..bc89f17530 100644 --- a/runtime/syntax/testdir/dumps/vim_ex_command_09.dump +++ b/runtime/syntax/testdir/dumps/vim_ex_command_09.dump @@ -13,8 +13,8 @@ @75 @75 |"+0#0000e05&| |U|n|r|e|p|o|r|t|e|d| |i|s@1|u|e| |(|:|m|a|p| |w|i|t|h| |t|r|a|i|l|i|n|g| |b|a|r| |i|n| |r|e|p|l|a|c|e|m|e|n|t| |t|e|x|t|)| +0#0000000&@11 +@75 |c+0#af5f00255&|o|m@1|a|n|d|!| +0#0000000&|F+0#0000001#ffff4012|o@1| +0#0000000#ffffff0@62 @6|\+0#e000e06&| +0#0000000&|m+0#af5f00255&|a|p| +0#0000000&|l|h|s| |r|h|s| ||| @53 @6|\+0#e000e06&| +0#0000000&|a+0#af5f00255&|b@1|r|e|v|i|a|t|e| +0#0000000&|f|o@1| |b|a|r| ||| @46 -@6|\+0#e000e06&| +0#0000000&|e+0#af5f00255&|c|h|o| +0#0000000&|"+0#e000002&|F|o@1|"| +0#0000000&@56 -@57|1|5|7|,|5| @8|9@1|%| +@57|1|5|7|,|5| @8|8|4|%| diff --git a/runtime/syntax/testdir/dumps/vim_ex_command_10.dump b/runtime/syntax/testdir/dumps/vim_ex_command_10.dump index 31663553c5..5cc86bdcf2 100644 --- a/runtime/syntax/testdir/dumps/vim_ex_command_10.dump +++ b/runtime/syntax/testdir/dumps/vim_ex_command_10.dump @@ -1,20 +1,20 @@ -| +0&#ffffff0@5|\+0#e000e06&| +0#0000000&|e+0#af5f00255&|c|h|o| +0#0000000&|"+0#e000002&|F|o@1|"| +0#0000000&@56 +| +0&#ffffff0@5|\+0#e000e06&| +0#0000000&|a+0#af5f00255&|b@1|r|e|v|i|a|t|e| +0#0000000&|f|o@1| |b|a|r| ||| @46 +@6|\+0#e000e06&| +0#0000000&|e+0#af5f00255&|c|h|o| +0#0000000&|"+0#e000002&|F|o@1|"| +0#0000000&@56 +@75 +@75 +|"+0#0000e05&| |I|s@1|u|e| |#|1|8|4|1|4| |(|S|y|n|t|a|x| |g|r|o|u|p| |v|i|m|U|s|e|r|C|m|d|R|e|p|l|a|c|e|m|e|n|t| |l|a|c|k|i|n|g| |a| |k|e@1|p|e|n|d|?|)| +0#0000000&@4 > @74 -|~+0#4040ff13&| @73 -|~| @73 -|~| @73 -|~| @73 -|~| @73 -|~| @73 -|~| @73 -|~| @73 -|~| @73 -|~| @73 -|~| @73 -|~| @73 -|~| @73 -|~| @73 -|~| @73 -|~| @73 -|~| @73 -| +0#0000000&@56|1|7|0|,|0|-|1| @6|B|o|t| +|d+0#af5f00255&|e|f| +0#0000000&|V|i|m|9|C|o|n|t|e|x|t|(+0#e000e06&|)| +0#0000000&@57 +@2|c+0#af5f00255&|o|m@1|a|n|d|!| +0#0000000&|M+0#0000001#ffff4012|y|F|u|n|c|t|i|o|n| +0#0000000#ffffff0|M|y|F|u|n|c|(+0#e000e06&|)| +0#0000000&@44 +@2|#+0#0000e05&| |I| |a|m| |a| |c|o|m@1|e|n|t| +0#0000000&@56 +@75 +@2|c+0#af5f00255&|o|m@1|a|n|d|!| +0#0000000&|T+0#0000001#ffff4012|o|g@1|l|e|W|r|a|p| +0#0000000#ffffff0|s+0#af5f00255&|e|t|l|o|c|a|l| +0#0000000&|w+0#e000e06&|r|a|p|!| +0#0000000&@38 +@2|#+0#0000e05&| |I| |a|m| |a| |c|o|m@1|e|n|t| |b|u|t| |I| |d|i|d|n|'|t| |g|e|t| |h|i|g|h|l|i|g|h|t|e|d| +0#0000000&@27 +|e+0#af5f00255&|n|d@1|e|f| +0#0000000&@68 +@75 +|c+0#af5f00255&|o|m@1|a|n|d|!| +0#0000000&|M+0#0000001#ffff4012|y|F|u|n|c|t|i|o|n| +0#0000000#ffffff0|c+0#af5f00255&|a|l@1| +0#0000000&|M|y|F|u|n|c|(+0#e000e06&|)| +0#0000000&@41 +|"+0#0000e05&| |I| |a|m| |a| |c|o|m@1|e|n|t| +0#0000000&@58 +@75 +|c+0#af5f00255&|o|m@1|a|n|d|!| +0#0000000&|T+0#0000001#ffff4012|o|g@1|l|e|W|r|a|p| +0#0000000#ffffff0|s+0#af5f00255&|e|t|l|o|c|a|l| +0#0000000&|w+0#e000e06&|r|a|p|!| +0#0000000&@40 +|"+0#0000e05&| |I| |a|m| |a| |c|o|m@1|e|n|t| |b|u|t| |I| |d|i|d|n|'|t| |g|e|t| |h|i|g|h|l|i|g|h|t|e|d| +0#0000000&@29 +@57|1|7|4|,|0|-|1| @6|9|4|%| diff --git a/runtime/syntax/testdir/dumps/vim_ex_command_11.dump b/runtime/syntax/testdir/dumps/vim_ex_command_11.dump new file mode 100644 index 0000000000..1e50b3f141 --- /dev/null +++ b/runtime/syntax/testdir/dumps/vim_ex_command_11.dump @@ -0,0 +1,20 @@ +|"+0#0000e05#ffffff0| |I| |a|m| |a| |c|o|m@1|e|n|t| |b|u|t| |I| |d|i|d|n|'|t| |g|e|t| |h|i|g|h|l|i|g|h|t|e|d| +0#0000000&@29 +@75 +@75 +|"+0#0000e05&| |I|s@1|u|e| |#|1|8|4@1|8| |(|c|o|m@1|e|n|t| |f|o|r| |s|u|b|s|e|q|u|e|n|t| |c|o|m@1|a|n|d| |i|s| |n|o|t| |h|i|g|h|l|i|g|h|t|e|d|)| +0#0000000&@8 +@75 +>d+0#af5f00255&|e|f| +0#0000000&|V|i|m|9|C|o|n|t|e|x|t|(+0#e000e06&|)| +0#0000000&@57 +@2|c+0#af5f00255&|o|m@1|a|n|d|!| +0#0000000&|-+0#e000e06&|n|a|r|g|s|=|1+0#00e0003&| +0#0000000&|-+0#e000e06&|c|o|m|p|l|e|t|e|=|f+0#00e0003&|i|l|e| +0#0000000&|R+0#0000001#ffff4012|g| +0#0000000#ffffff0|:|t+0#af5f00255&|e|r|m| +0#0000000&|r|g| |<|a|r|g|s|>| @21 +@2|#+0#0000e05&| |c|o|m@1|a|n|d|!| |-|n|a|r|g|s|=|1| |-|c|o|m|p|l|e|t|e|=|f|i|l|e| |R|g| |:|t|e|r|m| |+@1|s|h|e|l@1| |r|g| |<|a|r|g|s|>| +0#0000000&@11 +|e+0#af5f00255&|n|d@1|e|f| +0#0000000&@68 +@75 +|~+0#4040ff13&| @73 +|~| @73 +|~| @73 +|~| @73 +|~| @73 +|~| @73 +|~| @73 +|~| @73 +|~| @73 +| +0#0000000&@56|1|9|2|,|1| @8|B|o|t| diff --git a/runtime/syntax/testdir/input/vim_ex_command.vim b/runtime/syntax/testdir/input/vim_ex_command.vim index 56890143c7..a2f01a708e 100644 --- a/runtime/syntax/testdir/input/vim_ex_command.vim +++ b/runtime/syntax/testdir/input/vim_ex_command.vim @@ -163,8 +163,34 @@ command -range=% -nargs=? -bang Tb :,s/\v"[^"]*"/\=substitute(subm " Unreported issue (:map with trailing bar in replacement text) + command! Foo \ map lhs rhs | \ abbreviate foo bar | \ echo "Foo" + +" Issue #18414 (Syntax group vimUserCmdReplacement lacking a keepend?) + +def Vim9Context() + command! MyFunction MyFunc() + # I am a comment + + command! ToggleWrap setlocal wrap! + # I am a comment but I didn't get highlighted +enddef + +command! MyFunction call MyFunc() +" I am a comment + +command! ToggleWrap setlocal wrap! +" I am a comment but I didn't get highlighted + + +" Issue #18448 (comment for subsequent command is not highlighted) + +def Vim9Context() + command! -nargs=1 -complete=file Rg :term rg + # command! -nargs=1 -complete=file Rg :term ++shell rg +enddef + diff --git a/runtime/syntax/vim.vim b/runtime/syntax/vim.vim index 426674e976..1fbb2f64d2 100644 --- a/runtime/syntax/vim.vim +++ b/runtime/syntax/vim.vim @@ -919,6 +919,7 @@ syn region vimUserCmdReplacement contained \ skip=+\n\s*\%(\\\|["#]\\ \)+ \ end="$" \ contains=@vimContinue,@vimUserCmdList,vimComFilter + \ keepend syn region vimUserCmdBlock contained \ matchgroup=vimSep \ start="{"