vim-patch:9.0.1601: filetype detection fails for *.conf file without comments (#23896)

Problem:    Filetype detection fails for *.conf file without comments.
            (Dmitrii Tcyganok)
Solution:   Use "conf" filetype as a fallback for an empty .conf file.
            (closes vim/vim#12487, closes vim/vim#12483)

664fd12aa2

Co-authored-by: zeertzjq <zeertzjq@outlook.com>
This commit is contained in:
Christian Clason
2023-06-04 00:39:46 +02:00
committed by GitHub
parent 72300feecf
commit 0a439e3863
2 changed files with 4 additions and 1 deletions

View File

@@ -196,6 +196,9 @@ function M.conf(path, bufnr)
if vim.fn.did_filetype() ~= 0 or path:find(vim.g.ft_ignore_pat) then
return
end
if path:find('%.conf$') then
return 'conf'
end
for _, line in ipairs(getlines(bufnr, 1, 5)) do
if line:find('^#') then
return 'conf'