Archive for January, 2012

How do I set up my Vala IDE in Vim

Today I want to share how I set my Vim for Vala coding. It is not a fully-loaded IDE but it works for me very well. Hopefully it will help you too. First I would like to show a screenshot of Vim session when I’m hacking GNOME Gnames: Gnomine.

It shows basically three awesome Vim plugins (Tagbar, Fuzzyfinder and Nerdtree) and the terminal multiplexer, Tmux. For those are not familiar with the plugins, Tagbar shows the class variables, functions, etc for easy jumping. Nerdtree is a file explorer. Fuzzyfinder is a nifty buffer switcher. Note that at the bottom of the screenshot, Tmux has three windows, named as ‘src’,’build’ and ‘bash’ and Vim is running in ‘src’ window now. Such a setting makes you quickly switch back and forth between ‘src’ window for editing and ‘build’ window for building, or ‘bash’ window for something else.

I guess most Vim users have already known these. So the real story I’m going to tell is how to make tagbar work with Vala code. Tagbar is based on  ctags however the official ctags doesn’t support Vala. Luckily I have found anjuta-tags is a ctags clone with Vala support. Type in commandline to see if you have anjuta-tags available. It should be installed along with Anjuta. Therefore I replaced the default ctags with anjuta-tags by copying anjuta-tags to a location before ctags in PATH and rename it as ctags. I guess another way is to add

let g:tagbar_ctags_bin = "anjuta-tags"

in your .vimrc file.

That is NOT enough yet. You can generate Vala tags with anjuta-tags but Tagbar still shows nothing. Now you need to edit $VIM/autoload/tagbar.vim by adding the following lines.

" Vala {{{3
 let type_vala = {}
 let type_vala.ctagstype = 'vala'
 let type_vala.kinds = [
 \ {'short' : 'c', 'long' : 'classes', 'fold' : 0},
 \ {'short' : 'd', 'long' : 'delegates', 'fold' : 0},
 \ {'short' : 'e', 'long' : 'enumerations', 'fold' : 0},
 \ {'short' : 'E', 'long' : 'error domains', 'fold' : 0},
 \ {'short' : 'f', 'long' : 'fields', 'fold' : 0},
 \ {'short' : 'i', 'long' : 'interfaces', 'fold' : 0},
 \ {'short' : 'm', 'long' : 'methods', 'fold' : 0},
 \ {'short' : 'p', 'long' : 'properties', 'fold' : 0},
 \ {'short' : 'r', 'long' : 'error codes', 'fold' : 0},
 \ {'short' : 's', 'long' : 'structures', 'fold' : 0},
 \ {'short' : 'S', 'long' : 'signals', 'fold' : 0},
 \ {'short' : 'v', 'long' : 'enumeration values', 'fold' : 0}
 \ ]
 let type_vala.sro = '.'
 let type_vala.kind2scope = {
 \ 'i' : 'interface',
 \ 'c' : 'class',
 \ 's' : 'structure',
 \ 'e' : 'enum'
 \ }
 let type_vala.scope2kind = {
 \ 'interface' : 'i',
 \ 'class' : 'c',
 \ 'struct' : 's',
 \ 'enum' : 'e'
 \ }
 let s:known_types.vala = type_vala

Also, remember to check out for syntax highlighting:-)

Gnome Gnomine has a new look

I’m very glad today since My patch to the bug has been accepted which removes the status bar and put everything else into the toolbar. Hopefully in the coming Gnome release you will see a new look of Gnome Gnomine. Thanks for the reviews from Robert! Here is the preview:

GNOME OPW: the bi-weekly progress report

Hello everyone, I’ve seemed quiet during the past two weeks since I have been fighting with Vala, Javascript and Clutter. My short term goal is to port GNOME game Swell Foop from Javascript to Vala. After the first two weeks of warming up practices, this one is a tough one. There was a dark time to get started. Because both languages are new to me and Clutter is even newer, reading the Javascript code, understanding the logic and translating them to the equivalent Vala implementation was really a challenge. Anything seemed not working as you expected.  But I still think it would be better to make my hands dirty enough before throwing questions on IRC. Luckily Robert has provided a excellent case study(Lightsoff) to follow. Working through his code really made my life much easier. So today I’m very glad to show you my latest progress: a basic but running Swell Foop:

Vala version of Swell Foop

Did I just say running? It can run, load the theme and layout the actors but can’t response the mouse interaction at the moment. Anyway, I’m very excited to make it run. It is a tangible progress and will serve as my test field for adding the remaining functionality.

By playing around with Lightsoff and Swell Foop, I’ve been very impressed with the cool animation effects provided by Clutter. Comparing with these Clutter-powered games, other GNOME games look a little bit dull. I guess it might be a good idea to use Clutter more in other games. Maybe another round of game modernization?