mirror of
https://github.com/tpope/vim-fugitive.git
synced 2025-11-14 22:33:51 -05:00
Expand <cfile>
This doesn't play well with :Git as it can result in a fugitive:// URL, but it does make :Gedit <cfile> and :GBrowse <cfile> do what I mean.
This commit is contained in:
@@ -1159,7 +1159,7 @@ function! fugitive#Object(...) abort
|
|||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
let s:var = '\%(%\|#<\=\d\+\|##\=\)'
|
let s:var = '\%(%\|#<\=\d\+\|##\=\|<cfile>\)'
|
||||||
let s:flag = '\%(:[p8~.htre]\|:g\=s\(.\).\{-\}\1.\{-\}\1\)'
|
let s:flag = '\%(:[p8~.htre]\|:g\=s\(.\).\{-\}\1.\{-\}\1\)'
|
||||||
let s:expand = '\%(\(' . s:var . '\)\(' . s:flag . '*\)\(:S\)\=\)'
|
let s:expand = '\%(\(' . s:var . '\)\(' . s:flag . '*\)\(:S\)\=\)'
|
||||||
|
|
||||||
@@ -1194,6 +1194,15 @@ function! s:ExpandVar(other, var, flags, esc, ...) abort
|
|||||||
let buffer = s:BufName(len(a:other) > 1 ? '#'. a:other[1:-1] : '%')
|
let buffer = s:BufName(len(a:other) > 1 ? '#'. a:other[1:-1] : '%')
|
||||||
let owner = s:Owner(buffer)
|
let owner = s:Owner(buffer)
|
||||||
return len(owner) ? owner : '@'
|
return len(owner) ? owner : '@'
|
||||||
|
elseif a:var ==# '<cfile>'
|
||||||
|
let cfile = expand('<cfile>')
|
||||||
|
if v:version >= 704 && get(maparg('<Plug><cfile>', 'c', 0, 1), 'expr')
|
||||||
|
try
|
||||||
|
let cfile = eval(maparg('<Plug><cfile>', 'c'))
|
||||||
|
catch
|
||||||
|
endtry
|
||||||
|
endif
|
||||||
|
return cfile
|
||||||
endif
|
endif
|
||||||
let flags = a:flags
|
let flags = a:flags
|
||||||
let file = s:DotRelative(fugitive#Real(s:BufName(a:var)), cwd)
|
let file = s:DotRelative(fugitive#Real(s:BufName(a:var)), cwd)
|
||||||
|
|||||||
Reference in New Issue
Block a user