New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Associate file type to an existing text editor syntax highlight or a custom one. #7427
Comments
I finally found a solution. The key is this little line: Mode.getModeInfo().push(). I found the answer by exploring the source code and with the help of #7143, so thanks @wolfv. I will also post the answer in #4223 for reference. First, here's the complete code I used to associate file type to a specific text editor syntax highlight:
You will need those 3 dependencies in your "package.json" for this code to work: About this code:
I hope this will be help some people with this problem 🙂 |
Thank you very much! I think this would be a great "recipe" addition to the docs. |
Would you mind contributing to the docs? Or if you don't have time, would you mind if someone else packaged up your comments above as a new doc on how to do this? |
I'm not realy good with documentation and stuff and I don't realy have the time right now to do it. But I don't mind at all if some one else packaged up my comments as a new doc. In fact it would be my pleasure. Just to help a little bit with that, I edited my comment with some spelling correction and rewording (I want to thanks my wife for that :P). Thanks @jasongrout for the great feedback, it's realy appreciated. |
Reopening as a good first doc issue, then. Thanks! |
as stated, I have also noticed that: "The only concrete thing that docRegistry.addFileType() function does is to associate the file type with the image icon", So how de we make a new filetype associate the right mimeType to it? |
There already issue #4223 (and all those related one: #5064, #4005, #3858, #4048, #6442, #6813) that is talking about this, but none of them seem to be giving a working solution. I have already try what @BoPeng suggest in issue #4423 but it's not working and I kind of have to figure a solution quickly for this. So that's why I'm re-posting this issue, to have some feedback and have a clear solution, because all those issue are kind of dated and it's not clear what is available in the curent 1.1 version.
I have a file format that I want to open with the text editor (codemirror) and the syntax highlighter mathematica that is already there. So I did an application plugins and used the @jupyterlab/application.JupyterFrontEnd.docRegistry.addFileType(), but it's not working like I want it to. It's opening the text editor but it's not setting the language (syntaxe highlighter) correctly. I tough that the "mimeTypes" was the thing that specified to the text editor what syntax highlight to use, but apparently it's not the case. I tried many type of mimeTypes but it's not changing the result.
Here's my code:
I also tried to do a Mime Renderer Extensions, but it's seem to only give you the possibility to do your own render, where I would simply like to use the already existing jupyterlab code editor (codemirror) with a specific syntax highlight.
So what can I did to have the behaviour I'm locking for?
Also, when I have this working, I would like to tried to add a codemirror mode to have my own syntaxe highlighter, but again I see a lot of issue open on that mater, like #5504 and #5829 but no good documentation on the subject, so some help would also be appreciated for this to.
The text was updated successfully, but these errors were encountered: