From 1dfe25c30dda2910f1cd1d43f4c97e6224cbf433 Mon Sep 17 00:00:00 2001 From: srdusr Date: Sun, 5 Mar 2023 23:52:57 +0200 Subject: autocommand to add timestamp to backup files --- lua/user/opts.lua | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'lua') diff --git a/lua/user/opts.lua b/lua/user/opts.lua index 65eaa23..26dc60d 100644 --- a/lua/user/opts.lua +++ b/lua/user/opts.lua @@ -130,6 +130,15 @@ vim.opt.directory = { prefix .. "/nvim/tmp/.swp//" } vim.opt.backup = false -- vim.opt.undofile = false -- vim.opt.swapfile = true -- +-- Add timestamp as extension for backup files +vim.api.nvim_create_autocmd('BufWritePre', { + group = vim.api.nvim_create_augroup('timestamp_backupext', { clear = true }), + desc = 'Add timestamp to backup extension', + pattern = '*', + callback = function() + vim.opt.backupext = '-' .. vim.fn.strftime('%Y%m%d%H%M') + end, +}) -- Format --vim.opt.textwidth = 80 -- -- cgit v1.2.3