Skip to content

Commit 349edc9

Browse files
committed
Added support for gVim themes that don't specify a hi Normal guibg color
1 parent 6bbbc61 commit 349edc9

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

autoload/indent_guides.vim

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -82,22 +82,21 @@ function! indent_guides#highlight_colors()
8282
if has('gui_running')
8383
call indent_guides#gui_highlight_colors()
8484
else
85-
call indent_guides#cterm_highlight_colors()
85+
call indent_guides#basic_highlight_colors()
8686
endif
8787
endif
8888
endfunction
8989

9090
"
91-
" Defines the indent highlight colors for terminal vim.
91+
" Defines some basic indent highlight colors that work for Terminal Vim and
92+
" gVim when colors can't be automatically calculated.
9293
"
93-
" NOTE: This function contains no magic at the moment, it will simply use some
94-
" light or dark preset colors depending on the `set background=` value.
95-
"
96-
function! indent_guides#cterm_highlight_colors()
97-
let l:colors = (&g:background == 'dark') ? ['darkgrey', 'black'] : ['lightgrey', 'white']
94+
function! indent_guides#basic_highlight_colors()
95+
let l:cterm_colors = (&g:background == 'dark') ? ['darkgrey', 'black'] : ['lightgrey', 'white']
96+
let l:gui_colors = (&g:background == 'dark') ? ['grey15', 'grey30'] : ['grey70', 'grey85']
9897

99-
exe 'hi IndentGuidesEven ctermbg=' . l:colors[0]
100-
exe 'hi IndentGuidesOdd ctermbg=' . l:colors[1]
98+
exe 'hi IndentGuidesEven guibg=' . l:gui_colors[0] . ' ctermbg=' . l:cterm_colors[0]
99+
exe 'hi IndentGuidesOdd guibg=' . l:gui_colors[1] . ' ctermbg=' . l:cterm_colors[1]
101100
endfunction
102101

103102
"
@@ -116,6 +115,10 @@ function! indent_guides#gui_highlight_colors()
116115
" color name is being used, eg. 'white'
117116
let l:color_name = matchstr(s:hi_normal, s:color_name_bg_pat)
118117
let l:hi_normal_guibg = color_helper#color_name_to_hex(l:color_name)
118+
119+
else
120+
" background color could not be extracted, default to basic colors
121+
call indent_guides#basic_highlight_colors()
119122
endif
120123

121124
if l:hi_normal_guibg =~ s:color_hex_pat

0 commit comments

Comments
 (0)