Skip to content

Commit

Permalink
Add %P format item
Browse files Browse the repository at this point in the history
  • Loading branch information
rbong committed Sep 5, 2024
1 parent 09ee63b commit d7078bf
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
13 changes: 8 additions & 5 deletions autoload/flog/floggraph/format.vim
Original file line number Diff line number Diff line change
Expand Up @@ -127,23 +127,24 @@ function! flog#floggraph#format#FormatMarkLocalBranch(dict, key) abort
return flog#floggraph#format#FormatCommitLocalBranch(a:dict, l:commit)
endfunction

function! flog#floggraph#format#FormatPath() abort
function! flog#floggraph#format#FormatPath(separate_args) abort
let l:state = flog#state#GetBufState()
let l:path = l:state.opts.path

if !empty(l:state.opts.limit)
let [l:range, l:limit_path] = flog#args#SplitGitLimitArg(l:state.opts.limit)

if empty(l:limit_path)
return ''
return a:separate_args ? '--' : ''
endif

let l:path = [l:limit_path]
elseif empty(l:path)
return ''
return a:separate_args ? '--' : ''
endif

return join(flog#shell#EscapeList(l:path), ' ')
let l:paths = join(flog#shell#EscapeList(l:path), ' ')
return a:separate_args ? '-- ' .. l:paths : l:paths
endfunction

function! flog#floggraph#format#FormatIndexTree(dict) abort
Expand Down Expand Up @@ -186,7 +187,9 @@ function! flog#floggraph#format#HandleCommandItem(dict, item, end) abort
elseif a:item =~# "^%(l'."
let l:formatted_item = flog#floggraph#format#FormatMarkLocalBranch(a:dict, a:item[4 : -2])
elseif a:item ==# '%p'
let l:formatted_item = flog#floggraph#format#FormatPath()
let l:formatted_item = flog#floggraph#format#FormatPath(v:false)
elseif a:item ==# '%P'
let l:formatted_item = flog#floggraph#format#FormatPath(v:true)
elseif a:item ==# '%t'
let l:formatted_item = flog#floggraph#format#FormatIndexTree(a:dict)
else
Expand Down
5 changes: 5 additions & 0 deletions doc/flog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1256,6 +1256,11 @@ The following items are supported:
|:Flog_-path|, if any, escaping them and joining them
with spaces.

*flog-%P*
%P Same as |flog-%p|, but include "--" at the start.
Separates Git command arguments from paths.
Still returns "--" if no path or limit is specified.

*flog-%t*
%t A tree for the current index. When this is used, a new
tree will be created for the current index using
Expand Down

0 comments on commit d7078bf

Please sign in to comment.