diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua index 11b52c8..a9782d6 100644 --- a/.config/nvim/init.lua +++ b/.config/nvim/init.lua @@ -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") +-- ------------------------------------------------------------------------ +-- 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", + } +)