Add a check to ensure the fg attribute exists

before setting the value
This commit is contained in:
Akin Sowemimo
2020-10-10 10:54:05 +01:00
committed by Thomas Vigouroux
parent 1e43c0267f
commit c817b62ae4

View File

@@ -11,7 +11,17 @@ let g:loaded_nvim_treesitter = 1
lua require'nvim-treesitter'.setup()
highlight default TSNone term=NONE cterm=NONE gui=NONE guifg=foreground ctermfg=fg
function s:has_attr(attr)
return strlen(synIDattr(hlID('Normal'), a:attr)) > 0
endfunction
" if the ctermfg or guifg is not known by nvim then using the
" fg or foreground highlighting value will cause an E419 error
if s:has_attr('fg')
highlight default TSNone term=NONE cterm=NONE gui=NONE guifg=foreground ctermfg=fg
else
highlight default TSNone term=NONE cterm=NONE gui=NONE
endif
highlight default link TSError TSNone