f4z3r / gruvbox-material.nvim

Material Gruvbox colorscheme for Neovim written in Lua
MIT License
32 stars 4 forks source link

Feature Request highlight_group colour #15

Closed Parilia closed 3 months ago

Parilia commented 3 months ago

The current highlight group for yanking is red I would love if wither we hve the option for changing it or it is changed on dark to be something else. Personally I like the colour #a9b665 for it

f4z3r commented 3 months ago

Hi @Parilia, makes sense. I will try to find some time this weekend to apply to this project. I want to refactor how the configuration is done, and could introduce such a change with it 👍🏽

f4z3r commented 3 months ago

@Parilia I have thought about this a little. I am unsure I will make this configurable by default directly. The issue is that this highly depends on whether you use specific plugins etc. Moreover, you can override your preferences yourself by adding code such as:

-- IncSearch is used by default on yank by most plugins as far as I know
vim.api.nvim_set_hl(0, "IncSearch", { bg = "#a9b665" })

after the plugin was loaded.

What I might do, is to add a way to configure overrides to the plugin in its configuration, to ensure the overrides are applied on reloads (such as when using plugins as referenced in issue #13 )

Might I ask what plugin you use to highlight yanked text? Or do you set it up using autocmd? Because what I can of course do it to add custom highlight groups to the colourscheme.

Parilia commented 3 months ago

Yea that is fair, i use the autocmd and I couldnt actually fin on the net how to override it so thanks.


local highlight_group = vim.api.nvim_create_augroup('YankHighlight', { clear = true })
vim.api.nvim_create_autocmd('TextYankPost', {
    callback = function()
        vim.highlight.on_yank()
    end,
    group = highlight_group,
    pattern = '*',
})
f4z3r commented 3 months ago

You can update the highlight group using your code by passing it to the on_yank function, as such:

-- see `:h on_yank` for additional options (higroup defaults to IncSearch)
vim.highlight.on_yank({ higroup = "SomeHighlightGroup" })

That way you can define different highlights for incremental searches and yanks if you want.

I will close this issue as this is no longer relevant then.