Skip to content

Commit

Permalink
feat: clean undo files
Browse files Browse the repository at this point in the history
  • Loading branch information
gouflv committed Dec 2, 2022
1 parent 95db40e commit 66dbcc5
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
7 changes: 7 additions & 0 deletions lua/base.lua
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,10 @@ vim.api.nvim_create_user_command('CopyPath', function()
vim.fn.setreg('+', path)
vim.notify('Copied "' .. path .. '" to the clipboard')
end, {})

local clean_undo_files = require('utils').clean_undo_files
vim.api.nvim_create_autocmd('VimLeavePre', {
callback = function()
clean_undo_files()
end,
})
12 changes: 8 additions & 4 deletions lua/plugins.lua
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
local status, packer = pcall(require, 'packer')
if (not status) then
if not status then
return
end

-- Load packer.nvim
vim.cmd('packadd packer.nvim')

packer.startup({ function(use)
use {
'lewis6991/impatient.nvim',
Expand Down Expand Up @@ -170,3 +167,10 @@ end,
max_jobs = 10,
}
})

vim.cmd([[
augroup packer_user_config
autocmd!
autocmd BufWritePost plugins.lua source <afile> | PackerCompile
augroup end
]])
4 changes: 4 additions & 0 deletions lua/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,8 @@ function M.merge(a, b)
return vim.tbl_deep_extend('force', {}, a, b)
end

function M.clean_undo_files()
vim.fn.system('fd -p ~/.local/state/nvim/undo --changed-before 7d -X rm -f')
end

return M

0 comments on commit 66dbcc5

Please sign in to comment.