aboutsummaryrefslogtreecommitdiff
path: root/runtime/filetype.lua
diff options
context:
space:
mode:
authorGregory Anders <8965202+gpanders@users.noreply.github.com>2022-01-05 09:50:54 -0700
committerGitHub <noreply@github.com>2022-01-05 09:50:54 -0700
commitf40ce3456313138f2e0f822da9676ed3bc51f608 (patch)
treefe255279c898902a601e182e97092dc540f80736 /runtime/filetype.lua
parent55a59e56eda98f17448a1c318a346ae12d30fc05 (diff)
downloadrneovim-f40ce3456313138f2e0f822da9676ed3bc51f608.tar.gz
rneovim-f40ce3456313138f2e0f822da9676ed3bc51f608.tar.bz2
rneovim-f40ce3456313138f2e0f822da9676ed3bc51f608.zip
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.
Diffstat (limited to 'runtime/filetype.lua')
-rw-r--r--runtime/filetype.lua2
1 files changed, 1 insertions, 1 deletions
diff --git a/runtime/filetype.lua b/runtime/filetype.lua
index 855baf7dfa..fcfc5701f0 100644
--- a/runtime/filetype.lua
+++ b/runtime/filetype.lua
@@ -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