miversen33 / sunglasses.nvim

Put on your shades so you only see what you care about
GNU General Public License v3.0
125 stars 3 forks source link

Nested tables in user config aren't merged #16

Open yujinyuz opened 7 months ago

yujinyuz commented 7 months ago

I have this in my config

  {
    'miversen33/sunglasses.nvim',
    event = 'UIEnter',
    opts = {
      filter_type = 'NOSYNTAX',
      filter_percent = 0.45,
      excluded_filetypes = {
        'gitcommit',
      },
    },
  }

But it seems to override the default config. I tried opening nvim tree without the config and unfocused nvim tree and the nvim tree is still highlighted.

However, after adding that, unfocusing nvim tree now unhighlights it

Screenshot 2024-03-18 at 00 00 52
miversen33 commented 7 months ago

In theory it should be deep merging your config with the default, where it keeps your values and uses the default when yours aren't provided.

It is possible that vim.tbl_deep_extend does not merge nested table (though I thought it did).

I will have to poke this a bit, though I do wonder if it makes sense to add the 'gitcommit' filetype to the default excluded filetypes?

yujinyuz commented 7 months ago

I'm not sure as well. I was debugging something else and thought that this plugin was causing the issue so I wanted to add gitcommit (but it turns out it was a different case).

I guess there'd be no benefit in adding gitcommit here

miversen33 commented 7 months ago

Makes sense to me. Doesn't fix the initial issue of "why isn't my table being merged" though sadly. I will investigate sometime this week, its an easy fix if I need to manually merge the table, just not something I thought I needed to do lol

yujinyuz commented 7 months ago

@miversen33 I'm using tint.nvim in the mean time and I find the window_ignore_function useful.

Instead of having to exclude filetypes, I can disable them via callback. This is also useful during diff mode since it's not a filetype. This is another issue but we were talking about filetypes so just thought of brining it up

-- 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 ~= ''
        local diff_mode = vim.api.nvim_win_get_option(winid, 'diff')

        -- Do not tint `terminal` or floating windows or diff mode, tint everything else
        return buftype == 'terminal' or floating or diff_mode

})
miversen33 commented 7 months ago

I think that is handy logic but I don't think its a viable solution now. That is very much a "either use that function" or "use a table" thing and since I am already using the table option for configurations, I don't think I can "switch" everyone over to that now.

That said, I definitely did forget about diff mode, I will have to figure "something" out for that.

I will let you know when I get something in place to address the table merging issue as well :)