Add autoload autocommands for file change reload
This commit is contained in:
@@ -1,6 +1,5 @@
|
|||||||
require("config.lazy")
|
require("config.lazy")
|
||||||
|
|
||||||
|
|
||||||
-- colorscheme
|
-- colorscheme
|
||||||
vim.o.termguicolors = true
|
vim.o.termguicolors = true
|
||||||
vim.opt.winborder = 'rounded'
|
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 python set fileformat=unix encoding=utf-8")
|
||||||
vim.cmd("au FileType markdown,tex set spell spelllang=en_us")
|
vim.cmd("au FileType markdown,tex set spell spelllang=en_us")
|
||||||
|
|
||||||
|
-- ------------------------------------------------------------------------
|
||||||
|
-- Auto‑reload 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 auto‑check
|
||||||
|
-- * 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",
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user