1
0
mirror of https://github.com/amix/vimrc synced 2025-06-23 06:35:01 +08:00

Updated plugins

This commit is contained in:
Amir Salihefendic
2018-06-14 12:31:12 +02:00
parent 7288aee801
commit 3e3297af67
273 changed files with 11821 additions and 5377 deletions

View File

@ -470,6 +470,13 @@ Add this to your vim configuration (in an `/after/plugin` directory):
autocmd! gitgutter CursorHold,CursorHoldI
```
> I turned off realtime updates, how can I have signs updated when I save a file?
If you really want to update the signs when you save a file, add this to your vimrc:
```viml
autocmd BufWritePost * GitGutter
```
> Why can't I unstage staged changes?

View File

@ -16,6 +16,7 @@ endfunction
" Finds the file's path relative to the repo root.
function! gitgutter#init_buffer(bufnr)
if gitgutter#utility#is_active(a:bufnr)
call s:setup_maps()
let p = gitgutter#utility#repo_path(a:bufnr, 0)
if type(p) != s:t_string || empty(p)
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
return getbufvar(a:bufnr, 'changedtick') != gitgutter#utility#getbufvar(a:bufnr, 'tick')
endfunction

View File

@ -1,5 +1,5 @@
function! gitgutter#utility#supports_overscore_sign()
if s:windows()
if gitgutter#utility#windows()
return &encoding ==? 'utf-8'
else
return &termencoding ==? &encoding || &termencoding == ''
@ -11,7 +11,7 @@ function! gitgutter#utility#setbufvar(buffer, varname, val)
let needs_setting = empty(dict)
let dict[a:varname] = a:val
if needs_setting
call setbufvar(a:buffer, 'gitgutter', dict)
call setbufvar(+a:buffer, 'gitgutter', dict)
endif
endfunction
@ -114,7 +114,7 @@ function! gitgutter#utility#set_repo_path(bufnr) abort
" * -2 - not tracked by git
call gitgutter#utility#setbufvar(a:bufnr, 'path', -1)
let cmd = gitgutter#utility#cd_cmd(a:bufnr, g:gitgutter_git_executable.' ls-files --error-unmatch --full-name '.gitgutter#utility#shellescape(s:filename(a:bufnr)))
let cmd = gitgutter#utility#cd_cmd(a:bufnr, g:gitgutter_git_executable.' ls-files --error-unmatch --full-name -- '.gitgutter#utility#shellescape(s:filename(a:bufnr)))
if g:gitgutter_async && gitgutter#async#available()
if has('lambda')
@ -161,7 +161,7 @@ function! s:set_path(bufnr, path)
endfunction
function! gitgutter#utility#cd_cmd(bufnr, cmd) abort
let cd = s:unc_path(a:bufnr) ? 'pushd' : (s:windows() ? 'cd /d' : 'cd')
let cd = s:unc_path(a:bufnr) ? 'pushd' : (gitgutter#utility#windows() ? 'cd /d' : 'cd')
return cd.' '.s:dir(a:bufnr).' && '.a:cmd
endfunction
@ -205,6 +205,6 @@ function! s:strip_trailing_new_line(line) abort
return substitute(a:line, '\n$', '', '')
endfunction
function! s:windows()
function! gitgutter#utility#windows()
return has('win64') || has('win32') || has('win16')
endfunction

View File

@ -445,19 +445,29 @@ a. How do I turn off realtime updates?
>
autocmd! gitgutter CursorHold,CursorHoldI
<
b. Why can't I unstage staged changes?
b. I turned off realtime updates, how can I have signs updated when I save a
file?
If you really want to update the signs when you save a file, add this to your
|vimrc|:
>
autocmd BufWritePost * GitGutter
<
c. Why can't I unstage staged changes?
This plugin is for showing changes between the working tree and the index
(and staging/undoing those changes). Unstaging a staged hunk would require
showing changes between the index and HEAD, which is out of scope.
c. Why are the colours in the sign column weird?
d. Why are the colours in the sign column weird?
Your colorscheme is configuring the |hl-SignColumn| highlight group weirdly.
Please see |g:gitgutter_override_sign_column_highlight| on customising the
sign column.
d. What happens if I also use another plugin which uses signs (e.g. Syntastic)?
e. What happens if I also use another plugin which uses signs (e.g. Syntastic)?
Vim only allows one sign per line. Vim-gitgutter will not interfere with
signs it did not add.

View File

@ -76,6 +76,14 @@ call gitgutter#highlight#define_sign_column_highlight()
call gitgutter#highlight#define_highlights()
call gitgutter#highlight#define_signs()
" Prevent infinite loop where:
" - executing a job in the foreground launches a new window which takes the focus;
" - when the job finishes, focus returns to gvim;
" - the FocusGained event triggers a new job (see below).
if gitgutter#utility#windows() && !(g:gitgutter_async && gitgutter#async#available())
set noshelltemp
endif
" }}}
" Primary functions {{{
@ -159,47 +167,38 @@ 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>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>GitGutterUndoHunk :GitGutterUndoHunk<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
" }}}
function! s:flag_inactive_tabs()
let active_tab = tabpagenr()
for i in range(1, tabpagenr('$'))
if i != active_tab
call settabvar(i, 'gitgutter_force', 1)
endif
endfor
endfunction
function! s:on_bufenter()
if exists('t:gitgutter_didtabenter') && t:gitgutter_didtabenter
let t:gitgutter_didtabenter = 0
let force = !g:gitgutter_terminal_reports_focus
if exists('t:gitgutter_force') && t:gitgutter_force
let t:gitgutter_force = 0
let force = 1
endif
call gitgutter#all(force)
else
call gitgutter#init_buffer(bufnr(''))
call gitgutter#process_buffer(bufnr(''), !g:gitgutter_terminal_reports_focus)
endif
endfunction
" Autocommands {{{
augroup gitgutter
@ -207,14 +206,7 @@ augroup gitgutter
autocmd TabEnter * let t:gitgutter_didtabenter = 1
autocmd BufEnter *
\ if exists('t:gitgutter_didtabenter') && t:gitgutter_didtabenter |
\ let t:gitgutter_didtabenter = 0 |
\ call gitgutter#all(!g:gitgutter_terminal_reports_focus) |
\ else |
\ call gitgutter#init_buffer(bufnr('')) |
\ call gitgutter#process_buffer(bufnr(''), !g:gitgutter_terminal_reports_focus) |
\ endif
autocmd BufEnter * call s:on_bufenter()
autocmd CursorHold,CursorHoldI * call gitgutter#process_buffer(bufnr(''), 0)
autocmd FileChangedShellPost,ShellCmdPost * call gitgutter#process_buffer(bufnr(''), 1)
@ -224,7 +216,7 @@ augroup gitgutter
" vim -o file1 file2
autocmd VimEnter * if winnr() != winnr('$') | call gitgutter#all(0) | endif
autocmd FocusGained * call gitgutter#all(1)
autocmd FocusGained * call gitgutter#all(1) | call s:flag_inactive_tabs()
autocmd ColorScheme * call gitgutter#highlight#define_sign_column_highlight() | call gitgutter#highlight#define_highlights()

View File

@ -167,6 +167,20 @@ function Test_filename_with_square_brackets()
endfunction
function Test_filename_leading_dash()
call system('touch -- -fixture.txt && git add -- -fixture.txt')
edit -fixture.txt
normal ggo*
call s:trigger_gitgutter()
let expected = [
\ 'line=1 id=3000 name=GitGutterLineAdded',
\ 'line=2 id=3001 name=GitGutterLineAdded'
\ ]
call assert_equal(expected, s:signs('-fixture.txt'))
endfunction
" FIXME: this test fails when it is the first (or only) test to be run
function Test_follow_symlink()
let tmp = 'symlink'