rebase on 2015
[dotVim.git] / bundle / syntastic-3.4.0 / syntax_checkers / c / cppcheck.vim
blobe4223cb2d487139c0bab07bfca2bddddcfd88243
1 "============================================================================
2 "File:        cppcheck.vim
3 "Description: Syntax checking plugin for syntastic.vim using cppcheck.pl
4 "Maintainer:  LCD 47 <lcd047 at gmail dot com>
5 "License:     This program is free software. It comes without any warranty,
6 "             to the extent permitted by applicable law. You can redistribute
7 "             it and/or modify it under the terms of the Do What The Fuck You
8 "             Want To Public License, Version 2, as published by Sam Hocevar.
9 "             See http://sam.zoy.org/wtfpl/COPYING for more details.
10 "============================================================================
12 " The setting 'g:syntastic_cppcheck_config_file' allows you to define a file
13 " that contains additional compiler arguments like include directories or
14 " CFLAGS. The file is expected to contain one option per line. If none is
15 " given the filename defaults to '.syntastic_cppcheck_config':
17 "   let g:syntastic_cppcheck_config_file = '.config'
19 if exists("g:loaded_syntastic_c_cppcheck_checker")
20     finish
21 endif
22 let g:loaded_syntastic_c_cppcheck_checker = 1
24 if !exists('g:syntastic_cppcheck_config_file')
25     let g:syntastic_cppcheck_config_file = '.syntastic_cppcheck_config'
26 endif
28 let s:save_cpo = &cpo
29 set cpo&vim
31 function! SyntaxCheckers_c_cppcheck_GetLocList() dict
32     let makeprg = self.makeprgBuild({
33         \ 'args': syntastic#c#ReadConfig(g:syntastic_cppcheck_config_file),
34         \ 'args_after': '-q --enable=style' })
36     let errorformat =
37         \ '[%f:%l]: (%trror) %m,' .
38         \ '[%f:%l]: (%tarning) %m,' .
39         \ '[%f:%l]: (%ttyle) %m,' .
40         \ '[%f:%l]: (%terformance) %m,' .
41         \ '[%f:%l]: (%tortability) %m,' .
42         \ '[%f:%l]: (%tnformation) %m,' .
43         \ '[%f:%l]: (%tnconclusive) %m,' .
44         \ '%-G%.%#'
46     let loclist = SyntasticMake({
47         \ 'makeprg': makeprg,
48         \ 'errorformat': errorformat,
49         \ 'preprocess': 'cppcheck',
50         \ 'returns': [0] })
52     for e in loclist
53         if e['type'] =~? '\m^[SPI]'
54             let e['type'] = 'w'
55             let e['subtype'] = 'Style'
56         endif
57     endfor
59     return loclist
60 endfunction
62 call g:SyntasticRegistry.CreateAndRegisterChecker({
63     \ 'filetype': 'c',
64     \ 'name': 'cppcheck'})
66 let &cpo = s:save_cpo
67 unlet s:save_cpo
69 " vim: set et sts=4 sw=4: