mirror of
https://github.com/VectorKappa/dotfiles.git
synced 2025-12-19 16:26:10 +01:00
0.1.0 Initial Commit
This commit is contained in:
5
.vim_runtime/sources_non_forked/vim-gitgutter/.github/issue_template.md
vendored
Normal file
5
.vim_runtime/sources_non_forked/vim-gitgutter/.github/issue_template.md
vendored
Normal file
File diff suppressed because one or more lines are too long
5
.vim_runtime/sources_non_forked/vim-gitgutter/.gitignore
vendored
Normal file
5
.vim_runtime/sources_non_forked/vim-gitgutter/.gitignore
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
/doc/tags
|
||||
/misc
|
||||
/test/*.actual
|
||||
*.log
|
||||
|
||||
22
.vim_runtime/sources_non_forked/vim-gitgutter/LICENCE
Normal file
22
.vim_runtime/sources_non_forked/vim-gitgutter/LICENCE
Normal file
@@ -0,0 +1,22 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) Andrew Stewart
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
685
.vim_runtime/sources_non_forked/vim-gitgutter/README.mkd
Normal file
685
.vim_runtime/sources_non_forked/vim-gitgutter/README.mkd
Normal file
@@ -0,0 +1,685 @@
|
||||
## vim-gitgutter
|
||||
|
||||
A Vim plugin which shows a git diff in the sign column. It shows which lines have been added, modified, or removed. You can also preview, stage, and undo individual hunks; and stage partial hunks. The plugin also provides a hunk text object.
|
||||
|
||||
The signs are always up to date and the plugin never saves your buffer.
|
||||
|
||||
The name "gitgutter" comes from the Sublime Text 3 plugin which inspired this in 2013.
|
||||
|
||||
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.
|
||||
* Previews highlight intra-line changes.
|
||||
* Stage partial hunks.
|
||||
* Provides a hunk text object.
|
||||
* Diffs against index (default) or any commit.
|
||||
* Allows folding all unchanged text.
|
||||
* Provides fold text showing whether folded lines have been changed.
|
||||
* Can load all hunk locations into quickfix list or the current window's location list.
|
||||
* Handles line endings correctly, even with repos that do CRLF conversion.
|
||||
* Optional line highlighting.
|
||||
* Optional line number highlighting. (Only available in Neovim 0.3.2 or higher)
|
||||
* Fully customisable (signs, sign column, line (number) highlights, mappings, extra git-diff arguments, etc).
|
||||
* 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).
|
||||
|
||||
Constraints:
|
||||
|
||||
* Supports git only. If you work with other version control systems, I recommend [vim-signify](https://github.com/mhinz/vim-signify).
|
||||
* Relies on the `FocusGained` event. If your terminal doesn't report focus events, either use something like [Terminus][] or set `let g:gitgutter_terminal_reports_focus=0`. For tmux, `set -g focus-events on` in your tmux.conf.
|
||||
|
||||
Compatibility:
|
||||
|
||||
Compatible back to Vim 7.4, and probably 7.3.
|
||||
|
||||
|
||||
### Screenshot
|
||||
|
||||

|
||||
|
||||
In the screenshot above you can see:
|
||||
|
||||
* Lines 183-184 are new.
|
||||
* Lines 186-187 have been modified.
|
||||
* The preview for the modified lines highlights changed regions within the line.
|
||||
|
||||
|
||||
### Installation
|
||||
|
||||
Install using your favourite package manager, or use Vim's built-in package support.
|
||||
|
||||
Vim:
|
||||
|
||||
```
|
||||
mkdir -p ~/.vim/pack/airblade/start
|
||||
cd ~/.vim/pack/airblade/start
|
||||
git clone https://github.com/airblade/vim-gitgutter.git
|
||||
vim -u NONE -c "helptags vim-gitgutter/doc" -c q
|
||||
```
|
||||
|
||||
Neovim:
|
||||
|
||||
|
||||
```
|
||||
mkdir -p ~/.config/nvim/pack/airblade/start
|
||||
cd ~/.config/nvim/pack/airblade/start
|
||||
git clone https://github.com/airblade/vim-gitgutter.git
|
||||
nvim -u NONE -c "helptags vim-gitgutter/doc" -c q
|
||||
```
|
||||
|
||||
|
||||
### Windows
|
||||
|
||||
I recommend configuring vim-gitgutter with the full path to your git executable. For example:
|
||||
|
||||
```viml
|
||||
let g:gitgutter_git_executable = 'C:\Program Files\Git\bin\git.exe'
|
||||
```
|
||||
|
||||
This is to avoid a problem which occurs if you have file named `git.*` (i.e. with any extension in `PATHEXT`) in your current folder. `cmd.exe` prioritises the current folder over folders in `PATH` and will try to execute your file instead of the `git` binary.
|
||||
|
||||
|
||||
### Getting started
|
||||
|
||||
When you make a change to a file tracked by git, the diff markers should appear automatically. The delay is governed by vim's `updatetime` option; the default value is `4000`, i.e. 4 seconds, but I suggest reducing it to around 100ms (add `set updatetime=100` to your vimrc). Note `updatetime` also controls the delay before vim writes its swap file (see `:help updatetime`).
|
||||
|
||||
You can jump between hunks with `[c` and `]c`. You can preview, stage, and undo hunks with `<leader>hp`, `<leader>hs`, and `<leader>hu` respectively.
|
||||
|
||||
You cannot unstage a staged hunk.
|
||||
|
||||
After updating the signs, the plugin fires the `GitGutter` User autocommand.
|
||||
|
||||
After staging a hunk or part of a hunk, the plugin fires the `GitGutterStage` User autocommand.
|
||||
|
||||
|
||||
#### Activation
|
||||
|
||||
You can explicitly turn vim-gitgutter off and on (defaults to on):
|
||||
|
||||
* turn off with `:GitGutterDisable`
|
||||
* 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`
|
||||
* turn off with `:GitGutterSignsDisable`
|
||||
* toggle with `:GitGutterSignsToggle`.
|
||||
|
||||
And you can turn line highlighting on and off (defaults to off):
|
||||
|
||||
* turn on with `:GitGutterLineHighlightsEnable`
|
||||
* turn off with `:GitGutterLineHighlightsDisable`
|
||||
* toggle with `:GitGutterLineHighlightsToggle`.
|
||||
|
||||
Note that if you have line highlighting on and signs off, you will have an empty sign column – more accurately, a sign column with invisible signs. This is because line highlighting requires signs and Vim/NeoVim always shows the sign column when there are signs even if the signs are invisible.
|
||||
|
||||
With Neovim 0.3.2 or higher, you can turn line number highlighting on and off (defaults to off):
|
||||
|
||||
* turn on with `:GitGutterLineNrHighlightsEnable`
|
||||
* turn off with `:GitGutterLineNrHighlightsDisable`
|
||||
* toggle with `:GitGutterLineNrHighlightsToggle`.
|
||||
|
||||
The same caveat applies to line number highlighting as to line highlighting just above.
|
||||
|
||||
If you switch off both line highlighting and signs, you won't see the sign column.
|
||||
|
||||
In older Vims (pre 8.1.0614 / Neovim 0.4.0) vim-gitgutter will suppress the signs when a file has more than 500 changes, to avoid slowing down the UI. As soon as the number of changes falls below the limit vim-gitgutter will show the signs again. You can configure the threshold with:
|
||||
|
||||
```viml
|
||||
let g:gitgutter_max_signs = 500 " default value (Vim < 8.1.0614, Neovim < 0.4.0)
|
||||
let g:gitgutter_max_signs = -1 " default value (otherwise)
|
||||
```
|
||||
|
||||
You can also remove the limit by setting `g:gitgutter_max_signs = -1`.
|
||||
|
||||
#### Hunks
|
||||
|
||||
You can jump between hunks:
|
||||
|
||||
* jump to next hunk (change): `]c`
|
||||
* jump to previous hunk (change): `[c`.
|
||||
|
||||
Both of those take a preceding count.
|
||||
|
||||
To set your own mappings for these, for example `]h` and `[h`:
|
||||
|
||||
```viml
|
||||
nmap ]h <Plug>(GitGutterNextHunk)
|
||||
nmap [h <Plug>(GitGutterPrevHunk)
|
||||
```
|
||||
|
||||
You can load all your hunks into the quickfix list with `:GitGutterQuickFix`. Note this ignores any unsaved changes in your buffers. If the option `g:gitgutter_use_location_list` is set, this command will load hunks into the current window's location list instead.
|
||||
|
||||
You can stage or undo an individual hunk when your cursor is in it:
|
||||
|
||||
* stage the hunk with `<Leader>hs` or
|
||||
* undo it with `<Leader>hu`.
|
||||
|
||||
To stage part of an additions-only hunk by:
|
||||
|
||||
* either visually selecting the part you want and staging with your mapping, e.g. `<Leader>hs`;
|
||||
* or using a range with the `GitGutterStageHunk` command, e.g. `:42,45GitGutterStageHunk`.
|
||||
|
||||
To stage part of any hunk:
|
||||
|
||||
* preview the hunk, e.g. `<Leader>hp`;
|
||||
* move to the preview window, e.g. `:wincmd P`;
|
||||
* delete the lines you do not want to stage;
|
||||
* stage the remaining lines: either write (`:w`) the window or stage via `<Leader>hs` or `:GitGutterStageHunk`.
|
||||
|
||||
Note the above workflow is not possible if you have opted in to preview hunks with Vim's popup windows.
|
||||
|
||||
See the FAQ if you want to unstage staged changes.
|
||||
|
||||
The `.` command will work with both these if you install [repeat.vim](https://github.com/tpope/vim-repeat).
|
||||
|
||||
To set your own mappings for these, for example if you prefer `g`-based maps:
|
||||
|
||||
```viml
|
||||
nmap ghs <Plug>(GitGutterStageHunk)
|
||||
nmap ghu <Plug>(GitGutterUndoHunk)
|
||||
```
|
||||
|
||||
And you can preview a hunk's changes with `<Leader>hp`. The location of the preview window is configured with `g:gitgutter_preview_win_location` (default `'bo'`). You can of course change this mapping, e.g:
|
||||
|
||||
```viml
|
||||
nmap ghp <Plug>(GitGutterPreviewHunk)
|
||||
```
|
||||
|
||||
A hunk text object is provided which works in visual and operator-pending modes.
|
||||
|
||||
- `ic` operates on all lines in the current hunk.
|
||||
- `ac` operates on all lines in the current hunk and any trailing empty lines.
|
||||
|
||||
To re-map these, for example to `ih` and `ah`:
|
||||
|
||||
```viml
|
||||
omap ih <Plug>(GitGutterTextObjectInnerPending)
|
||||
omap ah <Plug>(GitGutterTextObjectOuterPending)
|
||||
xmap ih <Plug>(GitGutterTextObjectInnerVisual)
|
||||
xmap ah <Plug>(GitGutterTextObjectOuterVisual)
|
||||
```
|
||||
|
||||
If you don't want vim-gitgutter to set up any mappings at all, use this:
|
||||
|
||||
```viml
|
||||
let g:gitgutter_map_keys = 0
|
||||
```
|
||||
|
||||
Finally, you can force vim-gitgutter to update its signs across all visible buffers with `:GitGutterAll`.
|
||||
|
||||
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.
|
||||
|
||||
Use `gitgutter#fold#foldtext()` to augment the default `foldtext()` with an indicator of whether the folded lines have been changed.
|
||||
|
||||
```viml
|
||||
set foldtext=gitgutter#fold#foldtext()
|
||||
```
|
||||
|
||||
For a closed fold with changed lines:
|
||||
|
||||
```
|
||||
Default foldtext(): +-- 45 lines: abcdef
|
||||
gitgutter#fold#foldtext(): +-- 45 lines (*): abcdef
|
||||
```
|
||||
|
||||
You can use `gitgutter#fold#is_changed()` in your own `foldtext` expression to find out whether the folded lines have been changed.
|
||||
|
||||
|
||||
### Status line
|
||||
|
||||
Call the `GitGutterGetHunkSummary()` function from your status line to get a list of counts of added, modified, and removed lines in the current buffer. For example:
|
||||
|
||||
```viml
|
||||
" Your vimrc
|
||||
function! GitStatus()
|
||||
let [a,m,r] = GitGutterGetHunkSummary()
|
||||
return printf('+%d ~%d -%d', a, m, r)
|
||||
endfunction
|
||||
set statusline+=%{GitStatus()}
|
||||
```
|
||||
|
||||
|
||||
### Customisation
|
||||
|
||||
You can customise:
|
||||
|
||||
* The sign column's colours
|
||||
* Whether or not the sign column is shown when there aren't any signs (defaults to no)
|
||||
* How to handle non-gitgutter signs
|
||||
* The signs' colours and symbols
|
||||
* Line highlights
|
||||
* Whether the diff is relative to the index (default) or working tree.
|
||||
* The base of the diff
|
||||
* Extra arguments for `git` when running `git diff`
|
||||
* Extra arguments for `git diff`
|
||||
* Key mappings
|
||||
* Whether vim-gitgutter is on initially (defaults to on)
|
||||
* Whether signs are shown (defaults to yes)
|
||||
* Whether line highlighting is on initially (defaults to off)
|
||||
* Whether line number highlighting is on initially (defaults to off)
|
||||
* Whether vim-gitgutter runs asynchronously (defaults to yes)
|
||||
* Whether to clobber or preserve non-gitgutter signs
|
||||
* The priority of gitgutter's signs.
|
||||
* Whether to use a floating/popup window for hunk previews
|
||||
* Whether to populate the quickfix list or a location list with all hunks
|
||||
|
||||
Please note that vim-gitgutter won't override any colours or highlights you've set in your colorscheme.
|
||||
|
||||
|
||||
#### Sign column
|
||||
|
||||
Set the `SignColumn` highlight group to change the sign column's colour. For example:
|
||||
|
||||
```viml
|
||||
" vim-gitgutter used to do this by default:
|
||||
highlight! link SignColumn LineNr
|
||||
|
||||
" or you could do this:
|
||||
highlight SignColumn guibg=whatever ctermbg=whatever
|
||||
```
|
||||
|
||||
By default the sign column will appear when there are signs to show and disappear when there aren't. To always have the sign column, add to your vimrc:
|
||||
|
||||
```viml
|
||||
" Vim 7.4.2201
|
||||
set signcolumn=yes
|
||||
```
|
||||
|
||||
GitGutter can preserve or ignore non-gitgutter signs. For Vim v8.1.0614 and later you can set gitgutter's signs' priorities with `g:gitgutter_sign_priority`, so gitgutter defaults to clobbering other signs. For Neovim v0.4.0 and later you can set an expanding sign column so gitgutter again defaults to clobbering other signs. Otherwise, gitgutter defaults to preserving other signs. You can configure this with:
|
||||
|
||||
```viml
|
||||
let g:gitgutter_sign_allow_clobber = 1
|
||||
```
|
||||
|
||||
|
||||
#### Signs' colours and symbols
|
||||
|
||||
If you or your colourscheme has defined `GitGutter*` highlight groups, the plugin will use them for the signs' colours.
|
||||
|
||||
If you want the background colours to match the sign column, but don't want to update the `GitGutter*` groups yourself, you can get the plugin to do it:
|
||||
|
||||
```viml
|
||||
let g:gitgutter_set_sign_backgrounds = 1
|
||||
```
|
||||
|
||||
If no `GitGutter*` highlight groups exist, the plugin will check the `Diff*` highlight groups. If their foreground colours differ the plugin will use them; if not, these colours will be used:
|
||||
|
||||
```viml
|
||||
highlight GitGutterAdd guifg=#009900 ctermfg=2
|
||||
highlight GitGutterChange guifg=#bbbb00 ctermfg=3
|
||||
highlight GitGutterDelete guifg=#ff2222 ctermfg=1
|
||||
```
|
||||
|
||||
To customise the symbols, add the following to your `~/.vimrc`:
|
||||
|
||||
```viml
|
||||
let g:gitgutter_sign_added = 'xx'
|
||||
let g:gitgutter_sign_modified = 'yy'
|
||||
let g:gitgutter_sign_removed = 'zz'
|
||||
let g:gitgutter_sign_removed_first_line = '^^'
|
||||
let g:gitgutter_sign_modified_removed = 'ww'
|
||||
```
|
||||
|
||||
|
||||
#### Line highlights
|
||||
|
||||
Similarly to the signs' colours, set up the following highlight groups in your colorscheme or `~/.vimrc`:
|
||||
|
||||
```viml
|
||||
GitGutterAddLine " default: links to DiffAdd
|
||||
GitGutterChangeLine " default: links to DiffChange
|
||||
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
|
||||
```
|
||||
|
||||
|
||||
#### Line number highlights
|
||||
|
||||
NOTE: This feature requires Neovim 0.3.2 or higher.
|
||||
|
||||
Similarly to the signs' colours, set up the following highlight groups in your colorscheme or `~/.vimrc`:
|
||||
|
||||
```viml
|
||||
GitGutterAddLineNr " default: links to CursorLineNr
|
||||
GitGutterChangeLineNr " default: links to CursorLineNr
|
||||
GitGutterDeleteLineNr " default: links to CursorLineNr
|
||||
GitGutterChangeDeleteLineNr " default: links to CursorLineNr
|
||||
```
|
||||
|
||||
Maybe you think `CursorLineNr` is a bit annoying. For example, you could use `Underlined` for this:
|
||||
|
||||
```viml
|
||||
highlight link GitGutterChangeLineNr Underlined
|
||||
```
|
||||
|
||||
|
||||
#### Whether the diff is relative to the index or working tree
|
||||
|
||||
By default diffs are relative to the index. How you can make them relative to the working tree:
|
||||
|
||||
```viml
|
||||
let g:gitgutter_diff_relative_to = 'working_tree'
|
||||
```
|
||||
|
||||
|
||||
#### The base of the diff
|
||||
|
||||
By default buffers are diffed against the index. However you can diff against any commit by setting:
|
||||
|
||||
```viml
|
||||
let g:gitgutter_diff_base = '<commit SHA>'
|
||||
```
|
||||
|
||||
If you are looking at a previous version of a file with Fugitive (e.g. via `:0Gclog`), gitgutter sets the diff base to the parent of the current revision.
|
||||
|
||||
This setting is ignored when the diffs are relative to the working tree.
|
||||
|
||||
|
||||
#### Extra arguments for `git` when running `git diff`
|
||||
|
||||
If you want to pass extra arguments to `git` when running `git diff`, do so like this:
|
||||
|
||||
```viml
|
||||
let g:gitgutter_git_args = '--git-dir-""'
|
||||
```
|
||||
|
||||
#### Extra arguments for `git diff`
|
||||
|
||||
If you want to pass extra arguments to `git diff`, for example to ignore whitespace, do so like this:
|
||||
|
||||
```viml
|
||||
let g:gitgutter_diff_args = '-w'
|
||||
```
|
||||
|
||||
#### Key mappings
|
||||
|
||||
To disable all key mappings:
|
||||
|
||||
```viml
|
||||
let g:gitgutter_map_keys = 0
|
||||
```
|
||||
|
||||
See above for configuring maps for hunk-jumping and staging/undoing.
|
||||
|
||||
|
||||
#### Use a custom `grep` command
|
||||
|
||||
If you use an alternative to grep, you can tell vim-gitgutter to use it here.
|
||||
|
||||
```viml
|
||||
" Default:
|
||||
let g:gitgutter_grep = 'grep'
|
||||
```
|
||||
|
||||
#### To turn off vim-gitgutter by default
|
||||
|
||||
Add `let g:gitgutter_enabled = 0` to your `~/.vimrc`.
|
||||
|
||||
|
||||
#### To turn off signs by default
|
||||
|
||||
Add `let g:gitgutter_signs = 0` to your `~/.vimrc`.
|
||||
|
||||
|
||||
#### To turn on line highlighting by default
|
||||
|
||||
Add `let g:gitgutter_highlight_lines = 1` to your `~/.vimrc`.
|
||||
|
||||
|
||||
#### To turn on line number highlighting by default
|
||||
|
||||
Add `let g:gitgutter_highlight_linenrs = 1` to your `~/.vimrc`.
|
||||
|
||||
|
||||
#### To turn off asynchronous updates
|
||||
|
||||
By default diffs are run asynchronously. To run diffs synchronously instead:
|
||||
|
||||
```viml
|
||||
let g:gitgutter_async = 0
|
||||
```
|
||||
|
||||
|
||||
#### To use floating/popup windows for hunk previews
|
||||
|
||||
Add `let g:gitgutter_preview_win_floating = 1` to your `~/.vimrc`. Note that on Vim this prevents you staging (partial) hunks via the preview window.
|
||||
|
||||
|
||||
#### To load all hunks into the current window's location list instead of the quickfix list
|
||||
|
||||
Add `let g:gitgutter_use_location_list = 1` to your `~/.vimrc`.
|
||||
|
||||
|
||||
### Extensions
|
||||
|
||||
#### Operate on every line in a hunk
|
||||
|
||||
You can map an operator to do whatever you want to every line in a hunk.
|
||||
|
||||
Let's say, for example, you want to remove trailing whitespace.
|
||||
|
||||
```viml
|
||||
function! CleanUp(...)
|
||||
if a:0 " opfunc
|
||||
let [first, last] = [line("'["), line("']")]
|
||||
else
|
||||
let [first, last] = [line("'<"), line("'>")]
|
||||
endif
|
||||
for lnum in range(first, last)
|
||||
let line = getline(lnum)
|
||||
|
||||
" clean up the text, e.g.:
|
||||
let line = substitute(line, '\s\+$', '', '')
|
||||
|
||||
call setline(lnum, line)
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
nmap <silent> <Leader>x :set opfunc=CleanUp<CR>g@
|
||||
```
|
||||
|
||||
Then place your cursor in a hunk and type `\xic` (assuming a leader of `\`).
|
||||
|
||||
Alternatively you could place your cursor in a hunk, type `vic` to select it, then `:call CleanUp()`.
|
||||
|
||||
|
||||
#### Operate on every changed line in a file
|
||||
|
||||
You can write a command to do whatever you want to every changed line in a file.
|
||||
|
||||
```viml
|
||||
function! GlobalChangedLines(ex_cmd)
|
||||
for hunk in GitGutterGetHunks()
|
||||
for lnum in range(hunk[2], hunk[2]+hunk[3]-1)
|
||||
let cursor = getcurpos()
|
||||
silent! execute lnum.a:ex_cmd
|
||||
call setpos('.', cursor)
|
||||
endfor
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
command -nargs=1 Glines call GlobalChangedLines(<q-args>)
|
||||
```
|
||||
|
||||
Let's say, for example, you want to remove trailing whitespace from all changed lines:
|
||||
|
||||
```viml
|
||||
:Glines s/\s\+$//
|
||||
```
|
||||
|
||||
|
||||
#### Cycle through hunks in current buffer
|
||||
|
||||
This is like `:GitGutterNextHunk` but when it gets to the last hunk in the buffer it cycles around to the first.
|
||||
|
||||
```viml
|
||||
function! GitGutterNextHunkCycle()
|
||||
let line = line('.')
|
||||
silent! GitGutterNextHunk
|
||||
if line('.') == line
|
||||
1
|
||||
GitGutterNextHunk
|
||||
endif
|
||||
endfunction
|
||||
```
|
||||
|
||||
|
||||
#### Cycle through hunks in all buffers
|
||||
|
||||
You can use `:GitGutterQuickFix` to load all hunks into the quickfix list or the current window's location list.
|
||||
|
||||
Alternatively, given that`]c` and `[c` jump from one hunk to the next in the current buffer, you can use this code to jump to the next hunk no matter which buffer it's in.
|
||||
|
||||
```viml
|
||||
function! NextHunkAllBuffers()
|
||||
let line = line('.')
|
||||
GitGutterNextHunk
|
||||
if line('.') != line
|
||||
return
|
||||
endif
|
||||
|
||||
let bufnr = bufnr('')
|
||||
while 1
|
||||
bnext
|
||||
if bufnr('') == bufnr
|
||||
return
|
||||
endif
|
||||
if !empty(GitGutterGetHunks())
|
||||
1
|
||||
GitGutterNextHunk
|
||||
return
|
||||
endif
|
||||
endwhile
|
||||
endfunction
|
||||
|
||||
function! PrevHunkAllBuffers()
|
||||
let line = line('.')
|
||||
GitGutterPrevHunk
|
||||
if line('.') != line
|
||||
return
|
||||
endif
|
||||
|
||||
let bufnr = bufnr('')
|
||||
while 1
|
||||
bprevious
|
||||
if bufnr('') == bufnr
|
||||
return
|
||||
endif
|
||||
if !empty(GitGutterGetHunks())
|
||||
normal! G
|
||||
GitGutterPrevHunk
|
||||
return
|
||||
endif
|
||||
endwhile
|
||||
endfunction
|
||||
|
||||
nmap <silent> ]c :call NextHunkAllBuffers()<CR>
|
||||
nmap <silent> [c :call PrevHunkAllBuffers()<CR>
|
||||
```
|
||||
|
||||
|
||||
### FAQ
|
||||
|
||||
> How can I turn off realtime updates?
|
||||
|
||||
Add this to your vim configuration (in an `/after/plugin` directory):
|
||||
|
||||
```viml
|
||||
" .vim/after/plugin/gitgutter.vim
|
||||
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?
|
||||
|
||||
This plugin is for showing changes between the buffer 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.
|
||||
|
||||
> Why are the colours in the sign column weird?
|
||||
|
||||
Your colorscheme is configuring the `SignColumn` highlight group weirdly. Please see the section above on customising the sign column.
|
||||
|
||||
> What happens if I also use another plugin which uses signs (e.g. Syntastic)?
|
||||
|
||||
You can configure whether GitGutter preserves or clobbers other signs using `g:gitgutter_sign_allow_clobber`. Set to `1` to clobber other signs (default on Vim >= 8.1.0614 and NeoVim >= 0.4.0) or `0` to preserve them.
|
||||
|
||||
|
||||
### Troubleshooting
|
||||
|
||||
#### When no signs are showing at all
|
||||
|
||||
Here are some things you can check:
|
||||
|
||||
* Try adding `let g:gitgutter_grep=''` to your vimrc. If it works, the problem is grep producing non-plain output; e.g. ANSI escape codes or colours.
|
||||
* Verify `:echo system("git --version")` succeeds.
|
||||
* Verify your git config is compatible with the version of git returned by the command above.
|
||||
* Verify your Vim supports signs (`:echo has('signs')` should give `1`).
|
||||
* Verify your file is being tracked by git and has unstaged changes.
|
||||
|
||||
#### When the whole file is marked as added
|
||||
|
||||
* If you use zsh, and you set `CDPATH`, make sure `CDPATH` doesn't include the current directory.
|
||||
|
||||
#### When signs take a few seconds to appear
|
||||
|
||||
* Try reducing `updatetime`, e.g. `set updatetime=100`. Note this also controls the delay before vim writes its swap file.
|
||||
|
||||
#### When signs don't update after focusing Vim
|
||||
|
||||
* Your terminal probably isn't reporting focus events. Either try installing [Terminus][] or set `let g:gitgutter_terminal_reports_focus=0`. For tmux, try `set -g focus-events on` in your tmux.conf.
|
||||
|
||||
|
||||
### Shameless Plug
|
||||
|
||||
If this plugin has helped you, or you'd like to learn more about Vim, why not check out this screencast I wrote for PeepCode:
|
||||
|
||||
* [Smash Into Vim][siv]
|
||||
|
||||
This was one of PeepCode's all-time top three bestsellers and is now available at Pluralsight.
|
||||
|
||||
You can read reviews on my [website][airblade].
|
||||
|
||||
|
||||
### Intellectual Property
|
||||
|
||||
Copyright Andrew Stewart, AirBlade Software Ltd. Released under the MIT licence.
|
||||
|
||||
|
||||
[pathogen]: https://github.com/tpope/vim-pathogen
|
||||
[siv]: http://pluralsight.com/training/Courses/TableOfContents/smash-into-vim
|
||||
[airblade]: http://airbladesoftware.com/peepcode-vim
|
||||
[terminus]: https://github.com/wincent/terminus
|
||||
@@ -0,0 +1,209 @@
|
||||
" Primary functions {{{
|
||||
|
||||
function! gitgutter#all(force) abort
|
||||
let visible = tabpagebuflist()
|
||||
|
||||
for bufnr in range(1, bufnr('$') + 1)
|
||||
if buflisted(bufnr)
|
||||
let file = expand('#'.bufnr.':p')
|
||||
if !empty(file)
|
||||
if index(visible, bufnr) != -1
|
||||
call gitgutter#process_buffer(bufnr, a:force)
|
||||
elseif a:force
|
||||
call s:reset_tick(bufnr)
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
|
||||
function! gitgutter#process_buffer(bufnr, force) abort
|
||||
" NOTE a:bufnr is not necessarily the current buffer.
|
||||
|
||||
if gitgutter#utility#is_active(a:bufnr)
|
||||
|
||||
if has('patch-7.4.1559')
|
||||
let l:Callback = function('gitgutter#process_buffer', [a:bufnr, a:force])
|
||||
else
|
||||
let l:Callback = {'function': 'gitgutter#process_buffer', 'arguments': [a:bufnr, a:force]}
|
||||
endif
|
||||
let how = s:setup_path(a:bufnr, l:Callback)
|
||||
if [how] == ['async'] " avoid string-to-number conversion if how is a number
|
||||
return
|
||||
endif
|
||||
|
||||
if a:force || s:has_fresh_changes(a:bufnr)
|
||||
|
||||
let diff = 'NOT SET'
|
||||
try
|
||||
let diff = gitgutter#diff#run_diff(a:bufnr, g:gitgutter_diff_relative_to, 0)
|
||||
catch /gitgutter not tracked/
|
||||
call gitgutter#debug#log('Not tracked: '.gitgutter#utility#file(a:bufnr))
|
||||
catch /gitgutter diff failed/
|
||||
call gitgutter#debug#log('Diff failed: '.gitgutter#utility#file(a:bufnr))
|
||||
call gitgutter#hunk#reset(a:bufnr)
|
||||
endtry
|
||||
|
||||
if diff != 'async' && diff != 'NOT SET'
|
||||
call gitgutter#diff#handler(a:bufnr, diff)
|
||||
endif
|
||||
|
||||
endif
|
||||
endif
|
||||
endfunction
|
||||
|
||||
|
||||
function! gitgutter#disable() abort
|
||||
" get list of all buffers (across all tabs)
|
||||
for bufnr in range(1, bufnr('$') + 1)
|
||||
if buflisted(bufnr)
|
||||
let file = expand('#'.bufnr.':p')
|
||||
if !empty(file)
|
||||
call s:clear(bufnr)
|
||||
endif
|
||||
endif
|
||||
endfor
|
||||
|
||||
let g:gitgutter_enabled = 0
|
||||
endfunction
|
||||
|
||||
function! gitgutter#enable() abort
|
||||
let g:gitgutter_enabled = 1
|
||||
call gitgutter#all(1)
|
||||
endfunction
|
||||
|
||||
function! gitgutter#toggle() abort
|
||||
if g:gitgutter_enabled
|
||||
call gitgutter#disable()
|
||||
else
|
||||
call gitgutter#enable()
|
||||
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! gitgutter#setup_maps()
|
||||
if !g:gitgutter_map_keys
|
||||
return
|
||||
endif
|
||||
|
||||
" Note hasmapto() and maparg() operate on the current buffer.
|
||||
|
||||
let bufnr = bufnr('')
|
||||
|
||||
if gitgutter#utility#getbufvar(bufnr, 'mapped', 0)
|
||||
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)', 'v') && maparg('<Leader>hs', 'x') ==# ''
|
||||
xmap <buffer> <Leader>hs <Plug>(GitGutterStageHunk)
|
||||
endif
|
||||
if !hasmapto('<Plug>(GitGutterStageHunk)', 'n') && 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
|
||||
|
||||
call gitgutter#utility#setbufvar(bufnr, 'mapped', 1)
|
||||
endfunction
|
||||
|
||||
function! s:setup_path(bufnr, continuation)
|
||||
if gitgutter#utility#has_repo_path(a:bufnr) | return | endif
|
||||
|
||||
return gitgutter#utility#set_repo_path(a:bufnr, a:continuation)
|
||||
endfunction
|
||||
|
||||
function! s:has_fresh_changes(bufnr) abort
|
||||
return getbufvar(a:bufnr, 'changedtick') != gitgutter#utility#getbufvar(a:bufnr, 'tick')
|
||||
endfunction
|
||||
|
||||
function! s:reset_tick(bufnr) abort
|
||||
call gitgutter#utility#setbufvar(a:bufnr, 'tick', 0)
|
||||
endfunction
|
||||
|
||||
function! s:clear(bufnr)
|
||||
call gitgutter#sign#clear_signs(a:bufnr)
|
||||
call gitgutter#hunk#reset(a:bufnr)
|
||||
call s:reset_tick(a:bufnr)
|
||||
call gitgutter#utility#setbufvar(a:bufnr, 'path', '')
|
||||
endfunction
|
||||
|
||||
|
||||
" Note:
|
||||
" - this runs synchronously
|
||||
" - it ignores unsaved changes in buffers
|
||||
" - it does not change to the repo root
|
||||
function! gitgutter#quickfix()
|
||||
let locations = []
|
||||
let cmd = g:gitgutter_git_executable.' '.g:gitgutter_git_args.' --no-pager '.g:gitgutter_git_args.
|
||||
\ ' diff --no-ext-diff --no-color -U0 '.g:gitgutter_diff_args. ' '. g:gitgutter_diff_base
|
||||
let diff = systemlist(cmd)
|
||||
let lnum = 0
|
||||
for line in diff
|
||||
if line =~ '^diff --git [^"]'
|
||||
let paths = line[11:]
|
||||
let mid = (len(paths) - 1) / 2
|
||||
let [fnamel, fnamer] = [paths[:mid-1], paths[mid+1:]]
|
||||
let fname = fnamel ==# fnamer ? fnamel : fnamel[2:]
|
||||
elseif line =~ '^diff --git "'
|
||||
let [_, fnamel, _, fnamer] = split(line, '"')
|
||||
let fname = fnamel ==# fnamer ? fnamel : fnamel[2:]
|
||||
elseif line =~ '^@@'
|
||||
let lnum = matchlist(line, '+\(\d\+\)')[1]
|
||||
elseif lnum > 0
|
||||
call add(locations, {'filename': fname, 'lnum': lnum, 'text': line})
|
||||
let lnum = 0
|
||||
endif
|
||||
endfor
|
||||
if !g:gitgutter_use_location_list
|
||||
call setqflist(locations)
|
||||
else
|
||||
call setloclist(0, locations)
|
||||
endif
|
||||
endfunction
|
||||
658
.vim_runtime/sources_non_forked/vim-gitgutter/doc/gitgutter.txt
Normal file
658
.vim_runtime/sources_non_forked/vim-gitgutter/doc/gitgutter.txt
Normal file
@@ -0,0 +1,658 @@
|
||||
*gitgutter.txt* A Vim plugin which shows a git diff in the gutter.
|
||||
|
||||
|
||||
Vim GitGutter
|
||||
|
||||
|
||||
Author: Andy Stewart <https://airbladesoftware.com/>
|
||||
Plugin Homepage: <https://github.com/airblade/vim-gitgutter>
|
||||
|
||||
|
||||
===============================================================================
|
||||
CONTENTS *gitgutter*
|
||||
|
||||
Introduction ................. |gitgutter-introduction|
|
||||
Installation ................. |gitgutter-installation|
|
||||
Windows ................. |gitgutter-windows|
|
||||
Commands ..................... |gitgutter-commands|
|
||||
Mappings ..................... |gitgutter-mappings|
|
||||
Autocommand .................. |gitgutter-autocommand|
|
||||
Status line .................. |gitgutter-statusline|
|
||||
Options ...................... |gitgutter-options|
|
||||
Highlights ................... |gitgutter-highlights|
|
||||
FAQ .......................... |gitgutter-faq|
|
||||
TROUBLESHOOTING .............. |gitgutter-troubleshooting|
|
||||
|
||||
|
||||
===============================================================================
|
||||
INTRODUCTION *gitgutter-introduction*
|
||||
|
||||
GitGutter is a Vim plugin which shows a git diff in the sign column.
|
||||
It shows which lines have been added, modified, or removed. You can also
|
||||
preview, stage, and undo individual hunks. The plugin also provides a hunk
|
||||
text object.
|
||||
|
||||
The signs are always up to date and the plugin never saves your buffer.
|
||||
|
||||
The name "gitgutter" comes from the Sublime Text 3 plugin which inspired this
|
||||
one in 2013.
|
||||
|
||||
|
||||
===============================================================================
|
||||
INSTALLATION *gitgutter-installation*
|
||||
|
||||
Use your favourite package manager, or use Vim's built-in package support.
|
||||
|
||||
Vim:~
|
||||
>
|
||||
mkdir -p ~/.vim/pack/airblade/start
|
||||
cd ~/.vim/pack/airblade/start
|
||||
git clone https://github.com/airblade/vim-gitgutter.git
|
||||
vim -u NONE -c "helptags vim-gitgutter/doc" -c q
|
||||
<
|
||||
|
||||
Neovim:~
|
||||
>
|
||||
mkdir -p ~/.config/nvim/pack/airblade/start
|
||||
cd ~/.config/nvim/pack/airblade/start
|
||||
git clone https://github.com/airblade/vim-gitgutter.git
|
||||
nvim -u NONE -c "helptags vim-gitgutter/doc" -c q
|
||||
<
|
||||
|
||||
|
||||
===============================================================================
|
||||
WINDOWS *gitgutter-windows*
|
||||
|
||||
I recommend configuring vim-gitgutter with the full path to your git executable.
|
||||
For example:
|
||||
>
|
||||
let g:gitgutter_git_executable = 'C:\Program Files\Git\bin\git.exe'
|
||||
<
|
||||
This is to avoid a problem which occurs if you have file named "git.*" (i.e.
|
||||
with any extension in "PATHEXT") in your current folder. "cmd.exe" prioritises
|
||||
the current folder over folders in 'PATH' and will try to execute your file
|
||||
instead of the "git" binary.
|
||||
|
||||
|
||||
===============================================================================
|
||||
COMMANDS *gitgutter-commands*
|
||||
|
||||
Commands for turning vim-gitgutter on and off:~
|
||||
|
||||
*gitgutter-:GitGutterDisable*
|
||||
:GitGutterDisable Turn vim-gitgutter off for all buffers.
|
||||
|
||||
*gitgutter-:GitGutterEnable*
|
||||
:GitGutterEnable Turn vim-gitgutter on for all buffers.
|
||||
|
||||
*gitgutter-:GitGutterToggle*
|
||||
:GitGutterToggle Toggle vim-gitgutter on or off for all buffers.
|
||||
|
||||
*gitgutter-:GitGutter*
|
||||
:GitGutter Update signs for the current buffer. You shouldn't
|
||||
need to run this.
|
||||
|
||||
*gitgutter-:GitGutterAll*
|
||||
:GitGutterAll Update signs for all buffers. You shouldn't need to
|
||||
run this.
|
||||
|
||||
|
||||
Commands for turning signs on and off (defaults to on):~
|
||||
|
||||
*gitgutter-:GitGutterSignsEnable*
|
||||
:GitGutterSignsEnable Show signs for the diff.
|
||||
|
||||
*gitgutter-:GitGutterSignsDisable*
|
||||
:GitGutterSignsDisable Do not show signs for the diff.
|
||||
|
||||
*gitgutter-:GitGutterSignsToggle*
|
||||
:GitGutterSignsToggle Toggle signs on or off.
|
||||
|
||||
|
||||
Commands for turning line highlighting on and off (defaults to off):~
|
||||
|
||||
*gitgutter-:GitGutterLineHighlightsEnable*
|
||||
:GitGutterLineHighlightsEnable Turn on line highlighting.
|
||||
|
||||
*gitgutter-:GitGutterLineHighlightsDisable*
|
||||
:GitGutterLineHighlightsDisable Turn off line highlighting.
|
||||
|
||||
*gitgutter-:GitGutterLineHighlightsToggle*
|
||||
:GitGutterLineHighlightsToggle Turn line highlighting on or off.
|
||||
|
||||
|
||||
Commands for turning line number highlighting on and off (defaults to off):~
|
||||
NOTE: This feature requires Neovim 0.3.2 or higher.
|
||||
|
||||
*gitgutter-:GitGutterLineNrHighlightsEnable*
|
||||
:GitGutterLineNrHighlightsEnable Turn on line highlighting.
|
||||
|
||||
*gitgutter-:GitGutterLineNrHighlightsDisable*
|
||||
:GitGutterLineNrHighlightsDisable Turn off line highlighting.
|
||||
|
||||
*gitgutter-:GitGutterLineNrHighlightsToggle*
|
||||
:GitGutterLineNrHighlightsToggle Turn line highlighting on or off.
|
||||
|
||||
|
||||
Commands for jumping between hunks:~
|
||||
|
||||
*gitgutter-:GitGutterNextHunk*
|
||||
:GitGutterNextHunk Jump to the next [count] hunk.
|
||||
|
||||
*gitgutter-:GitGutterPrevHunk*
|
||||
:GitGutterPrevHunk Jump to the previous [count] hunk.
|
||||
|
||||
*gitgutter-:GitGutterQuickFix*
|
||||
:GitGutterQuickFix Load all hunks into the |quickfix| list. Note this
|
||||
ignores any unsaved changes in your buffers. The
|
||||
|g:gitgutter_use_location_list| option can be set to
|
||||
populate the location list of the current window instead
|
||||
|
||||
|
||||
Commands for operating on a hunk:~
|
||||
|
||||
*gitgutter-:GitGutterStageHunk*
|
||||
:GitGutterStageHunk Stage the hunk the cursor is in. Use a visual selection
|
||||
to stage part of an (additions-only) hunk; or use a
|
||||
range.
|
||||
|
||||
To stage part of any hunk, first |GitGutterPreviewHunk|
|
||||
it, then move to the preview window, delete the lines
|
||||
you do not want to stage, and |write| or
|
||||
|GitGutterStageHunk|.
|
||||
|
||||
*gitgutter-:GitGutterUndoHunk*
|
||||
:GitGutterUndoHunk Undo the hunk the cursor is in.
|
||||
|
||||
*gitgutter-:GitGutterPreviewHunk*
|
||||
:GitGutterPreviewHunk Preview the hunk the cursor is in.
|
||||
Use |:pclose| or |CTRL-W_CTRL-Z| to close the preview
|
||||
window.
|
||||
|
||||
To stage part of the hunk, move to the preview window,
|
||||
delete any lines you do not want to stage, and
|
||||
|GitGutterStageHunk|.
|
||||
|
||||
Commands for folds:~
|
||||
|
||||
*gitgutter-:GitGutterFold*
|
||||
:GitGutterFold Fold all unchanged lines. Execute again to undo.
|
||||
|
||||
|
||||
===============================================================================
|
||||
AUTOCOMMANDS *gitgutter-autocommands*
|
||||
|
||||
User GitGutter~
|
||||
|
||||
After updating a buffer's signs vim-gitgutter fires a |User| |autocmd| with the
|
||||
event GitGutter. You can listen for this event, for example:
|
||||
>
|
||||
autocmd User GitGutter call updateMyStatusLine()
|
||||
<
|
||||
A dictionary `g:gitgutter_hook_context` is made available during its execution,
|
||||
which contains an entry `bufnr` that contains the buffer number being updated.
|
||||
|
||||
User GitGutterStage~
|
||||
|
||||
After staging a hunk or part of a hunk vim-gitgutter fires a |User| |autocmd|
|
||||
with the event GitGutterStage. Staging always happens in the current buffer.
|
||||
|
||||
===============================================================================
|
||||
MAPPINGS *gitgutter-mappings*
|
||||
|
||||
You can disable all these mappings with:
|
||||
>
|
||||
let g:gitgutter_map_keys = 0
|
||||
<
|
||||
|
||||
Hunk operations:~
|
||||
|
||||
These can be repeated with `.` if you have vim-repeat installed.
|
||||
|
||||
*gitgutter-<Leader>hp*
|
||||
<Leader>hp Preview the hunk under the cursor.
|
||||
|
||||
*gitgutter-<Leader>hs*
|
||||
<Leader>hs Stage the hunk under the cursor.
|
||||
|
||||
*gitgutter-<Leader>hu*
|
||||
<Leader>hu Undo the hunk under the cursor.
|
||||
|
||||
You can change these mappings like this:
|
||||
>
|
||||
nmap ghp <Plug>(GitGutterPreviewHunk)
|
||||
nmap ghs <Plug>(GitGutterStageHunk)
|
||||
nmap ghu <Plug>(GitGutterUndoHunk)
|
||||
<
|
||||
|
||||
Hunk jumping:~
|
||||
|
||||
*gitgutter-]c*
|
||||
]c Jump to the next [count] hunk.
|
||||
|
||||
*gitgutter-[c*
|
||||
[c Jump to the previous [count] hunk.
|
||||
|
||||
You can change these mappings like this:
|
||||
>
|
||||
nmap [c <Plug>(GitGutterPrevHunk)
|
||||
nmap ]c <Plug>(GitGutterNextHunk)
|
||||
<
|
||||
|
||||
Hunk text object:~
|
||||
|
||||
*gitgutter-ic* *gitgutter-ac* *gitgutter-text-object*
|
||||
"ic" operates on the current hunk's lines. "ac" does the same but also includes
|
||||
trailing empty lines.
|
||||
>
|
||||
omap ic <Plug>(GitGutterTextObjectInnerPending)
|
||||
omap ac <Plug>(GitGutterTextObjectOuterPending)
|
||||
xmap ic <Plug>(GitGutterTextObjectInnerVisual)
|
||||
xmap ac <Plug>(GitGutterTextObjectOuterVisual)
|
||||
<
|
||||
|
||||
|
||||
===============================================================================
|
||||
STATUS LINE *gitgutter-statusline*
|
||||
|
||||
|
||||
Call the `GitGutterGetHunkSummary()` function from your status line to get a
|
||||
list of counts of added, modified, and removed lines in the current buffer.
|
||||
For example:
|
||||
>
|
||||
" Your vimrc
|
||||
function! GitStatus()
|
||||
let [a,m,r] = GitGutterGetHunkSummary()
|
||||
return printf('+%d ~%d -%d', a, m, r)
|
||||
endfunction
|
||||
set statusline+=%{GitStatus()}
|
||||
<
|
||||
|
||||
|
||||
===============================================================================
|
||||
OPTIONS *gitgutter-options*
|
||||
|
||||
The most important option is 'updatetime' which determines how long (in
|
||||
milliseconds) the plugin will wait after you stop typing before it updates the
|
||||
signs. Vim's default is 4000. I recommend 100. Note this also controls how
|
||||
long vim waits before writing its swap file.
|
||||
|
||||
Most important option:~
|
||||
|
||||
'updatetime'
|
||||
|
||||
Git:~
|
||||
|
||||
|g:gitgutter_git_executable|
|
||||
|g:gitgutter_git_args|
|
||||
|g:gitgutter_diff_args|
|
||||
|g:gitgutter_diff_relative_to|
|
||||
|g:gitgutter_diff_base|
|
||||
|
||||
Grep:~
|
||||
|
||||
|g:gitgutter_grep|
|
||||
|
||||
Signs:~
|
||||
|
||||
|g:gitgutter_signs|
|
||||
|g:gitgutter_highlight_lines|
|
||||
|g:gitgutter_highlight_linenrs|
|
||||
|g:gitgutter_max_signs|
|
||||
|g:gitgutter_sign_priority|
|
||||
|g:gitgutter_sign_allow_clobber|
|
||||
|g:gitgutter_sign_added|
|
||||
|g:gitgutter_sign_modified|
|
||||
|g:gitgutter_sign_removed|
|
||||
|g:gitgutter_sign_removed_first_line|
|
||||
|g:gitgutter_sign_modified_removed|
|
||||
|g:gitgutter_set_sign_backgrounds|
|
||||
|
||||
Hunk previews:~
|
||||
|
||||
|g:gitgutter_preview_win_floating|
|
||||
|
||||
Terminal:~
|
||||
|
||||
|g:gitgutter_terminal_reports_focus|
|
||||
|
||||
General:~
|
||||
|
||||
|g:gitgutter_enabled|
|
||||
|g:gitgutter_map_keys|
|
||||
|g:gitgutter_async|
|
||||
|g:gitgutter_log|
|
||||
|g:gitgutter_use_location_list|
|
||||
|
||||
|
||||
*g:gitgutter_preview_win_location*
|
||||
Default: 'bo'
|
||||
|
||||
This option determines where the preview window pops up as a result of the
|
||||
:GitGutterPreviewHunk command. Other plausible values are 'to', 'bel', 'abo'.
|
||||
See the end of the |opening-window| docs.
|
||||
|
||||
*g:gitgutter_git_executable*
|
||||
Default: 'git'
|
||||
|
||||
This option determines what git binary to use. Set this if git is not on your
|
||||
path.
|
||||
|
||||
*g:gitgutter_git_args*
|
||||
Default: empty
|
||||
|
||||
Use this option to pass any extra arguments to git when running git-diff.
|
||||
For example:
|
||||
>
|
||||
let g:gitgutter_git_args = '--git-dir=""'
|
||||
<
|
||||
|
||||
*g:gitgutter_diff_args*
|
||||
Default: empty
|
||||
|
||||
Use this option to pass any extra arguments to git-diff. For example:
|
||||
>
|
||||
let g:gitgutter_diff_args = '-w'
|
||||
<
|
||||
|
||||
*g:gitgutter_diff_relative_to*
|
||||
Default: empty
|
||||
|
||||
By default buffers are diffed against the index. Use this option to diff against
|
||||
the working tree. For example:
|
||||
>
|
||||
let g:gitgutter_diff_relative_to = 'working_tree'
|
||||
<
|
||||
|
||||
*g:gitgutter_diff_base*
|
||||
Default: empty
|
||||
|
||||
By default buffers are diffed against the index. Use this option to diff against
|
||||
a revision instead. For example:
|
||||
>
|
||||
let g:gitgutter_diff_base = '<some commit SHA>'
|
||||
<
|
||||
|
||||
If you are looking at a previous version of a file with Fugitive (e.g.
|
||||
via :0Gclog), gitgutter sets the diff base to the parent of the current revision.
|
||||
|
||||
This setting is ignore when the diff is relative to the working tree
|
||||
(|g:gitgutter_diff_relative_to|).
|
||||
|
||||
*g:gitgutter_grep*
|
||||
Default: 'grep'
|
||||
|
||||
The plugin pipes the output of git-diff into grep to minimise the amount of data
|
||||
vim has to process. Set this option if grep is not on your path.
|
||||
|
||||
grep must produce plain-text output without any ANSI escape codes or colours.
|
||||
Use this option to turn off colours if necessary.
|
||||
>
|
||||
let g:gitgutter_grep = 'grep --color=never'
|
||||
<
|
||||
If you do not want to use grep at all (perhaps to debug why signs are not
|
||||
showing), set this option to an empty string:
|
||||
>
|
||||
let g:gitgutter_grep = ''
|
||||
<
|
||||
|
||||
*g:gitgutter_signs*
|
||||
Default: 1
|
||||
|
||||
Determines whether or not to show signs.
|
||||
|
||||
*g:gitgutter_highlight_lines*
|
||||
Default: 0
|
||||
|
||||
Determines whether or not to show line highlights.
|
||||
|
||||
*g:gitgutter_highlight_linenrs*
|
||||
Default: 0
|
||||
|
||||
Determines whether or not to show line number highlights.
|
||||
|
||||
*g:gitgutter_max_signs*
|
||||
Default: 500 (Vim < 8.1.0614, Neovim < 0.4.0)
|
||||
-1 (otherwise)
|
||||
|
||||
Sets the maximum number of signs to show in a buffer. Vim is slow at updating
|
||||
signs, so to avoid slowing down the GUI the number of signs is capped. When
|
||||
the number of changed lines exceeds this value, the plugin removes all signs
|
||||
and displays a warning message.
|
||||
|
||||
When set to -1 the limit is not applied.
|
||||
|
||||
*g:gitgutter_sign_priority*
|
||||
Default: 10
|
||||
|
||||
Sets the |sign-priority| gitgutter assigns to its signs.
|
||||
|
||||
*g:gitgutter_sign_allow_clobber*
|
||||
Default: 0 (Vim < 8.1.0614, Neovim < 0.4.0)
|
||||
1 (otherwise)
|
||||
|
||||
Determines whether gitgutter preserves non-gitgutter signs. When 1, gitgutter
|
||||
will not preserve non-gitgutter signs.
|
||||
|
||||
*g:gitgutter_sign_added*
|
||||
*g:gitgutter_sign_modified*
|
||||
*g:gitgutter_sign_removed*
|
||||
*g:gitgutter_sign_removed_first_line*
|
||||
*g:gitgutter_sign_modified_removed*
|
||||
Defaults:
|
||||
>
|
||||
let g:gitgutter_sign_added = '+'
|
||||
let g:gitgutter_sign_modified = '~'
|
||||
let g:gitgutter_sign_removed = '_'
|
||||
let g:gitgutter_sign_removed_first_line = '‾'
|
||||
let g:gitgutter_sign_modified_removed = '~_'
|
||||
<
|
||||
You can use unicode characters but not images. Signs must not take up more than
|
||||
2 columns.
|
||||
|
||||
*g:gitgutter_set_sign_backgrounds*
|
||||
Default: 0
|
||||
|
||||
Only applies to existing GitGutter* highlight groups. See
|
||||
|gitgutter-highlights|.
|
||||
|
||||
Controls whether to override the signs' background colours to match the
|
||||
|hl-SignColumn|.
|
||||
|
||||
*g:gitgutter_preview_win_floating*
|
||||
Default: 0 (Vim)
|
||||
0 (NeoVim which does not support floating windows)
|
||||
1 (NeoVim which does support floating windows)
|
||||
|
||||
Whether to use floating/popup windows for hunk previews. Note that if you use
|
||||
popup windows on Vim you will not be able to stage partial hunks via the
|
||||
preview window.
|
||||
|
||||
*g:gitgutter_terminal_reports_focus*
|
||||
Default: 1
|
||||
|
||||
Normally the plugin uses |FocusGained| to force-update all buffers when Vim
|
||||
receives focus. However some terminals do not report focus events and so the
|
||||
|FocusGained| autocommand never fires.
|
||||
|
||||
If this applies to you, either install something like Terminus
|
||||
(https://github.com/wincent/terminus) to make |FocusGained| work or set this
|
||||
option to 0.
|
||||
|
||||
If you use tmux, try this in your tmux.conf:
|
||||
>
|
||||
set -g focus-events on
|
||||
<
|
||||
|
||||
When this option is 0, the plugin force-updates the buffer on |BufEnter|
|
||||
(instead of only updating if the buffer's contents has changed since the last
|
||||
update).
|
||||
|
||||
*g:gitgutter_enabled*
|
||||
Default: 1
|
||||
|
||||
Controls whether or not the plugin is on at startup.
|
||||
|
||||
*g:gitgutter_map_keys*
|
||||
Default: 1
|
||||
|
||||
Controls whether or not the plugin provides mappings. See |gitgutter-mappings|.
|
||||
|
||||
*g:gitgutter_async*
|
||||
Default: 1
|
||||
|
||||
Controls whether or not diffs are run in the background. This has no effect if
|
||||
your Vim does not support background jobs.
|
||||
|
||||
*g:gitgutter_log*
|
||||
Default: 0
|
||||
|
||||
When switched on, the plugin logs to gitgutter.log in the directory where it is
|
||||
installed. Additionally it logs channel activity to channel.log.
|
||||
|
||||
*g:gitgutter_use_location_list*
|
||||
Default: 0
|
||||
|
||||
When switched on, the :GitGutterQuickFix command populates the location list
|
||||
of the current window instead of the global quickfix list.
|
||||
|
||||
|
||||
===============================================================================
|
||||
HIGHLIGHTS *gitgutter-highlights*
|
||||
|
||||
To change the signs' colours, specify these highlight groups in your |vimrc|:
|
||||
>
|
||||
highlight GitGutterAdd guifg=#009900 ctermfg=2
|
||||
highlight GitGutterChange guifg=#bbbb00 ctermfg=3
|
||||
highlight GitGutterDelete guifg=#ff2222 ctermfg=1
|
||||
<
|
||||
|
||||
See |highlight-guifg| and |highlight-ctermfg| for the values you can use.
|
||||
|
||||
If you do not like the signs' background colours and you do not want to update
|
||||
the GitGutter* highlight groups yourself, you can get the plugin to do it
|
||||
|g:gitgutter_set_sign_backgrounds|.
|
||||
|
||||
To change the line highlights, set up the following highlight groups in your
|
||||
colorscheme or |vimrc|:
|
||||
>
|
||||
GitGutterAddLine " default: links to DiffAdd
|
||||
GitGutterChangeLine " default: links to DiffChange
|
||||
GitGutterDeleteLine " default: links to DiffDelete
|
||||
GitGutterChangeDeleteLine " default: links to GitGutterChangeLineDefault
|
||||
<
|
||||
|
||||
For example, to use |hl-DiffText| instead of |hl-DiffChange|:
|
||||
>
|
||||
highlight link GitGutterChangeLine DiffText
|
||||
<
|
||||
To change the line number highlights, set up the following highlight groups in
|
||||
your colorscheme or |vimrc|:
|
||||
>
|
||||
GitGutterAddLineNr " default: links to CursorLineNr
|
||||
GitGutterChangeLineNr " default: links to CursorLineNr
|
||||
GitGutterDeleteLineNr " default: links to CursorLineNr
|
||||
GitGutterChangeDeleteLineNr " default: links to CursorLineNr
|
||||
<
|
||||
For example, to use |hl-Underlined| instead of |hl-CursorLineNr|:
|
||||
>
|
||||
highlight link GitGutterChangeLineNr Underlined
|
||||
<
|
||||
|
||||
|
||||
===============================================================================
|
||||
FAQ *gitgutter-faq*
|
||||
|
||||
a. How do I turn off realtime updates?
|
||||
|
||||
Add this to your vim configuration in an |after-directory|:
|
||||
>
|
||||
autocmd! gitgutter CursorHold,CursorHoldI
|
||||
<
|
||||
|
||||
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.
|
||||
|
||||
d. Why are the colours in the sign column weird?
|
||||
|
||||
Your colorscheme is configuring the |hl-SignColumn| highlight group weirdly.
|
||||
Here are two ways you could change the colours:
|
||||
>
|
||||
highlight! link SignColumn LineNr
|
||||
highlight SignColumn guibg=whatever ctermbg=whatever
|
||||
<
|
||||
|
||||
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.
|
||||
|
||||
|
||||
===============================================================================
|
||||
TROUBLESHOOTING *gitgutter-troubleshooting*
|
||||
|
||||
When no signs are showing at all:~
|
||||
|
||||
1. Try bypassing grep with:
|
||||
>
|
||||
let g:gitgutter_grep = ''
|
||||
<
|
||||
If it works, the problem is grep outputting ANSI escape codes. Use this
|
||||
option to pass arguments to grep to turn off the escape codes.
|
||||
|
||||
2. Verify git is on your path:
|
||||
>
|
||||
:echo system('git --version')
|
||||
<
|
||||
|
||||
3. Verify your git config is compatible with the version of git return by the
|
||||
command above.
|
||||
|
||||
4. Verify your Vim supports signs. The following should give 1:
|
||||
>
|
||||
:echo has('signs')
|
||||
<
|
||||
|
||||
5. Check whether the plugin thinks git knows about your file:
|
||||
>
|
||||
:echo getbufvar('','gitgutter').path
|
||||
<
|
||||
If the result is -2, the plugin thinks your file is not tracked by git.
|
||||
|
||||
|
||||
When the whole file is marked as added:~
|
||||
|
||||
If you use zsh, and you set "CDPATH", make sure "CDPATH" does not include the
|
||||
current directory.
|
||||
|
||||
|
||||
When signs take a few seconds to appear:~
|
||||
|
||||
Try reducing 'updatetime':
|
||||
>
|
||||
set updatetime=100
|
||||
<
|
||||
|
||||
Note this also controls how long vim waits before writing its swap file.
|
||||
|
||||
|
||||
When signs don't update after focusing Vim:~
|
||||
|
||||
Your terminal probably isn't reporting focus events. Either try installing
|
||||
Terminus (https://github.com/wincent/terminus) or set:
|
||||
>
|
||||
let g:gitgutter_terminal_reports_focus = 0
|
||||
<
|
||||
|
||||
@@ -0,0 +1,285 @@
|
||||
scriptencoding utf-8
|
||||
|
||||
if exists('g:loaded_gitgutter') || !has('signs') || &cp
|
||||
finish
|
||||
endif
|
||||
let g:loaded_gitgutter = 1
|
||||
|
||||
" Initialisation {{{
|
||||
|
||||
if v:version < 703 || (v:version == 703 && !has("patch105"))
|
||||
call gitgutter#utility#warn('requires Vim 7.3.105')
|
||||
finish
|
||||
endif
|
||||
|
||||
function! s:set(var, default) abort
|
||||
if !exists(a:var)
|
||||
if type(a:default)
|
||||
execute 'let' a:var '=' string(a:default)
|
||||
else
|
||||
execute 'let' a:var '=' a:default
|
||||
endif
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:obsolete(var)
|
||||
if exists(a:var)
|
||||
call gitgutter#utility#warn(a:var.' is obsolete and has no effect.')
|
||||
endif
|
||||
endfunction
|
||||
|
||||
|
||||
call s:set('g:gitgutter_preview_win_location', 'bo')
|
||||
if exists('*nvim_open_win')
|
||||
call s:set('g:gitgutter_preview_win_floating', 1)
|
||||
else
|
||||
call s:set('g:gitgutter_preview_win_floating', 0)
|
||||
endif
|
||||
call s:set('g:gitgutter_enabled', 1)
|
||||
if exists('*sign_unplace')
|
||||
call s:set('g:gitgutter_max_signs', -1)
|
||||
else
|
||||
call s:set('g:gitgutter_max_signs', 500)
|
||||
endif
|
||||
call s:set('g:gitgutter_signs', 1)
|
||||
call s:set('g:gitgutter_highlight_lines', 0)
|
||||
call s:set('g:gitgutter_highlight_linenrs', 0)
|
||||
call s:set('g:gitgutter_sign_priority', 10)
|
||||
" Nvim 0.4.0 has an expanding sign column
|
||||
" The sign_place() function supports sign priority.
|
||||
if (has('nvim-0.4.0') || exists('*sign_place')) && !exists('g:gitgutter_sign_allow_clobber')
|
||||
let g:gitgutter_sign_allow_clobber = 1
|
||||
endif
|
||||
call s:set('g:gitgutter_sign_allow_clobber', 0)
|
||||
call s:set('g:gitgutter_set_sign_backgrounds', 0)
|
||||
call s:set('g:gitgutter_sign_added', '+')
|
||||
call s:set('g:gitgutter_sign_modified', '~')
|
||||
call s:set('g:gitgutter_sign_removed', '_')
|
||||
|
||||
if gitgutter#utility#supports_overscore_sign()
|
||||
call s:set('g:gitgutter_sign_removed_first_line', '‾')
|
||||
else
|
||||
call s:set('g:gitgutter_sign_removed_first_line', '_^')
|
||||
endif
|
||||
|
||||
call s:set('g:gitgutter_sign_removed_above_and_below', '[')
|
||||
call s:set('g:gitgutter_sign_modified_removed', '~_')
|
||||
call s:set('g:gitgutter_git_args', '')
|
||||
call s:set('g:gitgutter_diff_relative_to', 'index')
|
||||
call s:set('g:gitgutter_diff_args', '')
|
||||
call s:set('g:gitgutter_diff_base', '')
|
||||
call s:set('g:gitgutter_map_keys', 1)
|
||||
call s:set('g:gitgutter_terminal_reports_focus', 1)
|
||||
call s:set('g:gitgutter_async', 1)
|
||||
call s:set('g:gitgutter_log', 0)
|
||||
call s:set('g:gitgutter_use_location_list', 0)
|
||||
|
||||
call s:set('g:gitgutter_git_executable', 'git')
|
||||
if !executable(g:gitgutter_git_executable)
|
||||
if g:gitgutter_enabled
|
||||
call gitgutter#utility#warn('cannot find git. Please set g:gitgutter_git_executable.')
|
||||
endif
|
||||
finish
|
||||
endif
|
||||
|
||||
let default_grep = 'grep'
|
||||
call s:set('g:gitgutter_grep', default_grep)
|
||||
if !empty(g:gitgutter_grep)
|
||||
if executable(split(g:gitgutter_grep)[0])
|
||||
if $GREP_OPTIONS =~# '--color=always'
|
||||
let g:gitgutter_grep .= ' --color=never'
|
||||
endif
|
||||
else
|
||||
if g:gitgutter_grep !=# default_grep
|
||||
call gitgutter#utility#warn('cannot find '.g:gitgutter_grep.'. Please check g:gitgutter_grep.')
|
||||
endif
|
||||
let g:gitgutter_grep = ''
|
||||
endif
|
||||
endif
|
||||
|
||||
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 {{{
|
||||
|
||||
command! -bar GitGutterAll call gitgutter#all(1)
|
||||
command! -bar GitGutter call gitgutter#process_buffer(bufnr(''), 1)
|
||||
|
||||
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()
|
||||
|
||||
command! -bar GitGutterQuickFix call gitgutter#quickfix()
|
||||
|
||||
" }}}
|
||||
|
||||
" Line highlights {{{
|
||||
|
||||
command! -bar GitGutterLineHighlightsDisable call gitgutter#highlight#line_disable()
|
||||
command! -bar GitGutterLineHighlightsEnable call gitgutter#highlight#line_enable()
|
||||
command! -bar GitGutterLineHighlightsToggle call gitgutter#highlight#line_toggle()
|
||||
|
||||
" }}}
|
||||
|
||||
" 'number' column highlights {{{
|
||||
command! -bar GitGutterLineNrHighlightsDisable call gitgutter#highlight#linenr_disable()
|
||||
command! -bar GitGutterLineNrHighlightsEnable call gitgutter#highlight#linenr_enable()
|
||||
command! -bar GitGutterLineNrHighlightsToggle call gitgutter#highlight#linenr_toggle()
|
||||
" }}}
|
||||
|
||||
" Signs {{{
|
||||
|
||||
command! -bar GitGutterSignsEnable call gitgutter#sign#enable()
|
||||
command! -bar GitGutterSignsDisable call gitgutter#sign#disable()
|
||||
command! -bar GitGutterSignsToggle call gitgutter#sign#toggle()
|
||||
|
||||
" }}}
|
||||
|
||||
" Hunks {{{
|
||||
|
||||
command! -bar -count=1 GitGutterNextHunk call gitgutter#hunk#next_hunk(<count>)
|
||||
command! -bar -count=1 GitGutterPrevHunk call gitgutter#hunk#prev_hunk(<count>)
|
||||
|
||||
command! -bar -range=% GitGutterStageHunk call gitgutter#hunk#stage(<line1>,<line2>)
|
||||
command! -bar GitGutterUndoHunk call gitgutter#hunk#undo()
|
||||
command! -bar GitGutterPreviewHunk call gitgutter#hunk#preview()
|
||||
|
||||
" Hunk text object
|
||||
onoremap <silent> <Plug>(GitGutterTextObjectInnerPending) :<C-U>call gitgutter#hunk#text_object(1)<CR>
|
||||
onoremap <silent> <Plug>(GitGutterTextObjectOuterPending) :<C-U>call gitgutter#hunk#text_object(0)<CR>
|
||||
xnoremap <silent> <Plug>(GitGutterTextObjectInnerVisual) :<C-U>call gitgutter#hunk#text_object(1)<CR>
|
||||
xnoremap <silent> <Plug>(GitGutterTextObjectOuterVisual) :<C-U>call gitgutter#hunk#text_object(0)<CR>
|
||||
|
||||
|
||||
" Returns the git-diff hunks for the file or an empty list if there
|
||||
" aren't any hunks.
|
||||
"
|
||||
" The return value is a list of lists. There is one inner list per hunk.
|
||||
"
|
||||
" [
|
||||
" [from_line, from_count, to_line, to_count],
|
||||
" [from_line, from_count, to_line, to_count],
|
||||
" ...
|
||||
" ]
|
||||
"
|
||||
" where:
|
||||
"
|
||||
" `from` - refers to the staged file
|
||||
" `to` - refers to the working tree's file
|
||||
" `line` - refers to the line number where the change starts
|
||||
" `count` - refers to the number of lines the change covers
|
||||
function! GitGutterGetHunks()
|
||||
let bufnr = bufnr('')
|
||||
return gitgutter#utility#is_active(bufnr) ? gitgutter#hunk#hunks(bufnr) : []
|
||||
endfunction
|
||||
|
||||
" Returns an array that contains a summary of the hunk status for the current
|
||||
" window. The format is [ added, modified, removed ], where each value
|
||||
" represents the number of lines added/modified/removed respectively.
|
||||
function! GitGutterGetHunkSummary()
|
||||
return gitgutter#hunk#summary(winbufnr(0))
|
||||
endfunction
|
||||
|
||||
" }}}
|
||||
|
||||
" Folds {{{
|
||||
|
||||
command! -bar GitGutterFold call gitgutter#fold#toggle()
|
||||
|
||||
" }}}
|
||||
|
||||
command! -bar GitGutterDebug call gitgutter#debug#debug()
|
||||
|
||||
" Maps {{{
|
||||
|
||||
nnoremap <silent> <expr> <Plug>(GitGutterNextHunk) &diff ? ']c' : ":\<C-U>execute v:count1 . 'GitGutterNextHunk'\<CR>"
|
||||
nnoremap <silent> <expr> <Plug>GitGutterNextHunk &diff ? ']c' : ":\<C-U>call gitgutter#utility#warn('please change your map \<lt>Plug>GitGutterNextHunk to \<lt>Plug>(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>call gitgutter#utility#warn('please change your map \<lt>Plug>GitGutterPrevHunk to \<lt>Plug>(GitGutterPrevHunk)')\<CR>"
|
||||
|
||||
xnoremap <silent> <Plug>(GitGutterStageHunk) :GitGutterStageHunk<CR>
|
||||
xnoremap <silent> <Plug>GitGutterStageHunk :call gitgutter#utility#warn('please change your map <lt>Plug>GitGutterStageHunk to <lt>Plug>(GitGutterStageHunk)')<CR>
|
||||
nnoremap <silent> <Plug>(GitGutterStageHunk) :GitGutterStageHunk<CR>
|
||||
nnoremap <silent> <Plug>GitGutterStageHunk :call gitgutter#utility#warn('please change your map <lt>Plug>GitGutterStageHunk to <lt>Plug>(GitGutterStageHunk)')<CR>
|
||||
nnoremap <silent> <Plug>(GitGutterUndoHunk) :GitGutterUndoHunk<CR>
|
||||
nnoremap <silent> <Plug>GitGutterUndoHunk :call gitgutter#utility#warn('please change your map <lt>Plug>GitGutterUndoHunk to <lt>Plug>(GitGutterUndoHunk)')<CR>
|
||||
nnoremap <silent> <Plug>(GitGutterPreviewHunk) :GitGutterPreviewHunk<CR>
|
||||
nnoremap <silent> <Plug>GitGutterPreviewHunk :call gitgutter#utility#warn('please change your map <lt>Plug>GitGutterPreviewHunk to <lt>Plug>(GitGutterPreviewHunk)')<CR>
|
||||
|
||||
" }}}
|
||||
|
||||
function! s:on_bufenter()
|
||||
call gitgutter#setup_maps()
|
||||
|
||||
if exists('t:gitgutter_didtabenter') && t:gitgutter_didtabenter
|
||||
let t:gitgutter_didtabenter = 0
|
||||
call gitgutter#all(!g:gitgutter_terminal_reports_focus)
|
||||
else
|
||||
call gitgutter#process_buffer(bufnr(''), !g:gitgutter_terminal_reports_focus)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Autocommands {{{
|
||||
|
||||
augroup gitgutter
|
||||
autocmd!
|
||||
|
||||
autocmd TabEnter * let t:gitgutter_didtabenter = 1
|
||||
|
||||
autocmd BufEnter * call s:on_bufenter()
|
||||
|
||||
autocmd CursorHold,CursorHoldI * call gitgutter#process_buffer(bufnr(''), 0)
|
||||
if exists('*timer_start') && has('lambda')
|
||||
autocmd FileChangedShellPost * call timer_start(1, {-> gitgutter#process_buffer(bufnr(''), 1)})
|
||||
else
|
||||
autocmd FileChangedShellPost * call gitgutter#process_buffer(bufnr(''), 1)
|
||||
endif
|
||||
|
||||
" Ensure that all buffers are processed when opening vim with multiple files, e.g.:
|
||||
"
|
||||
" vim -o file1 file2
|
||||
autocmd VimEnter * if winnr() != winnr('$') | call gitgutter#all(0) | endif
|
||||
|
||||
autocmd ShellCmdPost * call gitgutter#all(1)
|
||||
autocmd BufLeave term://* call gitgutter#all(1)
|
||||
|
||||
autocmd User FugitiveChanged call gitgutter#all(1)
|
||||
|
||||
autocmd BufFilePre * GitGutterBufferDisable
|
||||
autocmd BufFilePost * GitGutterBufferEnable
|
||||
|
||||
" Handle all buffers when focus is gained, but only after it was lost.
|
||||
" FocusGained gets triggered on startup with Neovim at least already.
|
||||
" Therefore this tracks also if it was lost before.
|
||||
let s:focus_was_lost = 0
|
||||
autocmd FocusGained * if s:focus_was_lost | let focus_was_lost = 0 | call gitgutter#all(1) | endif
|
||||
autocmd FocusLost * let s:focus_was_lost = 1
|
||||
|
||||
if exists('##VimResume')
|
||||
autocmd VimResume * call gitgutter#all(1)
|
||||
endif
|
||||
|
||||
autocmd ColorScheme * call gitgutter#highlight#define_highlights()
|
||||
|
||||
" Disable during :vimgrep
|
||||
autocmd QuickFixCmdPre *vimgrep* let g:gitgutter_enabled = 0
|
||||
autocmd QuickFixCmdPost *vimgrep* let g:gitgutter_enabled = 1
|
||||
augroup END
|
||||
|
||||
" }}}
|
||||
|
||||
" vim:set et sw=2 fdm=marker:
|
||||
BIN
.vim_runtime/sources_non_forked/vim-gitgutter/screenshot.png
Normal file
BIN
.vim_runtime/sources_non_forked/vim-gitgutter/screenshot.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 587 KiB |
@@ -0,0 +1,8 @@
|
||||
The quick brown fox jumps
|
||||
over the lazy dog
|
||||
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>͂ɂقւƂ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʂ<EFBFBD><EFBFBD><EFBFBD>
|
||||
<EFBFBD>킩<EFBFBD>悽<EFBFBD>ꂻ<EFBFBD>˂Ȃ<EFBFBD><EFBFBD><EFBFBD>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̂<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>܂<EFBFBD><EFBFBD>ӂ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߂݂<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ђ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
a
|
||||
b
|
||||
c
|
||||
d
|
||||
e
|
||||
f
|
||||
g
|
||||
h
|
||||
i
|
||||
j
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
a
|
||||
b
|
||||
c
|
||||
d
|
||||
e
|
||||
f
|
||||
g
|
||||
h
|
||||
i
|
||||
j
|
||||
|
||||
162
.vim_runtime/sources_non_forked/vim-gitgutter/test/runner.vim
Normal file
162
.vim_runtime/sources_non_forked/vim-gitgutter/test/runner.vim
Normal file
@@ -0,0 +1,162 @@
|
||||
"
|
||||
" Adapted from https://github.com/vim/vim/blob/master/src/testdir/runtest.vim
|
||||
"
|
||||
" When debugging tests it can help to write debug output:
|
||||
" call Log('oh noes')
|
||||
"
|
||||
|
||||
function RunTest(test)
|
||||
if exists("*SetUp")
|
||||
call SetUp()
|
||||
endif
|
||||
|
||||
try
|
||||
execute 'call '.a:test
|
||||
catch
|
||||
call Exception()
|
||||
let s:errored = 1
|
||||
endtry
|
||||
|
||||
if exists("*TearDown")
|
||||
call TearDown()
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function Log(msg)
|
||||
if type(a:msg) == type('')
|
||||
call add(s:messages, a:msg)
|
||||
elseif type(a:msg) == type([])
|
||||
call extend(s:messages, a:msg)
|
||||
else
|
||||
call add(v:errors, 'Exception: unsupported type: '.type(a:msg))
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function Exception()
|
||||
call add(v:errors, v:throwpoint.'..'.'Exception: '.v:exception)
|
||||
endfunction
|
||||
|
||||
" Shuffles list in place.
|
||||
function Shuffle(list)
|
||||
" Fisher-Yates-Durstenfeld-Knuth
|
||||
let n = len(a:list)
|
||||
if n < 2
|
||||
return a:list
|
||||
endif
|
||||
for i in range(0, n-2)
|
||||
let j = Random(0, n-i-1)
|
||||
let e = a:list[i]
|
||||
let a:list[i] = a:list[i+j]
|
||||
let a:list[i+j] = e
|
||||
endfor
|
||||
return a:list
|
||||
endfunction
|
||||
|
||||
" Returns a pseudorandom integer i such that 0 <= i <= max
|
||||
function Random(min, max)
|
||||
if has('unix')
|
||||
let i = system('echo $RANDOM') " 0 <= i <= 32767
|
||||
else
|
||||
let i = system('echo %RANDOM%') " 0 <= i <= 32767
|
||||
endif
|
||||
return i * (a:max - a:min + 1) / 32768 + a:min
|
||||
endfunction
|
||||
|
||||
function FriendlyName(test_name)
|
||||
return substitute(a:test_name[5:-3], '_', ' ', 'g')
|
||||
endfunction
|
||||
|
||||
function Align(left, right)
|
||||
if type(a:right) == type([])
|
||||
let result = []
|
||||
for s in a:right
|
||||
if empty(result)
|
||||
call add(result, printf('%-'.s:indent.'S', a:left).s)
|
||||
else
|
||||
call add(result, printf('%-'.s:indent.'S', '').s)
|
||||
endif
|
||||
endfor
|
||||
return result
|
||||
endif
|
||||
|
||||
return printf('%-'.s:indent.'S', a:left).a:right
|
||||
endfunction
|
||||
|
||||
let g:testname = expand('%')
|
||||
let s:errored = 0
|
||||
let s:done = 0
|
||||
let s:fail = 0
|
||||
let s:errors = 0
|
||||
let s:messages = []
|
||||
let s:indent = ''
|
||||
|
||||
call Log(g:testname.':')
|
||||
|
||||
" Source the test script.
|
||||
try
|
||||
source %
|
||||
catch
|
||||
let s:errors += 1
|
||||
call Exception()
|
||||
endtry
|
||||
|
||||
" Locate the test functions.
|
||||
set nomore
|
||||
redir @q
|
||||
silent function /^Test_
|
||||
redir END
|
||||
let s:tests = split(substitute(@q, 'function \(\k*()\)', '\1', 'g'))
|
||||
|
||||
" If there is another argument, filter test-functions' names against it.
|
||||
if argc() > 1
|
||||
let s:tests = filter(s:tests, 'v:val =~ argv(1)')
|
||||
endif
|
||||
|
||||
let s:indent = max(map(copy(s:tests), {_, val -> len(FriendlyName(val))}))
|
||||
|
||||
" Run the tests in random order.
|
||||
for test in Shuffle(s:tests)
|
||||
call RunTest(test)
|
||||
let s:done += 1
|
||||
|
||||
let friendly_name = FriendlyName(test)
|
||||
if len(v:errors) == 0
|
||||
call Log(Align(friendly_name, ' - ok'))
|
||||
else
|
||||
if s:errored
|
||||
let s:errors += 1
|
||||
let s:errored = 0
|
||||
else
|
||||
let s:fail += 1
|
||||
endif
|
||||
call Log(Align(friendly_name, ' - not ok'))
|
||||
|
||||
let i = 0
|
||||
for error in v:errors
|
||||
if i != 0
|
||||
call Log(Align('',' ! ----'))
|
||||
endif
|
||||
for trace in reverse(split(error, '\.\.'))
|
||||
call Log(Align('', ' ! '.trace))
|
||||
endfor
|
||||
let i += 1
|
||||
endfor
|
||||
|
||||
let v:errors = []
|
||||
endif
|
||||
endfor
|
||||
|
||||
let summary = [
|
||||
\ s:done.( s:done == 1 ? ' test' : ' tests'),
|
||||
\ s:errors.(s:errors == 1 ? ' error' : ' errors'),
|
||||
\ s:fail.( s:fail == 1 ? ' failure' : ' failures'),
|
||||
\ ]
|
||||
call Log('')
|
||||
call Log(join(summary, ', '))
|
||||
|
||||
split messages.log
|
||||
call append(line('$'), s:messages)
|
||||
write
|
||||
|
||||
qall!
|
||||
|
||||
21
.vim_runtime/sources_non_forked/vim-gitgutter/test/test
Normal file
21
.vim_runtime/sources_non_forked/vim-gitgutter/test/test
Normal file
@@ -0,0 +1,21 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
VIM="/Applications/MacVim.app/Contents/MacOS/Vim -v"
|
||||
|
||||
export VIM_GITGUTTER_TEST=1
|
||||
|
||||
$VIM -u NONE -U NONE -N \
|
||||
--cmd 'set rtp+=../' \
|
||||
--cmd 'let g:gitgutter_async=0' \
|
||||
--cmd 'source ../plugin/gitgutter.vim' \
|
||||
-S runner.vim \
|
||||
test_*.vim \
|
||||
"$@"
|
||||
|
||||
cat messages.log
|
||||
|
||||
grep -q "0 errors, 0 failures" messages.log
|
||||
status=$?
|
||||
rm messages.log
|
||||
exit $status
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user