aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsrdusr <trevorgray@srdusr.com>2023-03-05 23:52:57 +0200
committersrdusr <trevorgray@srdusr.com>2023-03-05 23:52:57 +0200
commit1dfe25c30dda2910f1cd1d43f4c97e6224cbf433 (patch)
treeb360c79b288d9ddf12a7b215ecc96f37f8a6e857
parent30a76694d898a9b99dc06c5ff74ad43b9d9bea3b (diff)
downloaddotfiles-1dfe25c30dda2910f1cd1d43f4c97e6224cbf433.tar.gz
dotfiles-1dfe25c30dda2910f1cd1d43f4c97e6224cbf433.zip
autocommand to add timestamp to backup files
-rw-r--r--lua/user/opts.lua9
1 files changed, 9 insertions, 0 deletions
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 --