mirror of
https://github.com/kogakure/dotfiles.git
synced 2026-02-03 20:25:30 +00:00
chore(vim): Add Tabular plugin and custom alignment groups
This commit is contained in:
6
nvim/after/plugin/tabular.vim
Normal file
6
nvim/after/plugin/tabular.vim
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
" Custom Tabular Commands
|
||||||
|
|
||||||
|
AddTabularPattern! equals /^[^=]*\zs=/
|
||||||
|
AddTabularPattern! ruby_hash /^[^=>]*\zs=>/
|
||||||
|
AddTabularPattern! commas /,\s*\zs\s/l0
|
||||||
|
AddTabularPattern! colons /^[^:]*:\s*\zs\s/l0
|
||||||
@@ -18,3 +18,17 @@ function! ToggleWrap()
|
|||||||
setlocal display+=lastline
|
setlocal display+=lastline
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
" Automatic Tabular.vim with the (|)
|
||||||
|
inoremap <silent> <Bar> <Bar><Esc>:call <SID>align()<CR>a
|
||||||
|
|
||||||
|
function! s:align()
|
||||||
|
let p = '^\s*|\s.*\s|\s*$'
|
||||||
|
if exists(':Tabularize') && getline('.') =~# '^\s*|' && (getline(line('.')-1) =~# p || getline(line('.')+1) =~# p)
|
||||||
|
let column = strlen(substitute(getline('.')[0:col('.')],'[^|]','','g'))
|
||||||
|
let position = strlen(matchstr(getline('.')[0:col('.')],'.*|\s*\zs.*'))
|
||||||
|
Tabularize/|/l1
|
||||||
|
normal! 0
|
||||||
|
call search(repeat('[^|]*|',column).'\s\{-\}'.repeat('.',position),'ce',line('.'))
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|||||||
@@ -18,5 +18,8 @@ Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
|
|||||||
" Tpope
|
" Tpope
|
||||||
Plug 'tpope/vim-abolish'
|
Plug 'tpope/vim-abolish'
|
||||||
|
|
||||||
|
" Misc
|
||||||
|
Plug 'godlygeek/tabular'
|
||||||
|
|
||||||
call plug#end()
|
call plug#end()
|
||||||
doautocmd User PlugLoaded
|
doautocmd User PlugLoaded
|
||||||
|
|||||||
Reference in New Issue
Block a user