From 60967cd9aac545a5a5f17070d39121d4070e2298 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 27 Jul 2024 16:48:29 +0800 Subject: vim-patch:9.1.0616: filetype: Make syntax highlighting off for MS Makefiles (#29874) Problem: filetype: Make syntax highlighting off for MS Makefiles Solution: Try to detect MS Makefiles and adjust syntax rules to it. (Ken Takata) Highlighting of variable expansion in Microsoft Makefile can be broken. E.g.: https://github.com/vim/vim/blob/2979cfc2627d76a9c09cad46a1647dcd4aa73f5f/src/Make_mvc.mak#L1331 Don't use backslash as escape characters if `make_microsoft` is set. Also fix that `make_no_comments` was not considered if `make_microsoft` was set. Also add description for `make_microsoft` and `make_no_comments` to the documentation and include a very simple filetype test closes: vim/vim#15341 https://github.com/vim/vim/commit/eb4b903c9b238ebcc1d14cfcb207129b4931a33d Co-authored-by: Ken Takata --- runtime/syntax/make.vim | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'runtime/syntax') diff --git a/runtime/syntax/make.vim b/runtime/syntax/make.vim index b4573044ca..d3ddf78291 100644 --- a/runtime/syntax/make.vim +++ b/runtime/syntax/make.vim @@ -28,8 +28,13 @@ syn match makePreCondit "^!\s*\(cmdswitches\|error\|message\|include\|if\|ifdef\ syn case match " identifiers -syn region makeIdent start="\$(" skip="\\)\|\\\\" end=")" contains=makeStatement,makeIdent -syn region makeIdent start="\${" skip="\\}\|\\\\" end="}" contains=makeStatement,makeIdent +if exists("b:make_microsoft") || exists("make_microsoft") + syn region makeIdent start="\$(" end=")" contains=makeStatement,makeIdent + syn region makeIdent start="\${" end="}" contains=makeStatement,makeIdent +else + syn region makeIdent start="\$(" skip="\\)\|\\\\" end=")" contains=makeStatement,makeIdent + syn region makeIdent start="\${" skip="\\}\|\\\\" end="}" contains=makeStatement,makeIdent +endif syn match makeIdent "\$\$\w*" syn match makeIdent "\$[^({]" syn match makeIdent "^ *[^:#= \t]*\s*[:+?!*]="me=e-2 @@ -78,11 +83,13 @@ syn match makeOverride "^ *override\>" syn match makeStatement contained "(\(abspath\|addprefix\|addsuffix\|and\|basename\|call\|dir\|error\|eval\|file\|filter-out\|filter\|findstring\|firstword\|flavor\|foreach\|guile\|if\|info\|join\|lastword\|notdir\|or\|origin\|patsubst\|realpath\|shell\|sort\|strip\|subst\|suffix\|value\|warning\|wildcard\|word\|wordlist\|words\)\>"ms=s+1 " Comment -if exists("make_microsoft") - syn match makeComment "#.*" contains=@Spell,makeTodo -elseif !exists("make_no_comments") - syn region makeComment start="#" end="^$" end="[^\\]$" keepend contains=@Spell,makeTodo - syn match makeComment "#$" contains=@Spell +if !exists("make_no_comments") + if exists("b:make_microsoft") || exists("make_microsoft") + syn match makeComment "#.*" contains=@Spell,makeTodo + else + syn region makeComment start="#" end="^$" end="[^\\]$" keepend contains=@Spell,makeTodo + syn match makeComment "#$" contains=@Spell + endif endif syn keyword makeTodo TODO FIXME XXX contained -- cgit