]> git.r.bdr.sh - rbdr/dotfiles/blob - vim/syntax_checkers/cpp.vim
A whole bunch of new additions to the submodules
[rbdr/dotfiles] / vim / syntax_checkers / cpp.vim
1 "============================================================================
2 "File: cpp.vim
3 "Description: Syntax checking plugin for syntastic.vim
4 "Maintainer: Gregor Uhlenheuer <kongo2002 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 "
11 "============================================================================
12
13 " in order to also check header files add this to your .vimrc:
14 " (this usually creates a .gch file in your source directory)
15 "
16 " let g:syntastic_cpp_check_header = 1
17 "
18 " To disable the search of included header files after special
19 " libraries like gtk and glib add this line to your .vimrc:
20 "
21 " let g:syntastic_cpp_no_include_search = 1
22 "
23 " To enable header files being re-checked on every file write add the
24 " following line to your .vimrc. Otherwise the header files are checked only
25 " one time on initially loading the file.
26 " In order to force syntastic to refresh the header includes simply
27 " unlet b:syntastic_cpp_includes. Then the header files are being re-checked
28 " on the next file write.
29 "
30 " let g:syntastic_cpp_auto_refresh_includes = 1
31 "
32 " Alternatively you can set the buffer local variable b:syntastic_cpp_cflags.
33 " If this variable is set for the current buffer no search for additional
34 " libraries is done. I.e. set the variable like this:
35 "
36 " let b:syntastic_cpp_cflags = ' -I/usr/include/libsoup-2.4'
37 "
38 " Moreover it is possible to add additional compiler options to the syntax
39 " checking execution via the variable 'g:syntastic_cpp_compiler_options':
40 "
41 " let g:syntastic_cpp_compiler_options = ' -std=c++0x'
42
43 if exists('loaded_cpp_syntax_checker')
44 finish
45 endif
46 let loaded_cpp_syntax_checker = 1
47
48 if !executable('g++')
49 finish
50 endif
51
52 let s:save_cpo = &cpo
53 set cpo&vim
54
55 function! SyntaxCheckers_cpp_GetLocList()
56 let makeprg = 'g++ -fsyntax-only '.shellescape(expand('%'))
57 let errorformat = '%-G%f:%s:,%f:%l:%c: %m,%f:%l: %m'
58
59 if expand('%') =~? '\%(.h\|.hpp\|.hh\)$'
60 if exists('g:syntastic_cpp_check_header')
61 let makeprg = 'g++ -c '.shellescape(expand('%'))
62 else
63 return []
64 endif
65 endif
66
67 if exists('g:syntastic_cpp_compiler_options')
68 let makeprg .= g:syntastic_cpp_compiler_options
69 endif
70
71 if !exists('b:syntastic_cpp_cflags')
72 if !exists('g:syntastic_cpp_no_include_search') ||
73 \ g:syntastic_cpp_no_include_search != 1
74 if exists('g:syntastic_cpp_auto_refresh_includes') &&
75 \ g:syntastic_cpp_auto_refresh_includes != 0
76 let makeprg .= syntastic#c#SearchHeaders()
77 else
78 if !exists('b:syntastic_cpp_includes')
79 let b:syntastic_cpp_includes = syntastic#c#SearchHeaders()
80 endif
81 let makeprg .= b:syntastic_cpp_includes
82 endif
83 endif
84 else
85 let makeprg .= b:syntastic_cpp_cflags
86 endif
87
88 return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat })
89 endfunction
90
91 let &cpo = s:save_cpo
92 unlet s:save_cpo
93
94 " vim: set et sts=4 sw=4: