dotnet / interactive

.NET Interactive combines the power of .NET with many other languages to create notebooks, REPLs, and embedded coding experiences. Share code, explore data, write, and learn across your apps in ways you couldn't before.
MIT License
2.88k stars 382 forks source link

Let extension developers provide their own syntax highlighting rules on user defined kernels #1522

Open Lawlzee opened 3 years ago

Lawlzee commented 3 years ago

Is your feature request related to a problem? Please describe. As an extension developer, I would like to be able to provide syntax highlighting for my custom kernels. In my case, I am interested in providing syntax highlighting for a Razor kernel in VS Code.

Describe the solution you'd like I would like if to be able to an interface named ISupportSyntaxHighlighting that you implement in a custom kernel so that the kernel supports user defined syntax highlighting rules.

I am not sure how syntax highlighting works on all front-ends, but it would be great if ISupportSyntaxHighlighting would work the same way for all front-ends.

If syntax highlighting works in a different way for all front-ends, maybe the best solution could be to add an interface for each front-ends. For example, ISupportSyntaxHighlightingForVsCode for VsCode, ISupportSyntaxHighlightingForBinder for Binder, etc.

Describe alternatives you've considered I don't think their is any.

jonsequitur commented 3 years ago

Right now, syntax highlighting is VS Code-specific, and not controlled by the kernel, so it has to be defined statically in the VS Code extension using a TextMate grammar. Here's an example: https://github.com/dotnet/interactive/blob/6c11524ece389b7d553a547a679986824522f203/src/dotnet-interactive-vscode/stable/syntaxes/source.dotnet-interactive.magic-commands.tmGrammar.json#L0-L1

In the future we'd like to add support for semantic highlighting and ideally find a way for this to be extensible from the kernel, though I'm not sure VS Code's APIs support this dynamically.