hugopl/devblog

06 May 2014

Ruby on QtCreator

After some days recovering from a septoplasty I got some time to put love on my new pet, not a dog, not a cat, just something non-organic, i.e. yet another pet project. This time it’s a plugin to add Ruby language support on QtCreator, a C++/Qml IDE.

Why?

Because I want to would be enough, but as I’m in a good mood let me explain in a single paragraph:

I use QtCreator for C++, It’s faster and code navigation, auto-completion and refactoring works as expected. I want to have these features when doing Ruby programming, besides it’s fun to write this kind of stuff.

So the project is hosted on github, I’m working on it when I can, however it already have some features:

Project Manager

QtCreator is a project oriented IDE, however I dislike the bureaucracy related to project setups on most IDEs, so I went to the simpler approach: open a .rb file and all .rb files under the directory will be added to the project, later I plan to add the many extensions used on Ruby and Ruby related files like .rhtml, .ru, etc.

Project Manager

A project manager means you can type “Ctrl+K” on QtCreator to open any project files.

Basic syntax highlight

It’s working, just need to be improved a bit to recognize regexes, in string variables, symbols, etc. It’s very easy to add this, but as the basic stuff is working I’ll concentrate on other things and improve the highlight as I need it.

Syntax highlight

Basic code navigation

Basic code navigation is working too via the “Ctrl+K menu”, you can see (and navigate) all methods of the current file (“. “ shortcut) or all project methods (“m “ shortcut).

Syntax highlight

The backend for this is based on regular expressions, my first attempt was using a Ruby-based Ruby parser but it was too slow for the task taking 6 seconds to parse a 20K lines files while my simple C++ version took 385 miliseconds, still slow but is enough for now.

Indentation

This is simple, type: “def foobar”, hit enter and see the cursor when you expect it to be.

The future

The features I want to write ASAP are:

How to install and test?

Hmmm, there’s no docs at all, so consider the next lines as a documentation:

mkdir build
cd build
meique --QtCreatorSources=PATH_TO_QTCREATOR_SOURCE ..

Conclusion

This is it, if you want to help me on this just mail me, leave a comment or ping me on IRC.

comments powered by Disqus