~gpanders/dotfiles

6aac6168a574481b9b9e424c0d6c7267d95b8608 — Greg Anders 2 years ago 12291d3
[vim] Add vim-speeddating and vim-easy-align
2 files changed, 33 insertions(+), 1 deletions(-)

A vim/.vim/after/plugin/easyalign.vim
M vim/.vim/plugin/minpac.vim
A vim/.vim/after/plugin/easyalign.vim => vim/.vim/after/plugin/easyalign.vim +31 -0
@@ 0,0 1,31 @@
" vim-easy-align configuration
" Author: Greg Anders <greg@gpanders.com>
" Date: 2019-02-28

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

let s:save_cpo = &cpo
set cpo&vim

nmap gl <Plug>(EasyAlign)
xmap gl <Plug>(EasyAlign)

" Source: https://gist.github.com/tpope/287147
inoremap <silent> <Bar>   <Bar><Esc>:call <SID>align()<CR>a

function! s:align()
  let p = '^\s*|\s.*\s|\s*$'
  let l = line('.')
  if getline('.') =~# '^\s*|' && (getline(l-1) =~# p || getline(l+1) =~# p)
    let column = strlen(substitute(getline('.')[0:col('.')],'[^|]','','g'))
    let position = strlen(matchstr(getline('.')[0:col('.')],'.*|\s*\zs.*'))
    normal glip*|
    call cursor(l, 0)
    call search(repeat('[^|]*|', column) . '\s\{-\}' . repeat('.', position), 'ce', l)
  endif
endfunction

let &cpo = s:save_cpo
unlet s:save_cpo

M vim/.vim/plugin/minpac.vim => vim/.vim/plugin/minpac.vim +2 -1
@@ 17,6 17,7 @@ function! s:PackInit()
    call minpac#add('tpope/vim-eunuch')
    call minpac#add('tpope/vim-characterize')
    call minpac#add('tpope/vim-abolish')
    call minpac#add('tpope/vim-speeddating')

    " Better directory browser
    call minpac#add('justinmk/vim-dirvish')


@@ 28,7 29,7 @@ function! s:PackInit()
    call minpac#add('sheerun/vim-polyglot')

    " Align lines to a character, e.g. =, ;, :, etc.
    call minpac#add('godlygeek/tabular')
    call minpac#add('junegunn/vim-easy-align')

    " Fuzzy file finder and bonus commands
    call minpac#add('junegunn/fzf.vim')