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

Colorizer not attaching to buffers #433

Open
1 task done
Jappie3 opened this issue Nov 2, 2024 · 12 comments
Open
1 task done

Colorizer not attaching to buffers #433

Jappie3 opened this issue Nov 2, 2024 · 12 comments
Labels
bug Something isn't working

Comments

@Jappie3
Copy link

Jappie3 commented Nov 2, 2024

⚠️ Please verify that this bug has NOT been reported before.

  • I checked all existing issues and didn't find a similar issue

Description

Colorizer does not attach when opening a buffer, when running :ColorizerAttachToBuffer it correctly highlights colors

👟 Reproduction steps

minimal reproducible example:

{
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
    nvf.url = "github:notashelf/nvf";
  };

  outputs = {
    self,
    nixpkgs,
    ...
  } @ inputs: {
    packages."x86_64-linux" = {
      default =
        (inputs.nvf.lib.neovimConfiguration {
          modules = [
            {
              config.vim.theme.enable = true;
              config.vim.ui.colorizer.enable = true;
            }
          ];
          inherit (nixpkgs.legacyPackages."x86_64-linux") pkgs;
        })
        .neovim;
    };
  };
}
nix run

type 'green' or 'red' -> no color highlighting
run :ColorizerAttachToBuffer -> color highlighting

👀 Expected behavior

Colorizer should work without explicitly attaching it to the buffer

😓 Actual Behavior

It did not attach to the buffer

💻 Metadata

  • system: "x86_64-linux" - host os: Linux 6.6.58, NixOS, 24.11 (Vicuna), 24.11.20241029.807e915 - multi-user?: yes - sandbox: yes - version: nix-env (Lix, like Nix) 2.91.0 System type: x86_64-linux Additional system types: aarch64-linux, i686-linux Features: gc, signed-caches System configuration file: /etc/nix/nix.conf User configuration files: /home/jasper/.config/nix/nix.conf:/etc/xdg/nix/nix.conf:/home/jasper/.nix-profile/etc/xdg/nix/nix.conf:/nix/profile/etc/xdg/nix/nix.conf:/home/jasper/.local/state/nix/profile/etc/xdg/nix/nix.conf:/etc/profiles/per-user/jasper/etc/xdg/nix/nix.conf:/nix/var/nix/profiles/default/etc/xdg/nix/nix.conf:/run/current-system/sw/etc/xdg/nix/nix.conf Store directory: /nix/store State directory: /nix/var/nix Data directory: /nix/store/xjcvjdif1fv2zdsywa2g2r2rahymqbdm-lix-2.91.0/share - nixpkgs: /nix/store/m68ikm8045fj7ys7qvgr608z9l70hh1k-source

📝 Relevant log output

no clue how to get nvim logs tbh
@Jappie3 Jappie3 added the bug Something isn't working label Nov 2, 2024
@NotAShelf
Copy link
Owner

nvf does not enable the names feature for colorizer by default. You will need to enable it manually in colorizer.setupOpts. See: https://github.com/NotAShelf/nvf/blob/main/modules/plugins/ui/colorizer/colorizer.nix

@Jappie3
Copy link
Author

Jappie3 commented Nov 2, 2024

even adding colorizer.setupOpts.names = true;:

{
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
    nvf.url = "github:notashelf/nvf";
  };

  outputs = {
    self,
    nixpkgs,
    ...
  } @ inputs: {
    packages."x86_64-linux" = {
      default =
        (inputs.nvf.lib.neovimConfiguration {
          modules = [
            {
              config.vim.theme.enable = true;
              config.vim.ui.colorizer = {
                enable = true;
                setupOpts.names = true;
              };
            }
          ];
          inherit (nixpkgs.legacyPackages."x86_64-linux") pkgs;
        })
        .neovim;
    };
  };
}

it still does not attach to the buffer automatically, I manually have to run :ColorizerAttachToBuffer

@NotAShelf
Copy link
Owner

That is unusual, I'll take a look shortly.

@Jappie3
Copy link
Author

Jappie3 commented Nov 2, 2024

also color highlighting by name (e.g. 'blue', 'green') worked with the first flake example I posted... so either my system config (where it is enabled) is leaking (which could also mean that there's some incompatibility) or something weird is happening...

@NotAShelf
Copy link
Owner

Sorry, I forgot to respond to this earlier but colorizer has been updated not so long ago. Has this been resolved? Or does it still occur after the update?

@Jappie3
Copy link
Author

Jappie3 commented Feb 11, 2025

No worries, not like this is a high priority issue

Using the minimal reproducible example from the initial report - but with nvf pinned like this (master threw an error when running) nvf.url = "github:notashelf/nvf/a78026438cc8e280a696bcadb60f5c8f93b96a12"; (commit from 2 days ago) - colorizer still does not attach to buffers by default. After manually running :ColorizerAttachToBuffer it works.

Just to make sure, config.vim.ui.colorizer.enable = true; should be enough to enable it right?

@NotAShelf
Copy link
Owner

That should be it, yes. I've got colorizer working in my setup without any additional setups, maybe a missing soft-dependency?

@Jappie3
Copy link
Author

Jappie3 commented Feb 11, 2025

can you try nix runing this flake.nix?

{
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
    nvf.url = "github:notashelf/nvf/a78026438cc8e280a696bcadb60f5c8f93b96a12";
  };

  outputs = {
    self,
    nixpkgs,
    ...
  } @ inputs: {
    packages."x86_64-linux" = {
      default =
        (inputs.nvf.lib.neovimConfiguration {
          modules = [
            {
              config.vim.theme.enable = true;
              config.vim.ui.colorizer.enable = true;
            }
          ];
          inherit (nixpkgs.legacyPackages."x86_64-linux") pkgs;
        })
        .neovim;
    };
  };
}

@KodNova
Copy link

KodNova commented Feb 18, 2025

I am having the same issue. Got nearly my whole config switched over to nvf and got stuck on this plugin. When I go to a HTML file it does same thing as OP, have to run :ColorizerAttachToBuffer to make it work. But I cant get tailwindcss to work even running :ColorizerAttachToBuffer. I'm pretty sure I have tailwind enabled correctly.

ui.colorizer = {
  enable = true;
  setupOpts = {
    mode = "background";
    tailwind = true;
    names = true;
    RGB = true;
    RRGGBB = true;
    };
};

@jsjjohnston
Copy link

Had this issues and was able to resolve by including filetypes in the setup I think its related to this comment

          ui = {
            colorizer = {
              enable = true;
              setupOpts = {
                filetypes = { 
                  "*" = {
                    RGB = true;
                    RRGGBB = true;
                    always_update = true;
                    css = true;
                    mode = "background";
                  };
                };
              };
            };
          };

@Jappie3
Copy link
Author

Jappie3 commented Feb 24, 2025

can confirm: the below flake works (highlights colors) when opening a file with an 'regular' or common file extension - e.g. .html works, .aoeuaoeu doesn't.

at this point I'm not sure if we should keep this issue open here or if this is an intended limitation of colorizer... as far as I'm concerned this is a good solution and we can close it

flake
{
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
    nvf.url = "github:notashelf/nvf";
  };

  outputs =
    {
      self,
      nixpkgs,
      ...
    }@inputs:
    {
      packages."x86_64-linux" = {
        default =
          (inputs.nvf.lib.neovimConfiguration {
            modules = [
              {
                config = {
                  vim = {
                    theme.enable = true;
                    ui.colorizer.enable = true;
                    ui.colorizer.setupOpts = {
                      filetypes = {
                        "*" = {
                          RGB = true;
                          RRGGBB = true;
                          always_update = true;
                          css = true;
                          mode = "background";
                        };
                      };
                    };
                  };
                };
              }
            ];
            inherit (nixpkgs.legacyPackages."x86_64-linux") pkgs;
          }).neovim;
      };
    };
}

@NotAShelf
Copy link
Owner

I think it might be a good idea to provide some default value for colorizer filetypes, so that attaching to buffers works ootb.

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

4 participants