Skip to content

Commit fdea157

Browse files
authored
feat(filetype): support scripts.vim with filetype.lua (neovim#17517)
When filetype.vim is disabled, create the autocommand that runs scripts.vim in filetype.lua.
1 parent b5bf487 commit fdea157

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

runtime/filetype.lua

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ if vim.g.do_filetype_lua ~= 1 then
77
return
88
end
99

10+
-- TODO: Remove vim.cmd once Lua autocommands land
1011
vim.cmd [[
1112
augroup filetypedetect
1213
au BufRead,BufNewFile * call v:lua.vim.filetype.match(expand('<afile>'))
@@ -18,6 +19,12 @@ runtime! ftdetect/*.lua
1819
" Set a marker so that the ftdetect scripts are not sourced a second time by filetype.vim
1920
let g:did_load_ftdetect = 1
2021
22+
" If filetype.vim is disabled, set up the autocmd to use scripts.vim
23+
if exists('did_load_filetypes')
24+
au BufRead,BufNewFile * if !did_filetype() && expand('<amatch>') !~ g:ft_ignore_pat | runtime! scripts.vim | endif
25+
au StdinReadPost * if !did_filetype() | runtime! scripts.vim | endif
26+
endif
27+
2128
augroup END
2229
]]
2330

0 commit comments

Comments
 (0)