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
2019-03-08 08:04:56 -03:00
parent 1d42b63013
commit f50b2142bc
356 changed files with 6183 additions and 3837 deletions

View File

@ -9,14 +9,16 @@ Features:
* Shows signs for added, modified, and removed lines.
* Runs the diffs asynchronously where possible.
* Ensures signs are always up to date.
* Never saves the buffer.
* Quick jumping between blocks of changed lines ("hunks").
* Stage/undo/preview individual hunks.
* Provides a hunk text object.
* Diffs against index (default) or any commit.
* Allows folding all unchanged text.
* Handles line endings correctly, even with repos that do CRLF conversion.
* Optional line highlighting.
* Fully customisable (signs, sign column, line highlights, mappings, extra git-diff arguments, etc).
* Can be toggled on/off.
* Can be toggled on/off, globally or per buffer.
* Preserves signs from other plugins.
* Easy to integrate diff stats into status line; built-in integration with [vim-airline](https://github.com/bling/vim-airline/).
* Works with fish shell (in addition to the usual shells).
@ -118,6 +120,12 @@ You can explicitly turn vim-gitgutter off and on (defaults to on):
* turn on with `:GitGutterEnable`
* toggle with `:GitGutterToggle`.
To toggle vim-gitgutter per buffer:
* turn off with `:GitGutterBufferDisable`
* turn on with `:GitGutterBufferEnable`
* toggle with `:GitGutterBufferToggle`
You can turn the signs on and off (defaults to on):
* turn on with `:GitGutterSignsEnable`
@ -203,6 +211,13 @@ Finally, you can force vim-gitgutter to update its signs across all visible buff
See the customisation section below for how to change the defaults.
### Folding
Use the `GitGutterFold` command to fold all unchanged lines, leaving just the hunks visible. Use `zr` to unfold 3 lines of context above and below a hunk.
Execute `GitGutterFold` a second time to restore the previous view.
### Customisation
You can customise:
@ -255,16 +270,30 @@ endif
#### Signs' colours and symbols
To customise the colours, set up the following highlight groups in your colorscheme or `~/.vimrc`:
By default vim-gitgutter uses your colourscheme's `Diff*` highlight groups' foreground colours for the signs' foreground colours. For example, your `DiffAdd` foreground colour will be used for the `+` sign's foreground colour.
The signs' background colours will all be set to the sign column's background colour.
If you don't like the default colours, you can either fix your colourscheme's `Diff*` highlights or configure your own `GitGutter*` highlight groups. These groups are:
```viml
GitGutterAdd " an added line
GitGutterChange " a changed line
GitGutterDelete " at least one removed line
GitGutterChangeDelete " a changed line followed by at least one removed line
GitGutterAdd " an added line (default: links to DiffAdd)
GitGutterChange " a changed line (default: links to DiffChange)
GitGutterDelete " at least one removed line (default: links to DiffDelete)
GitGutterChangeDelete " a changed line followed by at least one removed line (default: links to GitGutterChange)
```
You can either set these with `highlight GitGutterAdd {key}={arg}...` or link them to existing highlight groups with, say, `highlight link GitGutterAdd DiffAdd`.
You can either set these with `highlight GitGutterAdd {key}={arg}...` or link them to existing highlight groups with, say, `highlight link GitGutterAdd MyDiffAdd`.
To get vim-gitgutter's original colours (based on git-diff's colours in my terminal):
```viml
highlight GitGutterAdd guifg=#009900 guibg=<X> ctermfg=2 ctermbg=<Y>
highlight GitGutterChange guifg=#bbbb00 guibg=<X> ctermfg=3 ctermbg=<Y>
highlight GitGutterDelete guifg=#ff2222 guibg=<X> ctermfg=1 ctermbg=<Y>
```
where you would replace `<X>` and `<Y>` with the background colour of your `SignColumn` in the gui and the terminal respectively. For example, with the solarized colorscheme and a dark background, `guibg=#073642` and `ctermbg=0`.
To customise the symbols, add the following to your `~/.vimrc`:
@ -288,6 +317,12 @@ GitGutterDeleteLine " default: links to DiffDelete
GitGutterChangeDeleteLine " default: links to GitGutterChangeLineDefault, i.e. DiffChange
```
For example, in some colorschemes the `DiffText` highlight group is easier to read than `DiffChange`. You could use it like this:
```viml
highlight link GitGutterChangeLine DiffText
```
#### The base of the diff

View File

@ -85,6 +85,27 @@ function! gitgutter#toggle() abort
endif
endfunction
function! gitgutter#buffer_disable() abort
let bufnr = bufnr('')
call gitgutter#utility#setbufvar(bufnr, 'enabled', 0)
call s:clear(bufnr)
endfunction
function! gitgutter#buffer_enable() abort
let bufnr = bufnr('')
call gitgutter#utility#setbufvar(bufnr, 'enabled', 1)
call gitgutter#process_buffer(bufnr, 1)
endfunction
function! gitgutter#buffer_toggle() abort
if gitgutter#utility#getbufvar(bufnr(''), 'enabled', 1)
call gitgutter#buffer_disable()
else
call gitgutter#buffer_enable()
endif
endfunction
" }}}
function! s:setup_maps()

View File

@ -45,20 +45,20 @@ function! gitgutter#highlight#define_highlights() abort
" Highlights used by the signs.
execute "highlight GitGutterAddDefault guifg=#009900 guibg=" . guibg . " ctermfg=2 ctermbg=" . ctermbg
execute "highlight GitGutterChangeDefault guifg=#bbbb00 guibg=" . guibg . " ctermfg=3 ctermbg=" . ctermbg
execute "highlight GitGutterDeleteDefault guifg=#ff2222 guibg=" . guibg . " ctermfg=1 ctermbg=" . ctermbg
highlight default link GitGutterChangeDeleteDefault GitGutterChangeDefault
" When they are invisible.
execute "highlight GitGutterAddInvisible guifg=bg guibg=" . guibg . " ctermfg=" . ctermbg . " ctermbg=" . ctermbg
execute "highlight GitGutterChangeInvisible guifg=bg guibg=" . guibg . " ctermfg=" . ctermbg . " ctermbg=" . ctermbg
execute "highlight GitGutterDeleteInvisible guifg=bg guibg=" . guibg . " ctermfg=" . ctermbg . " ctermbg=" . ctermbg
highlight default link GitGutterChangeDeleteInvisible GitGutterChangeInvisible
highlight default link GitGutterAdd GitGutterAddDefault
highlight default link GitGutterChange GitGutterChangeDefault
highlight default link GitGutterDelete GitGutterDeleteDefault
highlight default link GitGutterChangeDelete GitGutterChangeDeleteDefault
" When they are visible.
" By default use Diff* foreground colors with SignColumn's background.
for type in ['Add', 'Change', 'Delete']
let [guifg, ctermfg] = s:get_foreground_colors('Diff'.type)
execute "highlight GitGutter".type."Default guifg=".guifg." guibg=".guibg." ctermfg=".ctermfg." ctermbg=".ctermbg
execute "highlight default link GitGutter".type." GitGutter".type."Default"
endfor
highlight default link GitGutterChangeDelete GitGutterChange
" Highlights used for the whole line.
@ -131,6 +131,21 @@ function! s:define_sign_line_highlights() abort
endif
endfunction
function! s:get_foreground_colors(group) abort
redir => highlight
silent execute 'silent highlight ' . a:group
redir END
let link_matches = matchlist(highlight, 'links to \(\S\+\)')
if len(link_matches) > 0 " follow the link
return s:get_foreground_colors(link_matches[1])
endif
let ctermfg = s:match_highlight(highlight, 'ctermfg=\([0-9A-Za-z]\+\)')
let guifg = s:match_highlight(highlight, 'guifg=\([#0-9A-Za-z]\+\)')
return [guifg, ctermfg]
endfunction
function! s:get_background_colors(group) abort
redir => highlight
silent execute 'silent highlight ' . a:group

View File

@ -123,6 +123,30 @@ function! gitgutter#hunk#cursor_in_hunk(hunk) abort
return 0
endfunction
function! gitgutter#hunk#in_hunk(lnum)
" Hunks are sorted in the order they appear in the buffer.
for hunk in gitgutter#hunk#hunks(bufnr(''))
" if in a hunk on first line of buffer
if a:lnum == 1 && hunk[2] == 0
return 1
endif
" if in a hunk generally
if a:lnum >= hunk[2] && a:lnum < hunk[2] + (hunk[3] == 0 ? 1 : hunk[3])
return 1
endif
" if hunk starts after the given line
if a:lnum < hunk[2]
return 0
endif
endfor
return 0
endfunction
function! gitgutter#hunk#text_object(inner) abort
let hunk = s:current_hunk()

View File

@ -53,6 +53,7 @@ endfunction
" This function does not and should not make any system calls.
function! gitgutter#utility#is_active(bufnr) abort
return g:gitgutter_enabled &&
\ gitgutter#utility#getbufvar(a:bufnr, 'enabled', 1) &&
\ !pumvisible() &&
\ s:is_file_buffer(a:bufnr) &&
\ s:exists_file(a:bufnr) &&

View File

@ -148,6 +148,11 @@ Commands for operating on a hunk:~
Use |:pclose| or |CTRL-W_CTRL-Z| to close the preview
window.
Commands for folds:~
*gitgutter-:GitGutterFold*
:GitGutterFold Fold all unchanged lines. Execute again to undo.
===============================================================================
AUTOCOMMAND *gitgutter-autocommand*
@ -433,7 +438,7 @@ colorscheme or |vimrc|:
You can either set these with `highlight GitGutterAdd {key}={arg}...` or link
them to existing highlight groups with, say:
>
highlight link GitGutterAdd DiffAdd
highlight link GitGutterAdd MyDiffAdd
<
To change the line highlights, set up the following highlight groups in your
@ -445,6 +450,11 @@ colorscheme or |vimrc|:
GitGutterChangeDeleteLine " default: links to GitGutterChangeLineDefault
<
For example, to use |hl-DiffText| instead of |hl-DiffChange|:
>
highlight link GitGutterChangeLine DiffChange
<
===============================================================================
FAQ *gitgutter-faq*

View File

@ -97,6 +97,10 @@ command! -bar GitGutterDisable call gitgutter#disable()
command! -bar GitGutterEnable call gitgutter#enable()
command! -bar GitGutterToggle call gitgutter#toggle()
command! -bar GitGutterBufferDisable call gitgutter#buffer_disable()
command! -bar GitGutterBufferEnable call gitgutter#buffer_enable()
command! -bar GitGutterBufferToggle call gitgutter#buffer_toggle()
" }}}
" Line highlights {{{
@ -162,6 +166,12 @@ endfunction
" }}}
" Folds {{{
command! -bar GitGutterFold call gitgutter#fold#toggle()
" }}}
command! -bar GitGutterDebug call gitgutter#debug#debug()
" Maps {{{
@ -203,6 +213,7 @@ augroup gitgutter
autocmd VimEnter * if winnr() != winnr('$') | call gitgutter#all(0) | endif
autocmd FocusGained,ShellCmdPost * call gitgutter#all(1)
autocmd BufLeave term://* call gitgutter#all(1)
if exists('##VimResume')
autocmd VimResume * call gitgutter#all(1)