Exended Ruby Syntax For Gedit and GtkSourceview2


Some months ago since I started using jEdit I also started improving the gtksouceview language definition for ruby and Rails code for use with Gedit, because in most of cases Gedit is faster than jEdit, Now I have some improvements to show.
I used as base for show improvements some screenshots that I made from Railscasts, so I got some episodes that have the “little things” I’ve changed.
This first is a screnshot of Railscasts Episode 33, here we can see the function name properly highlighted and also some Rails specific methods. We can compare the Gedit Screenshot to TextMate screenshot and see that all:

Here we have a rhtml (html.erb) shippet from Episode 37, all tags are highighted properly, including xml markup and erb markup “<%= %>”:

In this (Episode 62) we have a classmethod correctly highlighed (here I prefered to let “self” keyword in the same color of methodname, but is possible to change in future), and the method definitions including method names ending with ?, ! (= signal in the first screenshot):

And last an example of string interpolation (Episode 69), that already exists in original language definition but doesn’t work(I don’t know exactly why), the approach of original attemp is to change the context of string back to main context, by this way the code “should” be highlighted as normal ruby code, and in theory could be other interopated strings in many levels, but, that doesn’t work and I changed to just colorize (I mean this should be the default and correct way) and interpolation is highlighted properly:

You can download a package I made, containing some useful plugins, code snippets and
the language definition. this pack is very useful also if you just installed linux (I use ubuntu) and need quick setup to a Rails development environment

The package also include Extract partial plugin and a Smart indent plugin

How to install.

download the package here in some place
open a terminal go to the place of download and type

$tar -zxvf [name of downloaded tarball]
$./install.sh

WARNING: Some commands need sudo password, so you will be asked.

Open gedit chose your preferred color, enable your preferred plugins and enjoy.
(The package also include the TODO-List plugin and you will need to follow plugin README to install)

Gmate Project Page

, , ,

  1. #1 by Roger Leite on outubro 3, 2008 - 10:59 am

    Alexandre, ótimo trabalho ! Realmente impressionante.

    Você já pensou na possibilidade de contribuir com o projeto gedit-rails?

    Fiz um post sobre “tunning” do gedit para Rails, pelo jeito, vou ter que atualiza-lo ou algo do genêro.

    Valeu!

  2. #2 by Alexandre on outubro 3, 2008 - 1:46 pm

    Olá Roger, Obrigado,
    estive olhando o gedit-rails (eu nao lembrava mais dele) e percebi que as funcionalidades adicionais de lá são praticamente as mesmas do meu projeto gmate podemos ver a possibilidade de dar um merge nos dois projetos, pois meu interesse é continuar mantendo os novos plugins que eu fiz (Smart Indent e Extract Partial) e também manter um fork atualizado dos outros plugins que estão no meu “pacote”, além é claro da criação de novos plugins conforme necessário.
    também atualizar com frequência os snippets os quais eu mesmo já perdi várias vezes.
    o projeto gedit-rails é seu?
    poste aqui um link para o seu post de tunning.
    Abraço

  3. #3 by thomas on outubro 27, 2008 - 3:49 am

    hey, thanks for that package. Eventhough i wasn’t able to install it with your script. The snippets and plugins where useful. Thanks!

    - Thomas

  4. #4 by Alexandre on outubro 27, 2008 - 11:30 am

    Hello, @thomas are you getting some error? what distro are you using?
    thanks for feedback

  5. #5 by MikeT on outubro 30, 2008 - 2:31 am

    Hey nice package, particularly like the huge set of colour profiles which I didn’t see around.

    Nice to see you’ve picked up on many of the plugins I was looking at as potential ones to install.

    Things I’d still like to be able to do:
    * Add [] around a selection
    * Add () around a selection
    * Toggle comment in/out on a selection
    * Select a rectangular area (not bound to lines) for delete/replace

  6. #6 by Alexandre on outubro 30, 2008 - 12:06 pm

    Hello Mike, you are already able to surround a selection with {, [, (, ‘ and “, to do this you will need to disable the default closing brackets plugin of Gedit and enable the Gemmini plugin. If your language is like mine that have a lot of áãé, I think to develop code, you may need to configure your keyboard to EN-US, so all pair completions will work fine, or alternativelly you can press “Alt Gr” + surrouding key.

    To comment uncomment a selection, you need to enable the plugin (Code comment) and use Ctrl+M to toggle comment in a selected area.

    Unfortunatelly Rectangular areas are not supported by gtksourceview yet

    Thank’s for feedback

  7. #7 by Hadret on fevereiro 7, 2010 - 10:32 am

    What’s the name of color scheme you’ve got on the last screenshot of you your post? (:

  8. #8 by alexandre on fevereiro 8, 2010 - 6:47 pm

    The name is railscasts… but when I moved my blog some images were lost…. :(

  9. #9 by T3 on julho 13, 2010 - 4:15 pm

    Thank you Alexandre.

    I really appreciate your work on that.

    Cheers,
    T3

(não será publicado)