Skip to content

Add syntax group for colors and numbers #13

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

Merged
merged 6 commits into from
Dec 27, 2021
Merged

Add syntax group for colors and numbers #13

merged 6 commits into from
Dec 27, 2021

Conversation

Fymyte
Copy link
Contributor

@Fymyte Fymyte commented Dec 8, 2021

Highlight Numbers and colors as Numbers
Giving colors a group now allows for using https://github.com/ap/vim-css-color types plugins

I am definitely not an expert in pattern matching so I've felt my way along and stopped when it worked
Any advice on how to improve those patterns is very welcome.

Signed-off-by: Fymyte pierguill@gmail.com

Highlight Numbers and colors as Numbers
Giving colors a group now allows for using https://github.com/ap/vim-css-color types plugins

Signed-off-by: Fymyte <pierguill@gmail.com>
@fladson
Copy link
Owner

fladson commented Dec 17, 2021

Hi @Fymyte, thank you for the contribution and sorry for not seeing this earlier.

I will take a look and get back to you.

@Fymyte
Copy link
Contributor Author

Fymyte commented Dec 17, 2021

I think that for the colors, we should only match something like #[0-9A-Fa-f]\{6,8} but I am not sure if it would match colors

Signed-off-by: Fymyte <pierguill@gmail.com>
@Fymyte
Copy link
Contributor Author

Fymyte commented Dec 17, 2021

I think I finally managed to restrain color matching. I found what I was doing wrong if you can test this

@fladson
Copy link
Owner

fladson commented Dec 21, 2021

Hey @Fymyte I did some testing today and I am not sure if we are there yet.
Some numbers found in the middle of values are being highlighted but not the entire value, so I am not sure if that is the desired outcome here.
I believe you want to highlight only the values that are numbers, right? If so, we also need to include the possible prefixes (+, -, etc.) and suffixes (%, px, etc.).

Screenshot 2021-12-21 at 11 36 01

For the theme configuration, it is working just fine:
Screenshot 2021-12-21 at 11 39 23

Signed-off-by: Fymyte <pierguill@gmail.com>
Signed-off-by: Fymyte <pierguill@gmail.com>
Signed-off-by: Fymyte <pierguill@gmail.com>
@Fymyte
Copy link
Contributor Author

Fymyte commented Dec 21, 2021

Fixed matching for colors with only 3 char, uses vim's builtin match for Hexa characters
Added match for prefix/suffix of number.
Fixed number highlighted in words

In the latter, I had to tweak the kittyActionKW match as it matched every whitespaces which followed, thus making impossible for number to use leader whitespace for matching.
It should not break anything from what I've seen

@fladson
Copy link
Owner

fladson commented Dec 22, 2021

Looking better now, thanks for the changes.
Still not matching pt, px, is it working for you?

Screenshot 2021-12-22 at 17 40 53

Signed-off-by: Fymyte <pierguill@gmail.com>
@Fymyte
Copy link
Contributor Author

Fymyte commented Dec 22, 2021

Looking better now, thanks for the changes.
Still not matching pt, px, is it working for you?

Screenshot 2021-12-22 at 17 40 53

I have created a new kittyUnit syntax group.
By default they are linked to Type.
Do prefer to see them as Number ?
Modification is line 40

@fladson fladson merged commit 6045608 into fladson:main Dec 27, 2021
@fladson
Copy link
Owner

fladson commented Dec 27, 2021

Ah, I got it now, let's keep it as it is.
Thank you again for the contribution @Fymyte!

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

Successfully merging this pull request may close these issues.

2 participants