fix(ftdetect): source plugins in autogroup (#18237)

In `filetype.lua`, source runtime `ftdetect` scripts within the `filetypedetect` augroup, same as `filetype.vim` (and only do so if `g:did_load_ftdetect` does not exist).
This commit is contained in:
Christian Clason 2022-04-23 17:57:38 +02:00 committed by GitHub
parent a98cf154ed
commit 5c53e29ca9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -17,10 +17,14 @@ vim.api.nvim_create_autocmd({"BufRead", "BufNewFile"}, {
})
-- These *must* be sourced after the autocommand above is created
vim.cmd [[
runtime! ftdetect/*.vim
runtime! ftdetect/*.lua
]]
if not vim.g.did_load_ftdetect then
vim.cmd [[
augroup filetypedetect
runtime! ftdetect/*.vim
runtime! ftdetect/*.lua
augroup END
]]
end
-- Set a marker so that the ftdetect scripts are not sourced a second time by filetype.vim
vim.g.did_load_ftdetect = 1