From eb97e0710ca1dee99cba8f5c44d80b84b0310a62 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Thu, 29 Nov 2018 19:52:37 +1300 Subject: Wrap Vim gitcommit autocmd clear in :execute Noticed that my b:undo_ftplugin script for this filetype was only getting halfway through its work, and stopping at this command. From `:help autocmd`: > Note: The ":autocmd" command can only be followed by another command when the > '|' appears before {cmd}. This works: > :augroup mine | au! BufRead | augroup END > But this sees "augroup" as part of the defined command: > :augroup mine | au! BufRead * | augroup END > :augroup mine | au BufRead * set tw=70 | augroup END > Instead you can put the group name into the command: > :au! mine BufRead * > :au mine BufRead * set tw=70 > Or use :execute: > :augroup mine | exe "au! BufRead *" | augroup END > :augroup mine | exe "au BufRead * set tw=70" | augroup END --- vim/after/ftplugin/gitcommit.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'vim/after/ftplugin/gitcommit.vim') diff --git a/vim/after/ftplugin/gitcommit.vim b/vim/after/ftplugin/gitcommit.vim index 2dc5fa37..0ba80c92 100644 --- a/vim/after/ftplugin/gitcommit.vim +++ b/vim/after/ftplugin/gitcommit.vim @@ -14,7 +14,7 @@ if has('autocmd') && exists('+cursorcolumn') autocmd CursorMoved,CursorMovedI \ let &l:colorcolumn = gitcommit#CursorColumn() augroup END - let b:undo_ftplugin .= '|autocmd! gitcommit' + let b:undo_ftplugin .= '|execute ''autocmd! gitcommit''' \ . '|augroup! gitcommit' endif -- cgit v1.2.3 From 59a0e5e3201c6041d3ca3da8efcb6e2b2b81fedd Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Thu, 29 Nov 2018 19:54:49 +1300 Subject: Restore value of 'colorcolumn' after ft=gitcommit --- vim/after/ftplugin/gitcommit.vim | 1 + 1 file changed, 1 insertion(+) (limited to 'vim/after/ftplugin/gitcommit.vim') diff --git a/vim/after/ftplugin/gitcommit.vim b/vim/after/ftplugin/gitcommit.vim index 0ba80c92..18bacfb8 100644 --- a/vim/after/ftplugin/gitcommit.vim +++ b/vim/after/ftplugin/gitcommit.vim @@ -16,6 +16,7 @@ if has('autocmd') && exists('+cursorcolumn') augroup END let b:undo_ftplugin .= '|execute ''autocmd! gitcommit''' \ . '|augroup! gitcommit' + \ . '|setlocal colorcolumn<' endif " Stop here if the user doesn't want ftplugin mappings -- cgit v1.2.3 From dc59d7e74635f9a56fef9049e34411d6ef535650 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Thu, 29 Nov 2018 23:26:52 +1300 Subject: Remove boilerplate after/ftplugin load guards I'm likely going to move away from Vim 6.0 support, at least for all of this filetype stuff. We will keep the one filetype load guard we actually need, which is the HTML one, to stop plugins like markdown.vim from loading it. --- vim/after/ftplugin/gitcommit.vim | 5 ----- 1 file changed, 5 deletions(-) (limited to 'vim/after/ftplugin/gitcommit.vim') diff --git a/vim/after/ftplugin/gitcommit.vim b/vim/after/ftplugin/gitcommit.vim index 18bacfb8..762df0ba 100644 --- a/vim/after/ftplugin/gitcommit.vim +++ b/vim/after/ftplugin/gitcommit.vim @@ -1,8 +1,3 @@ -" Extra configuration for Git commit messages -if &filetype !=# 'gitcommit' || v:version < 700 - finish -endif - " Make angle brackets behave like mail quotes setlocal comments+=n:> setlocal formatoptions+=coqr -- cgit v1.2.3 From 5f1f5b9de3d9ab80a0b5ecef4559b88990f42f4a Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Thu, 29 Nov 2018 23:29:09 +1300 Subject: Remove double-key mapping shortcuts I never use these anyway; I'm firmly in the habit of using underscores to represent the current line these days. --- vim/after/ftplugin/gitcommit.vim | 4 ---- 1 file changed, 4 deletions(-) (limited to 'vim/after/ftplugin/gitcommit.vim') diff --git a/vim/after/ftplugin/gitcommit.vim b/vim/after/ftplugin/gitcommit.vim index 762df0ba..1a4c1b1b 100644 --- a/vim/after/ftplugin/gitcommit.vim +++ b/vim/after/ftplugin/gitcommit.vim @@ -22,8 +22,6 @@ endif " Quote operator nnoremap q \ quote#Quote() -nnoremap qq - \ quote#Quote().'_' xnoremap q \ quote#Quote() let b:undo_ftplugin .= '|nunmap q' @@ -33,8 +31,6 @@ let b:undo_ftplugin .= '|nunmap q' " Quote operator with reformatting nnoremap Q \ quote#QuoteReformat() -nnoremap QQ - \ quote#QuoteReformat().'_' xnoremap Q \ quote#QuoteReformat() let b:undo_ftplugin .= '|nunmap Q' -- cgit v1.2.3