mirror of
https://github.com/preservim/vim-indent-guides.git
synced 2025-11-10 10:53:47 -05:00
Added support for gVim themes that don't specify a hi Normal guibg color
This commit is contained in:
@@ -82,22 +82,21 @@ function! indent_guides#highlight_colors()
|
|||||||
if has('gui_running')
|
if has('gui_running')
|
||||||
call indent_guides#gui_highlight_colors()
|
call indent_guides#gui_highlight_colors()
|
||||||
else
|
else
|
||||||
call indent_guides#cterm_highlight_colors()
|
call indent_guides#basic_highlight_colors()
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"
|
"
|
||||||
" Defines the indent highlight colors for terminal vim.
|
" Defines some basic indent highlight colors that work for Terminal Vim and
|
||||||
|
" gVim when colors can't be automatically calculated.
|
||||||
"
|
"
|
||||||
" NOTE: This function contains no magic at the moment, it will simply use some
|
function! indent_guides#basic_highlight_colors()
|
||||||
" light or dark preset colors depending on the `set background=` value.
|
let l:cterm_colors = (&g:background == 'dark') ? ['darkgrey', 'black'] : ['lightgrey', 'white']
|
||||||
"
|
let l:gui_colors = (&g:background == 'dark') ? ['grey15', 'grey30'] : ['grey70', 'grey85']
|
||||||
function! indent_guides#cterm_highlight_colors()
|
|
||||||
let l:colors = (&g:background == 'dark') ? ['darkgrey', 'black'] : ['lightgrey', 'white']
|
|
||||||
|
|
||||||
exe 'hi IndentGuidesEven ctermbg=' . l:colors[0]
|
exe 'hi IndentGuidesEven guibg=' . l:gui_colors[0] . ' ctermbg=' . l:cterm_colors[0]
|
||||||
exe 'hi IndentGuidesOdd ctermbg=' . l:colors[1]
|
exe 'hi IndentGuidesOdd guibg=' . l:gui_colors[1] . ' ctermbg=' . l:cterm_colors[1]
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"
|
"
|
||||||
@@ -116,6 +115,10 @@ function! indent_guides#gui_highlight_colors()
|
|||||||
" color name is being used, eg. 'white'
|
" color name is being used, eg. 'white'
|
||||||
let l:color_name = matchstr(s:hi_normal, s:color_name_bg_pat)
|
let l:color_name = matchstr(s:hi_normal, s:color_name_bg_pat)
|
||||||
let l:hi_normal_guibg = color_helper#color_name_to_hex(l:color_name)
|
let l:hi_normal_guibg = color_helper#color_name_to_hex(l:color_name)
|
||||||
|
|
||||||
|
else
|
||||||
|
" background color could not be extracted, default to basic colors
|
||||||
|
call indent_guides#basic_highlight_colors()
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if l:hi_normal_guibg =~ s:color_hex_pat
|
if l:hi_normal_guibg =~ s:color_hex_pat
|
||||||
|
|||||||
Reference in New Issue
Block a user