maxmx03 / solarized.nvim

Solarized is a sixteen color palette (eight monotones, eight accent colors) designed for use with terminal and gui applications. Solarized port for Neovim
https://ethanschoonover.com/solarized/
MIT License
132 stars 15 forks source link

Change highlighting of symbol under cursor #76

Open andcov opened 5 months ago

andcov commented 5 months ago

First of all, thank you for the beautiful colorscheme, I have started using it everywhere.

I was wondering if it is possible to change the way the character and the symbol under the cursor are highlighted. Currently, the char under the cursor maintains its bg and fg, while the rest of the symbol (and all other occurrences of the symbol) get inverted. Is is possible to instead invert the current char, maintain the font colour for the rest of the symbol, and maybe lightly highlight the bg.

For example, this is how Solarized looks when the cursor is over the keyword "vim":

SCR-20240402-mmzn

while this is how OnedarkPro looks like:

SCR-20240402-mnsr

I tried looking into the source code for an answer, but I am quite new to NeoVim and Lua, so I was not able to find much. I am using kickstart with some basic modifications as a config.

mekedron commented 3 weeks ago

Hello @andcov! I've noticed the same problem in my LazyVim configuration.

The cursor is really hard to distinguish from the background with default solarized theme when the word is highlighted by LSP.

However, by changing highlight color I could achieve this result:

Before:

image

After:

image

The code:

return {
  {
    "maxmx03/solarized.nvim",
    opts = {
      highlights = function()
        return {
          Visual = { bg = "#5f6d74", fg = "#cccdfb" },
        }
      end,
    },
  },
}

However, you'll notice that when you're in a middle of the word, and if you press v to enter the visual mode, the highlighted word still will be highlighted by LSP. It make it hard to see where your selection goes as it has the same color as the LSP highlight.

So there're 2 ways to fix that.

  1. You can add the following autocmd:
    vim.api.nvim_create_autocmd("ModeChanged", {
    pattern = "*:[vV\x16]*", -- Triggers on entering visual mode (v, V, or Ctrl+v)
    callback = function()
    vim.lsp.buf.clear_references()
    end,
    desc = "Clear LSP references when entering visual mode",
    })

2 You can completely disable LSP highlights:

return {
  "neovim/nvim-lspconfig",
  opts = {
    document_highlight = {
      enabled = false,
    },
}

Hope it helps!