diff options
| author | Thomas Vanbesien <tvanbesi@proton.me> | 2026-05-22 11:46:08 +0200 |
|---|---|---|
| committer | Thomas Vanbesien <tvanbesi@proton.me> | 2026-05-22 11:46:08 +0200 |
| commit | 1fb329fc26bfe119dd48b99dba300af87048a132 (patch) | |
| tree | a64c4d6d71420bdd17f9278079a76da631d4029f /.config | |
| parent | 047fae7cd3e921922aeb628230dbf75b52c43117 (diff) | |
| download | dotfiles-1fb329fc26bfe119dd48b99dba300af87048a132.tar.gz dotfiles-1fb329fc26bfe119dd48b99dba300af87048a132.zip | |
misc(nvim): reload buffer when its file changed on disk
Bump 'updatetime' to 1 second because it affects three things:
- swap file save frequency
- GitGutter signs update frequency
- CursorHold and CursorHoldI trigger frequency
100ms is too high of a frequency.
Enable focus events in tmux for nvim 'FocusGained' event,
Add two event handlers, one for updating the buffer with `checktime`,
another for logging a message when doing so.
Diffstat (limited to '.config')
| -rw-r--r-- | .config/nvim/init.lua | 18 | ||||
| -rw-r--r-- | .config/nvim/plugin/50-git.lua | 2 | ||||
| -rw-r--r-- | .config/tmux/tmux.conf | 2 |
3 files changed, 20 insertions, 2 deletions
diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua index 3f7515c..7ffe81f 100644 --- a/.config/nvim/init.lua +++ b/.config/nvim/init.lua @@ -66,6 +66,24 @@ vim.api.nvim_create_autocmd({ "WinEnter", "TermOpen" }, { end, }) +vim.opt.updatetime = 1000 -- Swap file save frequency; also how often GitGutter signs update in ms +-- Reload buffer when file has been modified outside of nvim +vim.api.nvim_create_autocmd({ "FocusGained", "BufEnter", "CursorHold", "CursorHoldI" }, { + desc = "Reload buffer when modified outside of nvim", + group = vim.g.dotfiles.augroup, + pattern = "*", + command = "checktime", +}) +-- Log a message when buffer is reloaded because the file has changed on disk outside of nvim +vim.api.nvim_create_autocmd({ "FileChangedShellPost" }, { + desc = "Notify buffer reloaded because its file has changed on disk", + group = vim.g.dotfiles.augroup, + pattern = "*", + callback = function() + vim.notify("File changed on disk, buffer reloaded", vim.log.levels.WARN) + end, +}) + ------------------------------------------------------------------------------------------------------------------------ -- Plugins ------------------------------------------------------------------------------------------------------------------------ diff --git a/.config/nvim/plugin/50-git.lua b/.config/nvim/plugin/50-git.lua index 609ab93..64e6cd0 100644 --- a/.config/nvim/plugin/50-git.lua +++ b/.config/nvim/plugin/50-git.lua @@ -4,8 +4,6 @@ vim.pack.add({ "https://github.com/airblade/vim-gitgutter" }) -- Show git status in the gutter -vim.opt.updatetime = 100 -- How often the git signs in the gutter update in ms - vim.keymap.set("n", "<Leader>gt", "<Cmd>GitGutterLineHighlightsToggle<CR>", { desc = "Toggle git line highlighting" }) vim.keymap.set("n", "<Leader>gg", "<Cmd>GitGutter<CR>", { desc = "Refresh GitGutter" }) vim.keymap.set("n", "<Leader>gq", "<Cmd>GitGutterQuickFix<CR>", { desc = "Git hunks to quickfix list" }) diff --git a/.config/tmux/tmux.conf b/.config/tmux/tmux.conf index 3a6be99..434bcf0 100644 --- a/.config/tmux/tmux.conf +++ b/.config/tmux/tmux.conf @@ -15,6 +15,8 @@ set-option -g window-status-format "[#I | #{p18:#{=/18/…:window_n set-option -g window-status-current-format "[ ▶ #I | #{p18:#{=/18/…:window_name}#{?window_flags,#F,}}]" set-option -g window-status-current-style "bold" +set-option -g focus-events on + unbind C-b set-option -g prefix C-Space bind-key C-space send-prefix |
