rust-lang / rust-lang/rust-analyzer
Document Color support
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 16.9k
- Forks
- 2.2k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 72
Description
The LSP has this interesting feature for document color requests https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_documentColor which allows a client to ask a server for color-like things in a document, giving the client the ability to render color swatches and the like to edit these color-like things. Now rust as a language doesn't have the concept of first class colors, but there are several libraries that model colors and I believe we can make this feature work for those.
As an example for palette::rgb::Rgb::new(0.0, 0.0, 0.0) we should be able to make use of this feature. But this will certainly require information from the library/user code itself, building heuristic for this is non-feasible, but there is something we will hopefully have in the future that will allow libaries/user code to give r-a the needed information, tool attributes.
So I would envision this as something like #[rust_analyzer::color(red, green, blue)] that you can attach to function definitions, where the components would match up with the functions arguments. Obviously this would need to be fleshed out more, are there more thing this would apply to than just function calls? What about hex strings, we wouldn't want to always interpret them as colors, but there should probably be a way to support these in some fashion as well
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the LSP documentColor specification and the linked rust-analyzer tool-attributes issue. Define how library or user-code metadata, including the proposed color attribute and possible hex strings, should identify color values and map their components. Done requires an agreed design and corresponding implementation and tests, but this issue names no files or existing test entry point.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- devtools
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100