diff options
| author | Akin Sowemimo <akin.sowemimo@gmail.com> | 2020-10-11 15:08:40 +0100 |
|---|---|---|
| committer | Thomas Vigouroux <tomvig38@gmail.com> | 2020-10-11 19:26:37 +0200 |
| commit | 19c9465a8c33d1362550b2c4385f594213848912 (patch) | |
| tree | 2282c109903032606a4d8ee2d2cddb43d60a88f9 | |
| parent | Add a check to ensure the fg attribute exists (diff) | |
| download | nvim-treesitter-19c9465a8c33d1362550b2c4385f594213848912.tar nvim-treesitter-19c9465a8c33d1362550b2c4385f594213848912.tar.gz nvim-treesitter-19c9465a8c33d1362550b2c4385f594213848912.tar.bz2 nvim-treesitter-19c9465a8c33d1362550b2c4385f594213848912.tar.lz nvim-treesitter-19c9465a8c33d1362550b2c4385f594213848912.tar.xz nvim-treesitter-19c9465a8c33d1362550b2c4385f594213848912.tar.zst nvim-treesitter-19c9465a8c33d1362550b2c4385f594213848912.zip | |
Explicitly check for cterm and gui values for fg
If a user hasn't set either we default to NONE
| -rw-r--r-- | plugin/nvim-treesitter.vim | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/plugin/nvim-treesitter.vim b/plugin/nvim-treesitter.vim index 38202be35..b32d1726e 100644 --- a/plugin/nvim-treesitter.vim +++ b/plugin/nvim-treesitter.vim @@ -11,17 +11,18 @@ let g:loaded_nvim_treesitter = 1 lua require'nvim-treesitter'.setup() -function s:has_attr(attr) - return strlen(synIDattr(hlID('Normal'), a:attr)) > 0 +function s:has_attr(attr, mode) + let norm_color = synIDattr(hlID('Normal'), a:attr, a:mode) + return strlen(norm_color) > 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 +" so we check to see if either highlight has been set if not default to NONE +let cterm_normal = s:has_attr('fg', 'cterm') ? 'fg' : 'NONE' +let gui_normal = s:has_attr('fg', 'gui') ? 'foreground' : 'NONE' + +execute 'highlight default TSNone term=NONE cterm=NONE gui=NONE guifg='.gui_normal.' ctermfg='.cterm_normal highlight default link TSError TSNone |
