Skip to content
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

Provide an API for advanced/semantic source highlighting #585

Open
seanmcbreen opened this issue Nov 24, 2015 · 48 comments

Comments

@seanmcbreen
Copy link
Contributor

commented Nov 24, 2015

From @Wosi on October 13, 2015 14:22

I'm looking for a way to implement an advanced source highlighting
where a language service changes the color of words in a file. The result would look similar to the output Visual Studio creates in C# files.
The screenshot shows C# code in Visual Studio. The word "Customer" is highlighted differently based on its context:
advancedhighlighting

To implement highlighting like this it's necassary to let a language service decide about the color of a word after the grammar based highlighter has done its job.
I would like to see an API for this in the future.

Copied from original issue: Microsoft/vscode-extensionbuilders#14

@seanmcbreen

This comment has been minimized.

Copy link
Contributor Author

commented Nov 24, 2015

From @egamma on October 13, 2015 14:40

The request makes sense OmniSharp supports semantic coloring and we currently have no API to expose this support.

@seanmcbreen

This comment has been minimized.

Copy link
Contributor Author

commented Nov 24, 2015

From @Krzysztof-Cieslak on October 13, 2015 14:43

👍 Same can be used for F# - Visual F# Power Tools for VS and F# support in Xamarin Studio are both using semantic highlighting.

@jrieken jrieken added feature-request and removed enhancement labels Nov 25, 2015

@jrieken

This comment has been minimized.

Copy link
Member

commented Nov 25, 2015

We are close but we are missing meta-colours ala the-color-of-a-keyword

@Krzysztof-Cieslak

This comment has been minimized.

Copy link
Contributor

commented Jul 4, 2016

Any progress with it? :)

@vilic

This comment has been minimized.

Copy link

commented Jul 19, 2016

Desperately want to know whether there've been any progress on this.

@NPatch

This comment has been minimized.

Copy link

commented Sep 5, 2016

Me2. Could you or will you expose it as json settings kinda like settings.json or keybindings.json?

@DustinCampbell

This comment has been minimized.

Copy link
Member

commented Sep 23, 2016

Would love to see this happen. Honestly, it'd be great to have a way to provide colorization without a textmate grammar. The C# extension has incredibly accurate colorization information already available to it in OmniSharp (using the same Roslyn APIs that are used to colorize VS).

@nfantone

This comment has been minimized.

Copy link

commented Sep 23, 2016

This would be extra nice. And if what @jrieken said a year ago still holds true, it shouldn't be extra hard to implement.

@troshko111

This comment has been minimized.

Copy link

commented Oct 12, 2016

Opened similar issue before found this one, since Atom is already doing this to some extent (semantic highlighting based on omnisharp data, not regexp tm grammar) I would love If you guys could prioritize this higher and move from backlog, imo this is huge improvement to the productivity and can be a true killer feature

@alexandrudima alexandrudima removed their assignment Oct 27, 2016

@ferologics

This comment has been minimized.

Copy link

commented Dec 13, 2016

+1 ⌨️

@kobalicek

This comment has been minimized.

Copy link

commented Dec 21, 2016

Not just that, customizing some keywords based on project would also be amazing, there is a lot of C++ code that relies on macros or uses some specifics, and ability to highlight that "easily" would be nice.

@Wosi

This comment has been minimized.

Copy link

commented Jan 10, 2017

Do the changes made for #18317 bring us closer to semantic highlighting?

@kobalicek

This comment has been minimized.

Copy link

commented Jan 10, 2017

Suppose I want to highlight my own keywords / variables, how can I test this?

My solution https://github.com/kobalicek/reloaded-cpp is just a hack at the moment, rewriting it to use existing C++ parser and just hooking it to my own symbol highlighter would be the way.

@MathiasMagnus

This comment has been minimized.

Copy link

commented Oct 9, 2018

I'd love to use VS Code prime time for C++ development, but the lack of proper C/C++ coloring is a deal breaker. I'm currently refactoring a huge CMake-ified C code base and it's crucial to get proper coloring in order to see if a given typedef/macro is visible in the given compilation unit (and perhaps see what it expands to in the given configuration). Dimming inactive code regions is a must. There's too much text to hover over and see if IntelliSense lights up. Coloring is infinitely faster.

I honestly cannot imagine how other languages get by in VS Code without this ability.

@dannymcgee

This comment has been minimized.

Copy link

commented Jan 3, 2019

Happy New Year!

+1 for this. I'm a little bit obsessed with syntax highlighting and it drives me absolutely bonkers that Intellisense recognizes this as a class, but the syntax highlighter just sees it as a generic variable.

semantic-highlighting-plz

