runtime(make): do not automatically indent after a special target

Commit: 
https://github.com/vim/vim/commit/7bc988067eff6657e6f047491cadb32e0829544d
Author: Eisuke Kawashima <e-k...@users.noreply.github.com>
Date:   Tue Apr 22 20:20:46 2025 +0200

    runtime(make): do not automatically indent after a special target
    
    prevent indentation if the previous line starts with e.g. `.PHONY:`
    
    closes: #17183
    
    Signed-off-by: Eisuke Kawashima <e-k...@users.noreply.github.com>
    Signed-off-by: Christian Brabandt <c...@256bit.org>

diff --git a/runtime/indent/make.vim b/runtime/indent/make.vim
index 4d1838b3a..aeea4de74 100644
--- a/runtime/indent/make.vim
+++ b/runtime/indent/make.vim
@@ -3,6 +3,7 @@
 " Maintainer:          Doug Kearns <dougkea...@gmail.com>
 " Previous Maintainer: Nikolai Weibull <n...@bitwi.se>
 " Last Change:         2022 Apr 06
+" 2025 Apr 22 by Vim Project: do not indent after special targets #17183
 
 if exists("b:did_indent")
   finish
@@ -21,6 +22,8 @@ endif
 
 let s:comment_rx = '^\s*#'
 let s:rule_rx = '^[^   #:][^#:]*:\{1,2}\%([^=:]\|$\)'
+" .PHONY, .DELETE_ON_ERROR, etc
+let s:rule_special = '^\.[A-Z_]\+\s*:'
 let s:continued_rule_rx = '^[^#:]*:\{1,2}\%([^=:]\|$\)'
 let s:continuation_rx = '\$'
 let s:assignment_rx = '^\s*\h\w*\s*[+:?]\==\s*\zs.*\$'
@@ -50,7 +53,7 @@ function GetMakeIndent()
   if prev_line =~ s:continuation_rx
     if prev_prev_line =~ s:continuation_rx
       return indent(prev_lnum)
-    elseif prev_line =~ s:rule_rx
+    elseif prev_line =~ s:rule_rx && prev_line !~ s:rule_special
       return shiftwidth()
     elseif prev_line =~ s:assignment_rx
       call cursor(prev_lnum, 1)
@@ -81,15 +84,15 @@ function GetMakeIndent()
       let line = getline(lnum)
     endwhile
     let folded_lnum = lnum + 1
-    if folded_line =~ s:rule_rx
-      if getline(v:lnum) =~ s:rule_rx
+    if folded_line =~ s:rule_rx && prev_line !~ s:rule_special
+      if getline(v:lnum) =~ s:rule_rx && prev_line !~ s:rule_special
         return 0
       else
         return &ts
       endif
     else
 "    elseif folded_line =~ s:folded_assignment_rx
-      if getline(v:lnum) =~ s:rule_rx
+      if getline(v:lnum) =~ s:rule_rx && prev_line !~ s:rule_special
         return 0
       else
         return indent(folded_lnum)
@@ -98,8 +101,8 @@ function GetMakeIndent()
 "      " TODO: ?
 "      return indent(prev_lnum)
     endif
-  elseif prev_line =~ s:rule_rx
-    if getline(v:lnum) =~ s:rule_rx
+  elseif prev_line =~ s:rule_rx && prev_line !~ s:rule_special
+    if getline(v:lnum) =~ s:rule_rx && prev_line !~ s:rule_special
       return 0
     else
       return &ts
diff --git a/runtime/indent/testdir/make.in b/runtime/indent/testdir/make.in
new file mode 100644
index 000000000..e9b2781bb
--- /dev/null
+++ b/runtime/indent/testdir/make.in
@@ -0,0 +1,20 @@
+# vim:ft=make
+# START_INDENT
+.POSIX :
+MAKEFLAGS += -rR
+
+.SUFFIXES: .F .f
+FC = f95
+FFLAGS =
+CPPFLAGS =
+
+.PHONY: help
+help:
+@echo indentation test
+
+.F.f:
+$(FC) $(CPPFLAGS) -E $< > $@
+
+.f.o:
+$(FC) $(FFLAGS) -c -o $@ $<
+# END_INDENT
diff --git a/runtime/indent/testdir/make.ok b/runtime/indent/testdir/make.ok
new file mode 100644
index 000000000..320554008
--- /dev/null
+++ b/runtime/indent/testdir/make.ok
@@ -0,0 +1,20 @@
+# vim:ft=make
+# START_INDENT
+.POSIX :
+MAKEFLAGS += -rR
+
+.SUFFIXES: .F .f
+FC = f95
+FFLAGS =
+CPPFLAGS =
+
+.PHONY: help
+help:
+       @echo indentation test
+
+.F.f:
+       $(FC) $(CPPFLAGS) -E $< > $@
+
+.f.o:
+       $(FC) $(FFLAGS) -c -o $@ $<
+# END_INDENT

-- 
-- 
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 vim_dev+unsubscr...@googlegroups.com.
To view this discussion visit 
https://groups.google.com/d/msgid/vim_dev/E1u7INg-001QQ1-2n%40256bit.org.

Raspunde prin e-mail lui