Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nested tables in user config aren't merged #16

Open
yujinyuz opened this issue Mar 16, 2024 · 5 comments
Open

Nested tables in user config aren't merged #16

yujinyuz opened this issue Mar 16, 2024 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@yujinyuz
Copy link
Contributor

yujinyuz commented Mar 16, 2024

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 miversen33 self-assigned this Mar 17, 2024
@miversen33
Copy link
Owner

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
Copy link
Contributor Author

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
Copy link
Owner

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
Copy link
Contributor Author

@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
Copy link
Owner

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

@miversen33 miversen33 added the bug Something isn't working label Mar 21, 2024
@miversen33 miversen33 changed the title Does the user config get merged? Nested tables in user config aren't merged Mar 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants