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
Define syntax highlighting for different file extensions #4223
Comments
As far as I know, you will need to define a Jupyterlab extension that adds the filetype to JupyterLab. The core code would be something like:
|
Thanks @BoPeng for your answer. It would be nice to be able to do this just with a setting. |
Did this get resolved? Or is still scheduled to be an update for a future release? |
So I'm trying to do exactly that but for different file format. 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 a extension and tried what @BoPeng suggested. 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? |
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. 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 🙂 |
Hi, I'd like to permanently associate all files called "Snakefile" and files that end with "*.smk" to the python highlighter. Is this now possible in Jupyterhub? Maybe even on the project level? |
Are there any updates on this issue? |
Is there a way to define which syntax highlighting scheme the text editor should use for different file extensions? If not, it would be nice if there was a way to define it in the advanced settings editor
For example, nextflow is written in groovy, but by convention uses the .nf file extension; it would be nice to be able to tell jupyterlab to default to groovy highlighting for .nf files instead of activating it manually every time I open a file in the text editor.
The text was updated successfully, but these errors were encountered: