Lua nvim_command highlight not working unless manually run

Viewed 956

I have the following line at the very end of my init.lua

vim.api.nvim_command('hi CursorLineNr guibg=bg')

But it doesn't work. When I launch nvim, the CursorLineNr highlight group is still wrong. And yet, when I manually type :hi CursorLineNr guibg=bg, it works.

I'm not sure if this has to do with any Packer plugins finishing execution after the very last line of my init.lua or something?

2 Answers

I have no idea if this is "correct", but it worked for me:

vim.api.nvim_command[[
  autocmd ColorScheme * highlight CocErrorSign guifg=#bf616a
]]

Make sure to put highlight settings after the colorscheme is set in your init.lua because it resets the highlight.

vim.cmd("colorcheme gruvbox")
vim.cmd("hi CursorLineNr guibg=bg")

In this order

Related