.config/nvim/plugin/auto-prune.lua

changeset 1162
e6da5f7156c2
parent 1161
2543467f42da
equal deleted inserted replaced
1161:2543467f42da 1162:e6da5f7156c2
14 os.remove(fpath) 14 os.remove(fpath)
15 end 15 end
16 end 16 end
17 end 17 end
18 18
19 vim.api.nvim_create_autocmd("VimEnter", { 19 local function auto_prune()
20 pattern = "*",
21 group = vim.api.nvim_create_augroup("AutoPrune", { clear = true }),
22 callback = function()
23 if vim.v.vim_did_enter then return end
24 if vim.go.swapfile then prune_files(vim.go.directory, 90) end 20 if vim.go.swapfile then prune_files(vim.go.directory, 90) end
25 if vim.go.backup then prune_files(vim.go.backupdir, 90) end 21 if vim.go.backup then prune_files(vim.go.backupdir, 90) end
26 if vim.go.undofile then prune_files(vim.go.undodir, 90) end 22 if vim.go.undofile then prune_files(vim.go.undodir, 90) end
27 end 23 end
28 }) 24
25 if vim.v.vim_did_enter then
26 auto_prune()
27 else
28 vim.api.nvim_create_autocmd("VimEnter", {
29 pattern = "*",
30 group = vim.api.nvim_create_augroup("AutoPrune", { clear = true }),
31 callback = auto_prune, })
32 end

mercurial