From 3f52145bbedc8d291567d41e29805c6bd5d3a467 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 16 May 2020 01:22:54 +1200 Subject: Write out over-engineered path creation function --- vim/autoload/path.vim | 14 -------------- vim/vimrc | 20 ++------------------ 2 files changed, 2 insertions(+), 32 deletions(-) delete mode 100644 vim/autoload/path.vim 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(), ==# '!') - -" 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 D \ :PutDate! " 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 g @@ -1384,7 +1368,7 @@ nnoremap G \ :cd %:hpwd "" Leader,P creates the path to the current file if it doesn’t exist nnoremap P - \ :CreatePath %:h + \ :call mkdir(expand('%:h'), 'p') " This group contains mappings that show information about Vim’s internals: " marks, registers, variables, and the like. -- cgit v1.2.3