[FEATURE] Let users register custom syntax grammars (e.g. TextMate) for code highlighting
Preflight Checklist
- [x] I have searched existing requests and this feature hasn't been requested yet
- [x] This is a single feature request (not multiple features)
Problem Statement
I develop a programming language whose keywords and punctuation are Chinese characters. Whenever Claude Code shows code in this language, the fenced block renders as plain monospace text: the highlighter only knows its built-in languages, and there is no way to add one. Every language outside the bundled set has the same problem (e.g. GDScript in #48181).
What I see today (Claude Code 2.1.179, macOS):
- CLI: code blocks go through highlight.js. For an unknown tag it logs
Language not supported while highlighting code, falling back to plaintextand prints the block uncolored. No setting loads extra languages. - Desktop app (Code tab): the app bundle includes Shiki, but there is no setting to add grammars.
- VS Code extension: the chat panel has no syntax highlighting yet (#64968).
We already maintain a TextMate grammar for this language in our VS Code extension. The grammar exists; Claude Code just has no way to use it.
Proposed Solution
Let users register extra grammars, keyed by language tag and file extension, in one format that every surface understands. TextMate grammars are the natural choice: VS Code extensions already ship them, and Shiki and vscode-textmate load them directly.
For example, in settings.json:
{
"syntaxHighlighting": {
"languages": [
{
"id": "mylang",
"aliases": ["MyLang"],
"extensions": [".mylang"],
"scopeName": "source.mylang",
"grammar": "~/.claude/grammars/mylang.tmLanguage.json"
}
]
}
}
Code blocks tagged mylang or MyLang, and diffs and file previews of .mylang files, would then be highlighted in the CLI, the desktop app and the VS Code extension. Plugins could ship grammars the same way, so installing a language's plugin also brings its highlighting.
If a TextMate engine is too heavy for the CLI, accepting a highlight.js language definition there would also work.
Alternative Solutions
- Tagging blocks as a similar built-in language: no bundled grammar understands CJK keywords or delimiters, so little or nothing gets colored.
- Opening the file in VS Code, where our extension highlights it. This moves the code out of the conversation.
- Having Claude render the code into a separate HTML page that loads our grammar with Shiki. Possible, but far too heavy for everyday snippets.
Priority
Medium - Would be very helpful
Feature Category
Configuration and settings
Use Case Example
- I ask Claude Code to explain or change a function written in my language.
- It answers with the code in a fenced block tagged with the language's name, plus a diff of its edit.
- Today both render as plain text, so I read keywords, strings and comments with no visual cues.
- With a registered grammar, they would look the same as in my editor.
Additional Context
Related issues; none of them asks for a way to add languages:
- #48181: GDScript has no highlighting. With a registration mechanism, users could fix cases like this themselves.
- #64968: no highlighting at all in the VS Code extension chat panel.
- #42189: custom theming + syntax highlighting plugin API; auto-closed as a duplicate of #25366, which is about color themes.
- #48636: customizable highlighting colors.