]> git.r.bdr.sh - rbdr/dotfiles/blame - vim/ftplugin/gitrebase.vim
Add shared coc config
[rbdr/dotfiles] / vim / ftplugin / gitrebase.vim
CommitLineData
0d23b6e5
BB
1" Vim filetype plugin
2" Language: git rebase --interactive
3" Maintainer: Tim Pope <vimNOSPAM@tpope.org>
4
5" Only do this when not done yet for this buffer
6if (exists("b:did_ftplugin"))
7 finish
8endif
9
10runtime! ftplugin/git.vim
11let b:did_ftplugin = 1
12
13setlocal comments=:# commentstring=#\ %s formatoptions-=t
14if !exists("b:undo_ftplugin")
15 let b:undo_ftplugin = ""
16endif
17let b:undo_ftplugin = b:undo_ftplugin."|setl com< cms< fo<"
18
19function! s:choose(word)
20 s/^\(\w\+\>\)\=\(\s*\)\ze\x\{4,40\}\>/\=(strlen(submatch(1)) == 1 ? a:word[0] : a:word) . substitute(submatch(2),'^$',' ','')/e
21endfunction
22
23function! s:cycle()
24 call s:choose(get({'s':'edit','p':'squash','e':'reword','r':'fixup'},getline('.')[0],'pick'))
25endfunction
26
27command! -buffer -bar Pick :call s:choose('pick')
28command! -buffer -bar Squash :call s:choose('squash')
29command! -buffer -bar Edit :call s:choose('edit')
30command! -buffer -bar Reword :call s:choose('reword')
31command! -buffer -bar Fixup :call s:choose('fixup')
32command! -buffer -bar Cycle :call s:cycle()
33" The above are more useful when they are mapped; for example:
34"nnoremap <buffer> <silent> S :Cycle<CR>
35
36if exists("g:no_plugin_maps") || exists("g:no_gitrebase_maps")
37 finish
38endif
39
40nnoremap <buffer> <expr> K col('.') < 7 && expand('<Lt>cword>') =~ '\X' && getline('.') =~ '^\w\+\s\+\x\+\>' ? 'wK' : 'K'
41
42let b:undo_ftplugin = b:undo_ftplugin . "|nunmap <buffer> K"