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

Bug: I noticed filetypes override other filetype configs #134

Open
Muizzyranking opened this issue Jan 14, 2025 · 13 comments
Open

Bug: I noticed filetypes override other filetype configs #134

Muizzyranking opened this issue Jan 14, 2025 · 13 comments
Assignees
Labels
bug Something isn't working

Comments

@Muizzyranking
Copy link

Describe the bug
A description of what the bug is.
What I mean is, I set the default option to make name false but then set HTML and CSS filetype to true. If I open HTML or CSS first, it makes name true for that instance and it always highlight names for other filetypes I did not specify. If I open other filetypes first, it doesn't highlight names even for HTML and CSS. I do not know if I am explaining this well.

To Reproduce
Provide your config and steps to reproduce.
You can use test/minimal.lua to produce a minimal config.

-- expect.lua
return {
      filetypes = {
        "*",
        html = { names = true },
        css = { names = true },
        javascript = { names = true },
        javascriptreact = { names = true },
      },
      user_default_options = {
        names = false,
        RGB = true,
        RRGGBB = true,
        RRGGBBAA = true,
        AARRGGBB = true,
        rgb_fn = true,
        hsl_fn = true,
        css = true,
        css_fn = true,
        mode = "virtualtext",
        tailwind = "both",
        sass = { enable = false, parsers = { "css" } },
        virtualtext = "",
        virtualtext_inline = true,
        virtualtext_mode = "foreground",
        always_update = false,
      },
      buftypes = {},
      user_commands = true,
    }

Expected behavior
A description of what you expected to happen.

I expect it to highlight name only in HTML, CSS and js, the rest should get the defaults. Moving from filetypes should not disrupt this

Operating System:
Fedora 41

Neovim Version:
Tried this both with NVIM v0.11.0-dev-1545+ga4f575abd8 and NVIM v0.10.2

@Muizzyranking Muizzyranking added the bug Something isn't working label Jan 14, 2025
@catgoose
Copy link
Owner

Yeah strange. The names=false in user_default_options should be the default. I'll take a look at this.

@catgoose
Copy link
Owner

catgoose commented Jan 17, 2025

I have a little more work to do, but could you try with the fix/134-filetype_configuration-decouple_namespaces branch?

@catgoose
Copy link
Owner

Does that branch work for you?

@Muizzyranking
Copy link
Author

Pardon my late response, I just got a hold of my PC. I tried the branch now and tried to reinstall, but I am getting error installing.

Image

I do not what I am doing wrong, I added branch = "fix/134-filetype_configuration-decouple_namespaces", isn't that what I am suppose to do?

@Muizzyranking
Copy link
Author

I have gotten it to work, but I get an error when I call set up even with an empty table
...re/nvim/lazy/nvim-colorizer.lua/lua/colorizer/config.lua:141: Error in names_custom function: attempt to call a nil value I think this is from the validate function, I tried looking into it, I do not seem to understand.

@Muizzyranking
Copy link
Author

I have been able to find the culprit. I just created a PR for the fix. Let me know if there other things I should do before closing this.

@catgoose
Copy link
Owner

Thanks, I'll look at your PR. Though, I am still working on the fix/134-filetype_configuration-decouple_namespaces branch. I need to store each filetype's names_custom as a key in the names parser so you can have different names_custom definitions for the default options and each filetype.

@catgoose
Copy link
Owner

fix/134-filetype_configuration-decouple_namespaces

Yep, that's right. Could you test latest on that branch?

Using the following setup opts, filetype settings should be respected including names_custom definitions!

 {
  filetypes = {
    "*",
    html = {
      names = true,
      names_opts = {
        lowercase = true,
        uppercase = false,
        camelcase = false,
        strip_digits = false,
      },
      names_custom = {
        one = "#0000ff",
        two = "#00ff00",
        three = "#ff0000",
        four = "#0eae90",
        seven = "#f0f000",
        nine = "#fa0ce0",
      },
      tailwind = false,
    },
    lua = {
      names = true,
      names_opts = {
        lowercase = false,
        uppercase = true,
        camelcase = true,
        strip_digits = true,
      },
      names_custom = {
        four = "#ffefaf",
        five = "#3f0fb0",
        six = "#f000f0",
        seven = "#00ff00",
      },
      tailwind = true,
    },
    css = {
      names = true,
      names_custom = {
        nine = "#fac00e",
      },
    },
    javascript = { names = true },
    javascriptreact = { names = true },
  },
  user_default_options = {
    names = false,
    names_custom = {
      four = "#00ff00",
      five = "#fafaaa",
      six = "#ffafff",
      seven = "#abcdef",
      nine = "#ff0000",
    },
    RGB = true,
    RRGGBB = true,
    RRGGBBAA = true,
    AARRGGBB = true,
    rgb_fn = true,
    hsl_fn = true,
    css = true,
    css_fn = true,
    mode = "background",
    sass = { enable = false, parsers = { "css" } },
    virtualtext = "",
    virtualtext_inline = true,
    virtualtext_mode = "foreground",
    always_update = false,
  },
  buftypes = {},
  user_commands = true,
  lazy_load = false,
}

Image

@Muizzyranking
Copy link
Author

I just updated, still on fix/134-filetype_configuration-decouple_namespaces, I think it works well but it makes neovim laggy as hell. I am unable to do anything. I had to use my lazyvim config to remove colorizer. Even when I pass an empty table to setup, it is still very very laggy. Thank you for your work. I have switched to the main branch for now.

@catgoose
Copy link
Owner

I noticed the lag too. I'll take a look later today or tomorrow.

@Muizzyranking
Copy link
Author

Thank you for taking your time.

@catgoose
Copy link
Owner

No problem! Can you try that branch again. I think I fixed the performance issues.

@Muizzyranking
Copy link
Author

Muizzyranking commented Jan 19, 2025

I have been using for the past 30 minutes, no issues so far. The only issue I noticed is from the names custom, some colors works, some don't. I think the user_default is overriding the names_custom in the filetype settings. Using the exact config you sent.

Image

See all filetype have the same highlight for custom names.

But when I remove names_custom from user default option, the highlight works as described in the filetype.
Other than this, there is no issue.

Should I leave this issue opened or you still need me to test later?

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