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'})

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

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

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.