Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for non-RGB terminal color #50

Closed
bew opened this issue Dec 7, 2024 · 7 comments · Fixed by #66
Closed

Support for non-RGB terminal color #50

bew opened this issue Dec 7, 2024 · 7 comments · Fixed by #66
Labels
enhancement New feature or enhancement

Comments

@bew
Copy link

bew commented Dec 7, 2024

When termguicolors is not set in neovim, there is no way to configure the cursor color.

I'm aware you have code to manipulate RGB to apply gamma / transparency / color blending.
But I really only need (I think?) a ramp of colors, which I could give with multiple groups using the 256-colors palette 🤔

@bew bew added the enhancement New feature or enhancement label Dec 7, 2024
@sphamba
Copy link
Owner

sphamba commented Dec 7, 2024

Since highlight groups are created on the fly, it is indeed not currently possible to simply define them yourself.
With the current implementation, one hacky way to go would be to manually trigger the creation of the highlight groups to then override them yourself:

-- In a .lua script

local config = require("smear_cursor.config")
local color = require("smear_cursor.color")

for i = 1, config.color_levels do
  color.get_hl_group({ level = i })
  color.get_hl_group({ level = i, inverted = true })
end

-- Then define your highlight groups

The name of the highlight groups are SmearCursorNormalX and SmearCursorNormaInvertedX, with X going from 1 to config.color_levels.

We'll have to make it easier somehow. Good luck

@bew
Copy link
Author

bew commented Dec 8, 2024

Hmm thx for the scaffold.
What are the inverted color groups for?
Can they be the exact same groups as the normal ones, with reverse = true ? Or do I have to choose colors for them?

@sphamba
Copy link
Owner

sphamba commented Dec 8, 2024

If you don't use a font that has legacy computing symbols, some block symbols will be missing their symmetric counterpart. Still, they can be rendered using inverted foreground and background colors on available symbols for a similar effect. You can use the same colors with reverse = true

@bew
Copy link
Author

bew commented Dec 15, 2024

For the record, this is what I use now:

    -- @2024-12 the plugin doesn't expose a way to customize hl groups as they are created
    -- on-the-fly based on various RGB colors (not terminal colors).
    -- So we need to get creative, and manually trigger group creation and override them.
    -- REF: https://github.com/sphamba/smear-cursor.nvim/issues/50#issuecomment-2525347852
    local config = require("smear_cursor.config")
    local color = require("smear_cursor.color")
    for i = 1, config.color_levels do
      color.get_hl_group({ level = i })
      -- note: my config doesn't seem to ever use the inverted color groups
      -- color.get_hl_group({ level = i, inverted = true })
    end
    -- NOTE: assert(#palette == config.color_levels) !
    local smear_palette_fire = {
      { ctermfg = 137 },
      { ctermfg = 136 },
      { ctermfg = 130 },
      { ctermfg = 166 },
    }
    local smear_palette_darkwhite = {
      { ctermfg = 235 },
      { ctermfg = 240 },
      { ctermfg = 245 },
      { ctermfg = 255 },
    }
    local smear_palette = smear_palette_fire
    for i, hl_spec in ipairs(smear_palette) do
      vim.api.nvim_set_hl(0, "SmearCursorNormal"..i, hl_spec)
    end
Palettes

image

Peek.2024-12-15.08-36.mp4

❤️ ✨


Some day I might do a PR, let's keep open 🤔

@bew
Copy link
Author

bew commented Dec 15, 2024

Hmm it's not working perfectly well though, when I re-apply my colorscheme, the colors are back to white, even if I re-run the code I posted above 🤔

@sphamba
Copy link
Owner

sphamba commented Dec 19, 2024

@bew Please check #66, revision 6686744, and see if it works for you!

@bew
Copy link
Author

bew commented Dec 20, 2024

Awesome thanks a lot it's great now ✨ ✨ ✨ ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants