diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2018-06-01 22:05:36 +1200 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2018-06-01 22:51:22 +1200 |
commit | 6103857e4859baf96de11a7b13cbb6dbb6f80894 (patch) | |
tree | 033a3e74250dc21c853736cf233628b44ae8414a | |
parent | Add backported shellslashes() fallback function (diff) | |
download | vim-auto-cache-dirs-6103857e4859baf96de11a7b13cbb6dbb6f80894.tar.gz vim-auto-cache-dirs-6103857e4859baf96de11a7b13cbb6dbb6f80894.zip |
Completely refactor SetDir() calling
Move the double-slash appending into it via a passed parameter, so that
we don't pass it to EstablishDir() with those appended already.
-rw-r--r-- | plugin/auto_cache_dirs.vim | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/plugin/auto_cache_dirs.vim b/plugin/auto_cache_dirs.vim index 374b445..2a8f2ff 100644 --- a/plugin/auto_cache_dirs.vim +++ b/plugin/auto_cache_dirs.vim @@ -95,11 +95,15 @@ endfunction " If we can find or create a directory for it, set an option and its related " directory option -function s:SetDir(subdir, option, optiondir) +function s:SetDir(option_bool, option_dir, subdir, name_path) let l:dir = g:auto_cache_dirs_root . '/' . a:subdir if s:EstablishDir(expand(l:dir)) - execute 'set ' . a:option - execute 'set ' . a:optiondir . '^=' . l:dir + execute 'set ' . a:option_bool + let l:item = l:dir + if a:name_path + let l:item = l:dir . '//' + endif + execute 'set ' . a:option_dir . '^=' . l:item else echoerr 'Could not create ' . l:dir endif @@ -108,22 +112,16 @@ endfunction " Set backup, swap, and undo data directories as configured function s:Run() if g:auto_cache_dirs_backup - let l:subdir = 'backup' - call s:SetDir(l:subdir, 'backup', 'backupdir') + call s:SetDir('backup', 'backupdir', 'backup', + \ 0) endif if g:auto_cache_dirs_swap - let l:subdir = 'swap' - if g:auto_cache_dirs_name_path - let l:subdir .= '//' - endif - call s:SetDir(l:subdir, 'swapfile', 'directory') + call s:SetDir('swapfile', 'directory', 'swap', + \ g:auto_cache_dirs_name_path) endif if g:auto_cache_dirs_undo && has('persistent_undo') - let l:subdir = 'undo' - if g:auto_cache_dirs_name_path - let l:subdir .= '//' - endif - call s:SetDir(l:subdir, 'undofile', 'undodir') + call s:SetDir('undofile', 'undodir', 'undo', + \ g:auto_cache_dirs_name_path) endif endfunction |