Add g:gitgutter_terminal_reports_focus to enable FocusGained workaround.

See #490.
This commit is contained in:
Andy Stewart
2018-02-28 15:09:36 +00:00
parent 4a66a09658
commit c39a5c240a
3 changed files with 30 additions and 6 deletions

View File

@@ -24,7 +24,7 @@ Features:
Constraints: Constraints:
* Supports git only. If you work with other version control systems, I recommend [vim-signify](https://github.com/mhinz/vim-signify). * 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, I suggest using something like [Terminus][]. * 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`.
### Screenshot ### Screenshot
@@ -506,7 +506,7 @@ Here are some things you can check:
#### When signs don't update after focusing Vim #### When signs don't update after focusing Vim
* Your terminal probably isn't reporting focus events. Try installing [Terminus][]. * Your terminal probably isn't reporting focus events. Either try installing [Terminus][] or set `let g:gitgutter_terminal_reports_focus=0`.
### Shameless Plug ### Shameless Plug

View File

@@ -252,6 +252,10 @@ Signs:~
|g:gitgutter_sign_column_always| |g:gitgutter_sign_column_always|
|g:gitgutter_override_sign_column_highlight| |g:gitgutter_override_sign_column_highlight|
Terminal:~
|g:gitgutter_terminal_reports_focus|
General:~ General:~
|g:gitgutter_enabled| |g:gitgutter_enabled|
@@ -365,6 +369,22 @@ it in your |vimrc|:
User-defined (terminal Vim) highlight SignColumn ctermbg={whatever} User-defined (terminal Vim) highlight SignColumn ctermbg={whatever}
User-defined (graphical Vim) highlight SignColumn guibg={whatever} User-defined (graphical Vim) highlight SignColumn guibg={whatever}
*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.
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* *g:gitgutter_enabled*
Default: 1 Default: 1
@@ -491,6 +511,9 @@ Try reducing 'updatetime':
When signs don't update after focusing Vim:~ When signs don't update after focusing Vim:~
Your terminal probably isn't reporting focus events. Try installing Terminus Your terminal probably isn't reporting focus events. Either try installing
(https://github.com/wincent/terminus). Terminus (https://github.com/wincent/terminus) or set:
>
let g:gitgutter_terminal_reports_focus = 0
<

View File

@@ -48,6 +48,7 @@ call s:set('g:gitgutter_sign_modified_removed', '~_')
call s:set('g:gitgutter_diff_args', '') call s:set('g:gitgutter_diff_args', '')
call s:set('g:gitgutter_diff_base', '') call s:set('g:gitgutter_diff_base', '')
call s:set('g:gitgutter_map_keys', 1) 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_async', 1)
call s:set('g:gitgutter_log', 0) call s:set('g:gitgutter_log', 0)
@@ -209,10 +210,10 @@ augroup gitgutter
autocmd BufEnter * autocmd BufEnter *
\ if exists('t:gitgutter_didtabenter') && t:gitgutter_didtabenter | \ if exists('t:gitgutter_didtabenter') && t:gitgutter_didtabenter |
\ let t:gitgutter_didtabenter = 0 | \ let t:gitgutter_didtabenter = 0 |
\ call gitgutter#all(0) | \ call gitgutter#all(!g:gitgutter_terminal_reports_focus) |
\ else | \ else |
\ call gitgutter#init_buffer(bufnr('')) | \ call gitgutter#init_buffer(bufnr('')) |
\ call gitgutter#process_buffer(bufnr(''), 0) | \ call gitgutter#process_buffer(bufnr(''), !g:gitgutter_terminal_reports_focus) |
\ endif \ endif
autocmd CursorHold,CursorHoldI * call gitgutter#process_buffer(bufnr(''), 0) autocmd CursorHold,CursorHoldI * call gitgutter#process_buffer(bufnr(''), 0)