Tint inactive windows in Neovim using window-local highlight namespaces.
- This feature was added via !13457. Your version of Neovim must include this change in order for this to work.
- If you are noticing that certain colors are not being tinted, it is because likely they are defined after
tint
has been loaded and are "standalone" (i.e. notlink
).tint
applies changes to your colorscheme (i.e. the global highlight namespace withns_id=0
) when itssetup
function is called. From this then, if you are lazy-loading a different plugin that declares its own standalone highlight groups and loads aftertint
, they will likely not work as intended.- To help work around this (perhaps until a better solution is found), you can use
require("tint").refresh()
after a plugin loads if you are having issues with its colors.
- Highlight groups that "replace" another in unfocused windows (e.g.
NormalNC
"replacing"Normal
) must have both highlight groups defined. The*NC
group is what will be tinted in unfocused windows.
Using window-local highlight namespaces, this plugin will iterate over each highlight group in the active colorscheme when the plugin is setup and either brighten or darken each value (based on what you configure) for inactive windows.
See docs or :h tint
for more details.
-- Default configuration
require("tint").setup()
Or if you want to override the defaults:
-- Override some defaults
require("tint").setup({
tint = -45, -- Darken colors, use a positive value to brighten
saturation = 0.6, -- Saturation to preserve
transforms = require("tint").transforms.SATURATE_TINT, -- Showing default behavior, but value here can be predefined set of transforms
tint_background_colors = true, -- Tint background portions of highlight groups
highlight_ignore_patterns = { "WinSeparator", "Status.*" }, -- Highlight group patterns to ignore, see `string.find`
window_ignore_function = function(winid)
local bufid = vim.api.nvim_win_get_buf(winid)
local buftype = vim.api.nvim_buf_get_option(bufid, "buftype")
local floating = vim.api.nvim_win_get_config(winid).relative ~= ""
-- Do not tint `terminal` or floating windows, tint everything else
return buftype == "terminal" or floating
end
})
See :h tint-transforms_api
for more details.
If you come up with a cool set of transformations that you think might be useful to others, see the contributing guide on how you can make this available for others.
-- Handle transformations of highlight groups for the tinted namespace yourself
require("tint").setup({
transforms = {
require("tint.transforms").saturate(0.5),
function(r, g, b, hl_group_info)
print("Higlight group name: " .. hl_group_info.hl_group_name)
local hl_def = vim.api.nvim_get_hl_by_name(hl_group_info.hl_group_name)
print("Highlight group definition: " .. vim.inspect(hl_def))
return r + 1, g + 1, b + 1
end
}
})
See :h tint-transforms-tint_with_threshold
for more details.
Your colorscheme might have colors that are slightly different from your default editor background, and those that are much further away. You want the colors that are further away tinted more, and those that are closer tinted less. In order to achieve this, you can set some arbitrary "tint bounding color" and keep all tinted colors some threshold away from it.
Setting this to the background
portion of your Normal
highlight group is usually the easiest way to go.
require("tint").setup({
transforms = {
require("tint.transforms").tint_with_threshold(-100, "#1C1C1C", 150), -- Try to tint by `-100`, but keep all colors at least `150` away from `#1C1C1C`
require("tint.transforms").saturate(0.5),
}
})
See docs or :h tint
for more details.
- The harder part of the plugin to dim colors from StackOverflow
- The general idea from Shade.nvim
bfredl
for making everyones life betterwilliamboman
for adding saturation to better mimic the wayShade
looks