summaryrefslogtreecommitdiffstats
path: root/ftplugin/vala.vim
blob: 00eefd1df4529dd05a6728161573892281c5054d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'vala') == -1

if exists('b:did_ftplugin')
  finish
endif
let b:did_ftplugin = 1

" Set 'formatoptions' to break comment lines but not other lines,
" and insert the comment leader when hitting <CR> or using "o".
setlocal formatoptions=t formatoptions+=croql
" j was only added in 7.3.541, so stop complaints about its nonexistence
" Where it makes sense, remove a comment leader when joining lines.
silent! setlocal formatoptions+=j

setlocal efm=%f:%l.%c-%[%^:]%#:\ %t%[%^:]%#:\ %m

setlocal comments=sO:*\ -,mO:*\ \ ,exO:*/,s1:/*,mb:*,ex:*/,:O//
setlocal commentstring=//%s

" When the matchit plugin is loaded, this makes the % command skip parens and
" braces in comments.
let b:match_words = '^\s*#\s*if\(\|def\|ndef\)\>:^\s*#\s*elif\>:^\s*#\s*else\>:^\s*#\s*endif\>'
let b:match_skip = 's:comment\|string\|character\|special'

" Insert a CCode attribute for the symbol below the cursor
" https://wiki.gnome.org/Projects/Vala/LegacyBindings
function! CCode() abort
  normal yiwO[CCode (cname = "pa")]
endfunction

" Set Vala Coding Style
" https://wiki.gnome.org/Projects/Vala/Hacking#Coding_Style
function! ValaCodingStyle() abort
  set ts=4 sts=4 sw=4 tw=0 wm=0
endfunction

command! -buffer -bar CCode call CCode()
command! -buffer -bar ValaCodingStyle call ValaCodingStyle()

if get(g:, 'vala_syntax_folding_enabled', 0)
  setlocal foldmethod=syntax
endif

" filter files in the browse dialog
if (has("browsefilter")) && !exists("b:browsefilter")
  let b:browsefilter = "Vala Source Files (*.vala)\t*.vala\n" .
        \ "Vala Vapi Files (*.vapi)\t*.vapi\n" .
        \ "All Files (*.*)\t*.*\n"
endif

endif