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
|
end
|
||||||
|
|
||||||
--- @type vim.filetype.mapfn
|
--- @type vim.filetype.mapfn
|
||||||
function M.fvwm_v2(path, _)
|
function M.fvwm_v2(_, _)
|
||||||
if fn.fnamemodify(path, ':e') == 'm4' then
|
|
||||||
return 'fvwm2m4'
|
|
||||||
end
|
|
||||||
return 'fvwm', function(bufnr)
|
return 'fvwm', function(bufnr)
|
||||||
vim.b[bufnr].fvwm_version = 2
|
vim.b[bufnr].fvwm_version = 2
|
||||||
end
|
end
|
||||||
@@ -1026,22 +1023,30 @@ function M.m(_, bufnr)
|
|||||||
end
|
end
|
||||||
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
|
--- @type vim.filetype.mapfn
|
||||||
function M.m4(path, bufnr)
|
function M.m4(path, bufnr)
|
||||||
local fname = fn.fnamemodify(path, ':t')
|
local fname = fn.fnamemodify(path, ':t')
|
||||||
path = fn.fnamemodify(path, ':p:h')
|
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
|
if fname:find('html%.m4$') then
|
||||||
return 'htmlm4'
|
return 'htmlm4'
|
||||||
end
|
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
|
if
|
||||||
fn.filereadable(path .. '/../configure.ac') ~= 0
|
fn.filereadable(path .. '/../configure.ac') ~= 0
|
||||||
or fn.filereadable(path .. '/configure.ac') ~= 0
|
or fn.filereadable(path .. '/configure.ac') ~= 0
|
||||||
@@ -1049,7 +1054,7 @@ function M.m4(path, bufnr)
|
|||||||
return 'config'
|
return 'config'
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Case 3: content heuristic (scan first ~200 lines)
|
-- Content heuristic for Autoconf M4 (scan first ~200 lines)
|
||||||
-- Signals:
|
-- Signals:
|
||||||
-- - Autoconf macro prefixes: AC_/AM_/AS_/AU_/AT_
|
-- - Autoconf macro prefixes: AC_/AM_/AS_/AU_/AT_
|
||||||
for _, line in ipairs(getlines(bufnr, 1, 200)) do
|
for _, line in ipairs(getlines(bufnr, 1, 200)) do
|
||||||
@@ -1058,7 +1063,7 @@ function M.m4(path, bufnr)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Case 4: default to POSIX M4
|
-- Default to POSIX M4
|
||||||
return 'm4'
|
return 'm4'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@@ -308,7 +308,8 @@ func s:GetFilenameChecks() abort
|
|||||||
\ 'fstab': ['fstab', 'mtab'],
|
\ 'fstab': ['fstab', 'mtab'],
|
||||||
\ 'func': ['file.fc'],
|
\ 'func': ['file.fc'],
|
||||||
\ 'fusion': ['file.fusion'],
|
\ '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'],
|
\ 'gdb': ['.gdbinit', 'gdbinit', '.cuda-gdbinit', 'cuda-gdbinit', 'file.gdb', '.config/gdbearlyinit', '.gdbearlyinit'],
|
||||||
\ 'gdmo': ['file.mo', 'file.gdmo'],
|
\ 'gdmo': ['file.mo', 'file.gdmo'],
|
||||||
\ 'gdresource': ['file.tscn', 'file.tres'],
|
\ 'gdresource': ['file.tscn', 'file.tres'],
|
||||||
|
Reference in New Issue
Block a user