mirror of
https://github.com/neovim/neovim.git
synced 2025-10-21 09:12:07 +00:00
vim-patch:9.1.1713: filetype: fvwm2m4 files are no longer detected
Problem: filetype: fvwm2m4 files are no longer recognized
(after 9.1.1687).
Solution: Add a special case in m4 filetype detection (zeertzjq).
closes: vim/vim#18146
5355e81868
Co-authored-by: Damien Lejay <damien@lejay.be>
This commit is contained in:
@@ -688,10 +688,7 @@ function M.fvwm_v1(_, _)
|
||||
end
|
||||
|
||||
--- @type vim.filetype.mapfn
|
||||
function M.fvwm_v2(path, _)
|
||||
if fn.fnamemodify(path, ':e') == 'm4' then
|
||||
return 'fvwm2m4'
|
||||
end
|
||||
function M.fvwm_v2(_, _)
|
||||
return 'fvwm', function(bufnr)
|
||||
vim.b[bufnr].fvwm_version = 2
|
||||
end
|
||||
@@ -1026,22 +1023,30 @@ function M.m(_, bufnr)
|
||||
end
|
||||
end
|
||||
|
||||
--- For files ending in *.m4, distinguish:
|
||||
--- – *.html.m4 files
|
||||
--- - *fvwm2rc*.m4 files
|
||||
--- – files in the Autoconf M4 dialect
|
||||
--- – files in POSIX M4
|
||||
--- @type vim.filetype.mapfn
|
||||
function M.m4(path, bufnr)
|
||||
local fname = fn.fnamemodify(path, ':t')
|
||||
path = fn.fnamemodify(path, ':p:h')
|
||||
|
||||
-- Case 0: canonical Autoconf file
|
||||
if fname == 'aclocal.m4' then
|
||||
return 'config'
|
||||
end
|
||||
|
||||
-- Case 1: html.m4
|
||||
if fname:find('html%.m4$') then
|
||||
return 'htmlm4'
|
||||
end
|
||||
|
||||
-- Case 2: repo heuristic (nearby configure.ac)
|
||||
if fname:find('fvwm2rc') then
|
||||
return 'fvwm2m4'
|
||||
end
|
||||
|
||||
-- Canonical Autoconf file
|
||||
if fname == 'aclocal.m4' then
|
||||
return 'config'
|
||||
end
|
||||
|
||||
-- Repo heuristic for Autoconf M4 (nearby configure.ac)
|
||||
if
|
||||
fn.filereadable(path .. '/../configure.ac') ~= 0
|
||||
or fn.filereadable(path .. '/configure.ac') ~= 0
|
||||
@@ -1049,7 +1054,7 @@ function M.m4(path, bufnr)
|
||||
return 'config'
|
||||
end
|
||||
|
||||
-- Case 3: content heuristic (scan first ~200 lines)
|
||||
-- Content heuristic for Autoconf M4 (scan first ~200 lines)
|
||||
-- Signals:
|
||||
-- - Autoconf macro prefixes: AC_/AM_/AS_/AU_/AT_
|
||||
for _, line in ipairs(getlines(bufnr, 1, 200)) do
|
||||
@@ -1058,7 +1063,7 @@ function M.m4(path, bufnr)
|
||||
end
|
||||
end
|
||||
|
||||
-- Case 4: default to POSIX M4
|
||||
-- Default to POSIX M4
|
||||
return 'm4'
|
||||
end
|
||||
|
||||
|
@@ -308,7 +308,8 @@ func s:GetFilenameChecks() abort
|
||||
\ 'fstab': ['fstab', 'mtab'],
|
||||
\ 'func': ['file.fc'],
|
||||
\ 'fusion': ['file.fusion'],
|
||||
\ 'fvwm': ['/.fvwm/file', 'any/.fvwm/file'],
|
||||
\ 'fvwm': ['/.fvwm/file', 'any/.fvwm/file', '.fvwmrc', 'foo.fvwmrc', 'fvwmrc.foo', '.fvwm2rc', 'foo.fvwm2rc', 'fvwm2rc.foo', 'foo.fvwm95.hook', 'fvwm95.foo.hook'],
|
||||
\ 'fvwm2m4': ['.fvwm2rc.m4', 'foo.fvwm2rc.m4', 'fvwm2rc.foo.m4'],
|
||||
\ 'gdb': ['.gdbinit', 'gdbinit', '.cuda-gdbinit', 'cuda-gdbinit', 'file.gdb', '.config/gdbearlyinit', '.gdbearlyinit'],
|
||||
\ 'gdmo': ['file.mo', 'file.gdmo'],
|
||||
\ 'gdresource': ['file.tscn', 'file.tres'],
|
||||
|
Reference in New Issue
Block a user