Home

Awesome

:eyeglasses: tint.nvim

Tint inactive windows in Neovim using window-local highlight namespaces.

:warning: Caveats

:clapper: Demo

tint

:grey_question: About

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.

:gear: Setup

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
})

Custom color transformations

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
  }
})

Bounding colors to some threshold

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),
  }
})

:desktop_computer: API

See docs or :h tint for more details.

:heart: Acknowledgements