fix(filetype): fix filetype patterns

This commit is contained in:
smjonas
2022-07-06 16:25:23 +02:00
parent c68f1d7263
commit f3c78a4465
3 changed files with 135 additions and 31 deletions

View File

@ -13,7 +13,13 @@ vim.api.nvim_create_autocmd({ 'BufRead', 'BufNewFile' }, {
group = 'filetypedetect',
callback = function(args)
local ft, on_detect = vim.filetype.match({ buf = args.buf })
if ft then
if not ft then
-- Generic configuration file used as fallback
ft = require('vim.filetype.detect').conf(args.file, args.buf)
if ft then
vim.api.nvim_cmd({ cmd = 'setf', args = { 'FALLBACK', ft } }, {})
end
else
vim.api.nvim_buf_set_option(args.buf, 'filetype', ft)
if on_detect then
on_detect(args.buf)