Permalink
Browse files

Prefer to use $VIM_CACHE_DIR/undo for undodir.

If $VIMFILES/.undo exists, it'll use that instead.  This also removes
the undo directory, but the contents will be left on the user's machine
until they move it to $VIM_CACHE_DIR/vim/undo ($XDG_CACHE_HOME/vim/undo,
by default).  An ignore was added for the .undo directory, just to keep
things clean.
  • Loading branch information...
1 parent dad9ef5 commit a003838eaff27a704568cd0e28c863dc87a682c0 @jszakmeister committed Apr 11, 2013
Showing with 9 additions and 2 deletions.
  1. +1 −0 .gitignore
  2. +0 −1 .undo/.gitignore
  3. +8 −1 vimrc
View
@@ -3,3 +3,4 @@ spell
*.so
*.pyc
*.cache
+.undo
View
@@ -1 +0,0 @@
-*
View
@@ -765,7 +765,14 @@ set sessionoptions=blank,buffers,curdir,folds,help,resize,slash
" Setup undofile capability if available.
if exists("&undodir")
set undofile
- set undodir=$VIMFILES/.undo
+
+ if isdirectory(expand('$VIMFILES/.undo'))
+ set undodir=$VIMFILES/.undo
+ else
+ " Use silent! because mkdir() can fail if the directory already exists.
+ silent! call mkdir(expand('$VIM_CACHE_DIR/undo'), "p")
+ set undodir=$VIM_CACHE_DIR/.undo
+ endif
endif
" -------------------------------------------------------------

0 comments on commit a003838

Please sign in to comment.