Retool section jump maps
This commit is contained in:
parent
9ac6a258d6
commit
dffa56c4ea
@ -2236,7 +2236,18 @@ function! s:StageJump(offset, section, ...) abort
|
|||||||
let line = search('^' . a:section, 'nw')
|
let line = search('^' . a:section, 'nw')
|
||||||
if line
|
if line
|
||||||
exe line
|
exe line
|
||||||
return s:NextItem(a:offset ? a:offset : 1)
|
if a:offset
|
||||||
|
for i in range(a:offset)
|
||||||
|
call search(s:file_pattern . '\|^$')
|
||||||
|
if empty(line('.'))
|
||||||
|
return ''
|
||||||
|
endif
|
||||||
|
endfor
|
||||||
|
call s:StageReveal()
|
||||||
|
else
|
||||||
|
call s:StageReveal()
|
||||||
|
+
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
return ''
|
return ''
|
||||||
endfunction
|
endfunction
|
||||||
@ -2627,15 +2638,21 @@ function! s:StageReveal(...) abort
|
|||||||
while end < line('$') && getline(end + 1) !~# '^commit '
|
while end < line('$') && getline(end + 1) !~# '^commit '
|
||||||
let end += 1
|
let end += 1
|
||||||
endwhile
|
endwhile
|
||||||
|
elseif getline(begin) =~# s:section_pattern
|
||||||
|
let end = begin
|
||||||
|
while len(getline(end + 1))
|
||||||
|
let end += 1
|
||||||
|
endwhile
|
||||||
endif
|
endif
|
||||||
if exists('end')
|
if exists('end')
|
||||||
while line('w$') < line('$') && end > line('w$') && line('.') > line('w0') + &scrolloff
|
while line('.') > line('w0') + &scrolloff && end > line('w$')
|
||||||
execute "normal! \<C-E>"
|
execute "normal! \<C-E>"
|
||||||
endwhile
|
endwhile
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
let s:item_pattern = '^[A-Z?] .\|^diff --\|^\%(\l\{3,\} \)\=[0-9a-f]\{4,\} \|^@'
|
let s:file_pattern = '^[A-Z?] .\|^diff --'
|
||||||
|
let s:item_pattern = s:file_pattern . '\|^\%(\l\{3,\} \)\=[0-9a-f]\{4,\} \|^@@'
|
||||||
|
|
||||||
function! s:NextItem(count) abort
|
function! s:NextItem(count) abort
|
||||||
for i in range(a:count)
|
for i in range(a:count)
|
||||||
@ -2657,27 +2674,72 @@ function! s:PreviousItem(count) abort
|
|||||||
return '.'
|
return '.'
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
let s:section_pattern = '^[A-Z][a-z][^:]*$'
|
||||||
|
let s:section_commit_pattern = s:section_pattern . '\|^commit '
|
||||||
|
|
||||||
function! s:NextSection(count) abort
|
function! s:NextSection(count) abort
|
||||||
for i in range(a:count)
|
let orig = line('.')
|
||||||
if !search('^[A-Z][a-z][^:]*$','W')
|
if getline('.') !~# '^commit '
|
||||||
return '.'
|
-
|
||||||
|
endif
|
||||||
|
for i in range(a:count)
|
||||||
|
if !search(s:section_commit_pattern, 'W')
|
||||||
|
break
|
||||||
endif
|
endif
|
||||||
+
|
|
||||||
endfor
|
endfor
|
||||||
|
if getline('.') =~# s:section_commit_pattern
|
||||||
call s:StageReveal()
|
call s:StageReveal()
|
||||||
return '.'
|
return getline('.') =~# s:section_pattern ? '+' : ':'
|
||||||
|
else
|
||||||
|
return orig
|
||||||
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:PreviousSection(count) abort
|
function! s:PreviousSection(count) abort
|
||||||
|
let orig = line('.')
|
||||||
|
if getline('.') !~# '^commit '
|
||||||
-
|
-
|
||||||
for i in range(a:count)
|
|
||||||
if !search('^[A-Z][a-z][^:]*$\|\%^','bW') || line('.') == 1
|
|
||||||
return '.'
|
|
||||||
endif
|
endif
|
||||||
+
|
for i in range(a:count)
|
||||||
|
if !search(s:section_commit_pattern . '\|\%^', 'bW')
|
||||||
|
break
|
||||||
|
endif
|
||||||
endfor
|
endfor
|
||||||
|
if getline('.') =~# s:section_commit_pattern || line('.') == 1
|
||||||
call s:StageReveal()
|
call s:StageReveal()
|
||||||
return '.'
|
return getline('.') =~# s:section_pattern ? '+' : ':'
|
||||||
|
else
|
||||||
|
return orig
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! s:NextSectionEnd(count) abort
|
||||||
|
+
|
||||||
|
if empty(getline('.'))
|
||||||
|
+
|
||||||
|
endif
|
||||||
|
for i in range(a:count)
|
||||||
|
if !search(s:section_commit_pattern, 'W')
|
||||||
|
return '$'
|
||||||
|
endif
|
||||||
|
endfor
|
||||||
|
return search('^.', 'Wb')
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! s:PreviousSectionEnd(count) abort
|
||||||
|
let old = line('.')
|
||||||
|
for i in range(a:count)
|
||||||
|
if search(s:section_commit_pattern, 'Wb') <= 1
|
||||||
|
exe old
|
||||||
|
if i
|
||||||
|
break
|
||||||
|
else
|
||||||
|
return ''
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
let old = line('.')
|
||||||
|
endfor
|
||||||
|
return search('^.', 'Wb')
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:StageInline(mode, ...) abort
|
function! s:StageInline(mode, ...) abort
|
||||||
@ -2756,7 +2818,7 @@ endfunction
|
|||||||
function! s:NextExpandedHunk(count) abort
|
function! s:NextExpandedHunk(count) abort
|
||||||
for i in range(a:count)
|
for i in range(a:count)
|
||||||
call s:StageInline('show', line('.'), 1)
|
call s:StageInline('show', line('.'), 1)
|
||||||
call search('^[A-Z?] .\|^diff --\|^@','W')
|
call search(s:file_pattern . '\|^@','W')
|
||||||
endfor
|
endfor
|
||||||
return '.'
|
return '.'
|
||||||
endfunction
|
endfunction
|
||||||
@ -4959,6 +5021,8 @@ function! fugitive#MapJumps(...) abort
|
|||||||
call s:MapEx('J', 'exe <SID>NextItem(v:count1)')
|
call s:MapEx('J', 'exe <SID>NextItem(v:count1)')
|
||||||
call s:MapEx('[[', 'exe <SID>PreviousSection(v:count1)')
|
call s:MapEx('[[', 'exe <SID>PreviousSection(v:count1)')
|
||||||
call s:MapEx(']]', 'exe <SID>NextSection(v:count1)')
|
call s:MapEx(']]', 'exe <SID>NextSection(v:count1)')
|
||||||
|
call s:MapEx('[]', 'exe <SID>PreviousSectionEnd(v:count1)')
|
||||||
|
call s:MapEx('][', 'exe <SID>NextSectionEnd(v:count1)')
|
||||||
endif
|
endif
|
||||||
exe "nnoremap <buffer> <silent>" s:nowait "- :<C-U>exe 'Gedit ' . <SID>fnameescape(<SID>NavigateUp(v:count1))<Bar> if getline(1) =~# '^tree \x\{40,\}$' && empty(getline(2))<Bar>call search('^'.escape(expand('#:t'),'.*[]~\').'/\=$','wc')<Bar>endif<CR>"
|
exe "nnoremap <buffer> <silent>" s:nowait "- :<C-U>exe 'Gedit ' . <SID>fnameescape(<SID>NavigateUp(v:count1))<Bar> if getline(1) =~# '^tree \x\{40,\}$' && empty(getline(2))<Bar>call search('^'.escape(expand('#:t'),'.*[]~\').'/\=$','wc')<Bar>endif<CR>"
|
||||||
nnoremap <buffer> <silent> P :<C-U>exe 'Gedit ' . <SID>fnameescape(<SID>ContainingCommit().'^'.v:count1.<SID>Relative(':'))<CR>
|
nnoremap <buffer> <silent> P :<C-U>exe 'Gedit ' . <SID>fnameescape(<SID>ContainingCommit().'^'.v:count1.<SID>Relative(':'))<CR>
|
||||||
|
@ -343,28 +343,34 @@ i Jump to the next file or hunk, expanding inline diffs
|
|||||||
automatically.
|
automatically.
|
||||||
|
|
||||||
*fugitive_[[*
|
*fugitive_[[*
|
||||||
[[ Jump to the previous section.
|
[[ Jump [count] sections backward.
|
||||||
|
|
||||||
*fugitive_]]*
|
*fugitive_]]*
|
||||||
]] Jump to the next section.
|
]] Jump [count] sections forward.
|
||||||
|
|
||||||
|
*fugitive_[]*
|
||||||
|
[] Jump [count] section ends backward.
|
||||||
|
|
||||||
|
*fugitive_][*
|
||||||
|
][ Jump [count] section ends forward.
|
||||||
|
|
||||||
*fugitive_gu*
|
*fugitive_gu*
|
||||||
gu Jump to "Unstaged" section.
|
gu Jump to file [count] in the "Unstaged" section.
|
||||||
|
|
||||||
*fugitive_gU*
|
*fugitive_gU*
|
||||||
gU Jump to "Untracked" section.
|
gU Jump to file [count] in the "Untracked" section.
|
||||||
|
|
||||||
*fugitive_gs*
|
*fugitive_gs*
|
||||||
gs Jump to "Staged" section.
|
gs Jump to file [count] in the "Staged" section.
|
||||||
|
|
||||||
*fugitive_gp*
|
*fugitive_gp*
|
||||||
gp Jump to "Unpushed" section.
|
gp Jump to file [count] in the "Unpushed" section.
|
||||||
|
|
||||||
*fugitive_gP*
|
*fugitive_gP*
|
||||||
gP Jump to "Unpulled" section.
|
gP Jump to file [count] in the "Unpulled" section.
|
||||||
|
|
||||||
*fugitive_gr*
|
*fugitive_gr*
|
||||||
gr Jump to "Rebasing" section.
|
gr Jump to file [count] in the "Rebasing" section.
|
||||||
|
|
||||||
*fugitive_gi*
|
*fugitive_gi*
|
||||||
gi Open .git/info/exclude in a split. Use a count to
|
gi Open .git/info/exclude in a split. Use a count to
|
||||||
|
Loading…
Reference in New Issue
Block a user