diff options
Diffstat (limited to 'runtime/filetype.lua')
-rw-r--r-- | runtime/filetype.lua | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/runtime/filetype.lua b/runtime/filetype.lua index 4880ed55ef..797033da06 100644 --- a/runtime/filetype.lua +++ b/runtime/filetype.lua @@ -21,7 +21,7 @@ vim.api.nvim_create_autocmd({ 'BufRead', 'BufNewFile', 'StdinReadPost' }, { -- Generic configuration file used as fallback ft = require('vim.filetype.detect').conf(args.file, args.buf) if ft then - vim.api.nvim_buf_call(args.buf, function() + vim._with({ buf = args.buf }, function() vim.api.nvim_cmd({ cmd = 'setf', args = { 'FALLBACK', ft } }, {}) end) end @@ -32,22 +32,13 @@ vim.api.nvim_create_autocmd({ 'BufRead', 'BufNewFile', 'StdinReadPost' }, { on_detect(args.buf) end - vim.api.nvim_buf_call(args.buf, function() + vim._with({ buf = args.buf }, function() vim.api.nvim_cmd({ cmd = 'setf', args = { ft } }, {}) end) end end, }) --- These *must* be sourced after the autocommand above is created -if not vim.g.did_load_ftdetect then - vim.cmd([[ - augroup filetypedetect - runtime! ftdetect/*.{vim,lua} - augroup END - ]]) -end - -- Set up the autocmd for user scripts.vim vim.api.nvim_create_autocmd({ 'BufRead', 'BufNewFile' }, { group = 'filetypedetect', @@ -62,3 +53,10 @@ vim.api.nvim_create_autocmd('StdinReadPost', { if not vim.g.ft_ignore_pat then vim.g.ft_ignore_pat = '\\.\\(Z\\|gz\\|bz2\\|zip\\|tgz\\)$' end + +-- These *must* be sourced after the autocommands above are created +vim.cmd([[ + augroup filetypedetect + runtime! ftdetect/*.{vim,lua} + augroup END +]]) |