Skip to content

Commit

Permalink
feat(filetype): support scripts.vim with filetype.lua (neovim#17517)
Browse files Browse the repository at this point in the history
When filetype.vim is disabled, create the autocommand that runs
scripts.vim in filetype.lua.
  • Loading branch information
gpanders authored Feb 24, 2022
1 parent b5bf487 commit fdea157
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions runtime/filetype.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ if vim.g.do_filetype_lua ~= 1 then
return
end

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

Expand Down

0 comments on commit fdea157

Please sign in to comment.