Skip to content

Commit

Permalink
Properly figure out (n)vim's color mode
Browse files Browse the repository at this point in the history
  • Loading branch information
adolenc committed Feb 15, 2017
1 parent adebc6c commit 332daf3
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions plugin/interestingwords.vim
Original file line number Diff line number Diff line change
Expand Up @@ -190,20 +190,22 @@ function! s:markRecentlyUsed(n)
call add(s:recentlyUsed, a:n)
endfunction

function! s:uiMode()
" Stolen from airline's airline#init#gui_mode()
return ((has('nvim') && exists('$NVIM_TUI_ENABLE_TRUE_COLOR') && !exists("+termguicolors"))
\ || has('gui_running') || (has("termtruecolor") && &guicolors == 1) || (has("termguicolors") && &termguicolors == 1)) ?
\ 'gui' : 'cterm'
endfunction

" initialise highlight colors from list of GUIColors
" initialise length of s:interestingWord list
" initialise s:recentlyUsed list
function! s:buildColors()
if (s:hasBuiltColors)
return
endif
if has('gui_running')
let ui = 'gui'
let wordColors = g:interestingWordsGUIColors
else
let ui = 'cterm'
let wordColors = g:interestingWordsTermColors
endif
let ui = s:uiMode()
let wordColors = (ui == 'gui') ? g:interestingWordsGUIColors : g:interestingWordsTermColors
if (exists('g:interestingWordsRandomiseColors') && g:interestingWordsRandomiseColors)
" fisher-yates shuffle
let i = len(wordColors)-1
Expand Down

0 comments on commit 332daf3

Please sign in to comment.