aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2020-05-16 01:22:54 +1200
committerTom Ryder <tom@sanctum.geek.nz>2020-05-16 01:29:15 +1200
commit3f52145bbedc8d291567d41e29805c6bd5d3a467 (patch)
tree73d2ab8dcf5d6efbfd47c21615eb92931da8c92a
parent516eea5f36f9d565014c23d8e0b10b43191aedce (diff)
downloaddotfiles-3f52145bbedc8d291567d41e29805c6bd5d3a467.tar.gz
dotfiles-3f52145bbedc8d291567d41e29805c6bd5d3a467.zip
Write out over-engineered path creation function
-rw-r--r--vim/autoload/path.vim14
-rw-r--r--vim/vimrc20
2 files changed, 2 insertions, 32 deletions
diff --git a/vim/autoload/path.vim b/vim/autoload/path.vim
deleted file mode 100644
index 54aacbc2..00000000
--- a/vim/autoload/path.vim
+++ /dev/null
@@ -1,14 +0,0 @@
-" Create all the directories needed for a path, with optional flag for
-" owner-only permissions
-function! path#Create(name, ...) abort
- if a:0 > 2
- echoerr 'Too many arguments'
- endif
- let name = fnamemodify(a:name, ':p')
- if isdirectory(name)
- return 1
- endif
- let path = 'p'
- let prot = a:0 == 1 && a:1 ? 0700 : 0755
- return mkdir(name, path, prot)
-endfunction
diff --git a/vim/vimrc b/vim/vimrc
index 13987c10..dc1183f6 100644
--- a/vim/vimrc
+++ b/vim/vimrc
@@ -162,21 +162,6 @@ if xdg#ConfigHome() !=# '' || !empty(xdg#ConfigDirs())
\), ','))
endif
-" We need a command to reliably establish a full path, whether or not the
-" directories already exist. We create a wrapper for the autoloaded function
-" path#Create() with similar calling conventions to mkdir(), but with the ‘p’
-" value for the second parameter {prot} forced on. Calling it with a bang
-" like :CreatePath! creates a private directory (permissions 0700).
-"
-command! -bang -bar -complete=dir -nargs=1 CreatePath
- \ call path#Create(expand(<q-args>), <q-bang> ==# '!')
-
-" Now that we have a way to create directories if they don’t already exist,
-" let’s apply it for the first time to the user runtime directory. Note that
-" we aren’t checking whether this actually succeeded. We do want errors
-" raised if there were problems with the creation, but we’ll barrel on ahead
-" regardless after warning the user about our failure.
-"
" Using a logical but non-default location for viminfo has the nice benefit of
" preventing command and search history from getting clobbered when something
" runs Vim without using this vimrc, because such an instance will safely
@@ -1373,8 +1358,7 @@ nnoremap <Leader>D
\ :PutDate!<CR>
" This group contains mappings that are to do with file and path management
-" relative to the current buffer. The Leader,P mapping that creates
-" directory hierarchies uses the :CreatePath command created earlier.
+" relative to the current buffer.
"" Leader,g shows the current file’s fully expanded path
nnoremap <Leader>g
@@ -1384,7 +1368,7 @@ nnoremap <Leader>G
\ :<C-U>cd %:h<Bar>pwd<CR>
"" Leader,P creates the path to the current file if it doesn’t exist
nnoremap <Leader>P
- \ :<C-U>CreatePath %:h<CR>
+ \ :<C-U>call mkdir(expand('%:h'), 'p')<CR>
" This group contains mappings that show information about Vim’s internals:
" marks, registers, variables, and the like.