jinh0 / eyeliner.nvim

👀 Move faster with unique f/F indicators.
441 stars 14 forks source link

feature: recolor after a colorscheme change, or allow users to set default colors #38

Closed aerosayan closed 1 year ago

aerosayan commented 1 year ago

Hello,

i absolutely love the plugin, and within a day it has become an important part of my dev process!

I noticed that the color of the highlighted characters doesn't change after we change the colorscheme.

Did you hardcode the colors?

  1. It would be good if the colors could automatically change after we change our colorscheme.
  2. Or, alternatively It would be helpful if we could set our own default color.

Thanks!

jinh0 commented 1 year ago

Hi @aerosayan I'm glad you're enjoying the plugin!

The colours are not hardcoded in: it is by default set to your colorscheme's colours for Constant, Define, and Comment. For reference, the code in shared.fnl:

(fn enable-highlights []
  (let [primary (utils.get-hl "Constant")
        secondary (utils.get-hl "Define")
        dimmed (utils.get-hl "Comment")]
    (utils.set-hl "EyelinerPrimary" primary.foreground)
    (utils.set-hl "EyelinerSecondary" secondary.foreground)
    (utils.set-hl "EyelinerDimmed" dimmed.foreground)
    (utils.set-autocmd "ColorScheme"
                       {:callback enable-highlights :group "Eyeliner"}))) 
  1. Or, alternatively It would be helpful if we could set our own default color.

I have written up some information about customizing the colours for eyeliner: https://github.com/jinh0/eyeliner.nvim#-customize-highlight-colors

  1. It would be good if the colors could automatically change after we change our colorscheme.

That's odd: the colours should automatically change after the colorscheme is changed... I just tested the plugin, and it works as expected. I will take another look.

For the time being, if nothing works, add the following code to your configuration:

vim.api.nvim_create_autocmd({'Colorscheme'}, {
  pattern = {'*'},
  callback = function ()
    vim.api.nvim_set_hl(0, 'EyelinerPrimary', { link = 'Constant' })
    vim.api.nvim_set_hl(0, 'EyelinerSecondary', { link = 'Define'})
    vim.api.nvim_set_hl(0, 'EyelinerDimmed', { link = 'Comment' })
  end
})

This should give you the expected behaviour for eyeliner when changing colorschemes.

Let me know if this helps!

joshuali925 commented 1 year ago

somewhat related, could the highlight be hi-default? e.g.

vim.api.nvim_set_hl(0, "EyelinerPrimary", {link = "Constant", default = True})

instead of https://github.com/jinh0/eyeliner.nvim/blob/0b21a862fa0782090350c13c8b32ccd58adc4d82/lua/eyeliner/shared.lua#L4-L6

This way if user (or colorscheme) sets EyelinerPrimary before the plugin gets loaded, plugin won't override the user setting.

Also i'm not sure if the autocmd is needed, since Eyeliner groups are already linked to highlight group names, which stays the same across colorscheme changes https://github.com/jinh0/eyeliner.nvim/blob/0b21a862fa0782090350c13c8b32ccd58adc4d82/lua/eyeliner/shared.lua#L7

i wanted to send a PR but i don't know any fennel..

mawkler commented 1 year ago

I also recently started getting an issue where eyeliner overrides my default EyelinerPrimary and EyelinerSecondary highlight groups when it gets lazy loaded.

jinh0 commented 1 year ago

Shoot, my bad @mawkler and @joshuali925 , I just reverted my latest commit https://github.com/jinh0/eyeliner.nvim/commit/a6c05ed7f2a59640bd18ff0702694deda483a08e . That should fix the overriding issue.

@joshuali925

vim.api.nvim_set_hl(0, "EyelinerPrimary", {link = "Constant", default = True})

You are correct, default = true is necessary. Thanks for pointing that out, it has been fixed!

Let me know if eyeliner is still overriding your colours on the latest commit.