Thomas Browne
Thomas Browne

Reputation: 24898

How do I persistently change coc.nvim colours from my ~/.config/nvim/init.vim?

I understand that I can change my coc.nvim colours from inside neovim, but how do I do so permanently from the init.vim file (or otherwise), so that they're changed automatically every time I open the editor?

Default colours poor for legibility:

enter image description here

Upvotes: 0

Views: 997

Answers (1)

Francisco Aguirre
Francisco Aguirre

Reputation: 456

My solution comes from the stackoverflow post you shared, this vi stackexchange post and learning a bit of vimscript with learning vimscript the hard way.

On your init.vim file you can write the following:

func! s:my_colors_setup() abort
  highlight CocFloating ctermbg=color " For background color
  highlight CocErrorFloat ctermfg=color " For text color
endfunc

augroup colorscheme_coc_setup | au!
  au VimEnter * call s:my_colors_setup()
augroup END

This works by calling the highlight command on a function that gets called when vim starts.

CocErrorFloat changes the text color for error popups, you could also change warnings, infos and hints with CocWarningFloat, CocInfoFloat and CocHintFloat respectively.

Upvotes: 1

Related Questions