~gpanders/dotfiles

fe3c3c6d5c840bb713a7160d9c2d0b7f5885ea99 — Greg Anders 2 years ago 885174d
Clean up plugins and use more consistent conventions
M vim/.vim/after/ftplugin/css.vim => vim/.vim/after/ftplugin/css.vim +8 -3
@@ 5,12 5,17 @@ if &filetype !=# 'css'
  finish
endif

let b:undo_ftplugin = get(b:, 'undo_ftplugin', '')

let g:css_format_on_write = 1

if executable('prettier')
  setlocal formatprg=prettier\ %
  let b:undo_ftplugin = get(b:, 'undo_ftplugin', '') . '|setl fp<'
  augroup css.vim.PreWrite
endif

if !empty(&l:formatprg)
  let b:undo_ftplugin .= '|setl fp<'
  augroup ftplugin.css
    autocmd!
    autocmd BufWritePre <buffer>
          \ if g:css_format_on_write |


@@ 20,5 25,5 @@ if executable('prettier')
          \   unlet view |
          \ endif
  augroup END
  let b:undo_ftplugin .= '|au! css.vim.PreWrite'
  let b:undo_ftplugin .= '|exe "au! ftplugin.css * <buffer>"'
endif

M vim/.vim/after/ftplugin/gitcommit.vim => vim/.vim/after/ftplugin/gitcommit.vim +3 -3
@@ 9,11 9,11 @@ setlocal textwidth=72
" warning if first line too long
match ErrorMsg /\%1l.\%>51v/

augroup gitcommit_ftplugin
  autocmd! * <buffer>
augroup ftplugin.gitcommit
  autocmd!
  autocmd BufWinEnter <buffer> normal gg0
augroup END

let b:undo_ftplugin .= '|setl tw< spell<'
let b:undo_ftplugin .= '|exe "au! gitcommit_ftplugin * <buffer>"'
let b:undo_ftplugin .= '|exe "au! ftplugin.gitcommit * <buffer>"'


M vim/.vim/after/ftplugin/python.vim => vim/.vim/after/ftplugin/python.vim +6 -5
@@ 3,6 3,8 @@ if &filetype !=# 'python'
  finish
endif

let b:undo_ftplugin = get(b:, 'undo_ftplugin', '')

" If a valid formatter executable is found, autoformat the buffer when writing
" the file
let g:python_format_on_write = 0


@@ 27,17 29,16 @@ endif

let &l:path = &path . ',' . g:python_include_path

let b:undo_ftplugin = get(b:, 'undo_ftplugin', '')
let b:undo_ftplugin .= '|setl path< cpt< cc<'

if executable('black')
  setl formatprg=black\ -q\ -
  setlocal formatprg=black\ -q\ -
elseif executable('yapf')
  setl formatprg=yapf
  setlocal formatprg=yapf
endif

if !empty(&l:formatprg)
  augroup python.vim.PreWrite
  augroup ftplugin.python
    autocmd!
    autocmd BufWritePre <buffer>
          \ if g:python_format_on_write |


@@ 47,5 48,5 @@ if !empty(&l:formatprg)
          \   unlet view |
          \ endif
  augroup END
  let b:undo_ftplugin .= ' fp<|au! python.vim.PreWrite'
  let b:undo_ftplugin .= ' fp<|exe "au! ftplugin.python * <buffer>"'
endif

M vim/.vim/after/plugin/coc.vim => vim/.vim/after/plugin/coc.vim +14 -9
@@ 8,15 8,20 @@ endif

let g:coc_filetypes = ['c', 'cpp', 'rust']

autocmd! CompleteDone * if pumvisible() == 0 | pclose | endif
inoremap <silent> <expr> <C-Space> coc#refresh()

augroup CocSetup
augroup plugin.coc
  autocmd!
  autocmd FileType * if index(g:coc_filetypes, &ft) >= 0 |
        \ setlocal formatexpr=CocAction('formatSelected') |
        \ exe "nmap <silent> <buffer> gr <Plug>(coc-references)" |
        \ exe "nmap <silent> <buffer> gd <Plug>(coc-definition)" |
        \ exe "au CursorHoldI,CursorMovedI <buffer> call CocAction('showSignatureHelp')" |
  autocmd FileType *
        \ if index(g:coc_filetypes, &ft) >= 0 |
        \   inoremap <buffer> <silent> <expr> <C-Space> coc#refresh() |
        \   setlocal formatexpr=CocAction('formatSelected') |
        \   nmap <silent> <buffer> gr <Plug>(coc-references) |
        \   nmap <silent> <buffer> gd <Plug>(coc-definition) |
        \   exec 'au! plugin.coc CursorHoldI,CursorMovedI <buffer> call CocAction("showSignatureHelp")' |
        \   let b:undo_ftplugin = get(b:, 'undo_ftplugin', '')
        \     . '|setl fex<'
        \     . '|iun <buffer> <C-Space>'
        \     . '|nun <buffer> gr'
        \     . '|nun <buffer> gd'
        \     . '|exe "au! plugin.coc * <buffer>"' |
        \ endif
augroup END

M vim/.vim/after/plugin/dispatch.vim => vim/.vim/after/plugin/dispatch.vim +1 -1
@@ 14,7 14,7 @@ endif
" when the command is `pytest' (without the dot) unless we add this
let g:dispatch_compilers['pytest'] = 'pytest'

augroup Dispatch
augroup plugin.dispatch
  autocmd!

  " C/C++

M vim/.vim/after/plugin/fzf.vim => vim/.vim/after/plugin/fzf.vim +7 -12
@@ 1,16 1,11 @@
" FZF must be installed to ~/.fzf
if !get(g:, 'loaded_fzf', 0) || exists(':Files') != 2
" fzf configuration
" Author: Greg Anders <greg@gpanders.com>

if !get(g:, 'loaded_fzf', 0)
  finish
endif

nnoremap <silent> ,f :Files<CR>
nnoremap <silent> ,t :Tags<CR>
nnoremap <silent> ,b :Buffers<CR>
nnoremap <silent> <Space>m :Marks<CR>

" Emacs-like M-x command
nnoremap <silent> <Space><Space> :Commands<CR>
nnoremap <silent> ,f :FZF<CR>

autocmd! FileType fzf
autocmd FileType fzf set laststatus=0 noruler
      \| autocmd BufLeave <buffer> set laststatus=2 ruler
autocmd! FileType fzf set laststatus=0 noruler
      \ | autocmd BufLeave <buffer> set laststatus=2 ruler

M vim/.vim/plugin/binary.vim => vim/.vim/plugin/binary.vim +2 -2
@@ 5,7 5,7 @@
" Author: Greg Anders <greg@gpanders.com>
" Date: 2018-12-24

augroup Binary
augroup plugin.binary
  autocmd!
  autocmd BufReadPost  * if &bin | %!xxd
  autocmd BufReadPost  * set ft=xxd


@@ 17,4 17,4 @@ augroup Binary
augroup END

" Delete the augroup if not in binary mode
au VimEnter * if !&binary | au! Binary | endif
au VimEnter * if !&binary | au! plugin.binary | endif

M vim/.vim/plugin/cursorline.vim => vim/.vim/plugin/cursorline.vim +1 -1
@@ 9,7 9,7 @@ let g:loaded_cursorline = 1

let g:cursorline_blacklist = ['tex']

augroup cursorline
augroup plugin.cursorline
  autocmd!
  autocmd InsertEnter,WinLeave * call cursorline#toggle(v:false)
  autocmd InsertLeave,WinEnter * call cursorline#toggle(v:true)