-
X
/home/ryan/Teach gedit Grails -- Apr 25, 2008 5:00pm
I spent the better portion of my lunch hour researching how to get Groovy and GSP syntax highlighting into gedit. As posted recently(LINK) I've found out that you can modify the heck of out gedit and add all sorts of useful things like code snippets and other nice little plugins.
Since I've been doing alot of Grails lately and the Groovy/Grails plugin for Eclipse "just sucks" I've been running around trying to find an editor that I like. I went to vi for a while and thats where I've written most of my current project. Its good, and I'm rather productive, but I like have the browseable file explorer. So I tried a few vi commands to get the whole split window, etc. That worked but then I wanted some tabs, so I tried Vim for while and again that was okay, but I still found it lacking.
Finally, Alexei showed me his pimped out gedit and thats all it took. I've been using gedit for the past few days now and kept wanting to figure out a way to get my groovy files and gsp files their own syntax scheme. (You *can* use the Java highlight mode and the HTML highlight mode, but I figured there had to be a better way.) So I did some looking around and adapted several existing files and eventually came up with a working solution.
What I had to do was edit my ~/.local/share/mime/packages/Override.xml file and add the following mime types. (I am pretty sure I don't have this quite right yet as gedit still wants me to select a highlight mode when I open the file for the first time. I was thinking it should auto-detect it, anyone have any thoughts?):
<mime-type type="text/x-groovy">
<sub-class-of type="text/x-java"/>
<comment>Groovy Source File</comment>
<glob pattern="*.groovy"/>
</mime-type>
<mime-type type="text/x-gsp">
<sub-class-of type="text/html"/>
<comment>Grails GSP File</comment>
<glob pattern="*.gsp"/>
</mime-type>
Then I took the /usr/share/gtksourceview-2.0/language-specs/java.xml file, copied over to groovy.xml and made some of the obvious changes, (I'm sure I missed some keywords, etc) and did the same with the html.xml file and copied it to gsp.xml. (Link to files)
The next time I opened gedit and went to View->Highlight Mode->Sources, Groovy was listed and upon opening a Groovy file and selecting the Groovy Highlight mode, I had syntax highlighting. (Incidentally, the GSP highlighting mode is listed under Markup, but all of this stuff is configurable in the xml file).
Finally I went through and added some common Groovy snippets as well as some GSP snippets to assist me in the actual writing of code. Overall, gedit has made me one very happy Grails guy. Bascially I'm sitting here with TextMate for Linux, so all of that goodness multiplied the grails goodness and the giggles(LINK) just keep coming.
~
:wq!
-
X
/home/t -- 2008-04-25 21:38:24
Hi! Really really like your design!(good posts too ;-)
I'm hoping you rolled the whole thing yourself! It looks that way anyway. Refreshing in the world made of wordpress templates. t
~
:wq!
-
X
/home/ryan -- 2008-04-25 22:31:59
@t -- Thanks for the compliments...its isn't pretty but I figured the geeks out there would "get it." And yes, I too am very tired of the standard wordpress templated sites. Indeed, I rolled this myself using Code Igniter and a simple CMS I designed. Again, thanks for the kind words.
~
:wq!
-
X
/home/Andres Almiray -- 2008-04-25 23:57:56
Hey Ryan, what about reposting to Groovy's mailing lists, I'm sure there are other UN*X/gedit users that would be interested ;-)
~
:wq!
-
X
/home/John -- 2008-04-26 09:35:52
Nice design, and I love how the comments end with the sequence:
"""
~
:wq!
"""
cool. BTW, where do you have your vim scripts for developing java/groovy software? I'm a vim fan and I'll appreciate having them.
Regards,
~
:wq!
-
X
/home/ryan -- 2008-04-26 12:17:34
@Andres -- I didn't think of putting it on there. Matter of fact, I'm not even a member of that list. Perhaps I'll have to remedy that situation this weekend...
~
:wq!
-
X
/home/ryan -- 2008-04-26 12:21:15
@John -- I used regular plugins for vi and they just happen to work with Vim. I can' try to post what I have, but its probably easier to just google for "WMToggle" +vi, and that will get you started. Once installed just type ":WMToggle" and it opens an explorer-like navigator on the left. (It requires one other plugin to be installed but I don't remember off the top of my head.) Also, you don't "need" a plugin to get a general "split" in vi. Once in Vim I think the command is something like ":split v", again, I can't remember off the top of my head...sorry. Also, glad you picked up on the ":wq", was hoping someone would mention it.
~
:wq!
-
X
/home/Marcos Silva Pereira -- 2008-04-27 18:54:15
Nice thing. I have used Gedit to develop too.
Did you discover why groovy sintax highlinghting is not used when you open a groovy file?
~
:wq!
-
X
/home/ryan -- 2008-04-28 09:57:59
{b]@Marcos[/b] -- I haven't figured it out just yet, but then again, I haven't had much time to look at this weekend. I was hoping some of the visitors to this site might be able to help me figure it out. When I figure it out, I'll post it.
~
:wq!
-
X
/home/alexica -- 2008-04-28 22:51:31
I'm not sure gedit auto-detects the highlight at all. I remember having to set it manually for .php and .js files.
~
:wq!
-
X
/home/Jack -- 2008-04-28 23:42:12
I've read a few posts on your site - and found this gedit post on dzone.com - I've been through the exact same procedure as you, denouncing eclipse, trying netbeans, going back to emacs, using notepad++ on a windows machine... but finally I landed on jEdit on linux.
I can recommend jEdit as it does everything (you can add tabs, I am still playing with the mouseless file changing, something I like in eclipse / emacs)
An additional bonus is the side panel for files is one of the best i've used and helps you keep a mental map of the project.
Still, I downloaded your files and will try gedit sometime in the future!
~
:wq!
-
X
/home/Marcos Silva Pereira -- 2008-04-29 00:57:34
@ryan,
In order to enable the highlight you must only change the groovy.lang to use "text/x-groovy" in "mimetypes" metadata properties.
Kind Regards
~
:wq!
-
X
/home/ryan -- 2008-04-29 09:46:19
@Jack -- I used jEdit a long long time ago (in a galaxy far, far away...couldn't resist) and it was my editor of choice for some time. The only complaint I really have about it is, I'm trying to avoid using an editor that is written in Java. My machine, while its no slouch, certainly isn't decked out and since I'm also running MySQL, Tomcat --or-- Jboss, etc, I'm trying to reduce the memory footprint. GEdit just seems really lightweight. I haven't checked out jEdit in some time though, I hear that there hasn't been much work on it lately, is that because its just got it all now? Just curious and perhaps I need to give it another look.
~
:wq!
-
X
/home/ryan -- 2008-04-29 09:49:57
@Marcos -- Good find Marcos, but alas, it still doesn't "recognize" it as a groovy source file and I have to go tell GEdit to use the Groovy Highlight Mode from the drop down list. Still I made the change because thats what is should have been. My hope is that I am missing just one small thing that will all of a sudden tell gedit, "you're editing a Groovy file, use Groovy highlighting" and the same for GSP files as well. Perhaps it can't be done like alexica says above...
~
:wq!
-
X
/home/Marcos Silva Pereira -- 2008-05-02 00:25:17
@ryan,
Strange. It works like a charm to me. Well, if you want, I could publish the files and so you could see the diffs.
Kind Regards
~
:wq!
-
X
/home/ryan -- 2008-05-02 09:17:30
@Marcos -- Sure thing, that might be quite helpful. Let me know where to grab it...
~
:wq!
-
X
/home/sr_bean -- 2008-05-03 22:58:49
For the automatic highlighting, I copied your Override.xml in /usr/share/mime/packages/groovy.xml - not sure if the name matters. Then ran "sudo update-mime-database /usr/share/mime".
Basically, applied this:
LINK
One neat command:
"gnomevfs-info foo.groovy"
will give you the MIME type of foo.groovy
~
:wq!
-
X
/home/ryan -- 2008-05-04 20:16:05
@sr_bean -- sweet...gonna have to give that one a shot as soon as my upgrade to Hardy Heron is all straightened out.
~
:wq!
-
X
/home/ryan -- 2008-05-05 11:15:29
@sr_bean -- Okay, a slightly modified version of what you mentioned worked for me. I had basically create a groovy.xml file in /usr/share/mime/packages and put the contents of my Override.xml file in there and then run the update-mime-database command. That seemed to do and perhaps that what you were trying to tell me to do...anyway gedit now recognizes my groovy files! Thanks again, and thanks for posting! This should help others out there as well.
~
:wq!
-
X
/home/Aaron -- 2008-06-16 19:10:33
for me groovy.xml and override.xml needed to be changed to include xml headers and mime-info tags before "sudo update-mime-database /usr/share/mime" would work.
Thanks for the help
~
:wq!
-
X
/home/lenards -- 2008-07-18 12:50:15
Kefah Issa's blog has a script for doing all the actions outlined here. In my initial tests, it's worked for me (I get syntax highlighting when opening .groovy and .gsp files).
LINK ~
:wq!
-
X
/home/ryan -- 2008-07-18 14:06:18
@lenards -- Thanks for the link...man that's excellent!
~
:wq!
-
X
/home/Aaron -- 2008-09-03 16:11:28
the bash script is a great idea! One less hurdle to getting my coworker to switch to Linux and gedit for grails development.
I have been trying to change the comment syntax for gsp's to %{-- instead of the html default, but must not understand how these .lang's work quite well enough to get it done. If I do I will let you know, otherwise feel free to use that as a suggestion to improve the syntax files you provide.
cheers!
~
:wq!
-
X
/home/jason kenny -- 2009-01-16 18:35:13
Personally I would put a lovely bench so all the squirrels could use it and maybe add a mini bar and a Jacuzzi at a later date just for the wildlife though!
~
:wq!
-
X
/home/ryan -- 2009-01-16 21:35:32
@jason -- ehrm...okey dokey
~
:wq!
-
X
Add Comments