aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2020-04-06 01:17:54 +1200
committerTom Ryder <tom@sanctum.geek.nz>2020-04-06 01:17:54 +1200
commit82994f97920709c7845fada95e95cd84302e2929 (patch)
tree25fd7880954c95b26c25c1c8cbd9caa2d4473b44
parent350ec5916a2f81dff72e937fac8f67a43be9130d (diff)
downloaddotfiles-82994f97920709c7845fada95e95cd84302e2929.tar.gz
dotfiles-82994f97920709c7845fada95e95cd84302e2929.zip
Call path create rather than command
Prevents issues with premature expansion of env variables.
-rw-r--r--o1
-rw-r--r--vim/autoload/path.vim4
-rw-r--r--vim/vimrc8
3 files changed, 7 insertions, 6 deletions
diff --git a/o b/o
new file mode 100644
index 00000000..3b2b1abe
--- /dev/null
+++ b/o
@@ -0,0 +1 @@
+da
diff --git a/vim/autoload/path.vim b/vim/autoload/path.vim
index e230cab2..54aacbc2 100644
--- a/vim/autoload/path.vim
+++ b/vim/autoload/path.vim
@@ -4,10 +4,10 @@ function! path#Create(name, ...) abort
if a:0 > 2
echoerr 'Too many arguments'
endif
- if isdirectory(a:name)
+ let name = fnamemodify(a:name, ':p')
+ if isdirectory(name)
return 1
endif
- let name = a:name
let path = 'p'
let prot = a:0 == 1 && a:1 ? 0700 : 0755
return mkdir(name, path, prot)
diff --git a/vim/vimrc b/vim/vimrc
index 013311b9..d0525c30 100644
--- a/vim/vimrc
+++ b/vim/vimrc
@@ -134,7 +134,7 @@ command! -bang -bar -complete=dir -nargs=1 CreatePath
" <https://github.com/vim/vim/releases/tag/v8.1.0716>
"
execute 'set viminfo+='.option#Escape('n'.$MYVIM.'/viminfo')
-CreatePath $MYVIM
+call path#Create($MYVIM)
" Speaking of recorded data in viminfo files, the default Vim limit of a mere
" 50 entries for command and search history is pretty stingy. Because I don’t
@@ -182,7 +182,7 @@ set backup
execute 'set backupdir^='.option#Escape(option#item#Escape(
\ $MYVIM.'/backup'.(has#('patch-8.1.251') ? '//' : ''),
\))
-CreatePath! $MYVIM/backup
+call path#Create($MYVIM.'/backup')
" Files in certain directories on Unix-compatible filesystems should not be
" backed up, for security reasons. This is particularly important if editing
@@ -220,7 +220,7 @@ endif
"
execute 'set directory^='
\.option#Escape(option#item#Escape($MYVIM.'/swap//'))
-CreatePath! $MYVIM/swap
+call path#Create($MYVIM.'/swap')
" Keep tracked undo history for files permanently, in a dedicated cache
" directory, so that the u/:undo and CTRL-R/:redo commands will work between
@@ -239,7 +239,7 @@ if has#('persistent_undo')
set undofile
execute 'set undodir^='
\.option#Escape(option#item#Escape($MYVIM.'/undo//'))
- CreatePath! $MYVIM/undo
+ call path#Create($MYVIM.'/undo')
endif
" Now that we have a bit more confidence in our runtime environment, set up