From 34803d74e4dfdb55edb56826050d9d26653e2e5a Mon Sep 17 00:00:00 2001 From: Buddy Sandidge Date: Tue, 16 Feb 2021 15:42:02 -0800 Subject: [PATCH] Avoid errors in old versions of vim --- vim/.config/vim/init.d/xdg.vim | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/vim/.config/vim/init.d/xdg.vim b/vim/.config/vim/init.d/xdg.vim index 1baf246..b7fa5fa 100644 --- a/vim/.config/vim/init.d/xdg.vim +++ b/vim/.config/vim/init.d/xdg.vim @@ -9,12 +9,31 @@ set runtimepath+=$XDG_CONFIG_HOME/vim/after set runtimepath+=$XDG_DATA_HOME/vim set packpath^=$XDG_DATA_HOME/vim -call mkdir($XDG_DATA_HOME.'/vim/spell', 'p', 0700) -set backupdir=$XDG_CACHE_HOME/vim/backup// | call mkdir(&backupdir, 'p', 0700) -set directory=$XDG_CACHE_HOME/vim/swap// | call mkdir(&directory, 'p', 0700) -set undodir=$XDG_CACHE_HOME/vim/undo// | call mkdir(&undodir, 'p', 0700) -set viewdir=$XDG_CACHE_HOME/vim/view// | call mkdir(&viewdir, 'p', 0700) +if !isdirectory($XDG_DATA_HOME.'/vim/spell') + call mkdir($XDG_DATA_HOME.'/vim/spell', 'p', 0700) +endif + +set backupdir=$XDG_CACHE_HOME/vim/backup/ +set directory=$XDG_CACHE_HOME/vim/swap/ +set undodir=$XDG_CACHE_HOME/vim/undo/ +set viewdir=$XDG_CACHE_HOME/vim/view/ + +if !isdirectory(&backupdir) + call mkdir(&backupdir, 'p', 0700) +endif + +if !isdirectory(&directory) + call mkdir(&directory, 'p', 0700) +endif + +if !isdirectory(&undodir) + call mkdir(&undodir, 'p', 0700) +endif + +if !isdirectory(&viewdir) + call mkdir(&viewdir, 'p', 0700) +endif if !has('nvim') set viminfofile=$XDG_CACHE_HOME/vim/viminfo