diff options
author | Christian Clason <c.clason@uni-graz.at> | 2022-07-06 16:57:44 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-06 16:57:44 +0200 |
commit | 1e03255646be3a31d44db4118ee2194d45f6bf1c (patch) | |
tree | 1676056236dfbe5eac29eb53231bf69c015dff92 /runtime/filetype.lua | |
parent | c84ae5706fb0c31c415fedbc15021e9b2ef46065 (diff) | |
parent | f9683f28236599a7082f43304a9685fad8ee8e00 (diff) | |
download | rneovim-1e03255646be3a31d44db4118ee2194d45f6bf1c.tar.gz rneovim-1e03255646be3a31d44db4118ee2194d45f6bf1c.tar.bz2 rneovim-1e03255646be3a31d44db4118ee2194d45f6bf1c.zip |
Merge pull request #19218 from smjonas/fix_ft_patterns
fix(filetype): fix filetype patterns
fix(filetype): remove call to vim.fn.resolve and pass filename to match function
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) |