robin/laufey

git clone https://git.robinwobin.dev/robin/laufey

Christian Clasonvim-patch:2f0936cb9a2e (#17007)e866da12ee

master
1.7 KiB45 linesraw
1" Vim filetype plugin
2" Language:	git rebase --interactive
3" Maintainer:	Tim Pope <vimNOSPAM@tpope.org>
4" Last Change:	2022 Jan 05
5
6" Only do this when not done yet for this buffer
7if (exists("b:did_ftplugin"))
8  finish
9endif
10
11let b:did_ftplugin = 1
12
13let &l:comments = ':' . (matchstr(getline('$'), '^[#;@!$%^&|:]\S\@!') . '#')[0]
14let &l:commentstring = &l:comments[1] . ' %s'
15setlocal formatoptions-=t
16setlocal nomodeline
17let b:undo_ftplugin = "setl com< cms< fo< ml<"
18
19function! s:choose(word) abort
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(count) abort
24  let words = ['pick', 'edit', 'fixup', 'squash', 'reword', 'drop']
25  let index = index(map(copy(words), 'v:val[0]'), getline('.')[0])
26  let index = ((index < 0 ? 0 : index) + 10000 * len(words) + a:count) % len(words)
27  call s:choose(words[index])
28endfunction
29
30command! -buffer -bar -range Pick   :<line1>,<line2>call s:choose('pick')
31command! -buffer -bar -range Squash :<line1>,<line2>call s:choose('squash')
32command! -buffer -bar -range Edit   :<line1>,<line2>call s:choose('edit')
33command! -buffer -bar -range Reword :<line1>,<line2>call s:choose('reword')
34command! -buffer -bar -range Fixup  :<line1>,<line2>call s:choose('fixup')
35command! -buffer -bar -range Drop   :<line1>,<line2>call s:choose('drop')
36command! -buffer -count=1 -bar -bang Cycle call s:cycle(<bang>0 ? -<count> : <count>)
37
38if exists("g:no_plugin_maps") || exists("g:no_gitrebase_maps")
39  finish
40endif
41
42nnoremap <buffer> <silent> <C-A> :<C-U><C-R>=v:count1<CR>Cycle<CR>
43nnoremap <buffer> <silent> <C-X> :<C-U><C-R>=v:count1<CR>Cycle!<CR>
44
45let b:undo_ftplugin = b:undo_ftplugin . "|exe 'nunmap <buffer> <C-A>'|exe 'nunmap <buffer> <C-X>'"