mirror of
https://github.com/tpope/vim-fugitive.git
synced 2026-10-03 00:43:53 +08:00
Provide FugitiveGenerate() and FugitiveParse()
This commit is contained in:
1 parent
1e41a88ec9
commit
71acb7da35
2 files changed
+38
-20
No files matched your search
@@ -152,6 +152,20 @@ function! FugitiveReal(...) abort
|
||||
return call('FugitivePath', a:000)
|
||||
endfunction
|
||||
|
||||
function! FugitiveGenerate(...) abort
|
||||
return fugitive#repo(a:0 > 1 ? a:2 : get(b:, 'git_dir', '')).translate(a:0 ? a:1 : '', 1)
|
||||
endfunction
|
||||
|
||||
function! FugitiveParse(...) abort
|
||||
let path = s:shellslash(a:0 ? a:1 : @%)
|
||||
let vals = matchlist(path, '\c^fugitive:\%(//\)\=\(.\{-\}\)\%(//\|::\)\(\x\{40\}\|[0-3]\)\(/.*\)\=$')
|
||||
if len(vals)
|
||||
return [(vals[2] =~# '^.$' ? ':' : '') . vals[2] . substitute(vals[3], '^/', ':', ''), vals[1]]
|
||||
endif
|
||||
let v:errmsg = 'fugitive: invalid Fugitive URL ' . path
|
||||
throw v:errmsg
|
||||
endfunction
|
||||
|
||||
augroup fugitive
|
||||
autocmd!
|
||||
|
||||
|
||||
Reference in new issue
Block a user