Commit: runtime(make): variables in make target lists use wrong highlighting

Christian Brabandt <[email protected]> Wed, 5 Aug 2026 21:30:04 +0200
Newsgroups gmane.editors.vim.devel
Message-ID <[email protected]>
runtime(make): variables in make target lists use wrong highlighting

Commit: https://github.com/vim/vim/commit/8c93e2d50dacabcd66cc4cb9573da497e98d3c26
Author: Bogdan Barbu <[email protected]>
Date:   Wed Aug 5 19:14:54 2026 +0000

    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 <[email protected]>
    Signed-off-by: Christian Brabandt <[email protected]>

diff --git a/runtime/syntax/make.vim b/runtime/syntax/make.vim
index 530b41e0e..23bdd090f 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 <[email protected]>, Roland Hieber <https://github.com/rohieb>
 " 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_./	 -]\+\s*:$"me=e-1
 syn match makeImplicit		"^\.[A-Za-z0-9_./	 -]\+\s*:[^=]"me=e-2
 
-syn region makeTargetinDefine transparent matchgroup=makeTargetinDefine
-	\ start="^[~A-Za-z0-9_./$(){}%-][A-Za-z0-9_./	 ${}()%-]*&\?:\?:\{1,2}[^:=]"rs=e-1
-	\ end="[^\]$"
-	\ keepend
+syn match makeTargetinDefine           "^[~A-Za-z0-9_./$(){}%-][A-Za-z0-9_./	 ${}()%-]*&\?:\?:\{1,2}\ze[^:=]"
+	\ contains=makeIdent,makeSpecTarget,makeComment
 syn match makeTargetinDefine           "^[~A-Za-z0-9_./$(){}%*@-][A-Za-z0-9_./	 $(){}%*@-]*&\?::\=\s*$"
 	\ contains=makeIdent,makeSpecTarget,makeComment
 
-syn region makeTarget transparent matchgroup=makeTarget
-	\ start="^[~A-Za-z0-9_./$(){}%-][A-Za-z0-9_./	 ${}()%-]*&\?:\?:\{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_./	 ${}()%-]*&\?:\?:\{1,2}\ze[^:=]"
+	\ contains=makeIdent,makeSpecTarget,makeComment
+	\ nextgroup=makePrerequisites skipwhite
 syn match makeTarget           "^[~A-Za-z0-9_./$(){}%*@-][A-Za-z0-9_./	 $(){}%*@-]*&\?::\=\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 cf31afb97..78d8f2904 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 082972a59..6e2e4cd0b 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 000000000..28ba95c00
--- /dev/null
+++ b/runtime/syntax/testdir/input/setup/make_01.vim
@@ -0,0 +1 @@
+highlight link makeIdent Todo

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups "vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To view this discussion visit https://groups.google.com/d/msgid/vim_dev/E1wrhJU-00Em6Z-0h%40256bit.org.