Add autoload autocommands for file change reload

This commit is contained in:
2025-12-01 20:03:07 -08:00
parent 833d17bc94
commit 798d6bb69c

View File

@@ -1,6 +1,5 @@
require("config.lazy")
-- colorscheme
vim.o.termguicolors = true
vim.opt.winborder = 'rounded'
@@ -36,4 +35,25 @@ vim.cmd("set lazyredraw")
vim.cmd("au FileType python set fileformat=unix encoding=utf-8")
vim.cmd("au FileType markdown,tex set spell spelllang=en_us")
-- ------------------------------------------------------------------------
-- Autoreload buffers when files change externally
-- ------------------------------------------------------------------------
-- Ensure the option is enabled (already set above, but kept for clarity)
vim.cmd("set autoread")
-- Create a dedicated augroup to avoid duplicate autocommands if this file
-- is sourced multiple times (e.g., when using :source ~/.config/nvim/init.lua).
vim.api.nvim_create_augroup("AutoReload", { clear = true })
-- Run `checktime` for the following events:
-- * CursorHold, CursorHoldI idle cursor, typical for autocheck
-- * FocusGained when you return to Neovim from another app
-- * BufEnter when you jump to a buffer that may already be stale
vim.api.nvim_create_autocmd(
{ "CursorHold", "CursorHoldI", "FocusGained", "BufEnter" },
{
group = "AutoReload",
pattern = "*",
command = "silent! checktime",
}
)