mirror of
https://github.com/amix/vimrc
synced 2025-06-29 02:55:01 +08:00
Updated plugins
This commit is contained in:
@ -162,7 +162,17 @@ 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.
|
||||
When you jump between hunks, a message like `Hunk 4 of 11` is shown on the command line. If you want to turn the message off, you can use:
|
||||
|
||||
```viml
|
||||
let g:gitgutter_show_msg_on_hunk_jumping = 0
|
||||
```
|
||||
|
||||
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. Use `:copen` (or `:lopen`) to open the quickfix / location list or add a custom command like this:
|
||||
|
||||
```viml
|
||||
command! Gqf GitGutterQuickFix | copen
|
||||
```
|
||||
|
||||
You can stage or undo an individual hunk when your cursor is in it:
|
||||
|
||||
@ -339,6 +349,7 @@ 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_removed_above_and_below = '{'
|
||||
let g:gitgutter_sign_modified_removed = 'ww'
|
||||
```
|
||||
|
||||
@ -648,7 +659,10 @@ Here are some things you can check:
|
||||
* 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.
|
||||
* Verify your file is being tracked by git and has unstaged changes. Check whether the plugin thinks git knows about your file: `:echo b:gitgutter.path` should show the path to the file in the repo.
|
||||
* Execute `:sign place group=gitgutter`; you should see a list of signs.
|
||||
- If the signs are listed: this is a colorscheme / highlight problem. Compare `:highlight GitGutterAdd` with `:highlight SignColumn`.
|
||||
- If no signs are listed: the call to git-diff is probably failing. Add `let g:gitgutter_log=1` to your vimrc, restart, reproduce the problem, and look at the `gitgutter.log` file in the plugin's directory.
|
||||
|
||||
#### When the whole file is marked as added
|
||||
|
||||
|
@ -180,9 +180,17 @@ endfunction
|
||||
" - it ignores unsaved changes in buffers
|
||||
" - it does not change to the repo root
|
||||
function! gitgutter#quickfix()
|
||||
let cmd = g:gitgutter_git_executable.' '.g:gitgutter_git_args.' rev-parse --show-cdup'
|
||||
let path_to_repo = get(systemlist(cmd), 0, '')
|
||||
if !empty(path_to_repo) && path_to_repo[-1:] != '/'
|
||||
let path_to_repo .= '/'
|
||||
endif
|
||||
|
||||
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 cmd = g:gitgutter_git_executable.' '.g:gitgutter_git_args.' --no-pager'.
|
||||
\ ' diff --no-ext-diff --no-color -U0'.
|
||||
\ ' --src-prefix=a/'.path_to_repo.' --dst-prefix=b/'.path_to_repo.' '.
|
||||
\ g:gitgutter_diff_args. ' '. g:gitgutter_diff_base
|
||||
let diff = systemlist(cmd)
|
||||
let lnum = 0
|
||||
for line in diff
|
||||
|
@ -6,6 +6,8 @@ let s:available = has('nvim') || (
|
||||
\ )
|
||||
\ )
|
||||
|
||||
let s:jobs = {}
|
||||
|
||||
function! gitgutter#async#available()
|
||||
return s:available
|
||||
endfunction
|
||||
@ -28,11 +30,12 @@ function! gitgutter#async#execute(cmd, bufnr, handler) abort
|
||||
\ 'on_exit': function('s:on_exit_nvim')
|
||||
\ }))
|
||||
else
|
||||
call job_start(command, {
|
||||
let job = job_start(command, {
|
||||
\ 'out_cb': function('s:on_stdout_vim', options),
|
||||
\ 'err_cb': function('s:on_stderr_vim', options),
|
||||
\ 'close_cb': function('s:on_exit_vim', options)
|
||||
\ })
|
||||
let s:jobs[s:job_id(job)] = 1
|
||||
endif
|
||||
endfunction
|
||||
|
||||
@ -83,6 +86,8 @@ endfunction
|
||||
|
||||
function! s:on_exit_vim(channel) dict abort
|
||||
let job = ch_getjob(a:channel)
|
||||
let jobid = s:job_id(job)
|
||||
if has_key(s:jobs, jobid) | unlet s:jobs[jobid] | endif
|
||||
while 1
|
||||
if job_status(job) == 'dead'
|
||||
let exit_code = job_info(job).exitval
|
||||
@ -95,3 +100,8 @@ function! s:on_exit_vim(channel) dict abort
|
||||
call self.handler.out(self.buffer, join(self.stdoutbuffer, "\n"))
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:job_id(job)
|
||||
" Vim
|
||||
return job_info(a:job).process
|
||||
endfunction
|
||||
|
@ -22,16 +22,6 @@ function! gitgutter#debug#debug()
|
||||
call s:separator()
|
||||
|
||||
call s:option('updatetime')
|
||||
call s:option('shell')
|
||||
call s:option('shellcmdflag')
|
||||
call s:option('shellpipe')
|
||||
call s:option('shellquote')
|
||||
call s:option('shellredir')
|
||||
call s:option('shellslash')
|
||||
call s:option('shelltemp')
|
||||
call s:option('shelltype')
|
||||
call s:option('shellxescape')
|
||||
call s:option('shellxquote')
|
||||
endfunction
|
||||
|
||||
|
||||
@ -52,10 +42,10 @@ function! s:git_version()
|
||||
endfunction
|
||||
|
||||
function! s:grep_version()
|
||||
let v = system('grep --version')
|
||||
let v = system(g:gitgutter_grep.' --version')
|
||||
call s:output( substitute(v, '\n$', '', '') )
|
||||
|
||||
let v = system('grep --help')
|
||||
let v = system(g:gitgutter_grep.' --help')
|
||||
call s:output( substitute(v, '\%x00', '', 'g') )
|
||||
endfunction
|
||||
|
||||
|
@ -12,6 +12,8 @@ endfunction
|
||||
|
||||
let s:c_flag = s:git_supports_command_line_config_override()
|
||||
|
||||
let s:temp_from = tempname()
|
||||
let s:temp_buffer = tempname()
|
||||
let s:counter = 0
|
||||
|
||||
" Returns a diff of the buffer against the index or the working tree.
|
||||
@ -75,9 +77,6 @@ function! gitgutter#diff#run_diff(bufnr, from, preserve_full_diff) abort
|
||||
throw 'gitgutter not tracked'
|
||||
endif
|
||||
|
||||
let temp_from = tempname()
|
||||
let temp_buffer = tempname()
|
||||
|
||||
" Wrap compound commands in parentheses to make Windows happy.
|
||||
" bash doesn't mind the parentheses.
|
||||
let cmd = '('
|
||||
@ -90,7 +89,7 @@ function! gitgutter#diff#run_diff(bufnr, from, preserve_full_diff) abort
|
||||
" second gitgutter#process_buffer() writing the file (synchronously, below)
|
||||
" and the first gitgutter#process_buffer()'s async job reading it (with
|
||||
" git-diff).
|
||||
let buff_file = temp_buffer.'.'.a:bufnr
|
||||
let buff_file = s:temp_buffer.'.'.a:bufnr
|
||||
|
||||
" Add a counter to avoid a similar race with two quick writes of the same buffer.
|
||||
" Use a modulus greater than a maximum reasonable number of visible buffers.
|
||||
@ -110,7 +109,7 @@ function! gitgutter#diff#run_diff(bufnr, from, preserve_full_diff) abort
|
||||
" Without the buffer number, from_file would have a race in the shell
|
||||
" between the second process writing it (with git-show) and the first
|
||||
" reading it (with git-diff).
|
||||
let from_file = temp_from.'.'.a:bufnr
|
||||
let from_file = s:temp_from.'.'.a:bufnr
|
||||
|
||||
" Add a counter to avoid a similar race with two quick writes of the same buffer.
|
||||
let from_file .= '.'.s:counter
|
||||
@ -128,7 +127,7 @@ function! gitgutter#diff#run_diff(bufnr, from, preserve_full_diff) abort
|
||||
endif
|
||||
|
||||
" Call git-diff.
|
||||
let cmd .= g:gitgutter_git_executable.' '.g:gitgutter_git_args.' --no-pager '.g:gitgutter_git_args
|
||||
let cmd .= g:gitgutter_git_executable.' '.g:gitgutter_git_args.' --no-pager'
|
||||
if s:c_flag
|
||||
let cmd .= ' -c "diff.autorefreshindex=0"'
|
||||
let cmd .= ' -c "diff.noprefix=false"'
|
||||
@ -400,7 +399,16 @@ function! s:write_buffer(bufnr, file)
|
||||
let bufcontents[0]=''.bufcontents[0]
|
||||
endif
|
||||
|
||||
call writefile(bufcontents, a:file, 'b')
|
||||
" The file we are writing to is a temporary file. Sometimes the parent
|
||||
" directory is deleted outside Vim but, because Vim caches the directory
|
||||
" name at startup and does not check for its existence subsequently, Vim
|
||||
" does not realise. This causes E482 errors.
|
||||
try
|
||||
call writefile(bufcontents, a:file, 'b')
|
||||
catch /E482/
|
||||
call mkdir(fnamemodify(a:file, ':h'), '', '0700')
|
||||
call writefile(bufcontents, a:file, 'b')
|
||||
endtry
|
||||
endfunction
|
||||
|
||||
|
||||
|
@ -77,7 +77,7 @@ function! gitgutter#highlight#define_highlights() abort
|
||||
|
||||
" When they are visible.
|
||||
for type in ["Add", "Change", "Delete"]
|
||||
if hlexists("GitGutter".type)
|
||||
if hlexists("GitGutter".type) && s:get_foreground_colors("GitGutter".type) != ['NONE', 'NONE']
|
||||
if g:gitgutter_set_sign_backgrounds
|
||||
execute "highlight GitGutter".type." guibg=".guibg." ctermbg=".ctermbg
|
||||
endif
|
||||
|
@ -46,39 +46,57 @@ endfunction
|
||||
|
||||
function! gitgutter#hunk#next_hunk(count) abort
|
||||
let bufnr = bufnr('')
|
||||
if gitgutter#utility#is_active(bufnr)
|
||||
let current_line = line('.')
|
||||
let hunk_count = 0
|
||||
for hunk in gitgutter#hunk#hunks(bufnr)
|
||||
if hunk[2] > current_line
|
||||
let hunk_count += 1
|
||||
if hunk_count == a:count
|
||||
execute 'normal!' hunk[2] . 'Gzv'
|
||||
return
|
||||
endif
|
||||
endif
|
||||
endfor
|
||||
call gitgutter#utility#warn('No more hunks')
|
||||
if !gitgutter#utility#is_active(bufnr) | return | endif
|
||||
|
||||
let hunks = gitgutter#hunk#hunks(bufnr)
|
||||
if empty(hunks)
|
||||
call gitgutter#utility#warn('No hunks in file')
|
||||
return
|
||||
endif
|
||||
|
||||
let current_line = line('.')
|
||||
let hunk_count = 0
|
||||
for hunk in hunks
|
||||
if hunk[2] > current_line
|
||||
let hunk_count += 1
|
||||
if hunk_count == a:count
|
||||
execute 'normal!' hunk[2] . 'Gzv'
|
||||
if g:gitgutter_show_msg_on_hunk_jumping
|
||||
redraw | echo printf('Hunk %d of %d', index(hunks, hunk) + 1, len(hunks))
|
||||
endif
|
||||
return
|
||||
endif
|
||||
endif
|
||||
endfor
|
||||
call gitgutter#utility#warn('No more hunks')
|
||||
endfunction
|
||||
|
||||
function! gitgutter#hunk#prev_hunk(count) abort
|
||||
let bufnr = bufnr('')
|
||||
if gitgutter#utility#is_active(bufnr)
|
||||
let current_line = line('.')
|
||||
let hunk_count = 0
|
||||
for hunk in reverse(copy(gitgutter#hunk#hunks(bufnr)))
|
||||
if hunk[2] < current_line
|
||||
let hunk_count += 1
|
||||
if hunk_count == a:count
|
||||
let target = hunk[2] == 0 ? 1 : hunk[2]
|
||||
execute 'normal!' target . 'Gzv'
|
||||
return
|
||||
endif
|
||||
endif
|
||||
endfor
|
||||
call gitgutter#utility#warn('No previous hunks')
|
||||
if !gitgutter#utility#is_active(bufnr) | return | endif
|
||||
|
||||
let hunks = gitgutter#hunk#hunks(bufnr)
|
||||
if empty(hunks)
|
||||
call gitgutter#utility#warn('No hunks in file')
|
||||
return
|
||||
endif
|
||||
|
||||
let current_line = line('.')
|
||||
let hunk_count = 0
|
||||
for hunk in reverse(copy(hunks))
|
||||
if hunk[2] < current_line
|
||||
let hunk_count += 1
|
||||
if hunk_count == a:count
|
||||
let target = hunk[2] == 0 ? 1 : hunk[2]
|
||||
execute 'normal!' target . 'Gzv'
|
||||
if g:gitgutter_show_msg_on_hunk_jumping
|
||||
redraw | echo printf('Hunk %d of %d', index(hunks, hunk) + 1, len(hunks))
|
||||
endif
|
||||
return
|
||||
endif
|
||||
endif
|
||||
endfor
|
||||
call gitgutter#utility#warn('No previous hunks')
|
||||
endfunction
|
||||
|
||||
" Returns the hunk the cursor is currently in or an empty list if the cursor
|
||||
@ -455,6 +473,9 @@ function! s:open_hunk_preview_window()
|
||||
setlocal filetype=diff buftype=acwrite bufhidden=delete
|
||||
" Reset some defaults in case someone else has changed them.
|
||||
setlocal noreadonly modifiable noswapfile
|
||||
if g:gitgutter_close_preview_on_escape
|
||||
nnoremap <buffer> <silent> <Esc> :pclose<CR>
|
||||
endif
|
||||
endfunction
|
||||
|
||||
|
||||
|
@ -146,7 +146,13 @@ Commands for jumping between hunks:~
|
||||
: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
|
||||
populate the location list of the current window
|
||||
instead. Use |:copen| (or |:lopen|) to open a buffer
|
||||
containing the search results in linked form; or add a
|
||||
custom command like this:
|
||||
>
|
||||
command! Gqf GitGutterQuickFix | copen
|
||||
<
|
||||
|
||||
|
||||
Commands for operating on a hunk:~
|
||||
@ -308,9 +314,14 @@ Signs:~
|
||||
|g:gitgutter_sign_modified_removed|
|
||||
|g:gitgutter_set_sign_backgrounds|
|
||||
|
||||
Hunk jumping:~
|
||||
|
||||
|g:gitgutter_show_msg_on_hunk_jumping|
|
||||
|
||||
Hunk previews:~
|
||||
|
||||
|g:gitgutter_preview_win_floating|
|
||||
|g:gitgutter_close_preview_on_escape|
|
||||
|
||||
Terminal:~
|
||||
|
||||
@ -438,6 +449,7 @@ will not preserve non-gitgutter signs.
|
||||
*g:gitgutter_sign_modified*
|
||||
*g:gitgutter_sign_removed*
|
||||
*g:gitgutter_sign_removed_first_line*
|
||||
*g:gitgutter_sign_removed_above_and_below*
|
||||
*g:gitgutter_sign_modified_removed*
|
||||
Defaults:
|
||||
>
|
||||
@ -445,6 +457,7 @@ Defaults:
|
||||
let g:gitgutter_sign_modified = '~'
|
||||
let g:gitgutter_sign_removed = '_'
|
||||
let g:gitgutter_sign_removed_first_line = '‾'
|
||||
let g:gitgutter_sign_removed_above_and_below = '_¯'
|
||||
let g:gitgutter_sign_modified_removed = '~_'
|
||||
<
|
||||
You can use unicode characters but not images. Signs must not take up more than
|
||||
@ -468,6 +481,11 @@ 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_close_preview_on_escape*
|
||||
Default: 0
|
||||
|
||||
Whether pressing <Esc> in a non-floating preview window closes it.
|
||||
|
||||
*g:gitgutter_terminal_reports_focus*
|
||||
Default: 1
|
||||
|
||||
@ -516,6 +534,11 @@ Default: 0
|
||||
When switched on, the :GitGutterQuickFix command populates the location list
|
||||
of the current window instead of the global quickfix list.
|
||||
|
||||
*g:gitgutter_show_msg_on_hunk_jumping*
|
||||
Default: 1
|
||||
|
||||
When switched on, a message like "Hunk 4 of 11" is shown on hunk jumping.
|
||||
|
||||
|
||||
===============================================================================
|
||||
HIGHLIGHTS *gitgutter-highlights*
|
||||
@ -631,6 +654,22 @@ When no signs are showing at all:~
|
||||
<
|
||||
If the result is -2, the plugin thinks your file is not tracked by git.
|
||||
|
||||
6. Check whether the signs have been placed:
|
||||
>
|
||||
:sign place group=gitgutter
|
||||
<
|
||||
If you see a list of signs, this is a colorscheme / highlight problem.
|
||||
Compare these two highlight values:
|
||||
>
|
||||
:highlight GitGutterAdd
|
||||
:highlight SignColumn
|
||||
<
|
||||
If no signs are listed, the call to git-diff is probably failing. Turn on
|
||||
logging by adding the following to your vimrc, restart, reproduce the problem,
|
||||
and examing the gitgutter.log file in the plugin's directory.
|
||||
>
|
||||
let g:gitgutter_log = 1
|
||||
<
|
||||
|
||||
When the whole file is marked as added:~
|
||||
|
||||
|
@ -12,15 +12,7 @@ if v:version < 703 || (v:version == 703 && !has("patch105"))
|
||||
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
|
||||
let s:nomodeline = (v:version > 703 || (v:version == 703 && has('patch442'))) ? '<nomodeline>' : ''
|
||||
|
||||
function! s:obsolete(var)
|
||||
if exists(a:var)
|
||||
@ -29,52 +21,54 @@ function! s:obsolete(var)
|
||||
endfunction
|
||||
|
||||
|
||||
call s:set('g:gitgutter_preview_win_location', 'bo')
|
||||
let g:gitgutter_preview_win_location = get(g:, 'gitgutter_preview_win_location', 'bo')
|
||||
if exists('*nvim_open_win')
|
||||
call s:set('g:gitgutter_preview_win_floating', 1)
|
||||
let g:gitgutter_preview_win_floating = get(g:, 'gitgutter_preview_win_floating', 1)
|
||||
else
|
||||
call s:set('g:gitgutter_preview_win_floating', 0)
|
||||
let g:gitgutter_preview_win_floating = get(g:, 'gitgutter_preview_win_floating', 0)
|
||||
endif
|
||||
call s:set('g:gitgutter_enabled', 1)
|
||||
let g:gitgutter_enabled = get(g:, 'gitgutter_enabled', 1)
|
||||
if exists('*sign_unplace')
|
||||
call s:set('g:gitgutter_max_signs', -1)
|
||||
let g:gitgutter_max_signs = get(g:, 'gitgutter_max_signs', -1)
|
||||
else
|
||||
call s:set('g:gitgutter_max_signs', 500)
|
||||
let g:gitgutter_max_signs = get(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)
|
||||
let g:gitgutter_signs = get(g:, 'gitgutter_signs', 1)
|
||||
let g:gitgutter_highlight_lines = get(g:, 'gitgutter_highlight_lines', 0)
|
||||
let g:gitgutter_highlight_linenrs = get(g:, 'gitgutter_highlight_linenrs', 0)
|
||||
let g:gitgutter_sign_priority = get(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', '_')
|
||||
let g:gitgutter_sign_allow_clobber = get(g:, 'gitgutter_sign_allow_clobber', 0)
|
||||
let g:gitgutter_set_sign_backgrounds = get(g:, 'gitgutter_set_sign_backgrounds', 0)
|
||||
let g:gitgutter_sign_added = get(g:, 'gitgutter_sign_added', '+')
|
||||
let g:gitgutter_sign_modified = get(g:, 'gitgutter_sign_modified', '~')
|
||||
let g:gitgutter_sign_removed = get(g:, 'gitgutter_sign_removed', '_')
|
||||
|
||||
if gitgutter#utility#supports_overscore_sign()
|
||||
call s:set('g:gitgutter_sign_removed_first_line', '‾')
|
||||
let g:gitgutter_sign_removed_first_line = get(g:, 'gitgutter_sign_removed_first_line', '‾')
|
||||
else
|
||||
call s:set('g:gitgutter_sign_removed_first_line', '_^')
|
||||
let g:gitgutter_sign_removed_first_line = get(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)
|
||||
let g:gitgutter_sign_removed_above_and_below = get(g:, 'gitgutter_sign_removed_above_and_below', '_¯')
|
||||
let g:gitgutter_sign_modified_removed = get(g:, 'gitgutter_sign_modified_removed', '~_')
|
||||
let g:gitgutter_git_args = get(g:, 'gitgutter_git_args', '')
|
||||
let g:gitgutter_diff_relative_to = get(g:, 'gitgutter_diff_relative_to', 'index')
|
||||
let g:gitgutter_diff_args = get(g:, 'gitgutter_diff_args', '')
|
||||
let g:gitgutter_diff_base = get(g:, 'gitgutter_diff_base', '')
|
||||
let g:gitgutter_map_keys = get(g:, 'gitgutter_map_keys', 1)
|
||||
let g:gitgutter_terminal_reports_focus = get(g:, 'gitgutter_terminal_reports_focus', 1)
|
||||
let g:gitgutter_async = get(g:, 'gitgutter_async', 1)
|
||||
let g:gitgutter_log = get(g:, 'gitgutter_log', 0)
|
||||
let g:gitgutter_use_location_list = get(g:, 'gitgutter_use_location_list', 0)
|
||||
let g:gitgutter_close_preview_on_escape = get(g:, 'gitgutter_close_preview_on_escape', 0)
|
||||
let g:gitgutter_show_msg_on_hunk_jumping = get(g:, 'gitgutter_show_msg_on_hunk_jumping', 1)
|
||||
|
||||
call s:set('g:gitgutter_git_executable', 'git')
|
||||
let g:gitgutter_git_executable = get(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.')
|
||||
@ -83,7 +77,7 @@ if !executable(g:gitgutter_git_executable)
|
||||
endif
|
||||
|
||||
let default_grep = 'grep'
|
||||
call s:set('g:gitgutter_grep', default_grep)
|
||||
let g:gitgutter_grep = get(g:, 'gitgutter_grep', default_grep)
|
||||
if !empty(g:gitgutter_grep)
|
||||
if executable(split(g:gitgutter_grep)[0])
|
||||
if $GREP_OPTIONS =~# '--color=always'
|
||||
@ -225,6 +219,21 @@ nnoremap <silent> <Plug>GitGutterPreviewHunk :call gitgutter#utility#warn('ple
|
||||
function! s:on_bufenter()
|
||||
call gitgutter#setup_maps()
|
||||
|
||||
" To keep vim's start-up fast, do not process the buffer when vim is starting.
|
||||
" Instead process it a short time later. Normally we would rely on our
|
||||
" CursorHold autocommand to handle this but it turns out CursorHold is not
|
||||
" guaranteed to fire if the user has not typed anything yet; so set up a
|
||||
" timer instead. The disadvantage is that if CursorHold does fire, the
|
||||
" plugin will do a round of unnecessary work; but since there will not have
|
||||
" been any changes to the buffer since the first round, the second round
|
||||
" will be cheap.
|
||||
if has('vim_starting') && !$VIM_GITGUTTER_TEST
|
||||
if exists('*timer_start')
|
||||
call timer_start(&updatetime, 'GitGutterCursorHold')
|
||||
endif
|
||||
return
|
||||
endif
|
||||
|
||||
if exists('t:gitgutter_didtabenter') && t:gitgutter_didtabenter
|
||||
let t:gitgutter_didtabenter = 0
|
||||
call gitgutter#all(!g:gitgutter_terminal_reports_focus)
|
||||
@ -233,6 +242,10 @@ function! s:on_bufenter()
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! GitGutterCursorHold(timer)
|
||||
execute 'doautocmd' s:nomodeline 'gitgutter CursorHold'
|
||||
endfunction
|
||||
|
||||
" Autocommands {{{
|
||||
|
||||
augroup gitgutter
|
||||
@ -242,6 +255,11 @@ augroup gitgutter
|
||||
|
||||
autocmd BufEnter * call s:on_bufenter()
|
||||
|
||||
" Ensure Vim is always checking for CursorMoved to avoid CursorMoved
|
||||
" being fired at the wrong time in floating preview window on Neovim.
|
||||
" See vim/vim#2053.
|
||||
autocmd CursorMoved * execute ''
|
||||
|
||||
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)})
|
||||
@ -266,7 +284,7 @@ augroup gitgutter
|
||||
" 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 FocusGained * if s:focus_was_lost | let s:focus_was_lost = 0 | call gitgutter#all(1) | endif
|
||||
autocmd FocusLost * let s:focus_was_lost = 1
|
||||
|
||||
if exists('##VimResume')
|
||||
|
Reference in New Issue
Block a user