From: Bogdan Barbu Date: Wed, 5 Aug 2026 19:14:54 +0000 (+0000) Subject: runtime(make): variables in make target lists use wrong highlighting X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=HEAD;p=thirdparty%2Fvim.git runtime(make): variables in make target lists use wrong highlighting Problem: Variables in make target lists are highlighted as targets when the prerequisite list is non-empty. Solution: Match target lists separately from prerequisite regions so that contained identifiers are highlighted correctly. Add regression test. closes: #20947 Signed-off-by: Bogdan Barbu Signed-off-by: Christian Brabandt --- diff --git a/runtime/syntax/make.vim b/runtime/syntax/make.vim index 530b41e0e9..23bdd090f0 100644 --- a/runtime/syntax/make.vim +++ b/runtime/syntax/make.vim @@ -3,13 +3,14 @@ " Maintainer: This runtime file is looking for a new maintainer. " Previous Maintainer: Claudio Fleiner , Roland Hieber " URL: https://github.com/vim/vim/blob/master/runtime/syntax/make.vim -" Last Change: 2022 Nov 06 +" Last Change: 2026 Aug 05 " 2025 Apr 15 by Vim project: rework Make flavor detection (#17089) " 2025 Oct 12 by Vim project: update makeDefine highlighting (#18403) " 2025 Oct 25 by Vim project: update makeTargetinDefine highlighting (#18570) " 2025 Dec 23 by Vim project: fix too greedy match (#18938) " 2025 Dec 23 by Vim project: wrong highlight with paranthesis inside quotes (#18818) " 2026 Apr 17 by Vim project: wrong highlight $ inside quotes (#19986) +" 2026 Aug 05 by Vim project: highlight variables in non-empty target lists " quit when a syntax file was already loaded if exists("b:current_syntax") @@ -66,18 +67,20 @@ syn match makeConfig "@[A-Za-z0-9_]\+@" syn match makeImplicit "^\.[A-Za-z0-9_./\t -]\+\s*:$"me=e-1 syn match makeImplicit "^\.[A-Za-z0-9_./\t -]\+\s*:[^=]"me=e-2 -syn region makeTargetinDefine transparent matchgroup=makeTargetinDefine - \ start="^[~A-Za-z0-9_./$(){}%-][A-Za-z0-9_./\t ${}()%-]*&\?:\?:\{1,2}[^:=]"rs=e-1 - \ end="[^\\]$" - \ keepend +syn match makeTargetinDefine "^[~A-Za-z0-9_./$(){}%-][A-Za-z0-9_./\t ${}()%-]*&\?:\?:\{1,2}\ze[^:=]" + \ contains=makeIdent,makeSpecTarget,makeComment syn match makeTargetinDefine "^[~A-Za-z0-9_./$(){}%*@-][A-Za-z0-9_./\t $(){}%*@-]*&\?::\=\s*$" \ contains=makeIdent,makeSpecTarget,makeComment -syn region makeTarget transparent matchgroup=makeTarget - \ start="^[~A-Za-z0-9_./$(){}%-][A-Za-z0-9_./\t ${}()%-]*&\?:\?:\{1,2}[^:=]"rs=e-1 +" Match prerequisites separately so identifiers can match inside target lists. +syn region makePrerequisites contained transparent + \ start="."rs=e-1 \ end="[^\\]$" \ keepend contains=makeIdent,makeSpecTarget,makeNextLine,makeComment,makeDString \ skipnl nextGroup=makeCommands +syn match makeTarget "^[~A-Za-z0-9_./$(){}%-][A-Za-z0-9_./\t ${}()%-]*&\?:\?:\{1,2}\ze[^:=]" + \ contains=makeIdent,makeSpecTarget,makeComment + \ nextgroup=makePrerequisites skipwhite syn match makeTarget "^[~A-Za-z0-9_./$(){}%*@-][A-Za-z0-9_./\t $(){}%*@-]*&\?::\=\s*$" \ contains=makeIdent,makeSpecTarget,makeComment \ skipnl nextgroup=makeCommands,makeCommandError diff --git a/runtime/syntax/testdir/dumps/make_01_00.dump b/runtime/syntax/testdir/dumps/make_01_00.dump index cf31afb973..78d8f29041 100644 --- a/runtime/syntax/testdir/dumps/make_01_00.dump +++ b/runtime/syntax/testdir/dumps/make_01_00.dump @@ -1,20 +1,20 @@ >#+0#0000e05#ffffff0| |c|o|m@1|e|n|t| +0#0000000&@65 @75 -|a+0#00e0e07&| |=+0#0000000&| |b| @69 -|$+0#00e0e07&|(|a|)| |=+0#0000000&| |1| @66 +|a+0#0000001#ffff4012| |=+0#0000000#ffffff0| |b| @69 +|$+0#0000001#ffff4012|(|a|)| |=+0#0000000#ffffff0| |1| @66 @75 -|$+0#00e0e07&|(|a|)|:@1| +0#0000000&@68 +|$+0#0000001#ffff4012|(|a|)|:+0#00e0e07#ffffff0@1| +0#0000000&@68 | +0#e000e06&@7|@|e+0#e000002&|c|h|o| |d|o|u|b|l|e|-|c|o|l|o|n| |r|u|l|e| +0#0000000&@43 @75 -|$+0#00e0e07&|(|a|)| |++0#0000000&|=| |o|u|t|p|u|t| @60 -@75 +|$+0#0000001#ffff4012|(|a|)|:+0#00e0e07#ffffff0| +0#0000000&|p|r|e|r|e|q|u|i|s|i|t|e| @56 +|$+0#0000001#ffff4012|(|a|)| |++0#0000000#ffffff0|=| |o|u|t|p|u|t| @60 |d+0#e000e06&|e|f|i|n|e| |s|a|y| +0#0000000&@64 -| +0#e000e06&@7|e|c|h|o| |$+0#00e0e07&|1| +0#0000000&@59 +|$+0#0000001#ffff4012|(|a|)|:+0#00e0e07#ffffff0| +0#e000e06&|p|r|e|r|e|q|u|i|s|i|t|e| +0#0000000&@56 +| +0#e000e06&@7|e|c|h|o| |$+0#0000001#ffff4012|1| +0#0000000#ffffff0@59 |e+0#e000e06&|n|d|e|f| +0#0000000&@69 -@75 |d+0#00e0e07&|e|f|a|u|l|t|:| +0#0000000&@66 -| +0#e000002&@7|$+0#00e0e07&|(|c+0#af5f00255&|a|l@1| +0#00e0e07&|s|a|y|,|"+0#e000002&|H|e|l@1|o| |(|w|o|r|l|d|)|!|"|)+0#00e0e07&| +0#0000000&@38 +| +0#e000002&@7|$+0#0000001#ffff4012|(|c+0#af5f00255#ffffff0|a|l@1| +0#0000001#ffff4012|s|a|y|,|"+0#e000002#ffffff0|H|e|l@1|o| |(|w|o|r|l|d|)|!|"|)+0#0000001#ffff4012| +0#0000000#ffffff0@38 @75 |f+0#00e0e07&|o@1|:| +0#0000000&@70 -| +0#e000002&@7|e|c|h|o| |"|b|a|r|$+0#00e0e07&@1|"+0#e000002&| |b|a|z| +0#0000000&@50 +| +0#e000002&@7|e|c|h|o| |"|b|a|r|$+0#0000001#ffff4012@1|"+0#e000002#ffffff0| |b|a|z| +0#0000000&@50 @57|1|,|1| @10|A|l@1| diff --git a/runtime/syntax/testdir/input/make_01.mak b/runtime/syntax/testdir/input/make_01.mak index 082972a59c..6e2e4cd0b4 100644 --- a/runtime/syntax/testdir/input/make_01.mak +++ b/runtime/syntax/testdir/input/make_01.mak @@ -6,12 +6,12 @@ $(a) = 1 $(a):: @echo double-colon rule +$(a): prerequisite $(a) += output - define say +$(a): prerequisite echo $1 endef - default: $(call say,"Hello (world)!") diff --git a/runtime/syntax/testdir/input/setup/make_01.vim b/runtime/syntax/testdir/input/setup/make_01.vim new file mode 100644 index 0000000000..28ba95c006 --- /dev/null +++ b/runtime/syntax/testdir/input/setup/make_01.vim @@ -0,0 +1 @@ +highlight link makeIdent Todo