~gpanders/dotfiles

db6e681467b631048e2ecee0e75cd0d17953d3ea — Greg Anders 1 year, 11 months ago 2c7633d
Don't highlight trailing whitespace in readonly buffers

Also don't start insert mode in mail files when they are readonly
2 files changed, 12 insertions(+), 10 deletions(-)

M vim/.vim/after/ftplugin/mail.vim
M vim/.vim/vimrc
M vim/.vim/after/ftplugin/mail.vim => vim/.vim/after/ftplugin/mail.vim +9 -7
@@ 17,13 17,15 @@ endif

augroup mail
    autocmd!
    " Place cursor in writing position and start insert mode
    if g:mail_posting_style ==# 'top'
        autocmd BufWinEnter <buffer> exe "normal! }2o\<Esc>k" | startinsert
    elseif g:mail_posting_style ==# 'bottom'
        autocmd BufWinEnter <buffer> exe "normal! G2o\<Esc>" | startinsert
    else
        echohl Error | echom 'Unknown value for g:mail_posting_style' | echohl None
    if !&readonly && &modifiable
        " Place cursor in writing position and start insert mode
        if g:mail_posting_style ==# 'top'
            autocmd BufWinEnter <buffer> exe "normal! }2o\<Esc>k" | startinsert
        elseif g:mail_posting_style ==# 'bottom'
            autocmd BufWinEnter <buffer> exe "normal! G2o\<Esc>" | startinsert
        else
            echohl Error | echom 'Unknown value for g:mail_posting_style' | echohl None
        endif
    endif
augroup END


M vim/.vim/vimrc => vim/.vim/vimrc +3 -3
@@ 451,8 451,8 @@ if has('nvim')
endif

" Create syntax group for trailing whitespace in each new buffer
function! s:whitespace()
    if !&modifiable
function! s:highlight_trailing_whitespace()
    if &readonly || !&modifiable
        return
    endif



@@ 461,7 461,7 @@ function! s:whitespace()
    endif
endfunction

autocmd Syntax * call s:whitespace()
autocmd Syntax * call s:highlight_trailing_whitespace()

" Enable omnicompletion from syntax if no other option available
" See :h ft-syntax-omni