Provide maps to find similar diff lines
This commit is contained in:
parent
ff058bf5b7
commit
c242cb6369
@ -146,10 +146,11 @@ endfunction
|
|||||||
let s:nowait = v:version >= 704 ? '<nowait>' : ''
|
let s:nowait = v:version >= 704 ? '<nowait>' : ''
|
||||||
|
|
||||||
function! s:Map(mode, lhs, rhs, ...) abort
|
function! s:Map(mode, lhs, rhs, ...) abort
|
||||||
|
for mode in split(a:mode, '\zs')
|
||||||
let flags = (a:0 ? a:1 : '') . (a:rhs =~# '<Plug>' ? '' : '<script>')
|
let flags = (a:0 ? a:1 : '') . (a:rhs =~# '<Plug>' ? '' : '<script>')
|
||||||
let head = a:lhs
|
let head = a:lhs
|
||||||
let tail = ''
|
let tail = ''
|
||||||
let keys = get(g:, a:mode.'remap', {})
|
let keys = get(g:, mode.'remap', {})
|
||||||
if type(keys) == type([])
|
if type(keys) == type([])
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
@ -164,13 +165,14 @@ function! s:Map(mode, lhs, rhs, ...) abort
|
|||||||
let tail = matchstr(head, '<[^<>]*>$\|.$') . tail
|
let tail = matchstr(head, '<[^<>]*>$\|.$') . tail
|
||||||
let head = substitute(head, '<[^<>]*>$\|.$', '', '')
|
let head = substitute(head, '<[^<>]*>$\|.$', '', '')
|
||||||
endwhile
|
endwhile
|
||||||
if flags !~# '<unique>' || empty(mapcheck(head.tail, a:mode))
|
if flags !~# '<unique>' || empty(mapcheck(head.tail, mode))
|
||||||
exe a:mode.'map <buffer>' s:nowait flags head.tail a:rhs
|
exe mode.'map <buffer>' s:nowait flags head.tail a:rhs
|
||||||
if a:0 > 1
|
if a:0 > 1
|
||||||
let b:undo_ftplugin = get(b:, 'undo_ftplugin', 'exe') .
|
let b:undo_ftplugin = get(b:, 'undo_ftplugin', 'exe') .
|
||||||
\ '|sil! exe "' . a:mode . 'unmap <buffer> ' . head.tail . '"'
|
\ '|sil! exe "' . mode . 'unmap <buffer> ' . head.tail . '"'
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
endfor
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" Section: Quickfix
|
" Section: Quickfix
|
||||||
@ -2831,6 +2833,23 @@ function! s:PreviousSectionEnd(count) abort
|
|||||||
return search('^.', 'Wb')
|
return search('^.', 'Wb')
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! s:PatchSearchExpr(reverse) abort
|
||||||
|
let line = getline('.')
|
||||||
|
if col('.') ==# 1 && line =~# '^[+-]'
|
||||||
|
if line =~# '^[+-]\{3\} '
|
||||||
|
let pattern = '^[+-]\{3\} ' . substitute(escape(strpart(line, 4), '^$.*[]~\'), '^\w/', '\\w/', '') . '$'
|
||||||
|
else
|
||||||
|
let pattern = '^[+-]\s*' . escape(substitute(strpart(line, 1), '^\s*\|\s*$', '', ''), '^$.*[]~\') . '\s*$'
|
||||||
|
endif
|
||||||
|
if a:reverse
|
||||||
|
return '?' . escape(pattern, '/') . "\<CR>"
|
||||||
|
else
|
||||||
|
return '/' . escape(pattern, '/?') . "\<CR>"
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
return a:reverse ? '#' : '*'
|
||||||
|
endfunction
|
||||||
|
|
||||||
function! s:StageInline(mode, ...) abort
|
function! s:StageInline(mode, ...) abort
|
||||||
if &filetype !=# 'fugitive'
|
if &filetype !=# 'fugitive'
|
||||||
return ''
|
return ''
|
||||||
@ -5446,6 +5465,8 @@ function! fugitive#MapJumps(...) abort
|
|||||||
call s:MapMotion(']]', 'exe <SID>NextSection(v:count1)')
|
call s:MapMotion(']]', 'exe <SID>NextSection(v:count1)')
|
||||||
call s:MapMotion('[]', 'exe <SID>PreviousSectionEnd(v:count1)')
|
call s:MapMotion('[]', 'exe <SID>PreviousSectionEnd(v:count1)')
|
||||||
call s:MapMotion('][', 'exe <SID>NextSectionEnd(v:count1)')
|
call s:MapMotion('][', 'exe <SID>NextSectionEnd(v:count1)')
|
||||||
|
call s:Map('nxo', '*', '<SID>PatchSearchExpr(0)', '<expr>')
|
||||||
|
call s:Map('nxo', '#', '<SID>PatchSearchExpr(1)', '<expr>')
|
||||||
endif
|
endif
|
||||||
call s:Map('n', 'S', ':<C-U>echoerr "Use gO"<CR>', '<silent>')
|
call s:Map('n', 'S', ':<C-U>echoerr "Use gO"<CR>', '<silent>')
|
||||||
call s:Map('n', 'dq', ":<C-U>call <SID>DiffClose()<CR>", '<silent>')
|
call s:Map('n', 'dq', ":<C-U>call <SID>DiffClose()<CR>", '<silent>')
|
||||||
|
@ -394,6 +394,14 @@ i Jump to the next file or hunk, expanding inline diffs
|
|||||||
*fugitive_][*
|
*fugitive_][*
|
||||||
][ Jump [count] section ends forward.
|
][ Jump [count] section ends forward.
|
||||||
|
|
||||||
|
*fugitive_star*
|
||||||
|
* One the first column of a + or - diff line, search for
|
||||||
|
the corresponding - or + line. Otherwise, defer to
|
||||||
|
built-in |star|.
|
||||||
|
|
||||||
|
*fugitive_#*
|
||||||
|
# Same as "*", but search backward.
|
||||||
|
|
||||||
*fugitive_gu*
|
*fugitive_gu*
|
||||||
gu Jump to file [count] in the "Untracked" or "Unstaged"
|
gu Jump to file [count] in the "Untracked" or "Unstaged"
|
||||||
section.
|
section.
|
||||||
|
Loading…
Reference in New Issue
Block a user