base16.nvim icon indicating copy to clipboard operation
base16.nvim copied to clipboard

Modifiers "bold", "italic" not applied via base16_color_modifiers when termguicolors == false

Open simchri opened this issue 11 months ago • 0 comments

Hi,

I have encountered an issue where overrides or modifications to highlight groups for setting bold or cursive font were ignored. This happens only when falling back to terminal colors, i.e. vim.opt.termguicolors = false.

vim.g.base16_color_modifiers = {
    Keyword = "fg=red bold",
}

With these settings, keywords would be rendered in red* as expected, but not bold. (*whatever the terminal's current interpretation of "red" is)

I traced it back to this section in base16.vim

https://github.com/Soares/base16.nvim/blob/340e9140e95a6e98d8a36b4a2e246cca1a2a3516/autoload/base16.vim#L45C1-L49C8

I would say a case is missing for termguicolors == false. The following fixed it for me:

  if len(l:attrs) > 0
    execute 'highlight' a:group 'gui='.join(l:attrs, ',')
      if !has('termguicolors') || !&termguicolors
        execute 'highlight' a:group 'cterm='.join(l:attrs, ',')
      endif
  elseif a:bang
    execute 'highlight' a:group 'gui=NONE'
      if !has('termguicolors') || !&termguicolors
        execute 'highlight' a:group 'cterm=NONE'
      endif
  endif

Would be glad if someone with knowledge on vimscript / highlighting could double-check this, since I am a total beginner here :)

simchri avatar Jan 03 '25 18:01 simchri