Use XDG for swap and backup as well, plus ensure that XDG cache dirs are created

This commit is contained in:
Danielle McLean 2017-09-11 09:32:55 +10:00
parent 405bea7ea4
commit 8b15560413
Signed by: 00dani
GPG key ID: 5A5D2D1AFF12EEC5

View file

@ -8,6 +8,12 @@ if !filereadable($XDG_CACHE_HOME . '/vim/autoload/plug.vim')
augroup END augroup END
endif endif
function s:ensure_dir(dir)
if filewritable(a:dir) != 2
call mkdir(a:dir, "p", 0700)
endif
endfunction
call plug#begin($XDG_CACHE_HOME . '/vim/bundle') call plug#begin($XDG_CACHE_HOME . '/vim/bundle')
Plug 'tpope/vim-sensible' Plug 'tpope/vim-sensible'
@ -62,12 +68,15 @@ else
set number set number
endif endif
for s:dir in ['backup', 'swap', 'undo']
call s:ensure_dir($XDG_CACHE_HOME . '/vim/' . s:dir)
endfor
set backupdir=.,$XDG_CACHE_HOME/vim/backup
set directory=.,$XDG_CACHE_HOME/vim/swap
if exists('+undofile') if exists('+undofile')
set undofile set undofile
let &undodir = $XDG_CACHE_HOME . '/vim/undo' set undodir=$XDG_CACHE_HOME/vim/undo
if filewritable(&undodir) != 2
call mkdir(&undodir, 'p', 0700)
endif
endif endif
let g:airline_powerline_fonts = 1 let g:airline_powerline_fonts = 1