mirror of
https://github.com/airblade/vim-gitgutter.git
synced 2025-11-08 11:33:48 -05:00
Combine Diff* foreground colours with SignColumn's background.
For default sign colours. It seems the Diff* highlight groups are generally designed for line highlighting so they have background colours which differ from the main background colour. While desirable for line highlights, this isn't what we want for the signs.
This commit is contained in:
@@ -45,14 +45,19 @@ function! gitgutter#highlight#define_highlights() abort
|
|||||||
|
|
||||||
" Highlights used by the signs.
|
" Highlights used by the signs.
|
||||||
|
|
||||||
|
" When they are invisible.
|
||||||
execute "highlight GitGutterAddInvisible guifg=bg guibg=" . guibg . " ctermfg=" . ctermbg . " ctermbg=" . ctermbg
|
execute "highlight GitGutterAddInvisible guifg=bg guibg=" . guibg . " ctermfg=" . ctermbg . " ctermbg=" . ctermbg
|
||||||
execute "highlight GitGutterChangeInvisible guifg=bg guibg=" . guibg . " ctermfg=" . ctermbg . " ctermbg=" . ctermbg
|
execute "highlight GitGutterChangeInvisible guifg=bg guibg=" . guibg . " ctermfg=" . ctermbg . " ctermbg=" . ctermbg
|
||||||
execute "highlight GitGutterDeleteInvisible guifg=bg guibg=" . guibg . " ctermfg=" . ctermbg . " ctermbg=" . ctermbg
|
execute "highlight GitGutterDeleteInvisible guifg=bg guibg=" . guibg . " ctermfg=" . ctermbg . " ctermbg=" . ctermbg
|
||||||
highlight default link GitGutterChangeDeleteInvisible GitGutterChangeInvisible
|
highlight default link GitGutterChangeDeleteInvisible GitGutterChangeInvisible
|
||||||
|
|
||||||
highlight default link GitGutterAdd DiffAdd
|
" When they are visible.
|
||||||
highlight default link GitGutterChange DiffChange
|
" By default use Diff* foreground colors with SignColumn's background.
|
||||||
highlight default link GitGutterDelete DiffDelete
|
for type in ['Add', 'Change', 'Delete']
|
||||||
|
let [guifg, ctermfg] = s:get_foreground_colors('Diff'.type)
|
||||||
|
execute "highlight GitGutter".type."Default guifg=".guifg." guibg=".guibg." ctermfg=".ctermfg." ctermbg=".ctermbg
|
||||||
|
execute "highlight default link GitGutter".type." GitGutter".type."Default"
|
||||||
|
endfor
|
||||||
highlight default link GitGutterChangeDelete GitGutterChange
|
highlight default link GitGutterChangeDelete GitGutterChange
|
||||||
|
|
||||||
" Highlights used for the whole line.
|
" Highlights used for the whole line.
|
||||||
@@ -126,6 +131,21 @@ function! s:define_sign_line_highlights() abort
|
|||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! s:get_foreground_colors(group) abort
|
||||||
|
redir => highlight
|
||||||
|
silent execute 'silent highlight ' . a:group
|
||||||
|
redir END
|
||||||
|
|
||||||
|
let link_matches = matchlist(highlight, 'links to \(\S\+\)')
|
||||||
|
if len(link_matches) > 0 " follow the link
|
||||||
|
return s:get_foreground_colors(link_matches[1])
|
||||||
|
endif
|
||||||
|
|
||||||
|
let ctermfg = s:match_highlight(highlight, 'ctermfg=\([0-9A-Za-z]\+\)')
|
||||||
|
let guifg = s:match_highlight(highlight, 'guifg=\([#0-9A-Za-z]\+\)')
|
||||||
|
return [guifg, ctermfg]
|
||||||
|
endfunction
|
||||||
|
|
||||||
function! s:get_background_colors(group) abort
|
function! s:get_background_colors(group) abort
|
||||||
redir => highlight
|
redir => highlight
|
||||||
silent execute 'silent highlight ' . a:group
|
silent execute 'silent highlight ' . a:group
|
||||||
|
|||||||
Reference in New Issue
Block a user