]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
runtime(make): variables in make target lists use wrong highlighting master
authorBogdan Barbu <l4b.bogdan.barbu@gmail.com>
Wed, 5 Aug 2026 19:14:54 +0000 (19:14 +0000)
committerChristian Brabandt <cb@256bit.org>
Wed, 5 Aug 2026 19:14:54 +0000 (19:14 +0000)
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 <l4b.bogdan.barbu@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
runtime/syntax/make.vim
runtime/syntax/testdir/dumps/make_01_00.dump
runtime/syntax/testdir/input/make_01.mak
runtime/syntax/testdir/input/setup/make_01.vim [new file with mode: 0644]

index 530b41e0e9f175040595f8952140c85e140dd651..23bdd090f06546c8ab218349126ba66398dda321 100644 (file)
@@ -3,13 +3,14 @@
 " Maintainer:  This runtime file is looking for a new maintainer.
 " Previous Maintainer: Claudio Fleiner <claudio@fleiner.com>, 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_./\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
index cf31afb97350b16cb627e515f2cec7f19db33f95..78d8f29041d19fb2fcee00b5e9896f5069213519 100644 (file)
@@ -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| 
index 082972a59ccfdbbb31aefacb151171d930e075d3..6e2e4cd0b47f1faac020f665acbdd258bcbd7789 100644 (file)
@@ -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 (file)
index 0000000..28ba95c
--- /dev/null
@@ -0,0 +1 @@
+highlight link makeIdent Todo