rktjmp / lush.nvim

Create Neovim themes with real-time feedback, export anywhere.
MIT License
1.4k stars 46 forks source link

Built-in support for `g:terminal_color_*` variables #116

Open musjj opened 1 year ago

musjj commented 1 year ago

https://neovim.io/doc/user/nvim_terminal_emulator.html#terminal-config Currently themes using lush.nvim have to implement a custom solution to set these variables. It would be cleaner if we can control these directly in the spec. Maybe something like:

return lush(function()
  return {
    g.terminal_color_1 { colors.foo },
    g.terminal_color_2 { colors.bar },
  }
end)

An issue is that terminal colors aren't refreshable, so this doesn't work very well with :Lushify. But still, this would make applying and building colorschemes with terminal support easier. What do you think?

rktjmp commented 1 year ago

As given that syntax wont (shouldnt?) work in Lush as the g.terminal_color_1 is an invalid group name. I'm not sure there would be a compatible syntax as the term colors don't really fit into the same "group" idea and I don't want to have magic group names that automatically translate - at least not in userland.

Possibly another function could be injected, like sym is that generates special keys internally, term_c(1) { fg = some_color }.

This should be an already compatible way to do it though, which I think is preferable and not very burdensome?


local theme = lush(function()
  return {
   Normal { fg = some_color },
   -- ...
  }
end)

g.terminal_color_1 = theme.Normal.fg.hex -- or tostring(theme.Normal.fg) or tostring(hsl(...)) if not using a group
-- ...

return theme