Skip to content

Missing "BG" color for cdeckInvisible highlight #2

@AndrewRadev

Description

@AndrewRadev

It seems like on my particular colorscheme, the syntax file errors out with:

E420: BG color unknown

It happens on this line:

hi cdeckInvisible guifg=bg guibg=bg ctermbg=bg ctermfg=bg

The problem, I think, is that the "bg" color only works if the Normal syntax group has a set background. In my case (a custom colorscheme), it looks like this:

hi Normal cterm=NONE ctermfg=White
hi Normal guifg=#dddddd guibg=Black

Even if I set ctermbg=NONE, it's the same issue -- it seems like it only works if there's a concrete color set, or I might be doing something wrong. The reason I'm not setting a specific color is because I'm using transparency in my terminal, so I'd like to keep this functionality.

Unfortunately, I'm not sure what a solution might look like. It would be nice if there was a way to check if "bg" was defined. This could work as a best-effort kind of thing, maybe:

try
  hi cdeckInvisible guifg=bg guibg=bg ctermbg=bg ctermfg=bg
catch /E420:/
  " No "bg" set, let's try our best to hide it:
  if &background == 'dark'
    hi cdeckInvisible guifg=Black guibg=Black ctermbg=Black ctermfg=Black
  elseif &background == 'light'
    hi cdeckInvisible guifg=White guibg=White ctermbg=White ctermfg=White
  endif
endtry

I've attached #3 as a PR that implements this fix.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions