vala.vim


Ⅰ. 插件描述

Vala syntax highlighting, indentation, snippets and more for Vim

Ⅱ. 基本信息

创建日期:  2016-10-19
使用用户:  2
Github星:  31
插件作者:  Adrià Arrufat

Ⅲ. 安装方法

使用Vundle管理器安装

在你的.vimrc下添加:
Plugin 'arrufat/vala-vim-without-it'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall

对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。

使用NeoBundle管理器安装

在你的.vimrc下添加:
NeoBundle 'arrufat/vala-vim-without-it'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall

使用VimPlug管理器安装

在你的.vimrc下添加:
Plug 'arrufat/vala-vim-without-it'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall

使用Pathogen管理器安装

在终端中运行以下命令:
cd ~/.vim/bundle
git clone https://github.com/arrufat/vala.vim

Ⅳ. 文档说明

# vala.vim

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.

vala.vim - solarized dark
vala.vim - solarized light

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> and HashTable<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:

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

添加新评论