[Feature]: Load user-provided code snippets into the Monaco editor
- Dominant language
- TypeScript
- Stars
- 72.1k
- Forks
- 4.7k
- Avg merge
- 14h 54m
- Merged PRs (30d)
- 520
Description
### Problem or use case
Orca does not currently provide a user-facing way to add editor snippets for unsupported languages, private DSLs, or frameworks. A user may want to type a prefix such as `component` or `route` and insert a template with tab stops and placeholders, but adding that behavior currently requires modifying Orca source and rebuilding the application.
This is separate from syntax highlighting: grammars classify text for colors, while snippets are Monaco completion items that insert structured text. Custom syntax highlighting is tracked in #8093, where completion is intentionally listed as a non-goal.
### Proposed solution
Add a small client-side mechanism for loading user-provided snippet files into Monaco.
A narrow initial implementation could:
- accept one or more local JSON or `.code-snippets` files using the common VS Code snippet shape
- support the common fields `prefix`, `body`, `description`, and `scope`
- let users explicitly associate a snippet file or pack with one or more Monaco language IDs
- register suggestions with Monaco through `registerCompletionItemProvider`, `CompletionItemKind.Snippet`, and `CompletionItemInsertTextRule.InsertAsSnippet`
- support standard tab stops and placeholders such as `$1`, `${1:name}`, and `$0`
- show multiple suggestions rather than silently overwriting entries when prefixes collide
- validate unreadable or malformed files and surface a clear error without breaking the editor
- apply snippets in the normal source editor for both local and SSH/remote files, while loading and executing the snippet definitions locally in the renderer
- allow a restart for newly added or changed snippet packs in the first version; live reload can be added later
Snippet packs should be able to target existing Monaco language IDs and any custom IDs registered through the grammar-loading capability proposed in #8093.
For framework snippets, explicit language scoping is sufficient for an initial implementation. Automatic framework detection is not required: Orca currently maps `.tsx` and `.jsx` to the base `typescript` and `javascript` Monaco IDs, so reliable React/Vue/etc. detection would be a separate concern.
Non-goals for this request:
- no language-server or LSP integration
- no syntax-highlighting or grammar loader; that is #8093
- no semantic completion or project-aware IntelliSense
- no VS Code extension host or Marketplace compatibility
- no executable JavaScript plugins
- no automatic framework detection in the initial implementation
### Alternatives or additional context
A small set of hard-coded snippets would be relatively straightforward because Orca already registers a Monaco completion provider for Markdown document links. That would not solve the user-extensibility problem, however, and every new language or framework pack would still require an Orca source change and rebuild.
The main implementation work is therefore not Monaco insertion itself. It is defining and validating the supported snippet-file subset, storing user registrations, scoping packs to language IDs, managing provider lifecycle and reloads, and handling conflicting prefixes predictably.
Related issues:
- User-provided TextMate grammars for custom syntax highlighting: #8093
- Configurable Monaco editor theme: #6308
This request should remain separate from #8093 because tokenization and completion use different Monaco APIs and can be implemented and released independently.
Contributor guide
Assessment
This issue has not been assessed yet.