microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
160.52k stars 28.1k forks source link

Feature request: prettify symbols mode #171074

Open voronoipotato opened 1 year ago

voronoipotato commented 1 year ago

Feature request: Emacs/Vim/Neovim has a cool feature called "prettify symbols mode," demonstrated for Haskell here. (called conceal in vim/nvim)

This is an intentional reopening of #2402 as it was closed despite public interest.

To put in simpler terms. It would be nice to have custom "ligatures" defined in the editor settings, by language, without making a custom font, and ideally capable of being context sensitive as is done in other major editors. It would be very nice if I could see what the symbols-prettifier aka "conceal" replaced when I hover over said symbol.

This is an intentional reopening of #2402 as it was closed despite public interest. I believe there was a misestimation public interest in the backlog cleanup, in part because the description was a bit technical. The extension Prettify Symbols Mode which does not work correctly, but people use it anyway has 16k downloads and a 4 star rating. This feature is very useful for many programming languages which have verbosity for historical purposes and making a ligature for it is laborious or in many cases fully impossible. This pushes language designers to recommend other editors like emacs (prettify-symbols-mode), vim (conceal), or neovim (conceal) which support this feature natively without extensions. It would be very helpful if vscode supported this useful feature available in other major editors. There's many more arguments for this feature in the main feature request. I understand that ligatures are pretty good for most, but they are also quite limited, and you may have a font that does not support the one ligature you want. A good example of this is in Microsoft's F# where it would be very nice for readability to have "fun " translate to "λ" without breaking the editor. It feels very weird recommending emacs/vim/nvim for a microsoft run language but there is no clear way forward.

voronoipotato commented 1 year ago

Apologies for any typos or errata, I'm trying to get this documented on my lunch break before I forget. Said "ligatures" do not need to support any custom symbols or kerning changes, I can use my existing ligatures for that. This is so I can redirect to existing symbols in my font that are not correct for the language I am using. fun -> λ comes to mind. It would also be very nice if I were able to write an extension that leverages this, such as a context aware "ligature".

ken-okabe commented 1 year ago

+1 for this feature request.

I've never recognized a feature like this in the majoir IDE(Emacs/Vim/Neovim) eco, so I personally developed an extention Lambda for fun F# for my own use, but somewhat hard to use in realworld coding.

You also emphasized which does not work correctly for the notable extension: Prettify Symbols Mode . We probably want to know what exactly does not work correctly there and how possibly the native implementation could solve the issue. Thanks.

voronoipotato commented 1 year ago

Firstly there's the awkwardness you mentioned in your issue where it doesn't work quite like a ligature. However there's additional issues in this plugin (that may be fixable) and I believe it has to do with trying to use "after" where replacements will show in the wrong place, or not refresh properly. Substitutions do not work in previews. I'm seeing there's a fork of this extension which is currently maintained https://marketplace.visualstudio.com/items?itemName=BRBoer.vsc-conceal but the same issue is happening there too https://github.com/Pancaek/vsc-conceal/issues/2 . I have not seen these issues in emacs and vim in my experience.

ken-okabe commented 1 year ago

Firstly there's the awkwardness you mentioned in your issue where it doesn't work quite like a ligature.

Well, I thought the demand for replacing fun with other characters is strong and fundamentally my fslang-suggestion is solely requesting that at the language level, and you also have mentioned Make the fun keyword optional in the same context I observed.

I will try both extensions you introduced.

voronoipotato commented 1 year ago

It's strong in that people agree it's an eyesore. It's not strong in that the proposed language changes for it are genuinely worse in certain scenarios. It would be nice to have an editor feature like emacs/vim/nvim has so you don't need to wait for this in every language or create a custom font for each language you use. Thank you for attempting this in an extension, I wasn't aware of your effort and I think it's cool.

ken-okabe commented 1 year ago

Speaking of F# matter, which I think is the common demand for this kind of feature request, I still believe there is a silent majority who favor an optional shorter syntax for F# lambda at the language level, observing the threads. Many unspoken. However, the idea seems to be very unpopular with the leading developers and some people. I like it at the language level, and you don't like it, that is POV. With the disagreement after all, as you say, this IDE-level solution is not limited to the specific issue but is versatile for other applications, so I really hope this feature is natively implemented. Even for my own extension, I would prefer the native general feature so I can recommend others to use it casually.

PS. Although I need to evaluate the behavior more, the VSextension Conceal works great for me so far (behaves better than Lambda for fun F#). Thanks for letting us know about this extension.

I really wish this become native, like Bracket Pair Colorizer 2...

voronoipotato commented 1 year ago

@stken2050 yeah, for me it matters because many beginners often benefit from verbosity, but within a domain; experienced users benefit from being able to see a terse representation. Imagine if you could show abstractsingletonproxyfactorybean as aspfb, and when you hover over it you see abstractsingletonproxyfactorybean, it would be huge. It's analogous to semantic compression for the symbolic representation. The ability to compress words into symbols (and vice versa) is extremely useful. It could also be used with a personal translation dictionary file to represent words in a language you are more familiar with, or symbols or acronyms that are easier to read, and it goes both ways. Domain non-experts could "de-acronym" their code, which would be INCREDIBLY USEFUL. I think the preference for infix representations is broadly a historical misstep, since it means adding operators have to fit in a larger nigh impossible to remember precedence list. The only reason why we actually prefer mathematical like expressions in a specialized domain is the compactness. Conceal-mode aka prettify-symbols-mode affords for that compactness for domain experts without killing the beginners.

Enivex commented 1 year ago

This would be especially useful for Latex with https://marketplace.visualstudio.com/items?itemName=James-Yu.latex-workshop

The existing https://github.com/Pancaek/vsc-conceal, while cool, is both too limited (for instance, it cannot use capture groups), slow, buggy, and not really actively maintained. Such a feature could really benefit from being built-in.

VSCodeTriageBot commented 1 year ago

This feature request is now a candidate for our backlog. The community has 60 days to upvote the issue. If it receives 20 upvotes we will move it to our backlog. If not, we will close it. To learn more about how we handle feature requests, please see our documentation.

Happy Coding!

VSCodeTriageBot commented 1 year ago

:slightly_smiling_face: This feature request received a sufficient number of community upvotes and we moved it to our backlog. To learn more about how we handle feature requests, please see our documentation.

Happy Coding!

aloispichler commented 5 days ago

What is the status, one year later?

voneiden commented 5 days ago

Same as one year before?