motiejus/dotfiles

Unnamed repository; edit this file 'description' to name the repository.
git clone https://git.jakstys.lt/motiejus/dotfiles.git
Log | Tree | Refs | README | LICENSE

commit 40facfde5ecb5fb893915fa7f9bd6e2379b5edbc (tree)
parent 236bd21b4515ffd8462fc00183c1f165d4f83922
Author: Tim Pope <code@tpope.net>
Date:   Fri, 10 Aug 2018 19:20:31 -0400

Rewrite <C-R><C-G> and y<C-G>

Diffstat:
Mautoload/fugitive.vim | 65+++++++++++++++++++++++++++++------------------------------------
1 file changed, 29 insertions(+), 36 deletions(-)

diff --git a/autoload/fugitive.vim b/autoload/fugitive.vim @@ -259,24 +259,6 @@ function! fugitive#RemoteUrl(...) abort return v:shell_error ? '' : out endfunction -function! s:recall() abort - let rev = s:sub(fugitive#buffer().rev(), '^/', '') - if rev ==# ':' - return matchstr(getline('.'),'^.\=\t\%([[:alpha:] ]\+: *\)\=\zs.\{-\}\ze\%( ([^()[:digit:]]\+)\)\=$\|^\d\{6} \x\{40\} \d\t\zs.*') - elseif fugitive#buffer().type('tree') - let file = matchstr(getline('.'), '\t\zs.*') - if empty(file) && line('.') > 2 - let file = s:sub(getline('.'), '/$', '') - endif - if !empty(file) && rev !~# ':$' - return rev . '/' . file - else - return rev . file - endif - endif - return rev -endfunction - function! s:map(mode, lhs, rhs, ...) abort let flags = (a:0 ? a:1 : '') . (a:rhs =~# '<Plug>' ? '' : '<script>') let head = a:lhs @@ -567,6 +549,32 @@ function! s:RemoveDot(path, ...) abort return a:path[2:-1] endfunction +function! fugitive#Object(...) abort + let dir = a:0 > 1 ? a:2 : get(b:, 'git_dir', '') + let [fdir, rev] = s:DirRev(a:0 ? a:1 : @%) + if s:cpath(dir) !=# s:cpath(fdir) + let rev = '' + endif + let tree = s:Tree(dir) + if empty(rev) && empty(tree) + elseif empty(rev) + let rev = fugitive#Path(a:0 ? a:1 : @%, './', dir) + let cdir = fugitive#CommonDir(dir) + if rev =~# '^\./\.git/refs/\%(tags\|heads\|remotes\)/.\|^\./\.git/\w*HEAD$' + let rev = rev[7:-1] + elseif s:cpath(cdir . '/refs/', rev[0 : len(cdir)]) + let rev = strpart(rev, len(cdir)+1) + elseif rev =~# '^\./.git\%(/\|$\)' + return fnamemodify(a:0 ? a:1 : @%, ':p') + endif + endif + if rev !~# '^\.\%(/\|$\)' || s:cpath(getcwd(), tree) + return rev + else + return tree . rev[1:-1] + endif +endfunction + function! s:Expand(rev) abort if a:rev =~# '^:[0-3]$' let file = a:rev . s:Relative(':') @@ -977,22 +985,7 @@ function! s:buffer_path(...) dict abort return self.relative() endfunction -function! s:buffer_rev() dict abort - let rev = matchstr(self.spec(),'^fugitive:\%(//\)\=.\{-\}\%(//\|::\)\zs.*') - if rev =~ '^\x/' - return ':'.rev[0].':'.rev[2:-1] - elseif rev =~ '.' - return s:sub(rev,'/',':') - elseif self.spec() =~ '\.git/index$' - return ':' - elseif self.spec() =~ '\.git/refs/\|\.git/.*HEAD$' - return self.spec()[strlen(self.repo().dir())+1 : -1] - else - return self.relative('/') - endif -endfunction - -call s:add_methods('buffer',['getvar','getline','repo','type','spec','name','commit','path','relative','rev']) +call s:add_methods('buffer',['getvar','getline','repo','type','spec','name','commit','path','relative']) " Section: Completion @@ -3657,8 +3650,8 @@ function! fugitive#Init() abort endtry endif if !exists('g:fugitive_no_maps') - call s:map('c', '<C-R><C-G>', 'fnameescape(<SID>recall())', '<expr>') - call s:map('n', 'y<C-G>', ':call setreg(v:register, <SID>recall())<CR>', '<silent>') + call s:map('c', '<C-R><C-G>', '<SID>fnameescape(fugitive#Object(@%))', '<expr>') + call s:map('n', 'y<C-G>', ':<C-U>call setreg(v:register, fugitive#Object(@%))<CR>', '<silent>') endif if expand('%:p') =~# ':[\/][\/]' let &l:path = s:sub(&path, '^\.%(,|$)', '')