diff options
| author | srdusr <trevorgray@srdusr.com> | 2023-03-05 23:52:57 +0200 |
|---|---|---|
| committer | srdusr <trevorgray@srdusr.com> | 2023-03-05 23:52:57 +0200 |
| commit | 1dfe25c30dda2910f1cd1d43f4c97e6224cbf433 (patch) | |
| tree | b360c79b288d9ddf12a7b215ecc96f37f8a6e857 /lua/user/opts.lua | |
| parent | 30a76694d898a9b99dc06c5ff74ad43b9d9bea3b (diff) | |
| download | dotfiles-1dfe25c30dda2910f1cd1d43f4c97e6224cbf433.tar.gz dotfiles-1dfe25c30dda2910f1cd1d43f4c97e6224cbf433.zip | |
autocommand to add timestamp to backup files
Diffstat (limited to 'lua/user/opts.lua')
| -rw-r--r-- | lua/user/opts.lua | 9 |
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 -- |
