[Feature Request] official guide for wiring TextMate grammars #3830
Replies: 3 comments 1 reply
-
@alexdima sorry to ping, but do you have any advice here? I'm really stuck on this issue 😕 my latest attempt was forking the monaco-tm example and following your answer here, but I just get black text I think possibly because the colorMap is only returning For context, I'm trying to create a Next.js plugin that sets up TextMate grammars automatically. |
Beta Was this translation helpful? Give feedback.
-
I don't know this is suitable for you, but you can monaco-vscode-api to use textmate grammer for syntax highlighting. |
Beta Was this translation helpful? Give feedback.
-
I also struggled with the same problem, and I ended up making this thing. It works pretty well and I use it for most of my projects involving |
Beta Was this translation helpful? Give feedback.
-
Context
Description
Hello, I've been struggling to find a solution that works with TextMate grammars and the latest releases for
monaco-editor
andmonaco-editor-webpack-plugin
. I've tried following the linkedmonaco-tm
package and the issue here #1915, but it seems some of the theme helpersgenerateTokensCSSForColorMap
,TokenizationRegistry
, andColor
are no longer available. I even read the wonderful blog post about the deep dive into how it's all working to try and better diagnose the issue and just can't seem to get any solution to work.I previously had this working using
monaco-editor-textmate
, but that has recently broke betweenmonaco-editor
versions0.29.1
and0.30.0
zikaari/monaco-editor-textmate#26.I've managed to distill the wiring of textmate down to the solution below based on
monaco-editor-textmate
and theia. I know it's not the most performant route per se, but I was hoping to use monaco as an enhancement on top of server-rendered shiki code blocks so this will be loaded on demand if someone wants to play around with code examples.For some reason between those versions of the editor, the matched foreground (
tokenTheme._match(scope)._foreground
) has changed and is now returning a different foreground in some cases causing the syntax highlighting to be off.I was going to file as a bug, but since there is no official guide and these are accessing private APIs it makes sense they are prone to breaking. Is it possible this is something on the roadmap or in the meantime there is a solution to workaround this until official guides/utilities might be available? I appreciate any help and understand there are a lot of moving parts here to make this all work.
Monaco Editor Playground Link
No response
Monaco Editor Playground Code
No response
Beta Was this translation helpful? Give feedback.
All reactions