diff options
Diffstat (limited to 'vim')
-rw-r--r-- | vim/after/ftplugin/c.vim | 2 | ||||
-rw-r--r-- | vim/after/ftplugin/gitcommit.vim | 8 | ||||
-rw-r--r-- | vim/after/ftplugin/help.vim | 9 | ||||
-rw-r--r-- | vim/after/ftplugin/html.vim | 5 | ||||
-rw-r--r-- | vim/after/ftplugin/mail.vim | 7 | ||||
-rw-r--r-- | vim/autoload/mail.vim | 34 |
6 files changed, 38 insertions, 27 deletions
diff --git a/vim/after/ftplugin/c.vim b/vim/after/ftplugin/c.vim index ccc5b170..e3eeaede 100644 --- a/vim/after/ftplugin/c.vim +++ b/vim/after/ftplugin/c.vim @@ -4,7 +4,7 @@ setlocal complete+=d " Set include pattern setlocal include=^\\s*#\\s*include -" Include headers on UNIX +" Include system headers on UNIX if has('unix') setlocal path+=/usr/include endif diff --git a/vim/after/ftplugin/gitcommit.vim b/vim/after/ftplugin/gitcommit.vim index 618b9324..465c0e81 100644 --- a/vim/after/ftplugin/gitcommit.vim +++ b/vim/after/ftplugin/gitcommit.vim @@ -5,12 +5,12 @@ let b:undo_ftplugin .= '|setlocal comments< formatoptions<' " Choose the color column depending on non-comment line count if has('autocmd') && exists('+cursorcolumn') - augroup gitcommit + augroup gitcommit_cursorcolumn autocmd CursorMoved,CursorMovedI <buffer> - \ let &l:colorcolumn = gitcommit#CursorColumn() + \ let &l:colorcolumn = gitcommit_cursorcolumn#CursorColumn() augroup END - let b:undo_ftplugin .= '|execute ''autocmd! gitcommit''' - \ . '|augroup! gitcommit' + let b:undo_ftplugin .= '|execute ''autocmd! gitcommit_cursorcolumn''' + \ . '|augroup! gitcommit_cursorcolumn' \ . '|setlocal colorcolumn<' endif diff --git a/vim/after/ftplugin/help.vim b/vim/after/ftplugin/help.vim index a0b637aa..a72dac8e 100644 --- a/vim/after/ftplugin/help.vim +++ b/vim/after/ftplugin/help.vim @@ -11,9 +11,12 @@ if has('conceal') && &modifiable && !&readonly let b:undo_ftplugin .= '|setlocal conceallevel<' endif -" Use :help for 'keywordprg'; odd that this isn't the default -setlocal keywordprg=:help -let b:undo_ftplugin .= '|setlocal keywordprg<' +" Use :help as 'keywordprg' if not already set; this is the default since Vim +" v8.1.0690 +if &keywordprg !=# ':help' + setlocal keywordprg=:help + let b:undo_ftplugin .= '|setlocal keywordprg<' +endif " Stop here if the user doesn't want ftplugin mappings if exists('g:no_plugin_maps') || exists('g:no_help_maps') diff --git a/vim/after/ftplugin/html.vim b/vim/after/ftplugin/html.vim index c4f2e35e..0dff879f 100644 --- a/vim/after/ftplugin/html.vim +++ b/vim/after/ftplugin/html.vim @@ -9,8 +9,9 @@ let b:undo_ftplugin .= '|unlet b:current_compiler' \ . '|setlocal errorformat< makeprg<' " tidy(1) copes fine with formatting an entire document, but not just part of -" it; we map \= to do the former, but don't actually set 'equalprg', falling -" back on the good-enough built-in Vim indentation behavior. +" it; we map \= to do the former, but don't actually set 'equalprg' for the +" latter, instead falling back on the good-enough built-in Vim indentation +" behavior nnoremap <buffer> <Leader>= :<C-U>call html#TidyBuffer()<CR> let b:undo_ftplugin .= '|nunmap <buffer> <Leader>=' diff --git a/vim/after/ftplugin/mail.vim b/vim/after/ftplugin/mail.vim index ffaa6709..898fd6a8 100644 --- a/vim/after/ftplugin/mail.vim +++ b/vim/after/ftplugin/mail.vim @@ -36,13 +36,6 @@ if exists('g:no_plugin_maps') || exists('g:no_mail_maps') finish endif -" Clear away the quoting maps that the stock mail.vim sets; they work fine, -" but we have nicer ones to define shortly -nunmap <buffer> <LocalLeader>q -vunmap <buffer> <LocalLeader>q -nunmap <buffer> <Plug>MailQuote -vunmap <buffer> <Plug>MailQuote - " Flag messages as important/unimportant nnoremap <buffer> <LocalLeader>h \ :<C-U>call mail#FlagImportant()<CR> diff --git a/vim/autoload/mail.vim b/vim/autoload/mail.vim index baff4bbf..f37a7865 100644 --- a/vim/autoload/mail.vim +++ b/vim/autoload/mail.vim @@ -1,19 +1,33 @@ +" Add a header to a mail message +function! mail#AddHeaderField(name, body) abort + let l:num = 0 + while l:num < line('$') && getline(l:num + 1) !=# '' + let l:num += 1 + endwhile + call append(l:num, a:name.': '.a:body) +endfunction + +" Add a set of headers to a mail message +function! mail#AddHeaderFields(fields) abort + for l:name in sort(keys(a:fields)) + call mail#AddHeaderField(l:name, a:fields[l:name]) + endfor +endfunction + " Flag a message as important function! mail#FlagImportant() abort - call cursor(1, 1) - call search('^$') - - - call append(line('.'), 'X-Priority: 1') - call append(line('.'), 'Importance: High') + call mail#AddHeaderFields({ + \ 'Importance': 'High', + \ 'X-Priority': 1 + \ }) endfunction " Flag a message as unimportant function! mail#FlagUnimportant() abort - call cursor(1, 1) - call search('^$') - - - call append(line('.'), 'X-Priority: 5') - call append(line('.'), 'Importance: Low') + call mail#AddHeaderFields({ + \ 'Importance': 'Low', + \ 'X-Priority': 5 + \ }) endfunction " Move through quoted paragraphs like normal-mode `{` and `}` |