From 576b7c11c3437b1904391d464f60b7c3261c71aa Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Tue, 14 Aug 2018 15:37:36 +1200 Subject: Add "hey" to generic mail quote greetings --- vim/after/ftplugin/mail.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vim/after/ftplugin/mail.vim b/vim/after/ftplugin/mail.vim index a30b155a..ab5454bc 100644 --- a/vim/after/ftplugin/mail.vim +++ b/vim/after/ftplugin/mail.vim @@ -13,7 +13,7 @@ if line('.') == 1 && col('.') == 1 " Check this line to see if it's a generic hello-name greeting that we can " just strip out; delete the following line too, if it's blank - if getline('.') =~? '^>\s*\%(\s*\%($' delete -- cgit v1.2.3 From e9d2bc6b4e0a912fa1256f38137233dd2056fada Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Tue, 14 Aug 2018 15:38:03 +1200 Subject: Delete multiple blank lines after skipped greeting --- vim/after/ftplugin/mail.vim | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/vim/after/ftplugin/mail.vim b/vim/after/ftplugin/mail.vim index ab5454bc..612dc523 100644 --- a/vim/after/ftplugin/mail.vim +++ b/vim/after/ftplugin/mail.vim @@ -12,12 +12,12 @@ if line('.') == 1 && col('.') == 1 call search('\m^>', 'c') " Check this line to see if it's a generic hello-name greeting that we can - " just strip out; delete the following line too, if it's blank + " just strip out; delete any following lines too, if they're blank if getline('.') =~? '^>\s*\%($' + while getline('.') =~# '^>$' delete - endif + endwhile endif " Now move to the first quoted or unquoted blank line -- cgit v1.2.3 From fc083db2efae845a4f6eff2eac977f164debcb9e Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Tue, 14 Aug 2018 19:40:11 +1200 Subject: Move Vim mail functions to autoload --- vim/after/ftplugin/mail.vim | 71 +++++---------------------------------------- vim/autoload/mail.vim | 58 ++++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+), 64 deletions(-) create mode 100644 vim/autoload/mail.vim diff --git a/vim/after/ftplugin/mail.vim b/vim/after/ftplugin/mail.vim index 612dc523..0b762e61 100644 --- a/vim/after/ftplugin/mail.vim +++ b/vim/after/ftplugin/mail.vim @@ -50,81 +50,24 @@ let b:undo_ftplugin .= '|nunmap q' \ . '|xunmap Q' " Flag a message as unimportant -function! s:FlagUnimportant() - call cursor(1, 1) - call search('^$') - - - call append(line('.'), 'X-Priority: 5') - call append(line('.'), 'Importance: Low') -endfunction nnoremap \ l - \ :call FlagUnimportant() + \ :call mail#FlagUnimportant() let b:undo_ftplugin .= '|nunmap l' -" Move through quoted paragraphs like normal-mode `{` and `}` -function! s:NewBlank(count, up, visual) abort - - " Reselect visual selection - if a:visual - normal! gv - endif - - " Flag for whether we've started a block - let l:block = 0 - - " Flag for the number of blocks passed - let l:blocks = 0 - - " Iterate through buffer lines - let l:num = line('.') - while a:up ? l:num > 1 : l:num < line('$') - - " If the line is blank - if getline(l:num) =~# '^[ >]*$' - - " If we'd moved through a non-blank block already, reset that flag and - " bump up the block count - if l:block - let l:block = 0 - let l:blocks += 1 - endif - - " If we've hit the number of blocks, end the loop - if l:blocks == a:count - break - endif - - " If the line is not blank, flag that we're going through a block - else - let l:block = 1 - endif - - " Move the line number or up or down depending on direction - let l:num += a:up ? -1 : 1 - - endwhile - - " Move to line if nonzero and not equal to the current line - if l:num != line('.') - execute 'normal '.l:num.'G' - endif - -endfunction - " Maps using NewBlank() function above for quoted paragraph movement nnoremap [ - \ :call NewBlank(v:count1, 1, 0) + \ :call mail#NewBlank(v:count1, 1, 0) nnoremap ] - \ :call NewBlank(v:count1, 0, 0) + \ :call mail#NewBlank(v:count1, 0, 0) onoremap [ - \ :call NewBlank(v:count1, 1, 0) + \ :call mail#NewBlank(v:count1, 1, 0) onoremap ] - \ :call NewBlank(v:count1, 0, 0) + \ :call mail#NewBlank(v:count1, 0, 0) xnoremap [ - \ :call NewBlank(v:count1, 1, 1) + \ :call mail#NewBlank(v:count1, 1, 1) xnoremap ] - \ :call NewBlank(v:count1, 0, 1) + \ :call mail#NewBlank(v:count1, 0, 1) let b:undo_ftplugin .= '|nunmap [' \ . '|nunmap ]' \ . '|ounmap [' diff --git a/vim/autoload/mail.vim b/vim/autoload/mail.vim new file mode 100644 index 00000000..4e8232c8 --- /dev/null +++ b/vim/autoload/mail.vim @@ -0,0 +1,58 @@ +" Flag a message as unimportant +function! mail#FlagUnimportant() + call cursor(1, 1) + call search('^$') + - + call append(line('.'), 'X-Priority: 5') + call append(line('.'), 'Importance: Low') +endfunction + +" Move through quoted paragraphs like normal-mode `{` and `}` +function! mail#NewBlank(count, up, visual) abort + + " Reselect visual selection + if a:visual + normal! gv + endif + + " Flag for whether we've started a block + let l:block = 0 + + " Flag for the number of blocks passed + let l:blocks = 0 + + " Iterate through buffer lines + let l:num = line('.') + while a:up ? l:num > 1 : l:num < line('$') + + " If the line is blank + if getline(l:num) =~# '^[ >]*$' + + " If we'd moved through a non-blank block already, reset that flag and + " bump up the block count + if l:block + let l:block = 0 + let l:blocks += 1 + endif + + " If we've hit the number of blocks, end the loop + if l:blocks == a:count + break + endif + + " If the line is not blank, flag that we're going through a block + else + let l:block = 1 + endif + + " Move the line number or up or down depending on direction + let l:num += a:up ? -1 : 1 + + endwhile + + " Move to line if nonzero and not equal to the current line + if l:num != line('.') + execute 'normal '.l:num.'G' + endif + +endfunction -- cgit v1.2.3 From 8c9d2f3dfe79fadd24db3cf01233889530efe4f5 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Tue, 14 Aug 2018 19:40:38 +1200 Subject: Add `abort` attribute to autoloaded mail function --- vim/autoload/mail.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vim/autoload/mail.vim b/vim/autoload/mail.vim index 4e8232c8..6bec6e55 100644 --- a/vim/autoload/mail.vim +++ b/vim/autoload/mail.vim @@ -1,5 +1,5 @@ " Flag a message as unimportant -function! mail#FlagUnimportant() +function! mail#FlagUnimportant() abort call cursor(1, 1) call search('^$') - -- cgit v1.2.3 From c786a0b813a46329899fbab1782a5f856f3ec79e Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Tue, 14 Aug 2018 19:44:06 +1200 Subject: Rearrange local mappings for mail --- vim/after/ftplugin/mail.vim | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/vim/after/ftplugin/mail.vim b/vim/after/ftplugin/mail.vim index 0b762e61..c3353cc7 100644 --- a/vim/after/ftplugin/mail.vim +++ b/vim/after/ftplugin/mail.vim @@ -34,27 +34,33 @@ if exists('g:no_plugin_maps') || exists('g:no_mail_maps') finish endif -" The quote mapping in the stock plugin is a good idea, but I prefer it to -" work as a motion rather than quoting to the end of the buffer -nnoremap q quote#Quote() -nnoremap qq quote#Quote().'_' -xnoremap q quote#Quote() -nnoremap Q quote#QuoteReformat() -nnoremap QQ quote#QuoteReformat().'_' -xnoremap Q quote#QuoteReformat() +" Flag a message as unimportant +nnoremap l + \ :call mail#FlagUnimportant() +let b:undo_ftplugin .= '|nunmap l' + +" Quote operator +nnoremap q + \ quote#Quote() +nnoremap qq + \ quote#Quote().'_' +xnoremap q + \ quote#Quote() let b:undo_ftplugin .= '|nunmap q' \ . '|nunmap qq' \ . '|xunmap q' - \ . '|nunmap Q' + +" Quote operator with reformatting +nnoremap Q + \ quote#QuoteReformat() +nnoremap QQ + \ quote#QuoteReformat().'_' +xnoremap Q + \ quote#QuoteReformat() +let b:undo_ftplugin .= '|nunmap Q' \ . '|nunmap QQ' \ . '|xunmap Q' -" Flag a message as unimportant -nnoremap - \ l - \ :call mail#FlagUnimportant() -let b:undo_ftplugin .= '|nunmap l' - " Maps using NewBlank() function above for quoted paragraph movement nnoremap [ \ :call mail#NewBlank(v:count1, 1, 0) -- cgit v1.2.3 From aec486fb68204b1842103401093314ea4accc003 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Tue, 14 Aug 2018 20:06:53 +1200 Subject: Use consistent format for local leader mappings --- vim/after/ftplugin/diff.vim | 9 ++++++--- vim/after/ftplugin/gitcommit.vim | 24 ++++++++++++++++-------- vim/after/ftplugin/markdown.vim | 24 ++++++++++++++++-------- 3 files changed, 38 insertions(+), 19 deletions(-) diff --git a/vim/after/ftplugin/diff.vim b/vim/after/ftplugin/diff.vim index 109b5b49..eecc8b8c 100644 --- a/vim/after/ftplugin/diff.vim +++ b/vim/after/ftplugin/diff.vim @@ -15,9 +15,12 @@ let b:undo_ftplugin .= '|nunmap {' \ . '|nunmap }' " Set mappings -nmap p (DiffPrune) -xmap p (DiffPrune) -nmap pp (DiffPrune)_ +nmap p + \ (DiffPrune) +xmap p + \ (DiffPrune) +nmap pp + \ (DiffPrune)_ let b:undo_ftplugin .= '|nunmap p' \ . '|xunmap p' \ . '|nunmap pp' diff --git a/vim/after/ftplugin/gitcommit.vim b/vim/after/ftplugin/gitcommit.vim index 5699188d..c9b14b6b 100644 --- a/vim/after/ftplugin/gitcommit.vim +++ b/vim/after/ftplugin/gitcommit.vim @@ -23,16 +23,24 @@ if exists('g:no_plugin_maps') || exists('g:no_gitcommit_maps') finish endif -" Mail quote mappings -nnoremap q quote#Quote() -nnoremap qq quote#Quote().'_' -xnoremap q quote#Quote() -nnoremap Q quote#QuoteReformat() -nnoremap QQ quote#QuoteReformat().'_' -xnoremap Q quote#QuoteReformat() +" Quote operator +nnoremap q + \ quote#Quote() +nnoremap qq + \ quote#Quote().'_' +xnoremap q + \ quote#Quote() let b:undo_ftplugin .= '|nunmap q' \ . '|nunmap qq' \ . '|xunmap q' - \ . '|nunmap Q' + +" Quote operator with reformatting +nnoremap Q + \ quote#QuoteReformat() +nnoremap QQ + \ quote#QuoteReformat().'_' +xnoremap Q + \ quote#QuoteReformat() +let b:undo_ftplugin .= '|nunmap Q' \ . '|nunmap QQ' \ . '|xunmap Q' diff --git a/vim/after/ftplugin/markdown.vim b/vim/after/ftplugin/markdown.vim index a5c80ca9..cd8873b9 100644 --- a/vim/after/ftplugin/markdown.vim +++ b/vim/after/ftplugin/markdown.vim @@ -26,16 +26,24 @@ if exists('g:no_plugin_maps') || exists('g:no_markdown_maps') finish endif -" Mail quote mappings -nnoremap q quote#Quote() -nnoremap qq quote#Quote().'_' -xnoremap q quote#Quote() -nnoremap Q quote#QuoteReformat() -nnoremap QQ quote#QuoteReformat().'_' -xnoremap Q quote#QuoteReformat() +" Quote operator +nnoremap q + \ quote#Quote() +nnoremap qq + \ quote#Quote().'_' +xnoremap q + \ quote#Quote() let b:undo_ftplugin .= '|nunmap q' \ . '|nunmap qq' \ . '|xunmap q' - \ . '|nunmap Q' + +" Quote operator with reformatting +nnoremap Q + \ quote#QuoteReformat() +nnoremap QQ + \ quote#QuoteReformat().'_' +xnoremap Q + \ quote#QuoteReformat() +let b:undo_ftplugin .= '|nunmap Q' \ . '|nunmap QQ' \ . '|xunmap Q' -- cgit v1.2.3 From 259161077e666a77c887bb5beaeeb1c2af6198b0 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 15 Aug 2018 09:19:57 +1200 Subject: Move Perl boilerplate generation to autoload --- vim/after/ftplugin/perl.vim | 61 +-------------------------------------------- vim/autoload/perl.vim | 58 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+), 60 deletions(-) create mode 100644 vim/autoload/perl.vim diff --git a/vim/after/ftplugin/perl.vim b/vim/after/ftplugin/perl.vim index 9c3ce6f6..ee8da2a7 100644 --- a/vim/after/ftplugin/perl.vim +++ b/vim/after/ftplugin/perl.vim @@ -13,65 +13,6 @@ let b:undo_ftplugin .= '|unlet b:current_compiler' setlocal matchpairs+=<:> let b:undo_ftplugin .= '|setlocal matchpairs<' -" Function to add boilerplate intelligently -function! s:Boilerplate() abort - - " Flag whether the buffer started blank - let l:blank = line2byte(line('$') + 1) <= 2 - - " This is a .pm file, guess its package name from path - if expand('%:e') ==# 'pm' - - let l:match = matchlist(expand('%:p'), '.*/lib/\(.\+\).pm$') - if len(l:match) - let l:package = substitute(l:match[1], '/', '::', 'g') - else - let l:package = expand('%:t:r') - endif - - " Otherwise, just use 'main' - else - let l:package = 'main' - endif - - " Lines always to add - let l:lines = [ - \ 'package '.l:package.';', - \ '', - \ 'use strict;', - \ 'use warnings;', - \ 'use utf8;', - \ '', - \ 'use 5.006;', - \ '', - \ 'our $VERSION = ''0.01'';', - \ '' - \ ] - - " Conditional lines depending on package - if l:package ==# 'main' - let l:lines = ['#!perl'] + l:lines - else - let l:lines = l:lines + ['', '1;'] - endif - - " Add all the lines in the array - for l:line in l:lines - call append(line('.') - 1, l:line) - endfor - - " If we started in a completely empty buffer, delete the current blank line - if l:blank - delete - endif - - " If we added a trailing '1' for a package, move the cursor up two lines - if l:package !=# 'main' - -2 - endif - -endfunction - " Stop here if the user doesn't want ftplugin mappings if exists('g:no_plugin_maps') || exists('g:no_perl_maps') finish @@ -79,7 +20,7 @@ endif " Add boilerplate intelligently nnoremap b - \ :call Boilerplate() + \ :call perl#Boilerplate() let b:undo_ftplugin .= '|nunmap b' " Mappings to choose compiler diff --git a/vim/autoload/perl.vim b/vim/autoload/perl.vim new file mode 100644 index 00000000..3b87bb36 --- /dev/null +++ b/vim/autoload/perl.vim @@ -0,0 +1,58 @@ +" Function to add boilerplate intelligently +function! perl#Boilerplate() abort + + " Flag whether the buffer started blank + let l:blank = line2byte(line('$') + 1) <= 2 + + " This is a .pm file, guess its package name from path + if expand('%:e') ==# 'pm' + + let l:match = matchlist(expand('%:p'), '.*/lib/\(.\+\).pm$') + if len(l:match) + let l:package = substitute(l:match[1], '/', '::', 'g') + else + let l:package = expand('%:t:r') + endif + + " Otherwise, just use 'main' + else + let l:package = 'main' + endif + + " Lines always to add + let l:lines = [ + \ 'package '.l:package.';', + \ '', + \ 'use strict;', + \ 'use warnings;', + \ 'use utf8;', + \ '', + \ 'use 5.006;', + \ '', + \ 'our $VERSION = ''0.01'';', + \ '' + \ ] + + " Conditional lines depending on package + if l:package ==# 'main' + let l:lines = ['#!perl'] + l:lines + else + let l:lines = l:lines + ['', '1;'] + endif + + " Add all the lines in the array + for l:line in l:lines + call append(line('.') - 1, l:line) + endfor + + " If we started in a completely empty buffer, delete the current blank line + if l:blank + delete + endif + + " If we added a trailing '1' for a package, move the cursor up two lines + if l:package !=# 'main' + -2 + endif + +endfunction -- cgit v1.2.3 From 7560d40639575a9d4bb904b700205b348d9d6e7c Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 15 Aug 2018 09:39:04 +1200 Subject: Unset g:is_posix when no longer needed --- vim/after/syntax/sh.vim | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/vim/after/syntax/sh.vim b/vim/after/syntax/sh.vim index 00f95fc0..977ee2cb 100644 --- a/vim/after/syntax/sh.vim +++ b/vim/after/syntax/sh.vim @@ -4,6 +4,13 @@ if &compatible || v:version < 700 finish endif +" Remove g:is_posix if we resorted to it in order to get correct POSIX sh +" highlighting with older Vim runtime files +if exists('g:is_posix') + \ && (v:version < 800 || v:version == 800 && !has('patch257')) + unlet g:is_posix +endif + " If we know we have another shell type, clear away the others completely, now " that core syntax/sh.vim is done prodding /bin/sh to determine the system " shell type (which I don't care about). -- cgit v1.2.3 From acdf782bac73130dfb4511dc4a45b0f932a51c81 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 15 Aug 2018 10:12:38 +1200 Subject: Bump VERSION --- VERSION | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/VERSION b/VERSION index 8dcab59d..20e8ebde 100644 --- a/VERSION +++ b/VERSION @@ -1,2 +1,2 @@ -tejr dotfiles v1.52.0 -Thu Aug 9 13:33:49 UTC 2018 +tejr dotfiles v1.53.0 +Tue Aug 14 22:12:38 UTC 2018 -- cgit v1.2.3