# HG changeset patch # User Meredith Howard # Date 1714959834 18000 # Node ID e6da5f7156c28de8b19d851b1ef046d2e387918d # Parent 2543467f42da682f837c8d3353ab83d51d0b13ab Fix VimEnter/vim_did_enter behavior diff --git a/.config/nvim/plugin/auto-prune.lua b/.config/nvim/plugin/auto-prune.lua --- a/.config/nvim/plugin/auto-prune.lua +++ b/.config/nvim/plugin/auto-prune.lua @@ -16,13 +16,17 @@ local function prune_files(path, days) end end -vim.api.nvim_create_autocmd("VimEnter", { - pattern = "*", - group = vim.api.nvim_create_augroup("AutoPrune", { clear = true }), - callback = function() - if vim.v.vim_did_enter then return end +local function auto_prune() if vim.go.swapfile then prune_files(vim.go.directory, 90) end if vim.go.backup then prune_files(vim.go.backupdir, 90) end if vim.go.undofile then prune_files(vim.go.undodir, 90) end - end -}) +end + +if vim.v.vim_did_enter then + auto_prune() +else + vim.api.nvim_create_autocmd("VimEnter", { + pattern = "*", + group = vim.api.nvim_create_augroup("AutoPrune", { clear = true }), + callback = auto_prune, }) +end