# HG changeset patch # User zegervdv # Date 1662097069 -7200 # Node ID c5ed13440614723f40abd2acec3f0cdd0a569bc0 # Parent 7e98d6e028196d58b39cf4f585e622363d463d9f Set and optionally create backup and undo dirs diff -r 7e98d6e02819 -r c5ed13440614 .chezmoitemplates/config.vim --- a/.chezmoitemplates/config.vim Thu Sep 01 15:59:47 2022 +0200 +++ b/.chezmoitemplates/config.vim Fri Sep 02 07:37:49 2022 +0200 @@ -4,25 +4,6 @@ let s:windows = has('win32') -" General Settings and options - -if !s:windows - if !isdirectory(expand(&backupdir)) - call mkdir(expand(&backupdir), "p") - endif - if !isdirectory(expand(&directory)) - call mkdir(expand(&directory), "p") - endif -end - -if v:version >= 703 - if !isdirectory(expand(&undodir)) - call mkdir(expand(&undodir), "p") - endif -endif - -" - " Mappings diff -r 7e98d6e02819 -r c5ed13440614 .chezmoitemplates/init.lua --- a/.chezmoitemplates/init.lua Thu Sep 01 15:59:47 2022 +0200 +++ b/.chezmoitemplates/init.lua Fri Sep 02 07:37:49 2022 +0200 @@ -770,12 +770,19 @@ opt.pastetoggle = '' -- Enable paste mode +local optdir = function(path) + local Path = require 'plenary.path' + local full_path = Path:new(vim.fn.stdpath 'cache' .. '/' .. path) + if not full_path:exists() then full_path:mkdir { parents = true } end + return full_path .. '//' +end + opt.undofile = true -- Persistently remember undos opt.undolevels = 1000 -opt.undodir = home .. '/.config/nvim/tmp/undo//' +opt.undodir = optdir 'undo' opt.swapfile = false -- Disable swap files opt.backup = true -- Keep backups -opt.backupdir = home .. '/.config/nvim/tmp/backup//' +opt.backupdir = optdir 'backup' -- Files to ignore from completion opt.wildignore:append {