aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--runtime/ftplugin/gitrebase.vim30
-rw-r--r--runtime/syntax/gitrebase.vim35
2 files changed, 43 insertions, 22 deletions
diff --git a/runtime/ftplugin/gitrebase.vim b/runtime/ftplugin/gitrebase.vim
index 6f73b5c499..2fed53c829 100644
--- a/runtime/ftplugin/gitrebase.vim
+++ b/runtime/ftplugin/gitrebase.vim
@@ -1,7 +1,7 @@
" Vim filetype plugin
" Language: git rebase --interactive
" Maintainer: Tim Pope <vimNOSPAM@tpope.org>
-" Last Change: 2016 Aug 29
+" Last Change: 2019 Dec 05
" Only do this when not done yet for this buffer
if (exists("b:did_ftplugin"))
@@ -18,27 +18,31 @@ if !exists("b:undo_ftplugin")
endif
let b:undo_ftplugin = b:undo_ftplugin."|setl com< cms< fo< ml<"
-function! s:choose(word)
+function! s:choose(word) abort
s/^\(\w\+\>\)\=\(\s*\)\ze\x\{4,40\}\>/\=(strlen(submatch(1)) == 1 ? a:word[0] : a:word) . substitute(submatch(2),'^$',' ','')/e
endfunction
-function! s:cycle()
- call s:choose(get({'s':'edit','p':'squash','e':'reword','r':'fixup'},getline('.')[0],'pick'))
+function! s:cycle(count) abort
+ let words = ['pick', 'edit', 'fixup', 'squash', 'reword', 'drop']
+ let index = index(map(copy(words), 'v:val[0]'), getline('.')[0])
+ let index = ((index < 0 ? 0 : index) + 10000 * len(words) + a:count) % len(words)
+ call s:choose(words[index])
endfunction
-command! -buffer -bar Pick :call s:choose('pick')
-command! -buffer -bar Squash :call s:choose('squash')
-command! -buffer -bar Edit :call s:choose('edit')
-command! -buffer -bar Reword :call s:choose('reword')
-command! -buffer -bar Fixup :call s:choose('fixup')
-command! -buffer -bar Cycle :call s:cycle()
-" The above are more useful when they are mapped; for example:
-"nnoremap <buffer> <silent> S :Cycle<CR>
+command! -buffer -bar -range Pick :<line1>,<line2>call s:choose('pick')
+command! -buffer -bar -range Squash :<line1>,<line2>call s:choose('squash')
+command! -buffer -bar -range Edit :<line1>,<line2>call s:choose('edit')
+command! -buffer -bar -range Reword :<line1>,<line2>call s:choose('reword')
+command! -buffer -bar -range Fixup :<line1>,<line2>call s:choose('fixup')
+command! -buffer -bar -range Drop :<line1>,<line2>call s:choose('drop')
+command! -buffer -count=1 -bar -bang Cycle call s:cycle(<bang>0 ? -<count> : <count>)
if exists("g:no_plugin_maps") || exists("g:no_gitrebase_maps")
finish
endif
nnoremap <buffer> <expr> K col('.') < 7 && expand('<Lt>cword>') =~ '\X' && getline('.') =~ '^\w\+\s\+\x\+\>' ? 'wK' : 'K'
+nnoremap <buffer> <silent> <C-A> :<C-U><C-R>=v:count1<CR>Cycle<CR>
+nnoremap <buffer> <silent> <C-X> :<C-U><C-R>=v:count1<CR>Cycle!<CR>
-let b:undo_ftplugin = b:undo_ftplugin . "|nunmap <buffer> K"
+let b:undo_ftplugin = b:undo_ftplugin . "|exe 'nunmap <buffer> K'|exe 'nunmap <buffer> <C-A>'|exe 'nunmap <buffer> <C-X>'"
diff --git a/runtime/syntax/gitrebase.vim b/runtime/syntax/gitrebase.vim
index a944c14dd7..bc6f34d1a7 100644
--- a/runtime/syntax/gitrebase.vim
+++ b/runtime/syntax/gitrebase.vim
@@ -2,7 +2,7 @@
" Language: git rebase --interactive
" Maintainer: Tim Pope <vimNOSPAM@tpope.org>
" Filenames: git-rebase-todo
-" Last Change: 2016 Aug 29
+" Last Change: 2019 Dec 06
if exists("b:current_syntax")
finish
@@ -10,31 +10,48 @@ endif
syn case match
-syn match gitrebaseHash "\v<\x{7,40}>" contained
-syn match gitrebaseCommit "\v<\x{7,40}>" nextgroup=gitrebaseSummary skipwhite
+syn match gitrebaseHash "\v<\x{7,}>" contained
+syn match gitrebaseCommit "\v<\x{7,}>" nextgroup=gitrebaseSummary skipwhite
syn match gitrebasePick "\v^p%(ick)=>" nextgroup=gitrebaseCommit skipwhite
syn match gitrebaseReword "\v^r%(eword)=>" nextgroup=gitrebaseCommit skipwhite
syn match gitrebaseEdit "\v^e%(dit)=>" nextgroup=gitrebaseCommit skipwhite
syn match gitrebaseSquash "\v^s%(quash)=>" nextgroup=gitrebaseCommit skipwhite
syn match gitrebaseFixup "\v^f%(ixup)=>" nextgroup=gitrebaseCommit skipwhite
syn match gitrebaseExec "\v^%(x|exec)>" nextgroup=gitrebaseCommand skipwhite
+syn match gitrebaseBreak "\v^b%(reak)=>"
syn match gitrebaseDrop "\v^d%(rop)=>" nextgroup=gitrebaseCommit skipwhite
+syn match gitrebaseNoop "\v^noop>"
+syn match gitrebaseMerge "\v^m(erge)=>" nextgroup=gitrebaseMergeOption,gitrebaseName skipwhite
+syn match gitrebaseLabel "\v^l(abel)=>" nextgroup=gitrebaseName skipwhite
+syn match gitrebaseReset "\v^(t|reset)=>" nextgroup=gitrebaseName skipwhite
syn match gitrebaseSummary ".*" contains=gitrebaseHash contained
syn match gitrebaseCommand ".*" contained
-syn match gitrebaseComment "^#.*" contains=gitrebaseHash
+syn match gitrebaseComment "^\s*#.*" contains=gitrebaseHash
syn match gitrebaseSquashError "\v%^%(s%(quash)=>|f%(ixup)=>)" nextgroup=gitrebaseCommit skipwhite
+syn match gitrebaseMergeOption "\v-[Cc]>" nextgroup=gitrebaseMergeCommit skipwhite contained
+syn match gitrebaseMergeCommit "\v<\x{7,}>" nextgroup=gitrebaseName skipwhite contained
+syn match gitrebaseName "\v[^[:space:].*?i:^~/-]\S+" nextgroup=gitrebaseMergeComment skipwhite contained
+syn match gitrebaseMergeComment "#" nextgroup=gitrebaseSummary skipwhite contained
hi def link gitrebaseCommit gitrebaseHash
hi def link gitrebaseHash Identifier
-hi def link gitrebasePick Statement
-hi def link gitrebaseReword Number
+hi def link gitrebasePick Type
+hi def link gitrebaseReword Conditional
hi def link gitrebaseEdit PreProc
-hi def link gitrebaseSquash Type
-hi def link gitrebaseFixup Special
-hi def link gitrebaseExec Function
+hi def link gitrebaseSquash Statement
+hi def link gitrebaseFixup Repeat
+hi def link gitrebaseExec Operator
+hi def link gitrebaseBreak Macro
hi def link gitrebaseDrop Comment
+hi def link gitrebaseNoop Comment
+hi def link gitrebaseMerge Exception
+hi def link gitrebaseLabel Label
+hi def link gitrebaseReset Keyword
hi def link gitrebaseSummary String
hi def link gitrebaseComment Comment
hi def link gitrebaseSquashError Error
+hi def link gitrebaseMergeCommit gitrebaseCommit
+hi def link gitrebaseMergeComment gitrebaseComment
+hi def link gitrebaseName Tag
let b:current_syntax = "gitrebase"