microsoft / language-server-protocol

Defines a common protocol for language servers.
https://microsoft.github.io/language-server-protocol/
Creative Commons Attribution 4.0 International
11.32k stars 803 forks source link

Add support for icons (like colors) #1225

Open Khaos66 opened 3 years ago

Khaos66 commented 3 years ago

There is a way for a language server to return colors found in the code. But I miss a way to do the same with icons/images. Some editors display icons referenced in code so that the developer can visually see the icon and not only the path or name of the icon. The LSP should specify a way to tell a client about icons or images found in the code. I guess there are two possibilities for the payload:

  1. a path to the icon
  2. the icon data itself (probably best encoded as Base64)

I hope to see this feature in the near future. Would be good for CSS and other languages with images.

dbaeumer commented 3 years ago

I am not sure I understand you request. Where should these icons show up?

Khaos66 commented 3 years ago

Well, of course there needs to be editor support added for this as well to actualy show up. But I was asuming that there needs to be LSP support for that feature first.

Anyway, here is how this could show up. Have you ever used Android Studio? There icons referenced in code are displayed on the left side of the line. This picture taken from A StackOverflow question should help you understand Preview

I'm not saying, that this is how editors should display the icons. It's just one way. I like how VSCode displays colors right next to the color code. Maybe this could be a valid way to display icons in code as well Preview

angelozerr commented 3 years ago

I think @Khaos66 would like to have a LSP request IconInformation that it could be consumed in CSS language server for instance to display the icon on the left of background-image (like for ColorInformation for CSS color)

[LIZARD_ICON] background-image: url("../../media/examples/lizard.png"); 
dbaeumer commented 3 years ago

Understood.

kjeremy commented 3 years ago

@DanTup

This would be really nice in flutter where you already get icons on hover.