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

Feature Request: add a code snippet component #500

Open
guiherzog opened this issue Jul 14, 2023 · 0 comments
Open

Feature Request: add a code snippet component #500

guiherzog opened this issue Jul 14, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@guiherzog
Copy link

Feature request

Provide a simple component that can render code snippets in a webview with syntax highlighting, themes, and settings considered.
They could be read-only initially, but perhaps making the editable could make sense.

I think in general, we strongly prefer creating editors or using VS Code's builtin APIs for showing code (peek view, etc).
However, there are several use cases, such as a conversational language model describing some code mixed with text, where having a small code snippet rendered would be nice.

Perhaps the implementation could be from wrapping around a Monaco editor in a web-component (example) that takes VS Code variables or some wrapping around settings, I did not invest much time thinking on the implementation, but I could after hearing your thoughts.

Expected behavior

We could be able to render small snippet with all the settings and themes coming from VS Code.
I imagine something like this.

<vscode-snippet language="typescript">
   function foo(bar: string) {
       return 'fuzzy wuzzy was a bear';
   }
<vscode-snippet>

Current behavior

Currently, it's not possible, we have a few options:

  1. Highlighting them manually based on some pre-defined semantic coloring and use a code mirror editor (similar to what chrome devtools does).
  2. Show a standalone Monaco editor similar to this example. The issue with this one is that, themes are not loaded by default, and user settings are not respected (font-size, indentation, etc).

Use case

We have several use cases:

  • Rendering snippets coming from ML extensions / LLMs.
  • Rendering snippets of search results from our custom code search extension.
  • Rendering inline code for our bug tracking extension.

Screenshots/references

This is similar to #315.

@guiherzog guiherzog added the enhancement New feature or request label Jul 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant