0

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

Thomas Browne
  • 23,824
  • 32
  • 78
  • 121

1 Answers1

1

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.

  • Seems to work quite well, BUT, I have to `:colorscheme xxxx` at least once to get it working. So I'm still have to interact - it's not automatically done. – Thomas Browne Mar 14 '22 at 11:39
  • 1
    You're right! I didn't know why `ColorScheme` worked. I have `colorscheme vim-monokai-tasty` in my config file. You could add a colorscheme if you'd like, but I found out the event `VimEnter` works automatically, I'll update my answer. – Francisco Aguirre Mar 14 '22 at 14:50