]> oss.titaniummirror.com Git - smckown/dotfiles.git/blobdiff - vimrc
Swap/undo/backup is working again
[smckown/dotfiles.git] / vimrc
diff --git a/vimrc b/vimrc
index 95c7b564cde16da898f44aa28ef5b3db39f96b05..cb58ffc8f85be56b864f312b5570dc28adaee85e 100644 (file)
--- a/vimrc
+++ b/vimrc
@@ -34,8 +34,7 @@ if has("gui_running")
   endif
 endif
 
-" jellybeans is a nice dark scheme same for vim/xterm and gvim
-colors jellybeans
+colors lucius
 
 " Local listchars def if utf-8 terminal.  Otherwise sensible defaults are OK.
 if &termencoding ==# 'utf-8' || &encoding ==# 'utf-8'
@@ -88,12 +87,34 @@ if has("autocmd")
   autocmd BufNewFile,BufRead *.plt,*.gnnuplot setf gnuplot
 endif
 
-" Turn off backup and undo files if the proper dirs in ~/.local are not present.
-let s:dir = has('win32') ? '~/Application Data/Vim' : has('mac') ? '~/Library/Vim' : '~/.local/share/vim'
-if !isdirectory(expand(s:dir) . '/backup/')
+" Setup swap/backup/undo
+" Note that as of vim 7.4, backupdir // will not expand backup files to a full
+" path as is the case with directory and undodir.
+let s:dir = expand(has('win32') ? '~/Application Data/Vim' : has('mac') ?
+  \ '~/Library/Vim' : '~/.local/share/vim')
+execute 'set directory^=' . s:dir . '/swap//'
+if !isdirectory(s:dir . '/')
+  call mkdir(s:dir)
+endif
+if !isdirectory(s:dir . '/swap/')
+  call mkdir(s:dir . '/swap')
+endif
+if !isdirectory(s:dir . '/backup/')
+  call mkdir(s:dir . '/backup')
+endif
+if !isdirectory(s:dir . '/undo/')
+  call mkdir(s:dir . '/undo')
+endif
+if isdirectory(s:dir . '/backup/')
+  execute 'set backupdir=' . s:dir . '/backup//'
+  set backup
+else
   set nobackup
 endif
-if !isdirectory(expand(s:dir) . '/undo/') && exists('+undofile')
+if has('persistent_undo') && isdirectory(s:dir . '/undo/')
+  execute 'set undodir=' . s:dir . '/undo//'
+  set undofile
+else
   set noundofile
 endif