Awesome
vala.vim
- Description
- File detection
- Syntax highlighting
- Indentation
- Syntastic
- Snippets
- Additional functionality
Description
This is a Vim plugin that provides file detection, syntax highlighting, proper indentation, better Syntastic integration, code snippets and more for the Vala programming language.
The base version has been imported directly from the official site.
Some of the features displayed in the above images are listed below.
File detection
Automatic detection of .vala
, .vapi
and .valadoc
files.
Syntax highlighting
- Methods: any word followed by
(
- Lambda expressions:
(...) =>
- Arrays, lists and hash tables as in
Array<int>
,List<string>
andHashTable<string, int>
- Operators and Delimiters:
+
,-
,*
,/
,=
,( )
,[ ]
,{ }
... - String formatting in
printf
-like methods:%d
,%f
,%s
,%c
,%u
,%%
... - String templates:
@"$var1 = $(var2 * var3)"
Indentation
The indentation file is largely based on the rust.vim plugin, which is mainly a fix on top of cindent
. It improves the indentation of:
- Method arguments spanning multiple lines.
- Code Attributes such as
CCode
,DBus
, etc. - Lambda expressions, like those used inside a
foreach
method.
Syntastic
The amazing Syntastic plugin already comes with support for Vala. One can make use of the following magic comments to specify particular packages and vapi directories, for example:
// modules: gio-2.0 gtk+-3.0
// vapidirs: vapi
However, I thought it would be useful to be able to specify which files should be compiled with the current one, as well as additional compiler flags, which will be passed to the valac
compiler:
// sources: neededfile.vala
// flags: --enable-deprecated
Note that passing files like this, while convenient, is suboptimal, since their location is relative to the current working path.
Snippets
Useful snippets with UltiSnips:
try catch
statements.for
,foreach
,while
loops.if else
statements.switch case
statements.class
,property
,signal
definitions.- Documentation using Valadoc taglets.
- Many more!
Additional functionality
This plugin also comes with helper functions to:
- Adhere to the Vala Coding Style.
- Insert
CCode
attributes for the symbol below the cursor, useful when creating Vala Legacy Bindings.
You can bind them by adding these lines to your .vimrc
:
if has("autocmd")
autocmd FileType vala ValaCodingStyle
autocmd FileType vala noremap <F8> :CCode<CR>
end