-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Support icon previews in editors via the analysis server #47667
Comments
@jacob314 @bwilkerson FYI - this cropped up again today in flutter/flutter#102560. Some questions I'm still not sure of the answers to:
I think it would be nice to avoid depending on Flutter, but I don't know if it's feasible (for example if it was the |
That would certainly be my preference. I don't understand enough about the situation yet to know whether doing so is practical. |
To make it work for non-standard icon packages we'd need some way to identify which packages were icon packages and which files in the package were font files. It would be nice if that could be added to the package itself, perhaps in the YAML file. In the IntelliJ plugin, I added a preference field where users could identify which packages were icon packages then used some heuristics to locate font files. All those I looked at included a class with a static field for each icon and I used additional heuristics to find those Dart files and use them to gen-up completion data. The one thing Flutter and Java have that Dart might not have is a library for reading TTF/OTF font files. |
The top priority is to support all Flutter icons from 1P and 3P Flutter packages.
It would also be nice leverage the analysis server / analyzer functionality for resolving icons to help DartDoc include previews of icons even if the author doesn't do anything special in the doc comments. That would also ensure that all are icon renders are consistent. For example: It would also make the doc comments for the Flutter icons cleaner if they didn't have to include HTML to render the icons. Right now that HTML is just noise if you jump to definition of an icon. |
We might also be able to show previews in hovers. |
Do you mean previews on hover when debugging or some other hover use case? |
I was thinking about the editing experience in the IDE. I have no idea whether there would be enough information in the debugger to provide that kind of feedback. |
My understanding is that this HTML is there to support the generated Dartdoc HTML on the web. Currently VS Code is regex-ing it out to replace with local icon previews but if we start appending/prepending icon previews into all
Yeah, this might be reason to have the Flutter tool generate previews - although that might mean it would have to create them all up-front (eg. in the hook after running |
I'm working on flutter/flutter#102560, which will be the replacement for Flutter's There is a new annotation,
Correct. The CSS class |
Out of curiosity, where is the annotation defined? |
@staticIconProvider
class Symbols {
...
/// <i class="material-icons-outlined md-36">10k</i> — Material Symbol `10k`.
/// https://fonts.google.com/icons?selected=Material+Symbols+Outlined:10k&icon.platform=flutter
static const IconData ten_k = IconDataOutlined(0xe951);
... If the HTML here is specifically for Dartdoc (which I presume is the only client that has the correct CSS/fonts set up that it would render correctly), could this be extracted to something that the server/clients could understand more easily? For example, the embedded YT videos look like:
Showing something similar (for ex.
I thought this was the case, but while just looking around I came across this: https://code.visualstudio.com/api/references/icons-in-labels#icon-contribution-point This seems like it may be possible to provide a
We can use svg too, although I'm not sure if that's exactly what you were after. |
@guidezpl Please have a look at a spec for adding icon preview support to the analysis server. It mentions a C program to generate icons. I expect to have that up on GitHub within a few days. |
Similar to how the analysis server will provide color previews to editors, it would be nice if icon paths for previews could also be provided.
Right now Dart-Code ships a full copy of the Flutter's Material/Cupertino icons in the extension and adds gutter icons based on text names. This doesn't scale very well to third party packages, needs duplicating in each editor using the LSP server, and doesn't version with the package/SDKs (all users get the same icon previews regardless of their version). It also makes the extension quite large (right now, ~99% of the Dart-Code extension file is icon previews).
@stevemessick has done some work on generating the previews from a font file in IntelliJ (flutter/flutter-intellij#5504, flutter/flutter-intellij#5595) but it has better access to things like ASTs than LSP-based editors so it would be better implemented in the server for those.
The text was updated successfully, but these errors were encountered: