Iron-E / nvim-highlite

A colorscheme generator that is "lite" on logic for the developer.
Other
240 stars 33 forks source link

Transparent Background Support #30

Closed nezartarbin closed 7 months ago

nezartarbin commented 9 months ago

Is there transparent background support? Some other colorscheme libraries have a way to specify background = false or disable_background = true. Is there an equivalent here? Thanks!

nezartarbin commented 9 months ago

Looks like this is possible without explicit support from the library by adding this somewhere in the config. Not sure if this is still something you'd be interested in adding since some other colorschemes support it.

  vim.api.nvim_create_autocmd("ColorScheme", {
    pattern = "*",
    callback = function()
      vim.cmd [[ highlight Normal ctermbg=NONE guibg=NONE ]]
    end
  })
Iron-E commented 9 months ago

Hello! Thank you for sharing this idea.

Given the primary motivation of this project, I am primarily motivated to add setup flags to control which highlight groups get generated in the colorscheme (i.e. disabling specific plugin support) rather than what the generated groups look like.

The intent is that users will be able to create their own tweaks with just a few lines, based on a preset (or any colorscheme) should the defaults be lacking. For example, this is how I suggest changing the Normal highlight group:

-- in <your config dir>/colors/my-colorscheme.lua
-- see https://github.com/Iron-E/nvim-highlite/blob/master-v4/doc/advanced-usage.md#where-to-put-your-colorscheme

local Highlite = require 'highlite' --- @type Highlite

-- see https://github.com/Iron-E/nvim-highlite/blob/master-v4/doc/advanced-usage.md#using-a-built-in-palette
local palette, terminal_palette = Highlite.palette 'highlite'

-- see https://github.com/Iron-E/nvim-highlite/blob/master-v4/doc/advanced-usage.md#2-generating-groups
local groups = Highlite.groups('highlite', palette)

-- see https://github.com/Iron-E/nvim-highlite/blob/master-v4/doc/advanced-usage.md#2a-overriding-groups-optional
groups.Normal = {fg = 'NONE', bg = 'NONE'}

-- see https://github.com/Iron-E/nvim-highlite/blob/master-v4/doc/advanced-usage.md#3-generate
Highlite.generate('highlite-custom', groups, terminal_palette)

Then, elsewhere in your config, you can set your colorscheme to my-colorscheme it will use the transparent background you expect. This will also boost startup time :)

See this FAQ entry for more insight.


Can you tell me more about the use case? Do you use several colorscheme presets from this repository and want to be able to switch between them without having to make this change each time?

Iron-E commented 7 months ago

See also https://github.com/Iron-E/nvim-highlite/discussions/28

Iron-E commented 7 months ago

Closing as duplicate of #28 for now, feel free to reopen