Repository navigation
Conversation
Languages were hardcoded in filetype.ts and parsers-config.ts. Add a `languages` map to cli.json and `context.languages.register()` for TUI plugins, both feeding one registry that maps extensions and registers the grammar wasm and highlight queries with OpenTUI. cli.json overrides plugins, and an override of a built-in falls back to it when removed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
|
The following comment was made by an LLM, it may be inaccurate: |
Contributor
There was a problem hiding this comment.
Looks good. With a cli.json languages entry pointing at OpenTUI's bundled zig grammar, a fence using the custom ID is plain text on the base and highlighted with this PR (screenshots below). The new tests and the tui and plugin type checks pass. I also checked that OpenTUI's addFiletypeParser replaces an existing parser while the worker is running, so overriding a built-in works, and that toolFiletype behaves the same as before for run and ACP.
Public API (all additive, backwards compatible):
- Plugin API: new
context.languages.register(definition) => unregisterand an exportedLanguageDefinitiontype in@opencode/plugin/tui/context. - Config: new optional
languageskey incli.json(record of{ extensions?, wasm, highlights, injections? }).
No blocking concerns.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Issue for this PR
No open issue. This is the feature requested in #18587, which was closed as stale.
Type of change
What does this PR do?
TUI languages are hardcoded in
parsers-config.tsandutil/filetype.ts, so each new language needs its own PR (#42902, #6406 and #17386 were all auto-closed), and in-house or niche languages can't be added at all. This lets users add tree-sitter languages themselves:languagesincli.json(paths relative to the file) andcontext.languages.register()for TUI plugins.util/languages.ts. It maps extensions forfiletype(), then hands parsers to OpenTUI withaddDefaultParsers, oraddFiletypeParserwhen the worker is already running.cli.jsonwins over plugins.Removing an override of a built-in restores the built-in.
filetype.tsgets the registry through a small setter, so@opencode/tui/mini/tool(used byrunand ACP) doesnot start importing OpenTUI. Mini's
toolFiletypenow reusesfiletype()instead of a copy of it.How did you verify your code works?
decoding, and a real highlight through the shared worker using OpenTUI's bundled zig grammar (no network).
```elmfences are highlighted inbun dev, through bothcli.jsonand a.opencode/plugins/elmplugin.bun run check(lint and typecheck of every package) passes.Screenshots / recordings
Screenshots to follow.
Checklist
🤖 Generated with Claude Code
Added by the opencode bot (AI-generated).
Public API: adds
languagesto cli.json andcontext.languages.register()/LanguageDefinitionto the TUI plugin API (backwards compatible)