Vala Tools

Coding in Vala with the Vim Text Editor

This page describes how to add Vala syntax highlighting and valac error parsing/navigation support to Vim

Syntax Highlighting

Plugin Managers

Syntax highlighting for Vala can be added using a Vim plugin manager.

Vundle manages Vim bundles and is an example of a Vim plugin manager.

After installing Vundle add the following line to ~/.vimrc:

Plugin 'arrufat/vala.vim'

This will then use the Vim bundle hosted on GitHub at https://github.com/arrufat/vala.vim

Other plugin managers are just as easy. Some examples:

Pathogen

git clone --depth=1 https://github.com/arrufat/vala.vim.git ~/.vim/bundle/vala.vim

NeoBundle

NeoBundle 'arrufat/vala.vim'

vim-plug

Plug 'arrufat/vala.vim'

Manual Installation

Alternatively the syntax highlighting bundle can be added manually.

Create these Vim local directories under your home directory with:

mkdir -p $HOME/.vim/ftdetect
mkdir -p $HOME/.vim/indent
mkdir -p $HOME/.vim/syntax

Download the Vala syntax highlighting definition for Vim, vala.vim, and copy the file to the syntax Vim local directory:

cp vala.vim $HOME/.vim/syntax/vala.vim

Create a new file $HOME/.vim/ftdetect/vala.vim with these 2 lines:

autocmd BufRead *.vala,*.vapi set efm=%f:%l.%c-%[%^:]%#:\ %t%[%^:]%#:\ %m
au BufRead,BufNewFile *.vala,*.vapi setfiletype vala

The cindent can also be set by saving indent/vala.vim to $HOME/.vim/syntax/vala.vim

Additional Configuration

The syntax file additionally supports following options in ~/.vimrc

" Disable valadoc syntax highlight
"let vala_ignore_valadoc = 1

" Enable comment strings
let vala_comment_strings = 1

" Highlight space errors
let vala_space_errors = 1
" Disable trailing space errors
"let vala_no_trail_space_error = 1
" Disable space-tab-space errors
let vala_no_tab_space_error = 1

" Minimum lines used for comment syncing (default 50)
"let vala_minlines = 120

Static Code Analysis

Syntastic is a Vim syntax checking plugin that supports Vala.

Jump to Definition

The Tagbar plugin, in combination with anjuta-tags, enables code navigation. For some more details see How do I set up my Vala IDE in Vim.

Projects/Vala/Vim (last edited 2016-10-19 21:14:28 by AlThomas)