How to add syntax highlighting for a new language in codemirror? - codemirror

I have developed a DSL with ANLTR 4 and now I am developing a text editor for this DSL with Angular and CodeMirror and I would like to add syntax highlighting. My question is how to add syntax highlighting for a new language in codemirror.

Your question has nothing at all to do with Angular, so I removed that tag.
To add syntax highlighting for a new language, you need to provide a custom "language mode" for codemirror. See their documentation at https://codemirror.net/doc/manual.html#modeapi

Related

Is this custom syntax highlighting from Atom package possible with VS Code in any and all languages?

This comment syntax highlighting from this package is very nice for making different comments stick out & organizing thoughts.
It looks like the picture below...
Is this possible in VS Code for any and all languages?
Requirement is that this should be possible to integrate with existing themes in VS Code.
Minimally I'm asking for Dart/Flutter, but would prefer a universal comment syntax highlighter so all languages get same comment treatment.
The TODO Highlight Extension does this.

Adding IcedCoffeeScript keywords to Webstorm Intellisense

I want to add a few IcedCoffeeScript keywords to the CoffeeScript files highlighting, but the edit button is grayed out for the CoffeeScript file type. Is there a way that I could duplicate a file type that's already in the list and add keywords? Or, is there a simple way to add keywords to an existing filetype? Why is edit file type grayed out for CoffeeScript files but not others?
No -- you cannot extend existing language by adding your own keywords, as original support is done via Java-based plugin (for proper language support: syntax, inspections, validations, code completions, refactorings etc).
Actual ticket on JetBrains Issue Tracker: http://youtrack.jetbrains.com/issue/RUBY-11996

Is it possible in Eclipse to define syntax highlighting for a language without resorting to Java programming?

I am looking for a way to define some syntax coloring for a language in Eclipse. I only need to highlight certain sets of keywords, so the logic is trivial. So I would like to be able to define these in a plain definition file. Is there perhaps some Eclipse plugin which allows this, or is it possible out of the box?
XText is a more generic and complex solution, which will generate for you the code for a custom Editor able to offer the usual IDE features, that are derived from a grammar (your "plain definition file"), including.
syntax coloring, but also
model navigation (F3, etc.),
code completion,
outline view, and
code templates.
The EclipseColorer plugin may fit the bill!
It's a bit fiddly, but try http://gstaff.org/colorEditor/.
It uses the jEdit syntax highlighting files. So you need to create your highlighting file and add it to the jar in the plugin, as well as editing the catalog file in there to include it.
I used jEdit itself to test and debug my custom highlighting, rather than having to exit Eclipse, make the change and reload it each time.

Customizability of the IDEs

I am thinking of modifying an existing IDE (Ex : By developing a plugin) to provide support for a proprietary scripting language. I just need to implement few features like syntax highlighting, Autocompleting etc. (i.e the requirements are really simple). What would be the best IDE or Text editor to integrate the feature. As an example if I think to develop an eclipse plugin for that it would be a pain.
What do you think about Notepad ++?
You might want to give the NetBeans Generic Language Framework a try.
NetBeans project called Generic Languages Framework allows you to define a programming language and integrate it to NetBeans IDE. In the first step you should describe the language - lexical part (define tokens using regular expressions) and syntax (grammar rules). In the second step you can define how to visualize this language in NetBeans. You can define colors for tokens (syntax coloring) or folding (based on grammar rules). You can define what parts of this language should be displayed in the navigator, and how to indent this language plus many other features.
This tutorial should guide you through the process of creating new NetBeans module, adding languages support into it, describing lexical and syntax structure of your language and adding support for all standard editor # features for your language.
Notepad++ allows you to define custom syntax highlight files in a very easy way, but it's not a very good solution for auto-completion (look at this SO question).
If you want a real IDE to extend, I suggest you to use Eclipse.
Update: Tutorial on how to develop an Eclipse plugin.
In vim you can easily add your custom syntax highlighting rules by adding another file in the syntax folder; for the details it is best to look at the help.
If I remember correctly notepad++ also allows defining custom syntax files.

Is there a VSCode equivalent to Notepad++'s user defined language configuration?

I really enjoyed defining syntax highlighting rules in Notepad++ for the various build logs and artifacts I've worked on in the past to make certain text markers pop out. I was wondering if VSCode has any capabilities to do likewise.
For reference to the unfamiliar here's the Notepad++ documentation and a live demonstration:
https://npp-user-manual.org/docs/user-defined-language-system/
How to Create Custom Language Definitions in Notepad++
Looks like there is support for something in this direction. The terminology is slightly different though and there may not be a GUI interface like Notedpad++
Declarative Language Feature
Syntax Highlight Guide: VS Code uses TextMate grammar for syntax highlighting. This guide will walk you through writing a simple TextMate grammar and converting it into a VS Code extension.
Create Custom Language in Visual Studio Code
https://code.visualstudio.com/api/language-extensions/overview#declarative-language-features
https://code.visualstudio.com/api/language-extensions/language-configuration-guide