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

Colors for items in the completion menu #12299

Merged

Conversation

NikitaRevenco
Copy link
Contributor

@NikitaRevenco NikitaRevenco commented Dec 19, 2024

This PR adds little colored boxes to completion items if its a color

image

It works on any Color completion item, so it works with CSS, tailwindcss, any other language server which provides "colors".

@NikitaRevenco NikitaRevenco changed the title feat: "Color" completion items now have a little box next to them showing the actual color feat: Color completion items now have a little box next to them showing the actual color Dec 19, 2024
@NikitaRevenco NikitaRevenco changed the title feat: Color completion items now have a little box next to them showing the actual color feat: Preview color for completion items Dec 19, 2024
@NikitaRevenco NikitaRevenco changed the title feat: Preview color for completion items Preview color for completion items Dec 19, 2024
@NikitaRevenco NikitaRevenco changed the title Preview color for completion items Color for completion items Dec 19, 2024
@NikitaRevenco NikitaRevenco changed the title Color for completion items Colors in the completion menu for items with CompletionItemKind::COLOR Dec 19, 2024
@NikitaRevenco NikitaRevenco changed the title Colors in the completion menu for items with CompletionItemKind::COLOR Colors for items in the completion menu Dec 19, 2024
helix-term/src/ui/completion.rs Outdated Show resolved Hide resolved
helix-term/src/ui/completion.rs Outdated Show resolved Hide resolved
helix-term/src/ui/completion.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@TornaxO7 TornaxO7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just my two cents 👀 You can decline them. But nice feature!

helix-term/src/ui/completion.rs Outdated Show resolved Hide resolved
helix-view/src/graphics.rs Show resolved Hide resolved
helix-term/src/ui/completion.rs Outdated Show resolved Hide resolved
helix-term/src/ui/completion.rs Outdated Show resolved Hide resolved
helix-term/src/ui/completion.rs Outdated Show resolved Hide resolved
helix-term/src/ui/completion.rs Outdated Show resolved Hide resolved
@filipdutescu
Copy link
Contributor

Not for this PR, but a good follow up would be to add the square before any colour string in a file, not just on LSP completions.

@tveskag
Copy link

tveskag commented Dec 20, 2024

This looks like it will conflict with #12151. It would be logical to combine the two if possible

@NikitaRevenco
Copy link
Contributor Author

NikitaRevenco commented Dec 20, 2024

This looks like it will conflict with #12151. It would be logical to combine the two if possible

It's not possible to think about all 272 PRs and whether this one will conflict with any of them

depending on which PR gets merged first, the other has to resolve merge conflicts

@NikitaRevenco
Copy link
Contributor Author

NikitaRevenco commented Dec 20, 2024

Not for this PR, but a good follow up would be to add the square before any colour string in a file, not just on LSP completions.

I'm actually working on that https://github.com/NikitaRevenco/helix/tree/textDocument/documentColor :)

@DaveTJones
Copy link

Just a thought, is the word 'color' before every color maybe a little redundant? The only scenario in which I can see this being useful is one in which the color to be rendered happens to match the background.

An alternative use for this space might be to show the hex/RGB/HSL representation of the color?

@NikitaRevenco
Copy link
Contributor Author

NikitaRevenco commented Dec 20, 2024

Just a thought, is the word 'color' before every color maybe a little redundant? The only scenario in which I can see this being useful is one in which the color to be rendered happens to match the background.

An alternative use for this space might be to show the hex/RGB/HSL representation of the color?

I think it's fine to keep it as is, if we have a bunch of hsl/hex/rgb colors it will get messy + the only information we actually do have is hex colors.

We would have to manually convert them to hsl/rgb if we needed to. Then, which should be pick - rgb or hsl?"Should it be a config option? + You can already see what the color is from the completion menu. It introduces so much unnecessary complexity and not worth it at all imo

@the-mikedavis the-mikedavis merged commit ba6e6dc into helix-editor:master Dec 20, 2024
6 checks passed
@DaveTJones
Copy link

I think it's fine to keep it as is, if we have a bunch of hsl/hex/rgb colors it will get messy + the only information we actually do have is hex colors.

We would have to manually convert them to hsl/rgb if we needed to. Then, which should be pick - rgb or hsl?"Should it be a config option? + You can already see what the color is from the completion menu. It introduces so much unnecessary complexity and not worth it at all imo

I agree that adding a RGB or HSL option is probably not worth the effort. My main point was that annotating each color as 'color' is redundant.

@NikitaRevenco
Copy link
Contributor Author

I think it's fine to keep it as is, if we have a bunch of hsl/hex/rgb colors it will get messy + the only information we actually do have is hex colors.
We would have to manually convert them to hsl/rgb if we needed to. Then, which should be pick - rgb or hsl?"Should it be a config option? + You can already see what the color is from the completion menu. It introduces so much unnecessary complexity and not worth it at all imo

I agree that adding a RGB or HSL option is probably not worth the effort. My main point was that annotating each color as 'color' is redundant.

it's for accessibility, since not everyone can recognize differences between colors

@nferhat
Copy link

nferhat commented Dec 27, 2024

Nice stuff! Can be easily merged with #12151

CedricMeu pushed a commit to CedricMeu/helix that referenced this pull request Jan 2, 2025
GladkihEgor pushed a commit to GladkihEgor/helix that referenced this pull request Jan 4, 2025
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.

7 participants