mirror of
https://github.com/neovim/neovim.git
synced 2026-05-03 04:25:03 +00:00
fix(filetype): match on <afile> rather than <abuf> (#16943)
Filetype detection runs on BufRead and BufNewFile autocommands, both of which can fire without an underlying buffer, so it's incorrect to use <abuf> to determine the file path. Instead, match on <afile> and assume that the buffer we're operating on is the current buffer. This is the same assumption that filetype.vim makes, so it should be safe.
This commit is contained in:
@@ -9,7 +9,7 @@ end
|
||||
|
||||
vim.cmd [[
|
||||
augroup filetypedetect
|
||||
au BufRead,BufNewFile * call v:lua.vim.filetype.match(str2nr(expand('<abuf>')))
|
||||
au BufRead,BufNewFile * call v:lua.vim.filetype.match(expand('<afile>'))
|
||||
|
||||
" These *must* be sourced after the autocommand above is created
|
||||
runtime! ftdetect/*.vim
|
||||
|
||||
Reference in New Issue
Block a user