@MathiasMagnus

This comment has been minimized.

Copy link

commented Jan 8, 2019

@dannymcgee You know what drives me bonkers? That collaborative code editing with remoting an entire session over the wire, even across IDEs of different flavors is implemented before text coloring. 🤯

@bn-l

This comment has been minimized.

Copy link

commented Jan 14, 2019

@dannymcgee You know what drives me bonkers? That collaborative code editing with remoting an entire session over the wire, even across IDEs of different flavors is implemented before text coloring. 🤯

QOL improvements are hard to point at in meetings and say "hey, look, I did that!"--no matter how useful or how requested they are.

I honestly cannot imagine how other languages get by in VS Code without this ability.

yup.

@MathiasMagnus

This comment has been minimized.

Copy link

commented Jan 14, 2019

@bn-l I can imagine, but isn't the entire purpose of an IDE is QOL? :) I write template-heavy code in C++, or I'm porting macro-heavy C code, and coloring something with the given compiler options makes all the difference in the world. In fact, I'd gladly free that 8 GB of space my big VS install takes and never look back if this feature were implemented. Until then, I'll keep enjoying cross-platform squigglies which probably won't come to VS Code, like ever.

@oktonion

This comment has been minimized.

Copy link

commented Jan 15, 2019

Could we just take a second to appreciate the lots of attention to the issue that is just hanging there like 3+ years with more than 260 likes and is a request for basic feature that any Intellisense-like code highlighter has. 👍🏼

@RacerDelux

This comment has been minimized.

Copy link

commented Jan 28, 2019

@oktonion The lack of this feature is the ONLY reason I do not use vscode. I have just gotten so used to it, and it is a very helpful feature.

@mdsitton

This comment has been minimized.

Copy link

commented Feb 2, 2019

Yeah same every time I come around to try out vscode. I run into this issue and end up searching for themes that work well with my language of choice for hours before giving up and moving back to whatever other editor(usually sublime text).

@KamasamaK

This comment has been minimized.

Copy link

commented Feb 2, 2019

Since people continue to post here asking for this and in case anyone didn't see, this is already on the Roadmap for 2019.

@kerams

This comment has been minimized.

Copy link

commented Feb 2, 2019

@KamasamaK It's been on there since at least 2017 (as semantic highlighting).

@MathiasMagnus

This comment has been minimized.

Copy link

commented Feb 2, 2019

@mdsitton I do the same. On a fresh install I only had the MSVC build tools and Code installed as my primary (and only editor). I managed for half a year when cross-platform builds and squiggles arrived for VS and I changed back. It's light years ahead. I could live with having to fire up two Code instances (one on Windows and one inside WSL), but the semantic coloring has been in VS since... forever? Not having coloring, inferior debugging capabilities, one of the cutting-edge CMake goodies... It's too much to give up when I'm already on Windows.

@KamasamaK

This comment has been minimized.

Copy link

commented Feb 2, 2019

@kerams You're right. I was about to say it was promoted from "stretch goal", which is how it was classified since the initial 2018 roadmap was published, but to be honest now I'm not sure since I see nothing is classified as a stretch goal right now.

@mdsitton

This comment has been minimized.

Copy link

commented Feb 8, 2019

Good to hear that it's finally on the roadmap. I also finally found a theme that handles C++ and C# semi acceptably "Kary Pro Colors". Looks like I may be finally trying it out for a more extended period of time for once.

Still looking forwards to this being implemented!

@SamB

This comment has been minimized.

Copy link
Contributor

commented Apr 19, 2019

The standalone variant of the editor, "Monaco", provides something sort of like ITokenizationSupport: https://microsoft.github.io/monaco-editor/api/modules/monaco.languages.html#settokensprovider

We might want something a bit different from Monaco here, though, because:

  1. Maybe we don't want to have to choose between "fast" and "with named scopes" on a per-language basis
  2. The "EncodedLanguageId" bits seem ... fiddly
    • What can we do with these other than set them to the wrong value?
  3. I imagine that doing an RPC per line might be somewhat expensive. The JavaScript API could easily abstract over whatever optimizations might be appropriate, but the LSP clearly cannot. (And you're gonna need the LSP support to talk to Roslyn, right?)
  4. Of course, LSPs will also need some source locations so they can find the code in their data structures...

I'm thinking injection grammars would probably not be viable here, but embeddedLanguages shouldn't be too hard.

@gulshan

This comment has been minimized.

Copy link

commented May 21, 2019

This tree-sitter based syntax hailighting seems pretty advanced-
#50140 (comment)

@gulshan

This comment has been minimized.

Copy link

commented Aug 9, 2019

Relevant #77140 and #77133

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.