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

[Feature request] Highlight the color that ccc.nvim can pick. #14

Closed
roland-5 opened this issue Sep 18, 2022 · 19 comments
Closed

[Feature request] Highlight the color that ccc.nvim can pick. #14

roland-5 opened this issue Sep 18, 2022 · 19 comments

Comments

@roland-5
Copy link

Hi,

I was wondering if I can replace colorizer.lua with using only ccc.nvim. If I open some files and there are, like hex numbers meaning come colors it would show, what color it's. I mean something like this:
ps_20220629004516

@uga-rosa
Copy link
Owner

In fact, this is the next feature I was planning to inplement ;)

@uga-rosa uga-rosa changed the title Displaying automatically colors in files [Feature request] Highlight the color that ccc.nvim can pick. Sep 18, 2022
@uga-rosa
Copy link
Owner

uga-rosa commented Sep 19, 2022

Done.
You can use :CccHighlighterToggle. See help document for details.

@roland-5
Copy link
Author

Thanks! That was quick and exacting. Just added to my config:

local ccc = require("ccc")
local mapping = ccc.mapping
ccc.setup({
    highlighter = {
      auto_enable = true,
          },
})

But I have one question. Is there an option not to color the parts of the words that mean the colors?
ps_20220919190945

@uga-rosa
Copy link
Owner

uga-rosa commented Sep 19, 2022

It is highlighted the colors that can be picked up. So, you can do it this way.

local ccc = require("ccc")
ccc.setup({
    pickers = {
        ccc.picker.hex,
        ccc.picker.css_rgb,
        ccc.picker.css_hsl,
        -- ccc.picker.css_name,
    },
}

See :h ccc-option-pickers

@uga-rosa
Copy link
Owner

uga-rosa commented Sep 19, 2022

You can also specify file types to enable highlighting by using the options highlighter.filetypes and highlighter.excludes.

@roland-5
Copy link
Author

Thanks! <3

@uga-rosa
Copy link
Owner

I have already decided to disable css_name by default.

@SeniorMars
Copy link

CleanShot 2022-09-21 at 13 07 05@2x

This is probably an issue but css_name also highlights words that contain a css_name. Probably a regular expression thing?

@uga-rosa
Copy link
Owner

Have you updated to the latest version?

@gegoune

This comment was marked as resolved.

@uga-rosa
Copy link
Owner

uga-rosa commented Sep 21, 2022

pickers = {
ccc.picker.hex,
ccc.picker.css_rgb,
ccc.picker.css_hsl,
},

This is the default setting, and I don't have css_name in there properly. And I can't reproduce it in my environment. Are you sure you are able to update it? Can you go to the plugin directory and check the commit?

@SeniorMars
Copy link

Have you updated to the latest version?

I have updated it to the latest version, and I have enabled css_name, but it still highlights words that don't match exactly.

@SeniorMars
Copy link

CleanShot 2022-09-21 at 15 50 05@2x

@uga-rosa
Copy link
Owner

Ah - you're enabling it yourself.
It's an exact match. ccc just haven't looked at the before and after of it. And there is an option called exclude_pattern that I put in to counteract that, but it's hard to use as it is now, so I'll let you know when I update it, along with how to set it up.

@uga-rosa
Copy link
Owner

Done.
With exclude_pattern, you can determine the conditions before and after the match. The default settings are as follows

exclude_pattern = {
    hex = "[%w_]{{pattern}}",
    css_rgb = nil,
    css_hsl = nil,
    css_name = {
        "[%w_]{{pattern}}",
        "{{pattern}}[%w_]",
    },
}

With this setting, css_name is now excluded if there is an alphabet or underscore before or after this.

@SeniorMars
Copy link

image

I get this error once I update to the latest commit

@uga-rosa
Copy link
Owner

uga-rosa commented Sep 21, 2022

Sorry, fixed. It's a trace of print debug.

@roland-5
Copy link
Author

Wow, guys! For names it now works ideally. :D That's so cool. <3

@SeniorMars
Copy link

Yep! Thank you so much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants