From 3155b55819b5af8f6186b597331c04c94eaf93db Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Tue, 17 Jul 2018 16:08:22 +1200 Subject: Separate shebang_create_exec into autoload funcs --- vim/autoload/shebang_create_exec.vim | 14 ++++++++++++++ vim/plugin/shebang_create_exec.vim | 18 ++---------------- 2 files changed, 16 insertions(+), 16 deletions(-) create mode 100644 vim/autoload/shebang_create_exec.vim diff --git a/vim/autoload/shebang_create_exec.vim b/vim/autoload/shebang_create_exec.vim new file mode 100644 index 00000000..b01cf584 --- /dev/null +++ b/vim/autoload/shebang_create_exec.vim @@ -0,0 +1,14 @@ +" If the buffer starts with a shebang and the file being saved to doesn't +" exist yet, set up a hook to make it executable after the write is done +function! shebang_create_exec#Check(filename) abort + if stridx(getline(1), '#!') == 0 && !filereadable(a:filename) + autocmd shebang_create_exec BufWritePost + \ call shebang_create_exec#Chmod(expand(':p')) + endif +endfunction + +" Make the file executable and clear away the hook that called us +function! shebang_create_exec#Chmod(filename) abort + autocmd! shebang_create_exec BufWritePost + call system('chmod +x '.shellescape(a:filename)) +endfunction diff --git a/vim/plugin/shebang_create_exec.vim b/vim/plugin/shebang_create_exec.vim index 7fabd8f7..401a23b8 100644 --- a/vim/plugin/shebang_create_exec.vim +++ b/vim/plugin/shebang_create_exec.vim @@ -16,20 +16,6 @@ let g:loaded_shebang_create_exec = 1 " Set up hook for before writes to check the buffer for new shebangs augroup shebang_create_exec autocmd! - autocmd BufWritePre * call s:Check(expand(':p')) + autocmd BufWritePre * + \ call shebang_create_exec#Check(expand(':p')) augroup END - -" If the buffer starts with a shebang and the file being saved to doesn't -" exist yet, set up a hook to make it executable after the write is done -function! s:Check(filename) abort - if stridx(getline(1), '#!') == 0 && !filereadable(a:filename) - autocmd shebang_create_exec BufWritePost - \ call s:Chmod(expand(':p')) - endif -endfunction - -" Make the file executable and clear away the hook that called us -function! s:Chmod(filename) abort - autocmd! shebang_create_exec BufWritePost - call system('chmod +x '.shellescape(a:filename)) -endfunction -- cgit v1.2.3 From 91d40bfe186c888b845d5c64ef5aade1be9f37ab Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Tue, 17 Jul 2018 16:19:15 +1200 Subject: Adjust formatting of .gitmodules I forgot to check this after I added the last two plugins. --- .gitmodules | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.gitmodules b/.gitmodules index 4565f637..976d02fa 100644 --- a/.gitmodules +++ b/.gitmodules @@ -11,6 +11,9 @@ [submodule "vim/bundle/copy_linebreak"] path = vim/bundle/copy_linebreak url = https://sanctum.geek.nz/code/vim-copy-linebreak.git +[submodule "vim/bundle/digraph_search"] + path = vim/bundle/digraph_search + url = https://sanctum.geek.nz/code/vim-digraph-search.git [submodule "vim/bundle/insert_cancel"] path = vim/bundle/insert_cancel url = https://sanctum.geek.nz/code/vim-insert-cancel.git @@ -38,6 +41,9 @@ [submodule "vim/bundle/uncap_ex"] path = vim/bundle/uncap_ex url = https://sanctum.geek.nz/code/vim-uncap-ex.git +[submodule "vim/bundle/vimrc_reload_filetype"] + path = vim/bundle/vimrc_reload_filetype + url = https://sanctum.geek.nz/code/vim-vimrc-reload-filetype.git # My Vim filetype plugins [submodule "vim/bundle/diff_prune"] @@ -68,9 +74,3 @@ [submodule "vim/bundle/surround"] path = vim/bundle/surround url = https://sanctum.geek.nz/clone/vim-surround.git -[submodule "vim/bundle/digraph_search"] - path = vim/bundle/digraph_search - url = https://sanctum.geek.nz/code/vim-digraph-search.git -[submodule "vim/bundle/vimrc_reload_filetype"] - path = vim/bundle/vimrc_reload_filetype - url = https://sanctum.geek.nz/code/vim-vimrc-reload-filetype.git -- cgit v1.2.3 From 30d3c595060c6d40ca2b6a478cd79a8ca6b9ddc4 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Tue, 17 Jul 2018 16:20:10 +1200 Subject: Spin shebang_create_exec.vim into own distribution --- .gitmodules | 3 +++ vim/autoload/shebang_create_exec.vim | 14 -------------- vim/bundle/shebang_create_exec | 1 + vim/plugin/shebang_create_exec.vim | 21 --------------------- 4 files changed, 4 insertions(+), 35 deletions(-) delete mode 100644 vim/autoload/shebang_create_exec.vim create mode 160000 vim/bundle/shebang_create_exec delete mode 100644 vim/plugin/shebang_create_exec.vim diff --git a/.gitmodules b/.gitmodules index 976d02fa..bad6f54b 100644 --- a/.gitmodules +++ b/.gitmodules @@ -32,6 +32,9 @@ [submodule "vim/bundle/redact_pass"] path = vim/bundle/redact_pass url = https://sanctum.geek.nz/code/vim-redact-pass.git +[submodule "vim/bundle/shebang_create_exec"] + path = vim/bundle/shebang_create_exec + url = https://sanctum.geek.nz/code/vim-shebang-create-exec.git [submodule "vim/bundle/strip_trailing_whitespace"] path = vim/bundle/strip_trailing_whitespace url = https://sanctum.geek.nz/code/vim-strip-trailing-whitespace.git diff --git a/vim/autoload/shebang_create_exec.vim b/vim/autoload/shebang_create_exec.vim deleted file mode 100644 index b01cf584..00000000 --- a/vim/autoload/shebang_create_exec.vim +++ /dev/null @@ -1,14 +0,0 @@ -" If the buffer starts with a shebang and the file being saved to doesn't -" exist yet, set up a hook to make it executable after the write is done -function! shebang_create_exec#Check(filename) abort - if stridx(getline(1), '#!') == 0 && !filereadable(a:filename) - autocmd shebang_create_exec BufWritePost - \ call shebang_create_exec#Chmod(expand(':p')) - endif -endfunction - -" Make the file executable and clear away the hook that called us -function! shebang_create_exec#Chmod(filename) abort - autocmd! shebang_create_exec BufWritePost - call system('chmod +x '.shellescape(a:filename)) -endfunction diff --git a/vim/bundle/shebang_create_exec b/vim/bundle/shebang_create_exec new file mode 160000 index 00000000..9adbf4f7 --- /dev/null +++ b/vim/bundle/shebang_create_exec @@ -0,0 +1 @@ +Subproject commit 9adbf4f7e575fe8bbcfb2e1b2b6cd34bf42140a2 diff --git a/vim/plugin/shebang_create_exec.vim b/vim/plugin/shebang_create_exec.vim deleted file mode 100644 index 401a23b8..00000000 --- a/vim/plugin/shebang_create_exec.vim +++ /dev/null @@ -1,21 +0,0 @@ -" -" shebang_create_exec.vim: Make a file executable on first save if it starts with a -" shebang. -" -" Author: Tom Ryder -" License: Same as Vim itself -" -if exists('g:loaded_shebang_create_exec') || &compatible - finish -endif -if !has('autocmd') || !has('unix') || !exists('*shellescape') - finish -endif -let g:loaded_shebang_create_exec = 1 - -" Set up hook for before writes to check the buffer for new shebangs -augroup shebang_create_exec - autocmd! - autocmd BufWritePre * - \ call shebang_create_exec#Check(expand(':p')) -augroup END -- cgit v1.2.3 From ca42611aec7e22165f01bb1c89016d163bdcd455 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Tue, 17 Jul 2018 22:48:51 +1200 Subject: Check b:is_posix existence not value --- vim/after/ftplugin/sh.vim | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/vim/after/ftplugin/sh.vim b/vim/after/ftplugin/sh.vim index 88254ea6..475527b9 100644 --- a/vim/after/ftplugin/sh.vim +++ b/vim/after/ftplugin/sh.vim @@ -27,7 +27,8 @@ let b:undo_ftplugin .= '|unlet b:current_compiler b:sh_check_compiler' \ . '|setlocal errorformat< makeprg<' " Resort to g:is_posix for correct syntax on older runtime files -if b:is_posix && (v:version < 800 || v:version == 800 && !has('patch257')) +if exists('b:is_posix') + \ && (v:version < 800 || v:version == 800 && !has('patch257')) let g:is_posix = 1 endif -- cgit v1.2.3 From fcc0e387b0f4ae02a07b6c721066749161f9444f Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 18 Jul 2018 10:13:30 +1200 Subject: Scrap auto_cache_dirs plugin for a new approach Trying this instead; creating the relevant directories at install time. Also putting all three under one "cache" subdir of ~/.vim or ~/vimfiles. I'm not sure this is actually better, but I do like that the relevant options are now set in the .vimrc rather than in a plugin, so I guess we'll see. --- .gitmodules | 3 --- Makefile | 8 +++++++- vim/bundle/auto_cache_dirs | 1 - vim/vimrc | 40 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 47 insertions(+), 5 deletions(-) delete mode 160000 vim/bundle/auto_cache_dirs diff --git a/.gitmodules b/.gitmodules index bad6f54b..093f1fc4 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,7 +1,4 @@ # My Vim plugins -[submodule "vim/bundle/auto_cache_dirs"] - path = vim/bundle/auto_cache_dirs - url = https://sanctum.geek.nz/code/vim-auto-cache-dirs.git [submodule "vim/bundle/big_file_options"] path = vim/bundle/big_file_options url = https://sanctum.geek.nz/code/vim-big-file-options.git diff --git a/Makefile b/Makefile index e3e0ad38..507221a8 100644 --- a/Makefile +++ b/Makefile @@ -548,11 +548,17 @@ install-vim-bundle: install-vim-config 'cp -p -- "$$1" $(VIMDIR)/"$${1#vim/bundle/*/}"' _ {} \; $(VIM) -e -u NONE -c 'helptags $(VIMDIR)/doc' -c quit +install-vim-cache: + mkdir -p -- \ + $(VIMDIR)/cache/backup \ + $(VIMDIR)/cache/swap \ + $(VIMDIR)/cache/undo + install-vim-compiler: mkdir -p -- $(VIMDIR)/compiler cp -p -- vim/compiler/*.vim $(VIMDIR)/compiler -install-vim-config: +install-vim-config: install-vim-cache cp -p -- vim/vimrc $(VIMRC) if [ -e /etc/debian_version ] ; then \ cp -p -- vim/system/debian.vim $(VIMDIR)/system.vim ; \ diff --git a/vim/bundle/auto_cache_dirs b/vim/bundle/auto_cache_dirs deleted file mode 160000 index 70ce1808..00000000 --- a/vim/bundle/auto_cache_dirs +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 70ce18086dcd84044b307d1481ae8651b9edd4ab diff --git a/vim/vimrc b/vim/vimrc index c8e219f1..e6ff3c77 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -50,6 +50,13 @@ set backspace+=eol " Line breaks set backspace+=indent " Spaces from 'autoindent' set backspace+=start " The start of current insertion +" Try to keep swapfiles in one system-appropriate dir +if has('unix') + set directory^=~/.vim/cache/undo +elseif has('win32') || has('win64') + set directory^=~/vimfiles/cache/undo +endif + " How to deal with lines wrapping beyond the last screen row if v:version > 704 || v:version == 704 && has('patch2109') set display=truncate " Show '@@@' on the last line, if supported @@ -105,6 +112,24 @@ set shortmess+=I " Give me a bit longer to complete mappings set timeoutlen=3000 +" Backup settings +if has('backup') + + " Do keep backups + set backup + + " Try to keep them all in one system-appropriate dir, with full path + if has('unix') + set backupdir^=~/.vim/cache/backup// + elseif has('win32') || has('win64') + set backupdir^=~/vimfiles/cache/backup// + endif + + " Don't back up stuff in /dev/shm or /var/tmp + set backupskip+=/dev/shm,/var/tmp + +endif + " Clear default 'comments' value, let the filetype handle it if has('comments') set comments= @@ -142,6 +167,21 @@ if has('mksession') set sessionoptions-=options endif +" Persistent undo settings +if has('persistent_undo') + + " Do keep undo files + set undofile + + " Try to keep them all in one system-appropriate dir + if has('unix') + set undodir^=~/.vim/cache/undo// + elseif has('win32') || has('win64') + set undodir^=~/vimfiles/cache/undo// + endif + +endif + " Let me move beyond buffer text in visual block mode if has('virtualedit') set virtualedit+=block -- cgit v1.2.3 From a70662afde9887b550dcccb96d3768b9eef31396 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 18 Jul 2018 10:14:52 +1200 Subject: Bump VERSION --- VERSION | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/VERSION b/VERSION index 8f530b83..ba32cbdb 100644 --- a/VERSION +++ b/VERSION @@ -1,2 +1,2 @@ -tejr dotfiles v1.33.0 -Tue Jul 17 03:59:26 UTC 2018 +tejr dotfiles v1.34.0 +Tue Jul 17 22:14:46 UTC 2018 -- cgit v1.2.3