Document Color support #13122
Labels
A-ide
general IDE features
C-feature
Category: feature request
S-unactionable
Issue requires feedback, design decisions or is blocked on other work
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 wellThe text was updated successfully, but these errors were encountered: