mirror of
https://github.com/neovim/neovim.git
synced 2026-04-22 15:25:30 +00:00
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.:
2979cfc262/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
eb4b903c9b
Co-authored-by: Ken Takata <kentkt@csc.jp>
This commit is contained in:
@@ -693,8 +693,8 @@ local extension = {
|
||||
return not (path:find('html%.m4$') or path:find('fvwm2rc')) and 'm4' or nil
|
||||
end,
|
||||
eml = 'mail',
|
||||
mk = 'make',
|
||||
mak = 'make',
|
||||
mk = detect.make,
|
||||
mak = detect.make,
|
||||
page = 'mallard',
|
||||
map = 'map',
|
||||
mws = 'maple',
|
||||
@@ -2122,7 +2122,7 @@ local pattern = {
|
||||
['^Containerfile%.'] = starsetf('dockerfile'),
|
||||
['^Dockerfile%.'] = starsetf('dockerfile'),
|
||||
['^[jJ]ustfile$'] = 'just',
|
||||
['[mM]akefile$'] = 'make',
|
||||
['[mM]akefile$'] = detect.make,
|
||||
['^[mM]akefile'] = starsetf('make'),
|
||||
['^[rR]akefile$'] = 'ruby',
|
||||
['^[rR]akefile'] = starsetf('ruby'),
|
||||
|
||||
@@ -972,6 +972,24 @@ local function m4(contents)
|
||||
end
|
||||
end
|
||||
|
||||
--- Check if it is a Microsoft Makefile
|
||||
--- @type vim.filetype.mapfn
|
||||
function M.make(_, bufnr)
|
||||
vim.b.make_microsoft = nil
|
||||
for _, line in ipairs(getlines(bufnr, 1, 1000)) do
|
||||
if matchregex(line, [[\c^\s*!\s*\(ifn\=\(def\)\=\|include\|message\|error\)\>]]) then
|
||||
vim.b.make_microsoft = 1
|
||||
break
|
||||
elseif
|
||||
matchregex(line, [[^ *ifn\=\(eq\|def\)\>]])
|
||||
or findany(line, { '^ *[-s]?%s', '^ *%w+%s*[!?:+]=' })
|
||||
then
|
||||
break
|
||||
end
|
||||
end
|
||||
return 'make'
|
||||
end
|
||||
|
||||
--- @type vim.filetype.mapfn
|
||||
function M.markdown(_, _)
|
||||
return vim.g.filetype_md or 'markdown'
|
||||
|
||||
Reference in New Issue
Block a user