Change the cursor color, the guifg seem doesn't work

-- cursor style
vim.opt.guicursor = 'n-v-c:block-Cursor,i-ci-ve:ver25-Cursor,r-cr-o:hor20-Cursor,a:blinkon100'

function hiCursor() 
  vim.api.nvim_set_hl(0, "Cursor", {fg='#cc9900', bg='#339966'})
  vim.api.nvim_set_hl(0, "CursorReset", {fg='white', bg='white'})
end

vim.api.nvim_create_autocmd("ColorScheme", {
    pattern = "*",
    callback = hiCursor,
  })

function resetHi()
vim.opt.guicursor = 'a:ver25-CursorReset,a:blinkon100'
end

vim.api.nvim_create_autocmd("VimLeave", {
    pattern = "*",
    callback = resetHi, 
  })

The guifg does’t work. The fg is still white.
Screenshot 2022-12-15 at 14.45.30
Actually, my terminal is iterm2, i want to use ctermfg and ctermbg, but neither work.

Your cursor’s color is probably being set inside your terminal’s configuration file, which has higher precedence than your vim’s cursor config using highlight groups.

1 Like

this is the kind of stuff that really should be in bold in the :h highlight :smile: spent about an hour before you saved the rest of my day @mroavi

1 Like