1

I've recently installed Base16 theme and having issues disabling Bold text, I found the customization snippets and have the following in my .init.vim (NeoVim) :

function! s:base16_customize() abort
  call Base16hi("Bold", "", "", "", "", "", "")
endfunction

augroup on_change_colorschema
  autocmd!
  autocmd ColorScheme * call s:base16_customize()
augroup END

colorscheme base16-tomorrow-night

I've tried puting the colorscheme line before and after the snipet but none worked, even calling the function doesn't do anything.

Another thing I tried was to highlight the 'Bold' parameter with no sucess:

hi Bold term=NONE

The highlight and the call works if I don't use termguicolors but I have it set for better colors.

I also tried to completly disable bold by adding set t_md= proposed here and also this but I use the terminal version.

1 Answer 1

3

Here is the source for Base16hi(...):

" Highlighting function
" Optional variables are attributes and guisp
function! g:Base16hi(group, guifg, guibg, ctermfg, ctermbg, ...)
  let l:attr = get(a:, 1, "")
  let l:guisp = get(a:, 2, "")

  if a:guifg != ""
    exec "hi " . a:group . " guifg=#" . a:guifg
  endif
  if a:guibg != ""
    exec "hi " . a:group . " guibg=#" . a:guibg
  endif
  if a:ctermfg != ""
    exec "hi " . a:group . " ctermfg=" . a:ctermfg
  endif
  if a:ctermbg != ""
    exec "hi " . a:group . " ctermbg=" . a:ctermbg
  endif
  if l:attr != ""
    exec "hi " . a:group . " gui=" . l:attr . " cterm=" . l:attr
  endif
  if l:guisp != ""
    exec "hi " . a:group . " guisp=#" . l:guisp
  endif
endfunction

You can see that it only executes a highlight command when the passed argument is not "". What you want to be passing is "NONE", not "". Note that when you set it to NONE, any additional attributes will also be reset (underline, italic, etc.)

But, you can't pass "NONE" for every argument, or you will get an error when it is expecting a color code. Specifically, you want:

call Base16hi("Bold", "", "", "", "", "NONE")

This will set gui and cterm to NONE instead of bold.

However, directly setting the highlight is better and more portable than relying on a colorscheme's utility function:

hi Bold cterm=NONE gui=NONE

Other groups might have gui or cterm set to bold, independently of the Bold highlight group. In that case, you could do the following:

" remove bold
function! s:base16_customize() abort
    " get list of colorschemes
    let l:colorschemes = getcompletion('', 'highlight')

    for c in l:colorschemes
        if synIDattr(synIDtrans(hlID(c)), 'bold')
            exec 'hi ' . c . ' cterm=NONE gui=NONE'
        endif
    endfor
endfunction

This will loop through the defined highlight groups, and if it has bold set, it will clear it. This may be slow if you have many highlight groups.

Relevant help:

:h getcompletion()
:h synIDattr()
:h synIDtrans()
:h hlID()
7
  • Tried just that but it doesn't work, also tried to put NONE everywhere doesn't work
    – vcbbcvbcv
    Sep 18, 2020 at 12:54
  • It works for me using nvim --clean, then setting colorscheme to base16-tomorrow-night, then running call Base16hi("Bold", "", "", "", "", "NONE"). Testing against the output of :so $VIMRUNTIME/syntax/hitest.vim Sep 18, 2020 at 13:06
  • How can I reproduce that in my config file so that it's loaded every times ?
    – vcbbcvbcv
    Sep 18, 2020 at 13:17
  • Your autocmd works for me, what is the output of :verbose hi Bold? Sep 18, 2020 at 13:24
  • The output is: Bold xxx cterm=bold gui=bold guisp=#NONE Last set from ~/.config/nvim/init.vim I just realized that the style was applied to the terminal version, and I use set termguicolors, tried with hi Bold cterm=NONE gui=NONE term=NONE with no success. But if I remove termguicolors it works. Is there a way to make it work with termguicolors ?
    – vcbbcvbcv
    Sep 18, 2020 at 13:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.