Merged
Conversation
Modelled after the custom theme registration. I don't have an easy way to test this but i believe it _should_ just work
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
There was a problem hiding this comment.
Pull request overview
Adds an API to register and use custom Shiki languages (dynamic loaders + filename/extension mapping) so syntax highlighting can work for non-bundled grammars.
Changes:
- Introduces
registerCustomLanguageand a custom language registry used by language resolution. - Extends filename/extension-to-language detection to support custom mappings.
- Updates public types/exports and docs to reflect custom language support.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/diffs/src/utils/setLanguageOverride.ts | Updates typing for language overrides (now via overloads). |
| packages/diffs/src/utils/getFiletypeFromFileName.ts | Adds a custom mapping Map and checks it during language inference. |
| packages/diffs/src/types.ts | Expands SupportedLanguages to allow custom string language IDs. |
| packages/diffs/src/index.ts | Exports the new registerCustomLanguage API. |
| packages/diffs/src/highlighter/languages/resolveLanguage.ts | Resolves languages from either bundled Shiki loaders or registered custom loaders. |
| packages/diffs/src/highlighter/languages/registerCustomLanguage.ts | New API to register custom language loaders and optional extension/filename mappings. |
| packages/diffs/src/highlighter/languages/constants.ts | Adds storage for registered custom language loaders. |
| apps/docs/app/docs/page.tsx | Wires the new utility example into the docs page rendering/preloading. |
| apps/docs/app/docs/Utilities/content.mdx | Adds documentation section for registerCustomLanguage. |
| apps/docs/app/docs/Utilities/constants.ts | Adds a runnable docs helper snippet demonstrating registerCustomLanguage. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
amadeus
added a commit
that referenced
this pull request
Jan 29, 2026
* Add support for custom shiki language grammars Modelled after the custom theme registration. I don't have an easy way to test this but i believe it _should_ just work * Add docs for custom language registration * Code review * Throw if trying to register text or ansi
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.
A quick side quest for #301
Essentially this re-creates a language registry for custom shiki grammars. I haven't been really tested this yet though, but I think it should just work.
Basically I created a registration API like custom theme where you provide a language, a loader and some file extensions/filenames to map the language to. Then just rely on automatic language detection or utilize language overrides:
Fixes #301