From e7a0e9f6f26d154b1e550de94414ea71e354c563 Mon Sep 17 00:00:00 2001 From: rbong Date: Thu, 5 Sep 2024 13:22:02 -0400 Subject: [PATCH] Add %P format item --- autoload/flog/floggraph/format.vim | 13 ++++++++----- doc/flog.txt | 5 +++++ 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/autoload/flog/floggraph/format.vim b/autoload/flog/floggraph/format.vim index a6d7613..fc5d3bb 100644 --- a/autoload/flog/floggraph/format.vim +++ b/autoload/flog/floggraph/format.vim @@ -127,7 +127,7 @@ 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 @@ -135,15 +135,16 @@ function! flog#floggraph#format#FormatPath() abort 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 @@ -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 diff --git a/doc/flog.txt b/doc/flog.txt index f3e33a3..b418228 100644 --- a/doc/flog.txt +++ b/doc/flog.txt @@ -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