blob: 4680d285e778dd9be59caba322364eaeb79a9994 [file] [log] [blame]
Bram Moolenaar8c8de832008-06-24 22:58:06 +00001" Vim filetype plugin
2" Language: git rebase --interactive
Bram Moolenaar5c736222010-01-06 20:54:52 +01003" Maintainer: Tim Pope <vimNOSPAM@tpope.org>
4" Last Change: 2009 Dec 24
Bram Moolenaar8c8de832008-06-24 22:58:06 +00005
6" Only do this when not done yet for this buffer
7if (exists("b:did_ftplugin"))
8 finish
9endif
10
11runtime! ftplugin/git.vim
12let b:did_ftplugin = 1
13
14setlocal comments=:# commentstring=#\ %s formatoptions-=t
15if !exists("b:undo_ftplugin")
16 let b:undo_ftplugin = ""
17endif
18let b:undo_ftplugin = b:undo_ftplugin."|setl com< cms< fo<"
19
20function! s:choose(word)
21 s/^\(\w\+\>\)\=\(\s*\)\ze\x\{4,40\}\>/\=(strlen(submatch(1)) == 1 ? a:word[0] : a:word) . substitute(submatch(2),'^$',' ','')/e
22endfunction
23
24function! s:cycle()
Bram Moolenaar5c736222010-01-06 20:54:52 +010025 call s:choose(get({'s':'edit','p':'squash','e':'reword'},getline('.')[0],'pick'))
Bram Moolenaar8c8de832008-06-24 22:58:06 +000026endfunction
27
28command! -buffer -bar Pick :call s:choose('pick')
29command! -buffer -bar Squash :call s:choose('squash')
30command! -buffer -bar Edit :call s:choose('edit')
Bram Moolenaar5c736222010-01-06 20:54:52 +010031command! -buffer -bar Reword :call s:choose('reword')
Bram Moolenaar8c8de832008-06-24 22:58:06 +000032command! -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"