1 "============================================================================
3 "Description: Syntax checking plugin for syntastic.vim
4 "Maintainer: Konstantin Stepanov (me@kstep.me)
5 "Notes: Add special comment line into your vala file starting with
6 " "// modules: " and containing space delimited list of vala
7 " modules, used by the file, so this script can build correct
9 " Add another special comment line into your vala file starting
10 " with "// vapidirs: " followed by a space delimited list of
11 " the vapi directories so this script can build with the correct
13 " Alternatively you can set the g:syntastic_vala_modules array
14 " and/or the g:syntastic_vala_vapidirs array
15 " in your .vimrc or .lvimrc with localvimrc plugin
16 " (http://www.vim.org/scripts/script.php?script_id=441).
17 " Valac compiler is not the fastest thing in the world, so you
18 " may want to disable this plugin with
19 " let g:syntastic_vala_check_disabled = 1 command in your .vimrc or
20 " command line. Unlet this variable to set it to 0 to reenable
22 "License: This program is free software. It comes without any warranty,
23 " to the extent permitted by applicable law. You can redistribute
24 " it and/or modify it under the terms of the Do What The Fuck You
25 " Want To Public License, Version 2, as published by Sam Hocevar.
26 " See http://sam.zoy.org/wtfpl/COPYING for more details.
28 "============================================================================
30 if exists("g:loaded_syntastic_vala_valac_checker")
33 let g:loaded_syntastic_vala_valac_checker = 1
38 function! SyntaxCheckers_vala_valac_GetHighlightRegex(pos)
39 let length = strlen(matchstr(a:pos['text'], '\m\^\+$'))
40 return '\%>' . (a:pos['col'] - 1) . 'c.*\%<' . (a:pos['col'] + length + 1) . 'c'
43 function! s:GetValaModules()
44 if exists('g:syntastic_vala_modules')
45 if type(g:syntastic_vala_modules) == type('')
46 return split(g:syntastic_vala_modules, '\s\+')
47 elseif type(g:syntastic_vala_modules) == type([])
48 return copy(g:syntastic_vala_modules)
50 echoerr 'g:syntastic_vala_modules must be either list or string: fallback to in file modules string'
54 let modules_line = search('^// modules: ', 'n')
55 let modules_str = getline(modules_line)
56 return split(strpart(modules_str, 12), '\s\+')
59 function! s:GetValaVapiDirs()
60 if exists('g:syntastic_vala_vapi_dirs')
61 if type(g:syntastic_vala_vapi_dirs) == type('')
62 return split(g:syntastic_vala_vapi_dirs, '\s\+')
63 elseif type(g:syntastic_vala_vapi_dirs) == type([])
64 return copy(g:syntastic_vala_vapi_dirs)
66 echoerr 'g:syntastic_vala_vapi_dirs must be either list or string: fallback to in file modules string'
70 let vapi_line = search('^//\s*vapidirs:\s*','n')
71 let vapi_str = getline(vapi_line)
72 return split( substitute( vapi_str, '^//\s*vapidirs:\s*', '', 'g' ), '\s\+' )
75 function! SyntaxCheckers_vala_valac_GetLocList() dict
76 let vala_pkg_args = join(map(s:GetValaModules(), '"--pkg ".v:val'), ' ')
77 let vala_vapi_args = join(map(s:GetValaVapiDirs(), '"--vapidir ".v:val'), ' ')
78 let makeprg = self.makeprgBuild({ 'args': '-C ' . vala_pkg_args . " " . vala_vapi_args })
81 \ '%A%f:%l.%c-%\d%\+.%\d%\+: %t%[a-z]%\+: %m,'.
85 return SyntasticMake({
87 \ 'errorformat': errorformat })
90 call g:SyntasticRegistry.CreateAndRegisterChecker({
97 " vim: set et sts=4 sw=4: