levouh/tint.nvim

Programatically set `tint_background_colors`

lougreenwood opened this issue · 4 comments

I'm trying to configure tint.nvim such that my NeoTree window doesn't get it's bg tinted, however I want everything else to be tinted.

I see that there is the tint_background_colors option, but it seems it's only possible to set this as a global option.

Ideally I would be able pass a function where I can inspect the window type and conditionally disable bg tinting for that window.

I initially looked into handling this with a custom transform, but when I saw this option it made me think that being able to pass a callback function to toggle this value per-window would be cleaner.

Actually, it seems that maybe I'm confused or there is a bug....

I'm noticing that with the following config, when the active window is not NeoTree, the NeoTree background still gets tinted.

  {
    "levouh/tint.nvim",
    enabled = true,
    opts = {
      highlight_ignore_patterns = { "WinSeparator", "Status.*" },
      tint = 40, -- Darken colors, use a positive value to brighten
      saturation = 0.10, -- Saturation to preserve
      tint_background_colors = false,
      transforms = {
        require("tint.transforms").tint_with_threshold(-80, "#1C1C1C", 150), -- Try to tint by `-100`, but keep all colors at least `150` away from `#1C1C1C`
        require("tint.transforms").saturate(0.3),
      },
    },
  },

If I disable tint.nvim then moving focus away from NeoTree then the NeoTreeNormalNC is correctly used.

However, if I enable tint.nvim, moving away from NeoTree results a different tint being applied.

So it seems that even with tint_background_colors = false that NeoTreeNormalNC is getting it's bg tinted, or not used at all.

Is this expected, or am I misunderstanding something?

Here's a video of me showing the behaviour both with and without tint.nvim enabled and some garish colours being used to demonstrate the behaviour.

tint-nvim-neotree-issue.mp4

(Edit: After recording the video, I decided to set NormalNC to be the same as what I have set for NeoTreeNormalNC in the video, and this is what is used when tinting... so it seems that when a window is tinted (e.g NeoTree then it's own, custom "*NormalNC" is overwritten by the default NormalNC...)

Thanks!

levouh commented

tint_background_colors works in that every highlight group has many attributes, including a foreground and a background color. This option makes the plugin only tint the foreground color of each highlight group, not the background color.

I would look at :h tint-option-window_ignore_function, and simply return false for windows you do not want to be tinted, and then true by default.

Thanks, although maybe I wasn't clear.

It seems that even when tint_background_colors is false and when the NeoTree window is not active, NeoTree appears to use the NormalNC.bg highlight. This doesn't seem to be expected?

If I disable tint.nvim, when NeoTree is not active it (correctly/expectedly) uses the NeoTreeNormalNC.bg highlight.

I can record a video demonstrating this - although first could you confirm whether it's expected that tint.nvim with tint_background_colors = false causes an in-active window to use NormalNC.bg for it's background?

Thanks!

I'm not 100% sure I understand the question correctly, but I would imagine that NeoTreeNormalNC is linked to NormalNC?