airblade / vim-gitgutter

A Vim plugin which shows git diff markers in the sign column and stages/previews/undoes hunks and partial hunks.
MIT License
8.37k stars 297 forks source link

Gutter turns opaque when reloading vimrc #596

Closed chaimleib closed 5 years ago

chaimleib commented 5 years ago

What is the latest commit SHA in your installed vim-gitgutter?

7eeea63

What vim/nvim version are you on?

nvim v0.3.4 vim v8.0 vim v8.1

If no signs are showing at all, what does :echo b:gitgutter.path give?

Signs are showing, but .config/nvim/init.vim

If no signs are showing at all, and the path value is a path and not -2, does it work with let g:gitgutter_grep=''?

Not applicable, but no

To reproduce

  1. Use this init.vim:
    
    set nocompatible

call plug#begin('~/.config/nvim/plugged') Plug 'airblade/vim-gitgutter' call plug#end()

autocmd! bufwritepost init.vim source ~/.config/nvim/init.vim colorscheme default "or any colorscheme


Or, this .vimrc:
```vim
set nocompatible

call plug#begin('~/.vim/plugged')
  Plug 'airblade/vim-gitgutter'
call plug#end()

autocmd! bufwritepost .vimrc source ~/.vimrc
colorscheme default  "or any colorscheme
  1. Open the rc file in (n)vim, and run :w.

What happens

A grey bar appears in the gutter wherever there isn't a mark.

Expected

No changes to the UI. The gutter should remain transparent.

chaimleib commented 5 years ago

I also tried these to remove vim-plug from the equation, and I still reproduced it:

nvim:

set nocompatible
set rtp+=~/.vim/bundle/vim-gitgutter

autocmd! bufwritepost init.vim source ~/.config/nvim/init.vim
colorscheme default  "or any colorscheme

vim:

set nocompatible
set rtp+=~/.vim/bundle/vim-gitgutter

autocmd! bufwritepost .vimrc source ~/.vimrc
colorscheme default  "or any colorscheme
airblade commented 5 years ago

I can't reproduce this on vim 8.1. Also with the minimal vimrc my Vim can't find the colorscheme default.

What does :au ColorScheme give you?

chaimleib commented 5 years ago

nvim:

:au ColorScheme
--- Autocommands ---
gitgutter  ColorScheme
    *         call gitgutter#highlight#define_sign_column_highlight() | call gitgutter#highlight#def
ine_highlights()

vim 8.1:

:au ColorScheme
--- Autocommands ---
gitgutter  ColorScheme
    *         call gitgutter#highlight#define_sign_column_highlight() | call gitgutter#highlight#def
ine_highlights()

It doesn't change after :w.

chaimleib commented 5 years ago

I found this in the help:

   :colo[rscheme]          Output the name of the currently active color scheme.
                           This is basically the same as
                                   :echo g:colors_name
                           In case g:colors_name has not been defined :colo will
                           output "default".  When compiled without the +eval
                           feature it will output "unknown".

   :colo[rscheme] {name}   Load color scheme {name}.  This searches 'runtimepath'
                           for the file "colors/{name}.vim".  The first one that
                           is found is loaded.
                           Also searches all plugins in 'packpath', first below
                           "start" and then under "opt".

The default vim from brew is compiled with +eval.

I checked the runtimepath and packpath, too.

vim 8.1:

:colo
default
:set runtimepath?
  runtimepath=~/.vim,/usr/local/share/vim/vimfiles,/usr/local/share/vim/vim81,/usr/local/share/vim/v
imfiles/after,~/.vim/after,~/.vim/bundle/vim-gitgutter
:set packpath?
  packpath=~/.vim,/usr/local/share/vim/vimfiles,/usr/local/share/vim/vim81,/usr/local/share/vim/vimf
iles/after,~/.vim/after

nvim:

:colo
default
:set runtimepath?
  runtimepath=~/.config/nvim,/etc/xdg/nvim,~/.local/share/nvim/site,/usr/local/share/nvim/site,/usr/
share/nvim/site,/usr/local/Cellar/neovim/0.3.4/share/nvim/runtime,/usr/share/nvim/site/after,/usr/lo
cal/share/nvim/site/after,~/.local/share/nvim/site/after,/etc/xdg/nvim/after,~/.config/nvim/after,~/
.vim/bundle/vim-gitgutter
:set packpath?
  packpath=~/.config/nvim,/etc/xdg/nvim,~/.local/share/nvim/site,/usr/local/share/nvim/site,/usr/sha
re/nvim/site,/usr/local/Cellar/neovim/0.3.4/share/nvim/runtime,/usr/share/nvim/site/after,/usr/local
/share/nvim/site/after,~/.local/share/nvim/site/after,/etc/xdg/nvim/after,~/.config/nvim/after

These also don't change after :w.

chaimleib commented 5 years ago

I did an ls on all the runtimepaths. This is a superset of everything in the packpath.

vim 8.1:

$ ls ~/.vim,/usr/local/share/vim/vimfiles
ls: /Users/chalbert/.vim,/usr/local/share/vim/vimfiles: No such file or directory
$ ls /usr/local/share/vim/vim81
autoload           evim.vim           indent             mswin.vim          spell
bugreport.vim      filetype.vim       indent.vim         optwin.vim         synmenu.vim
colors             ftoff.vim          indoff.vim         pack               syntax
compiler           ftplugin           keymap             plugin             tools
defaults.vim       ftplugin.vim       lang               print              tutor
delmenu.vim        ftplugof.vim       macros             rgb.txt            vimrc_example.vim
doc                gvimrc_example.vim menu.vim           scripts.vim
$ ls /usr/local/share/vim/vim81/colors  # not in rtp, but interesting
README.txt    default.vim   elflord.vim   koehler.vim   pablo.vim     shine.vim     torte.vim
blue.vim      delek.vim     evening.vim   morning.vim   peachpuff.vim slate.vim     zellner.vim
darkblue.vim  desert.vim    industry.vim  murphy.vim    ron.vim       tools
$ ls /usr/local/share/vim/vimfiles/after
ls: /usr/local/share/vim/vimfiles/after: No such file or directory
$ ls ~/.vim/after
ls: /Users/chalbert/.vim/after: No such file or directory
$ ls ~/.vim/bundle/vim-gitgutter
LICENCE        autoload       plugin         test
README.mkd     doc            screenshot.png unplace.vim

nvim:

$ ls /Users/chalbert/.config/nvim
autoload init.vim plugged
$ ls /etc/xdg/nvim
ls: /etc/xdg/nvim: No such file or directory
$ ls /Users/chalbert/.local/share/nvim/site
ls: /Users/chalbert/.local/share/nvim/site: No such file or directory
$ ls /usr/local/share/nvim/site
ls: /usr/local/share/nvim/site: No such file or directory
$ ls /usr/share/nvim/site
ls: /usr/share/nvim/site: No such file or directory
$ ls /usr/local/Cellar/neovim/0.3.4/share/nvim/runtime
autoload      doc           ftplugof.vim  lua           mswin.vim     rgb.txt       tools
bugreport.vim filetype.vim  indent        macmap.vim    optwin.vim    scripts.vim   tutor
colors        ftoff.vim     indent.vim    macros        pack          spell
compiler      ftplugin      indoff.vim    makemenu.vim  plugin        synmenu.vim
delmenu.vim   ftplugin.vim  keymap        menu.vim      print         syntax
$ ls /usr/local/Cellar/neovim/0.3.4/share/nvim/runtime/colors  # not in rtp, but interesting
blue.vim      delek.vim     evening.vim   morning.vim   peachpuff.vim slate.vim
darkblue.vim  desert.vim    industry.vim  murphy.vim    ron.vim       torte.vim
default.vim   elflord.vim   koehler.vim   pablo.vim     shine.vim     zellner.vim
$ ls /usr/share/nvim/site/after
ls: /usr/share/nvim/site/after: No such file or directory
$ ls /usr/local/share/nvim/site/after
ls: /usr/local/share/nvim/site/after: No such file or directory
$ ls /Users/chalbert/.local/share/nvim/site/after
ls: /Users/chalbert/.local/share/nvim/site/after: No such file or directory
$ ls /etc/xdg/nvim/after
ls: /etc/xdg/nvim/after: No such file or directory
$ ls /Users/chalbert/.config/nvim/after
ls: /Users/chalbert/.config/nvim/after: No such file or directory
$ ls /Users/chalbert/.vim/bundle/vim-gitgutter
LICENCE        autoload       plugin         test
README.mkd     doc            screenshot.png unplace.vim
airblade commented 5 years ago

You didn't explicitly say this but I assume the problem only occurs when you're editing your init.vim / vimrc?

Does it still occur if you remove the colorscheme default line?

chaimleib commented 5 years ago

Yes, I have to be in that buffer, writing the init.vim/.vimrc file. I don't need to change anything, just to save it again. That's enough to trigger bufwritepost.

If I remove the colorscheme line, there are no gutter glitches when I save.

airblade commented 5 years ago

The colorscheme line loads your default colorscheme, which presumably resets all the highlight groups. Then vim-gitgutter's ColorScheme autocommand fires and sets up gitgutter's highlights and colours.

I don't know why it's glitching for you. I still can't reproduce the problem.

plexigras commented 5 years ago

can reproduce in neovim but not in vim by doing nvim -u example.vim

" contents of example.vim
set rtp+=~/.vim/bundle/vim-gitgutter
set signcolumn=yes
plexigras commented 5 years ago

i don't know why but this fixes it

let g:gitgutter_override_sign_column_highlight = 0
chaimleib commented 5 years ago

I can no longer reproduce the issue.