mirror of
https://github.com/neovim/neovim.git
synced 2025-10-21 09:12:07 +00:00
vim-patch:7bc9880: runtime(make): do not automatically indent after a special target
prevent indentation if the previous line starts with e.g. `.PHONY:`
closes: vim/vim#17183
7bc988067e
Co-authored-by: Eisuke Kawashima <e-kwsm@users.noreply.github.com>
This commit is contained in:

committed by
Christian Clason

parent
1dbede5b93
commit
2ea14c0cf4
@@ -3,6 +3,7 @@
|
|||||||
" Maintainer: Doug Kearns <dougkearns@gmail.com>
|
" Maintainer: Doug Kearns <dougkearns@gmail.com>
|
||||||
" Previous Maintainer: Nikolai Weibull <now@bitwi.se>
|
" Previous Maintainer: Nikolai Weibull <now@bitwi.se>
|
||||||
" Last Change: 2022 Apr 06
|
" Last Change: 2022 Apr 06
|
||||||
|
" 2025 Apr 22 by Vim Project: do not indent after special targets #17183
|
||||||
|
|
||||||
if exists("b:did_indent")
|
if exists("b:did_indent")
|
||||||
finish
|
finish
|
||||||
@@ -21,6 +22,8 @@ endif
|
|||||||
|
|
||||||
let s:comment_rx = '^\s*#'
|
let s:comment_rx = '^\s*#'
|
||||||
let s:rule_rx = '^[^ \t#:][^#:]*:\{1,2}\%([^=:]\|$\)'
|
let s:rule_rx = '^[^ \t#:][^#:]*:\{1,2}\%([^=:]\|$\)'
|
||||||
|
" .PHONY, .DELETE_ON_ERROR, etc
|
||||||
|
let s:rule_special = '^\.[A-Z_]\+\s*:'
|
||||||
let s:continued_rule_rx = '^[^#:]*:\{1,2}\%([^=:]\|$\)'
|
let s:continued_rule_rx = '^[^#:]*:\{1,2}\%([^=:]\|$\)'
|
||||||
let s:continuation_rx = '\\$'
|
let s:continuation_rx = '\\$'
|
||||||
let s:assignment_rx = '^\s*\h\w*\s*[+:?]\==\s*\zs.*\\$'
|
let s:assignment_rx = '^\s*\h\w*\s*[+:?]\==\s*\zs.*\\$'
|
||||||
@@ -50,7 +53,7 @@ function GetMakeIndent()
|
|||||||
if prev_line =~ s:continuation_rx
|
if prev_line =~ s:continuation_rx
|
||||||
if prev_prev_line =~ s:continuation_rx
|
if prev_prev_line =~ s:continuation_rx
|
||||||
return indent(prev_lnum)
|
return indent(prev_lnum)
|
||||||
elseif prev_line =~ s:rule_rx
|
elseif prev_line =~ s:rule_rx && prev_line !~ s:rule_special
|
||||||
return shiftwidth()
|
return shiftwidth()
|
||||||
elseif prev_line =~ s:assignment_rx
|
elseif prev_line =~ s:assignment_rx
|
||||||
call cursor(prev_lnum, 1)
|
call cursor(prev_lnum, 1)
|
||||||
@@ -81,15 +84,15 @@ function GetMakeIndent()
|
|||||||
let line = getline(lnum)
|
let line = getline(lnum)
|
||||||
endwhile
|
endwhile
|
||||||
let folded_lnum = lnum + 1
|
let folded_lnum = lnum + 1
|
||||||
if folded_line =~ s:rule_rx
|
if folded_line =~ s:rule_rx && prev_line !~ s:rule_special
|
||||||
if getline(v:lnum) =~ s:rule_rx
|
if getline(v:lnum) =~ s:rule_rx && prev_line !~ s:rule_special
|
||||||
return 0
|
return 0
|
||||||
else
|
else
|
||||||
return &ts
|
return &ts
|
||||||
endif
|
endif
|
||||||
else
|
else
|
||||||
" elseif folded_line =~ s:folded_assignment_rx
|
" 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
|
return 0
|
||||||
else
|
else
|
||||||
return indent(folded_lnum)
|
return indent(folded_lnum)
|
||||||
@@ -98,8 +101,8 @@ function GetMakeIndent()
|
|||||||
" " TODO: ?
|
" " TODO: ?
|
||||||
" return indent(prev_lnum)
|
" return indent(prev_lnum)
|
||||||
endif
|
endif
|
||||||
elseif prev_line =~ s:rule_rx
|
elseif prev_line =~ s:rule_rx && prev_line !~ s:rule_special
|
||||||
if getline(v:lnum) =~ s:rule_rx
|
if getline(v:lnum) =~ s:rule_rx && prev_line !~ s:rule_special
|
||||||
return 0
|
return 0
|
||||||
else
|
else
|
||||||
return &ts
|
return &ts
|
||||||
|
20
runtime/indent/testdir/make.in
Normal file
20
runtime/indent/testdir/make.in
Normal file
@@ -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
|
20
runtime/indent/testdir/make.ok
Normal file
20
runtime/indent/testdir/make.ok
Normal file
@@ -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
|
Reference in New Issue
Block a user