airblade/vim-gitgutter

Append key to g:gitgutter_floating_window_options

astier opened this issue · 3 comments

astier commented

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

edb607c

What vim/nvim version are you on?

NVIM v0.8.3

I want to modify the border of the floating window. Preferably I would simply append it to the default config like that:

let g:gitgutter_floating_window_options['border'] = 'single'

This doesn't seem to work. I solve it by redefining all keys like described in the gitgutter-documentation:

let g:gitgutter_floating_window_options = {
\ 'border': 'single',
\ 'relative': 'cursor',
\ 'row': 1,
\ 'col': 0,
\ 'width': 42,
\ 'height': &previewheight,
\ 'style': 'minimal',
\}

Is it somehow possible append keys to g:gitgutter_floating_window_options so I don't have to touch the default values and make it a little bit shorter? Thank you.

You're right, that would be much nicer.

I'll update the code when I can.

The trick here is knowing the order in which your config and plugins are loaded. Your config is read first and then the plugins. So when Vim processes your vimrc, the variable g:gitgutter_floating_window_options doesn't exist – this is why you cannot set a key/value on it.

Happily vim has a solution for this problem. After it loads plugins, it reads any config in an after/ directory. So if you create a file such as ~/.vim/after/vim-gitgutter/overrides.vim with this content:

let g:gitgutter_floating_window_options['border'] = 'single'

– you'll get the result you want.

astier commented

That's awesome. Somehow I didn't think of it especially since I already have a ~/.vim/after/plugin/gitgutter.vim to override some other things. Thank you!