aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2019-06-06 16:09:08 +1200
committerTom Ryder <tom@sanctum.geek.nz>2019-06-06 16:16:02 +1200
commit6f29fbf9ed992ff47a172de17edadf1324391e51 (patch)
tree27913f551e9fb556dcbb9854248de817053d6fe9
parentAdd a couple of 'formatoptions' (diff)
downloaddotfiles-6f29fbf9ed992ff47a172de17edadf1324391e51.tar.gz
dotfiles-6f29fbf9ed992ff47a172de17edadf1324391e51.zip
Improve handling of awkward filenames in options
-rw-r--r--vim/autoload/vimrc.vim10
-rw-r--r--vim/vimrc8
2 files changed, 12 insertions, 6 deletions
diff --git a/vim/autoload/vimrc.vim b/vim/autoload/vimrc.vim
index de73720b..25d3b22e 100644
--- a/vim/autoload/vimrc.vim
+++ b/vim/autoload/vimrc.vim
@@ -1,6 +1,12 @@
-" Escape a text value for inclusion in a comma-separated option value
+" Escape a text value for inclusion in an option value
function! vimrc#EscapeSet(string) abort
- return escape(a:string, '\ ,')
+ return escape(a:string, '\ ')
+endfunction
+
+" Escape a text value for inclusion as an element in a comma-separated list
+" option value
+function! vimrc#EscapeSetList(string) abort
+ return vimrc#EscapeSet(escape(a:string, ','))
endfunction
" Check that we have a plugin available, and will be loading it
diff --git a/vim/vimrc b/vim/vimrc
index d167ed02..b2f32930 100644
--- a/vim/vimrc
+++ b/vim/vimrc
@@ -24,7 +24,7 @@ set backspace+=start " Before the start of current insertion
" Keep backup files in dedicated directory; add trailing double-slash to keep
" full path in name, if Vim is new enough to support that
set backup
-execute 'set backupdir^='.vimrc#EscapeSet($MYVIM.'/cache/backup')
+execute 'set backupdir^='.vimrc#EscapeSetList($MYVIM.'/cache/backup')
\ . (vimrc#Version('8.1.251') ? '//' : '')
" Add some *nix paths not to back up
@@ -55,7 +55,7 @@ set confirm
set cpoptions+=J
" Keep swap files in dedicated directory, named with full path
-set directory^=$MYVIM/cache/swap//
+execute 'set directory^='.vimrc#EscapeSetList($MYVIM.'/cache/swap')
" If the environment didn't set an encoding, use UTF-8, not ASCII
if !exists('$LANG')
@@ -169,7 +169,7 @@ endif
" Keep persistent undo files in dedicated directory, named with full path
if has('persistent_undo') " v7.2.438
set undofile
- set undodir^=$MYVIM/cache/undo//
+ execute 'set undodir^='.vimrc#EscapeSetList($MYVIM.'/cache/undo//')
endif
" Keep the viminfo file in the home Vim directory, mostly to stop history
@@ -177,7 +177,7 @@ endif
if exists('+viminfofile') " Use new option method if we can (v8.1.716)
set viminfofile=$MYVIM/cache/viminfo
else " Resort to clunkier method with 'viminfo' option flag
- execute 'set viminfo+=n'.vimrc#EscapeSet($MYVIM.'/cache/viminfo')
+ execute 'set viminfo+='.vimrc#EscapeSet('n'.$MYVIM.'/cache/viminfo')
endif
" Let me move beyond buffer text in visual block mode