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 9619055cfd5d049b3dc67fcdd3cc2f263d72affc (tree)
parent 48daf7ae7247a6cc268ebe71564e4734eb4bfc0b
Author: Tim Pope <code@tpope.net>
Date:   Sat,  7 Apr 2012 16:14:51 -0400

Map - to go up a directory

Diffstat:
Mdoc/fugitive.txt | 3+++
Mplugin/fugitive.vim | 27++++++++++++++++++++++++++-
2 files changed, 29 insertions(+), 1 deletion(-)

diff --git a/doc/fugitive.txt b/doc/fugitive.txt @@ -235,6 +235,9 @@ o Jump to the revision under the cursor in a new split. *fugitive-O* O Jump to the revision under the cursor in a new tab. + *fugitive--* +- Go to the tree containing the current tree or blob. + *fugitive-~* ~ Go to the current file in the [count]th first ancestor. diff --git a/plugin/fugitive.vim b/plugin/fugitive.vim @@ -537,7 +537,31 @@ function! s:buffer_containing_commit() dict abort endif endfunction -call s:add_methods('buffer',['getvar','setvar','getline','repo','type','spec','name','commit','path','rev','sha1','expand','containing_commit']) +function! s:buffer_up(...) dict abort + let rev = self.rev() + let c = a:0 ? a:1 : 1 + while c + if rev =~# '^[/:]$' + let rev = 'HEAD' + elseif rev =~# '^:' + let rev = ':' + elseif rev =~# '^[^^~:]\+$' + let rev .= '^{}' + elseif rev =~# '^/\|:.*/' + let rev = s:sub(rev, '.*\zs/.*', '') + elseif rev =~# ':.' + let rev = matchstr(rev, '^[^:]*:') + elseif rev =~# ':$' + let rev = rev[0:-2] + else + return rev.'~'.c + endif + let c -= 1 + endwhile + return rev +endfunction + +call s:add_methods('buffer',['getvar','setvar','getline','repo','type','spec','name','commit','path','rev','sha1','expand','containing_commit','up']) " }}}1 " Git {{{1 @@ -2149,6 +2173,7 @@ function! s:JumpInit() abort if !&modifiable nnoremap <buffer> <silent> o :<C-U>exe <SID>GF("split")<CR> nnoremap <buffer> <silent> O :<C-U>exe <SID>GF("tabedit")<CR> + nnoremap <buffer> <silent> - :<C-U>exe <SID>Edit('edit',0,<SID>buffer().up(v:count1))<CR> nnoremap <buffer> <silent> P :<C-U>exe <SID>Edit('edit',0,<SID>buffer().commit().'^'.v:count1.<SID>buffer().path(':'))<CR> nnoremap <buffer> <silent> ~ :<C-U>exe <SID>Edit('edit',0,<SID>buffer().commit().'~'.v:count1.<SID>buffer().path(':'))<CR> nnoremap <buffer> <silent> C :<C-U>exe <SID>Edit('edit',0,<SID>buffer().containing_commit())<CR>