blob: 6f73b5c499ed15f1353033b9e490ec5c0da5ca0c [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>
Bram Moolenaar89bcfda2016-08-30 23:26:57 +02004" Last Change: 2016 Aug 29
Bram Moolenaar8c8de832008-06-24 22:58:06 +00005
6" Only do this when not done yet for this buffer
7if (exists("b:did_ftplugin"))
Bram Moolenaar7a329912010-05-21 12:05:36 +02008 finish
Bram Moolenaar8c8de832008-06-24 22:58:06 +00009endif
10
11runtime! ftplugin/git.vim
12let b:did_ftplugin = 1
13
14setlocal comments=:# commentstring=#\ %s formatoptions-=t
Bram Moolenaar89bcfda2016-08-30 23:26:57 +020015setlocal nomodeline
Bram Moolenaar8c8de832008-06-24 22:58:06 +000016if !exists("b:undo_ftplugin")
Bram Moolenaar7a329912010-05-21 12:05:36 +020017 let b:undo_ftplugin = ""
Bram Moolenaar8c8de832008-06-24 22:58:06 +000018endif
Bram Moolenaar89bcfda2016-08-30 23:26:57 +020019let b:undo_ftplugin = b:undo_ftplugin."|setl com< cms< fo< ml<"
Bram Moolenaar8c8de832008-06-24 22:58:06 +000020
21function! s:choose(word)
Bram Moolenaar7a329912010-05-21 12:05:36 +020022 s/^\(\w\+\>\)\=\(\s*\)\ze\x\{4,40\}\>/\=(strlen(submatch(1)) == 1 ? a:word[0] : a:word) . substitute(submatch(2),'^$',' ','')/e
Bram Moolenaar8c8de832008-06-24 22:58:06 +000023endfunction
24
25function! s:cycle()
Bram Moolenaar7a329912010-05-21 12:05:36 +020026 call s:choose(get({'s':'edit','p':'squash','e':'reword','r':'fixup'},getline('.')[0],'pick'))
Bram Moolenaar8c8de832008-06-24 22:58:06 +000027endfunction
28
29command! -buffer -bar Pick :call s:choose('pick')
30command! -buffer -bar Squash :call s:choose('squash')
31command! -buffer -bar Edit :call s:choose('edit')
Bram Moolenaar5c736222010-01-06 20:54:52 +010032command! -buffer -bar Reword :call s:choose('reword')
Bram Moolenaar7a329912010-05-21 12:05:36 +020033command! -buffer -bar Fixup :call s:choose('fixup')
Bram Moolenaar8c8de832008-06-24 22:58:06 +000034command! -buffer -bar Cycle :call s:cycle()
35" The above are more useful when they are mapped; for example:
36"nnoremap <buffer> <silent> S :Cycle<CR>
37
38if exists("g:no_plugin_maps") || exists("g:no_gitrebase_maps")
Bram Moolenaar7a329912010-05-21 12:05:36 +020039 finish
Bram Moolenaar8c8de832008-06-24 22:58:06 +000040endif
41
42nnoremap <buffer> <expr> K col('.') < 7 && expand('<Lt>cword>') =~ '\X' && getline('.') =~ '^\w\+\s\+\x\+\>' ? 'wK' : 'K'
43
44let b:undo_ftplugin = b:undo_ftplugin . "|nunmap <buffer> K"