Skip to content
rbong edited this page Jul 3, 2022 · 12 revisions

Grouping Custom Commands

Put custom commands in an autogroup in your .vimrc, like so:

v1

augroup flog
  autocmd FileType floggraph nno <buffer> x :<C-U>call flog#run_command('command goes here')<CR>
  " etc.
augroup END

v2

augroup flog
  autocmd FileType floggraph nno <buffer> x :<C-U>call flog#Exec('command goes here')<CR>
  " etc.
augroup END

User-Submitted Commands

Create a Fixup Commit

This will create a fixup commit for the commit under the cursor in normal mode when pressing cf. Fixup commits are automatically applied to other commits when running git rebase --autosquash.

v1

autocmd FileType floggraph nno <buffer> cf :<C-U>call flog#run_command('Git commit -m "fixup! %h"', 0, 1)<CR>

v2

autocmd FileType floggraph nno <buffer> cf :<C-U>call flog#Exec('Git commit -m "fixup! %h"', 0, 1)<CR>

Reset to Commit

This will reset to the selected commit using --mixed with cv, and using --hard with cV.

v1

autocmd FileType floggraph nno <buffer> cv :<C-U>call flog#run_command("Git reset --mixed %h", 0, 1)<CR>
autocmd FileType floggraph nno <buffer> cV :<C-U>call flog#run_command("Git reset --hard %h", 0, 1)<CR>

v2

autocmd FileType floggraph nno <buffer> cv :<C-U>call flog#Exec("Git reset --mixed %h", 0, 1)<CR>
autocmd FileType floggraph nno <buffer> cV :<C-U>call flog#Exec("Git reset --hard %h", 0, 1)<CR>

Merge with --no-ff

This changes the cm binding to automatically merge the first local branch under the cursor with the --no-ff binding.

v1

autocmd FileType floggraph nno <buffer> cm :<C-U>call flog#run_command('Git merge %l --no-ff', 0, 1)<CR>

v2

autocmd FileType floggraph nno <buffer> cm :<C-U>call flog#Exec('Git merge %l --no-ff', 0, 1)<CR>

Disable Split While Jumping Refs

By default ]r/[r opens a split after jumping. This disables that behaviour.

v1

autocmd FileType floggraph nno <buffer> <silent> ]r :<C-U>call flog#next_ref()<CR>
autocmd FileType floggraph nno <buffer> <silent> [r :<C-U>call flog#previous_ref()<CR>

v2

This is the default behavior in v2.

Enable Diff Links For git diff Subcommands

Fugitive has a problem with diff links when running any git diff subcommand: see this related issue.

This is a workaround for that behavior.

v1

autocmd FileType floggraph nno <buffer> <silent> <Plug>(FlogVDiffSplitRight) :<C-U>call flog#run_tmp_command('vertical belowright Git show HEAD %h')<CR>
autocmd FileType floggraph vno <buffer> <silent> <Plug>(FlogVDiffSplitRight) :<C-U>call flog#run_tmp_command("vertical belowright Git show %(h'>) %(h'<)")<CR>
autocmd FileType floggraph nno <buffer> <silent> <Plug>(FlogVDiffSplitLastCommitRight) :<C-U> call flog#run_tmp_command("vertical belowright Git show %(h'!) %H")<CR>

v2

autocmd FileType floggraph nno <buffer> <silent> <Plug>(FlogVDiffSplitRight) :<C-U>call flog#ExecTmp('vertical belowright Git show HEAD %h', 0, 0)<CR>
autocmd FileType floggraph vno <buffer> <silent> <Plug>(FlogVDiffSplitRight) :<C-U>call flog#ExecTmp("vertical belowright Git show %(h'>) %(h'<)", 0, 0)<CR>
autocmd FileType floggraph nno <buffer> <silent> <Plug>(FlogVDiffSplitLastCommitRight) :<C-U> call flog#ExecTmp("vertical belowright Git show %(h'!) %H", 0, 0)<CR>
Clone this wiki locally