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

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.

Related

How to setup a new language IDE

At work we are using a proprietary language and to program we are using Notepad++ with a simple code highlight. That is really annoying so, what I want to do is to invest some time to setup a text editor or an existing IDE to support my language.
I've googled a lot and there are so many options and before starting to work I wanna ask to you what is the best choice.
What I want to do is to have, like an IDE, a syntax highlight, a window with the function list tree, with the local function variables inside the same subtree, maybe text autocomplete (if I type "pro" I would like to see the suggestion "procedure" and if I press enter it will write for me something like
procedure "name" {
--code--
}
with the cursor on "name" ready to change it.
etc etc...
Can you suggest me the right path to follow?
Is it to keep using Notepad++? With sourcecookifier? functionlist?
Or I have to change to another text editor?
Or there is some famous IDE like Eclipse, NetBeans etc that allow to easily add my own language?
PS. my language is pretty simple, I don't have complex structures, is Pascal-like. Something like that:
variable int xyz
PROCEDURE asd
BEGIN
END PROCEDURE asd
I would recommend you to stay with Notepad++ and extend it with some plugins and configuration. This would be fairly quick and easy to set up and still give a big win, even though you might not be able to get all the nice features of something like Eclipse. But since you already know the Notepad++ it wouldn't require learning an entirely new tool.
Some plugins that I have found useful
Function List
Light Explorer
XBrackets Lite
There are probably a lot more that can be useful to you.
Notepad++ also got some built in auto-completion functionality that can be enabled in the settings.
Have you evaluated Eclipse XTEXT ?
What is Xtext?
Xtext is a framework for development of programming languages and domain specific languages.
The only IDE I have used for the last few years is Eclipse. There are lots of other IDEs available, also notable and popular is Netbeans. There are many others. It's important to note that all IDEs have their fans, but I can only speak to Eclipse.
Eclipse is a platform, which means it is an application on which you can build other applications. Eclipse provides a framework which you can customize and extend to produce a working application. It takes care of the user interface, preferences storage, modularisation using OSGi, and lots of other things.
Eclipse has facilities to support what you're looking for:
Syntax highlighting in the editor.
The Outline View provides function and variable listing in a tree
Autocompletion and Suggestions (activated by hitting ctrl-space)
Code Templates to fill out files and procedures etc.
The disadvantage is that customising and extending Eclipse to do what you want isn't trivial. Having written a language debugger for Eclipse, I can tell you that leveraging Eclipse's platform helped enormously, but there's a learning curve. You'd essentially have to be coming up with a new set of plugins to provide your highlighting, outlining, autocomplete suggestions and templates (I'm not sure if template support is built into the platform or not).
So I would say, unless you can find some sort of extensible editor for Eclipse - I know Aptana is extensible for tag-based markup - you are probably as well staying with your existing tooling.
Do explore the other IDEs though - I've heard good things about IDEA as well as Netbeans. :)
Good luck!
I can recommend SynWrite editor. Good support for external languages, fully customizable. (Editor of new lexers is there)

eclipse editor, how to work with text editor (theme) when working with a specific perspective?

Is there a way to change the 'Appearance color' (or theme) in the editor when choosing to work with a specific view/perspective?
To be more specific, I'm starting to use python and I wish to have a different theme but when switching to Java I'd like to use the default editor.
Doable?
There is nothing to make the theme depend on the perspective, I believe.
The straightforward solution would be installing a Python plugin, which then has its own editor (and own syntax highlighting settings). You would have to do that for every file type, nonetheless.
Apart from that, your best choice is probably the Eclipse Colorer plugin, which can do syntax coloring based on the file type.
(Disclaimer: I've never used any of those myself).

Is There Mustache Syntax Highlighter Or Plugin For NetBeans?

There are such thing as Mustache. I'm using NetBeans and I need to edit .mustache files. The problem is that when I open it using NetBeans, syntax is just like for plain text.
1) Is it possible to have HTML-like syntax for .mustache files?
2) Is there any plugin that allows to work easier with Mustache? I have found only this tutorial.
If creating your own plugin is to hard, you might be already content if mustache templates are displayed as (normal) HTML instead of plain text.
This can be configured in Options > Miscellaneous > Files. Create a 'New' file extension named 'mustache'. Than select 'HTML Files (text/html)' as associated file type.
It seemes that the way described at the link you've posted is
only way: write your own plugin for netbeans (it's quite difficult task)
1) Follow http://wiki.netbeans.org/SyntaxColoringANTLR
2) But the more difficult thing is to implement your language definition as an embedded one.
It's needed if you want to highlight mustache template tags inside other language files (html, xhtml)
In older versions of NetBeans was a really simple api and module (it cannot be itegrated with all the platform services, like refactoring and so on) but it was based on grammar definition (BNF or something like that) and color scheme for tokens.
I think better is to open this files as text/x-twig.

Add to language syntax in Netbeans/Eclipse

This may seem like seem like a bit of a weird/uncommon request but I am trying to find out if it is possible. I would like to add to the language syntax in Netbeans or Eclipse easily without needing to create an entirely new language. According to this question How to add more syntax elements for eclipse it is not possible in Eclipse, but that was asked in 2008 so maybe things have changed.
The reason I want to do it is I am developing in node.js and it uses callbacks quite heavily. So it would be nice if I could make the word 'callback' and 'callback()' be highlighted in a different colour so it can be easily seen in amongst the rest of the code.
Thanks for your help!
The css thing is really easy:
go to Options/Miscellaneous/Files, create new file extension less and then select proper MIME type text/x-css. I Believe that it is possible to extend syntax highlighting in NetBeans IDE but you have to write your own plugin to do that.

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.