From c817b62ae4f98e7ef326f6c2277520ff323f6785 Mon Sep 17 00:00:00 2001 From: Akin Sowemimo Date: Sat, 10 Oct 2020 10:54:05 +0100 Subject: Add a check to ensure the fg attribute exists before setting the value --- plugin/nvim-treesitter.vim | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'plugin') diff --git a/plugin/nvim-treesitter.vim b/plugin/nvim-treesitter.vim index f88592f1f..38202be35 100644 --- a/plugin/nvim-treesitter.vim +++ b/plugin/nvim-treesitter.vim @@ -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 -- cgit v1.2.3-70-g09d2