diff --git a/dots/.config/nvim/lua/core/options.lua b/dots/.config/nvim/lua/core/options.lua index 3c72f35b..275c8a92 100755 --- a/dots/.config/nvim/lua/core/options.lua +++ b/dots/.config/nvim/lua/core/options.lua @@ -141,7 +141,8 @@ M.setup = function() opt.exrc = true -- Backups - opt.backupdir = vim.fn.stdpath('state') .. "/backup//" + opt.backupdir = vim.fn.stdpath("state") .. "/backup//" + opt.backupskip = opt.backupskip + "*/*passage.*" opt.backup = true end diff --git a/dots/.config/nvim/lua/core/postload.lua b/dots/.config/nvim/lua/core/postload.lua index e69de29b..c67a58c1 100755 --- a/dots/.config/nvim/lua/core/postload.lua +++ b/dots/.config/nvim/lua/core/postload.lua @@ -0,0 +1,23 @@ +local M = {} + +local augroup = vim.api.nvim_create_augroup("user-autocmds", { clear = false }) +vim.api.nvim_create_autocmd("BufReadPre", { + group = augroup, + desc = "Ensure backupskip files do not leave anything behind", + pattern = vim.opt.backupskip:get(), + callback = function(args) + ---@type integer + local bufnr = args.buf + + vim.iter({ + "swapfile", + "undofile", + }):each(function(opt) + vim.api.nvim_set_option_value(opt, false, { + buf = bufnr, + }) + end) + end, +}) + +return M