Skip to content

Commit

Permalink
Add more range capabilities
Browse files Browse the repository at this point in the history
  • Loading branch information
rbong committed Jan 24, 2024
1 parent bb1fda0 commit 6289ab2
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 4 deletions.
21 changes: 21 additions & 0 deletions autoload/flog/cmd/flog/args.vim
Original file line number Diff line number Diff line change
Expand Up @@ -338,3 +338,24 @@ function! flog#cmd#flog#args#Complete(arg_lead, cmd_line, cursor_pos) abort
endif
return flog#args#FilterCompletions(a:arg_lead, l:default_completion)
endfunction

" Get arguments for a range passed to Flog.
function! flog#cmd#flog#args#GetRangeArgs(range, line1, line2) abort
let l:limit = ''

if a:range ==# 1
if a:line1 ==# 0
let l:limit = '1,'
else
let l:limit = a:line1 . ',' . a:line2
endif
elseif a:range ==# 2
let l:limit = a:line1 . ',' . a:line2
endif

if l:limit !=# ''
return ['-limit=' . l:limit . ':' . expand('%:p')]
endif

return []
endfunction
6 changes: 4 additions & 2 deletions doc/flog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@ These commands open Flog.
run from any file in a git repository. Any |fugitive-commands| can be run
from the buffer.

When opened in visual mode or passed a range, the currently selected range
and filename is passed to "-limit=".
When opened in visual mode or passed a range, the selected range and
filename is passed to "-limit".

When called with range "0", passes the entire file to "-limit".

The first time this is called, runs "git commit-graph write". This can be
changed with |g:flog_write_commit_graph|.
Expand Down
4 changes: 2 additions & 2 deletions plugin/flog.vim
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,6 @@ let g:flog_open_cmd_modifiers = [

" Commands

command! -range=0 -complete=customlist,flog#cmd#flog#args#Complete -nargs=* Flog call flog#cmd#Flog((<range> ==# 2 ? ['-limit=<line1>,<line2>:' .. expand('%:p')] : []) + [<f-args>])
command! -range=0 -complete=customlist,flog#cmd#flog#args#Complete -nargs=* Flogsplit call flog#cmd#Flog((<range> ==# 2 ? ['-limit=<line1>,<line2>:' .. expand('%:p')] : []) + ['-open-cmd=<mods> split', <f-args>])
command! -range=0 -complete=customlist,flog#cmd#flog#args#Complete -nargs=* Flog call flog#cmd#Flog(flog#cmd#flog#args#GetRangeArgs(<range>, <line1>, <line2>) + [<f-args>])
command! -range=0 -complete=customlist,flog#cmd#flog#args#Complete -nargs=* Flogsplit call flog#cmd#Flog(flog#cmd#flog#args#GetRangeArgs(<range>, <line1>, <line2>) + ['-open-cmd=<mods> split', <f-args>])
command! -range -bang -complete=customlist,flog#cmd#floggit#args#Complete -nargs=* Floggit call flog#cmd#Floggit('<mods>', '<args>', '<bang>')

0 comments on commit 6289ab2

Please sign in to comment.