mirror of
https://github.com/airblade/vim-gitgutter.git
synced 2025-11-08 11:33:48 -05:00
Make maps buffer-local.
This commit is contained in:
@@ -16,6 +16,7 @@ endfunction
|
|||||||
" Finds the file's path relative to the repo root.
|
" Finds the file's path relative to the repo root.
|
||||||
function! gitgutter#init_buffer(bufnr)
|
function! gitgutter#init_buffer(bufnr)
|
||||||
if gitgutter#utility#is_active(a:bufnr)
|
if gitgutter#utility#is_active(a:bufnr)
|
||||||
|
call s:setup_maps()
|
||||||
let p = gitgutter#utility#repo_path(a:bufnr, 0)
|
let p = gitgutter#utility#repo_path(a:bufnr, 0)
|
||||||
if type(p) != s:t_string || empty(p)
|
if type(p) != s:t_string || empty(p)
|
||||||
call gitgutter#utility#set_repo_path(a:bufnr)
|
call gitgutter#utility#set_repo_path(a:bufnr)
|
||||||
@@ -81,6 +82,42 @@ endfunction
|
|||||||
|
|
||||||
" }}}
|
" }}}
|
||||||
|
|
||||||
|
function! s:setup_maps()
|
||||||
|
if !g:gitgutter_map_keys
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
|
||||||
|
if !hasmapto('<Plug>GitGutterPrevHunk') && maparg('[c', 'n') ==# ''
|
||||||
|
nmap <buffer> [c <Plug>GitGutterPrevHunk
|
||||||
|
endif
|
||||||
|
if !hasmapto('<Plug>GitGutterNextHunk') && maparg(']c', 'n') ==# ''
|
||||||
|
nmap <buffer> ]c <Plug>GitGutterNextHunk
|
||||||
|
endif
|
||||||
|
|
||||||
|
if !hasmapto('<Plug>GitGutterStageHunk') && maparg('<Leader>hs', 'n') ==# ''
|
||||||
|
nmap <buffer> <Leader>hs <Plug>GitGutterStageHunk
|
||||||
|
endif
|
||||||
|
if !hasmapto('<Plug>GitGutterUndoHunk') && maparg('<Leader>hu', 'n') ==# ''
|
||||||
|
nmap <buffer> <Leader>hu <Plug>GitGutterUndoHunk
|
||||||
|
endif
|
||||||
|
if !hasmapto('<Plug>GitGutterPreviewHunk') && maparg('<Leader>hp', 'n') ==# ''
|
||||||
|
nmap <buffer> <Leader>hp <Plug>GitGutterPreviewHunk
|
||||||
|
endif
|
||||||
|
|
||||||
|
if !hasmapto('<Plug>GitGutterTextObjectInnerPending') && maparg('ic', 'o') ==# ''
|
||||||
|
omap <buffer> ic <Plug>GitGutterTextObjectInnerPending
|
||||||
|
endif
|
||||||
|
if !hasmapto('<Plug>GitGutterTextObjectOuterPending') && maparg('ac', 'o') ==# ''
|
||||||
|
omap <buffer> ac <Plug>GitGutterTextObjectOuterPending
|
||||||
|
endif
|
||||||
|
if !hasmapto('<Plug>GitGutterTextObjectInnerVisual') && maparg('ic', 'x') ==# ''
|
||||||
|
xmap <buffer> ic <Plug>GitGutterTextObjectInnerVisual
|
||||||
|
endif
|
||||||
|
if !hasmapto('<Plug>GitGutterTextObjectOuterVisual') && maparg('ac', 'x') ==# ''
|
||||||
|
xmap <buffer> ac <Plug>GitGutterTextObjectOuterVisual
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
function! s:has_fresh_changes(bufnr) abort
|
function! s:has_fresh_changes(bufnr) abort
|
||||||
return getbufvar(a:bufnr, 'changedtick') != gitgutter#utility#getbufvar(a:bufnr, 'tick')
|
return getbufvar(a:bufnr, 'changedtick') != gitgutter#utility#getbufvar(a:bufnr, 'tick')
|
||||||
endfunction
|
endfunction
|
||||||
|
|||||||
@@ -167,45 +167,10 @@ command! -bar GitGutterDebug call gitgutter#debug#debug()
|
|||||||
nnoremap <silent> <expr> <Plug>GitGutterNextHunk &diff ? ']c' : ":\<C-U>execute v:count1 . 'GitGutterNextHunk'\<CR>"
|
nnoremap <silent> <expr> <Plug>GitGutterNextHunk &diff ? ']c' : ":\<C-U>execute v:count1 . 'GitGutterNextHunk'\<CR>"
|
||||||
nnoremap <silent> <expr> <Plug>GitGutterPrevHunk &diff ? '[c' : ":\<C-U>execute v:count1 . 'GitGutterPrevHunk'\<CR>"
|
nnoremap <silent> <expr> <Plug>GitGutterPrevHunk &diff ? '[c' : ":\<C-U>execute v:count1 . 'GitGutterPrevHunk'\<CR>"
|
||||||
|
|
||||||
if g:gitgutter_map_keys
|
|
||||||
if !hasmapto('<Plug>GitGutterPrevHunk') && maparg('[c', 'n') ==# ''
|
|
||||||
nmap [c <Plug>GitGutterPrevHunk
|
|
||||||
endif
|
|
||||||
if !hasmapto('<Plug>GitGutterNextHunk') && maparg(']c', 'n') ==# ''
|
|
||||||
nmap ]c <Plug>GitGutterNextHunk
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
|
|
||||||
nnoremap <silent> <Plug>GitGutterStageHunk :GitGutterStageHunk<CR>
|
nnoremap <silent> <Plug>GitGutterStageHunk :GitGutterStageHunk<CR>
|
||||||
nnoremap <silent> <Plug>GitGutterUndoHunk :GitGutterUndoHunk<CR>
|
nnoremap <silent> <Plug>GitGutterUndoHunk :GitGutterUndoHunk<CR>
|
||||||
nnoremap <silent> <Plug>GitGutterPreviewHunk :GitGutterPreviewHunk<CR>
|
nnoremap <silent> <Plug>GitGutterPreviewHunk :GitGutterPreviewHunk<CR>
|
||||||
|
|
||||||
if g:gitgutter_map_keys
|
|
||||||
if !hasmapto('<Plug>GitGutterStageHunk') && maparg('<Leader>hs', 'n') ==# ''
|
|
||||||
nmap <Leader>hs <Plug>GitGutterStageHunk
|
|
||||||
endif
|
|
||||||
if !hasmapto('<Plug>GitGutterUndoHunk') && maparg('<Leader>hu', 'n') ==# ''
|
|
||||||
nmap <Leader>hu <Plug>GitGutterUndoHunk
|
|
||||||
endif
|
|
||||||
if !hasmapto('<Plug>GitGutterPreviewHunk') && maparg('<Leader>hp', 'n') ==# ''
|
|
||||||
nmap <Leader>hp <Plug>GitGutterPreviewHunk
|
|
||||||
endif
|
|
||||||
|
|
||||||
if !hasmapto('<Plug>GitGutterTextObjectInnerPending') && maparg('ic', 'o') ==# ''
|
|
||||||
omap ic <Plug>GitGutterTextObjectInnerPending
|
|
||||||
endif
|
|
||||||
if !hasmapto('<Plug>GitGutterTextObjectOuterPending') && maparg('ac', 'o') ==# ''
|
|
||||||
omap ac <Plug>GitGutterTextObjectOuterPending
|
|
||||||
endif
|
|
||||||
if !hasmapto('<Plug>GitGutterTextObjectInnerVisual') && maparg('ic', 'x') ==# ''
|
|
||||||
xmap ic <Plug>GitGutterTextObjectInnerVisual
|
|
||||||
endif
|
|
||||||
if !hasmapto('<Plug>GitGutterTextObjectOuterVisual') && maparg('ac', 'x') ==# ''
|
|
||||||
xmap ac <Plug>GitGutterTextObjectOuterVisual
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
" }}}
|
" }}}
|
||||||
|
|
||||||
" Autocommands {{{
|
" Autocommands {{{
|
||||||
|
|||||||
Reference in New Issue
Block a user