aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/filetype
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2024-07-27 16:48:29 +0800
committerGitHub <noreply@github.com>2024-07-27 16:48:29 +0800
commit60967cd9aac545a5a5f17070d39121d4070e2298 (patch)
tree3e4514463f6a69673bf299de42f5bd1ff2892ace /runtime/lua/vim/filetype
parentaa853f362addded400d52d8fdfe5247c300c0e89 (diff)
downloadrneovim-60967cd9aac545a5a5f17070d39121d4070e2298.tar.gz
rneovim-60967cd9aac545a5a5f17070d39121d4070e2298.tar.bz2
rneovim-60967cd9aac545a5a5f17070d39121d4070e2298.zip
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 <kentkt@csc.jp>
Diffstat (limited to 'runtime/lua/vim/filetype')
-rw-r--r--runtime/lua/vim/filetype/detect.lua18
1 files changed, 18 insertions, 0 deletions
diff --git a/runtime/lua/vim/filetype/detect.lua b/runtime/lua/vim/filetype/detect.lua
index 1fe7db0e1f..cb953f9d0c 100644
--- a/runtime/lua/vim/filetype/detect.lua
+++ b/runtime/lua/vim/filetype/detect.lua
@@ -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'