fix(autocmds): avoid checktime when buftype=nofile

It triggered an 'E11: Invalid in command-line window; <CR> executes,
CTRL-C quits' error when Neovim was in Command Line window and
FocusGained.
This commit is contained in:
Frederick Zhang 2023-12-30 01:51:37 +11:00
parent 879e29504d
commit 88fef0b968
No known key found for this signature in database
GPG key ID: 980A192C361BE1AE

View file

@ -7,7 +7,11 @@ end
-- Check if we need to reload the file when it changed -- Check if we need to reload the file when it changed
vim.api.nvim_create_autocmd({ "FocusGained", "TermClose", "TermLeave" }, { vim.api.nvim_create_autocmd({ "FocusGained", "TermClose", "TermLeave" }, {
group = augroup("checktime"), group = augroup("checktime"),
command = "checktime", callback = function()
if vim.o.buftype ~= 'nofile' then
vim.cmd('checktime')
end
end
}) })
-- Highlight on yank -- Highlight on yank