Skip to content

Commit

Permalink
Add -reverse option
Browse files Browse the repository at this point in the history
  • Loading branch information
rbong committed May 2, 2021
1 parent 75aa5be commit 4bb36f6
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 0 deletions.
15 changes: 15 additions & 0 deletions autoload/flog.vim
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ function! flog#get_internal_default_args() abort
\ 'bisect': v:false,
\ 'no_merges': v:false,
\ 'reflog': v:false,
\ 'reverse': v:false,
\ 'no_graph': v:false,
\ 'no_patch': v:false,
\ 'skip': v:null,
Expand Down Expand Up @@ -308,6 +309,8 @@ function! flog#parse_set_args(args, current_args, defaults) abort
let a:current_args.no_merges = v:true
elseif l:arg ==# '-reflog'
let a:current_args.reflog = v:true
elseif l:arg ==# '-reverse'
let a:current_args.reverse = v:true
elseif l:arg ==# '-no-graph'
let a:current_args.no_graph = v:true
elseif l:arg ==# '-no-patch'
Expand Down Expand Up @@ -812,6 +815,9 @@ function! flog#build_log_args() abort
if l:opts.reflog
let l:args .= ' --reflog'
endif
if l:opts.reverse
let l:args .= ' --reverse'
endif
if l:opts.no_patch
let l:args .= ' --no-patch'
endif
Expand Down Expand Up @@ -1105,6 +1111,9 @@ function! flog#set_graph_buffer_title() abort
if l:opts.reflog
let l:title .= ' [reflog]'
endif
if l:opts.reverse
let l:title .= ' [reverse]'
endif
if l:opts.no_graph
let l:title .= ' [no_graph]'
endif
Expand Down Expand Up @@ -1270,6 +1279,12 @@ function! flog#toggle_reflog_option() abort
call flog#populate_graph_buffer()
endfunction

function! flog#toggle_reverse_option() abort
let l:state = flog#get_state()
let l:state.reverse = l:state.reverse ? v:false : v:true
call flog#populate_graph_buffer()
endfunction

function! flog#toggle_no_graph_option() abort
let l:state = flog#get_state()
let l:state.no_graph = l:state.no_graph ? v:false : v:true
Expand Down
7 changes: 7 additions & 0 deletions doc/flog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ COMMANDS *flog-commands*
-bisect Enable the "--bisect" argument by default.
-no-merges Enable the "--no-merges" argument by default.
-reflog Enable the "--reflog" argument by default.
-reverse Enable the "--reverse" argument by default.
-no-graph Disable the "--graph" argument by default.
-no-patch Enable the "--no-patch" argument by default.
-skip=<number> Passed to "--skip", skipping that number of commits by
Expand Down Expand Up @@ -245,6 +246,12 @@ gp *flog-gp*
Toggle the "--no-patch" argument. Useful while the "-limit" option is
specified.

gsr *<Plug>(FlogToggleReverse)*
*flog-gsr*

Toggle the "--reverse" argument. Does not conflict with other sort options.
Mnemonic: "sort reverse".

*<Plug>(FlogUpdate)*
u *flog-u*

Expand Down
5 changes: 5 additions & 0 deletions ftplugin/floggraph.vim
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,11 @@ if !hasmapto('<Plug>(FlogToggleReflog)')
endif
nnoremap <buffer> <silent> <Plug>(FlogToggleReflog) :call flog#toggle_reflog_option()<CR>
if !hasmapto('<Plug>(FlogToggleReverse)')
nmap <buffer> gsr <Plug>(FlogToggleReverse)
endif
nnoremap <buffer> <silent> <Plug>(FlogToggleReverse) :call flog#toggle_reverse_option()<CR>
if !hasmapto('<Plug>(FlogToggleNoGraph)')
nmap <buffer> gx <Plug>(FlogToggleNoGraph)
endif
Expand Down
1 change: 1 addition & 0 deletions plugin/flog.vim
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ let g:flog_default_completion = [
\ '-raw-args=',
\ '-reflog ',
\ '-rev=',
\ '-reverse',
\ '-search=',
\ '-skip='
\ ]
Expand Down

0 comments on commit 4bb36f6

Please sign in to comment.