diff options
Diffstat (limited to 'runtime/filetype.lua')
-rw-r--r-- | runtime/filetype.lua | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/runtime/filetype.lua b/runtime/filetype.lua index 35bb31edce..f1885a8b95 100644 --- a/runtime/filetype.lua +++ b/runtime/filetype.lua @@ -12,8 +12,14 @@ vim.api.nvim_create_augroup('filetypedetect', { clear = false }) 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 + local ft, on_detect = vim.filetype.match({ filename = args.match, buf = args.buf }) + 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) |