Skip to content

Commit 04be0a9

Browse files
author
Alex Dong
committed
Updated syntastic
1 parent 74cf046 commit 04be0a9

36 files changed

+938
-210
lines changed

autoload/syntastic/c.vim

+1-1
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ function! syntastic#c#SearchHeaders()
128128
" search included headers
129129
for hfile in files
130130
if hfile != ''
131-
let filename = expand('%:p:h') . ((has('win32') || has('win64')) ?
131+
let filename = expand('%:p:h') . (has('win32') ?
132132
\ '\' : '/') . hfile
133133
try
134134
let lines = readfile(filename, '', 100)

doc/syntastic.txt

+15-1
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,20 @@ syntax errors: >
163163
let g:syntastic_enable_signs=1
164164
<
165165

166+
*'syntastic_error_symbol'* *'syntastic_style_error_symbol'*
167+
*'syntastic_warning_symbol'* *'syntastic_style_warning_symbol'*
168+
Use this option to control what the syntastic |:sign| text contains. Several
169+
error symobls can be customized:
170+
syntastic_error_symbol - For syntax errors, defaults to '>>'
171+
syntastic_style_error_symbol - For style errors, defaults to 'S>'
172+
syntastic_warning_symbol - For syntax warnings, defaults to '>>'
173+
syntastic_style_warning_symbol - For style warnings, defaults to 'S>'
174+
175+
Example: >
176+
let g:syntastic_error_symbol='✗'
177+
let g:syntastic_warning_symbol='⚠'
178+
<
179+
166180
*'syntastic_enable_balloons'*
167181
Default: 1
168182
Use this option to tell syntastic whether to display error messages in balloons
@@ -340,7 +354,7 @@ The author of syntastic is a mighty wild stallion, hear him roar! >
340354

341355
<
342356
He likes to trot around in the back yard reading his emails and sipping a
343-
scolding hot cup of Earl Grey. Email him at martin.grenfell at gmail dot com.
357+
scalding hot cup of Earl Grey. Email him at martin.grenfell at gmail dot com.
344358
He can also be found trolling the #vim channel on the freenode IRC network as
345359
scrooloose.
346360

doc/tags

+4
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,14 @@
4141
'syntastic_enable_balloons' syntastic.txt /*'syntastic_enable_balloons'*
4242
'syntastic_enable_highlighting' syntastic.txt /*'syntastic_enable_highlighting'*
4343
'syntastic_enable_signs' syntastic.txt /*'syntastic_enable_signs'*
44+
'syntastic_error_symbol' syntastic.txt /*'syntastic_error_symbol'*
4445
'syntastic_loc_list_height' syntastic.txt /*'syntastic_loc_list_height'*
4546
'syntastic_mode_map' syntastic.txt /*'syntastic_mode_map'*
4647
'syntastic_quiet_warnings' syntastic.txt /*'syntastic_quiet_warnings'*
4748
'syntastic_stl_format' syntastic.txt /*'syntastic_stl_format'*
49+
'syntastic_style_error_symbol' syntastic.txt /*'syntastic_style_error_symbol'*
50+
'syntastic_style_warning_symbol' syntastic.txt /*'syntastic_style_warning_symbol'*
51+
'syntastic_warning_symbol' syntastic.txt /*'syntastic_warning_symbol'*
4852
,b camelcasemotion.txt /*,b*
4953
,e camelcasemotion.txt /*,e*
5054
,w camelcasemotion.txt /*,w*

plugin/syntastic.vim

+44-17
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ if exists("g:loaded_syntastic_plugin")
1717
endif
1818
let g:loaded_syntastic_plugin = 1
1919

20-
let s:running_windows = has("win16") || has("win32") || has("win64")
20+
let s:running_windows = has("win16") || has("win32")
2121

2222
if !s:running_windows
2323
let s:uname = system('uname')
@@ -26,6 +26,23 @@ endif
2626
if !exists("g:syntastic_enable_signs")
2727
let g:syntastic_enable_signs = 1
2828
endif
29+
30+
if !exists("g:syntastic_error_symbol")
31+
let g:syntastic_error_symbol = '>>'
32+
endif
33+
34+
if !exists("g:syntastic_warning_symbol")
35+
let g:syntastic_warning_symbol = '>>'
36+
endif
37+
38+
if !exists("g:syntastic_style_error_symbol")
39+
let g:syntastic_style_error_symbol = 'S>'
40+
endif
41+
42+
if !exists("g:syntastic_style_warning_symbol")
43+
let g:syntastic_style_warning_symbol = 'S>'
44+
endif
45+
2946
if !has('signs')
3047
let g:syntastic_enable_signs = 0
3148
endif
@@ -115,9 +132,7 @@ function! s:UpdateErrors(auto_invoked)
115132
call s:CacheErrors()
116133
end
117134

118-
if s:BufHasErrorsOrWarningsToDisplay()
119-
call setloclist(0, s:LocList())
120-
endif
135+
call setloclist(0, s:LocList())
121136

122137
if g:syntastic_enable_balloons
123138
call s:RefreshBalloons()
@@ -185,6 +200,8 @@ function! s:CacheErrors()
185200
for ft in split(fts, '\.')
186201
if s:Checkable(ft)
187202
let errors = SyntaxCheckers_{ft}_GetLocList()
203+
"keep only lines that effectively match an error/warning
204+
let errors = s:FilterLocList({'valid': 1}, errors)
188205
"make errors have type "E" by default
189206
call SyntasticAddToErrors(errors, {'type': 'E'})
190207
call extend(s:LocList(), errors)
@@ -272,10 +289,10 @@ endfunction
272289

273290
if g:syntastic_enable_signs
274291
"define the signs used to display syntax and style errors/warns
275-
sign define SyntasticError text=>> texthl=error
276-
sign define SyntasticWarning text=>> texthl=todo
277-
sign define SyntasticStyleError text=S> texthl=error
278-
sign define SyntasticStyleWarning text=S> texthl=todo
292+
exe 'sign define SyntasticError text='.g:syntastic_error_symbol.' texthl=error'
293+
exe 'sign define SyntasticWarning text='.g:syntastic_warning_symbol.' texthl=todo'
294+
exe 'sign define SyntasticStyleError text='.g:syntastic_style_error_symbol.' texthl=error'
295+
exe 'sign define SyntasticStyleWarning text='.g:syntastic_style_warning_symbol.' texthl=todo'
279296
endif
280297

281298
"start counting sign ids at 5000, start here to hopefully avoid conflicting
@@ -346,6 +363,7 @@ endfunction
346363
"display the cached errors for this buf in the location list
347364
function! s:ShowLocList()
348365
if !empty(s:LocList())
366+
call setloclist(0, s:LocList())
349367
let num = winnr()
350368
exec "lopen " . g:syntastic_loc_list_height
351369
if num != winnr()
@@ -470,6 +488,15 @@ function! s:LoadChecker(checker, ft)
470488
exec "runtime syntax_checkers/" . a:ft . "/" . a:checker . ".vim"
471489
endfunction
472490

491+
"the script changes &shellpipe and &shell to stop the screen flicking when
492+
"shelling out to syntax checkers. Not all OSs support the hacks though
493+
function! s:OSSupportsShellpipeHack()
494+
if !exists("s:os_supports_shellpipe_hack")
495+
let s:os_supports_shellpipe_hack = !s:running_windows && (s:uname !~ "FreeBSD") && (s:uname !~ "OpenBSD")
496+
endif
497+
return s:os_supports_shellpipe_hack
498+
endfunction
499+
473500
"return a string representing the state of buffer according to
474501
"g:syntastic_stl_format
475502
"
@@ -529,36 +556,36 @@ endfunction
529556
" 'subtype' - all errors will be assigned the given subtype
530557
function! SyntasticMake(options)
531558
let old_loclist = getloclist(0)
532-
let old_makeprg = &makeprg
559+
let old_makeprg = &l:makeprg
533560
let old_shellpipe = &shellpipe
534561
let old_shell = &shell
535-
let old_errorformat = &errorformat
562+
let old_errorformat = &l:errorformat
536563

537-
if !s:running_windows && (s:uname !~ "FreeBSD")
564+
if s:OSSupportsShellpipeHack()
538565
"this is a hack to stop the screen needing to be ':redraw'n when
539566
"when :lmake is run. Otherwise the screen flickers annoyingly
540567
let &shellpipe='&>'
541568
let &shell = '/bin/bash'
542569
endif
543570

544571
if has_key(a:options, 'makeprg')
545-
let &makeprg = a:options['makeprg']
572+
let &l:makeprg = a:options['makeprg']
546573
endif
547574

548575
if has_key(a:options, 'errorformat')
549-
let &errorformat = a:options['errorformat']
576+
let &l:errorformat = a:options['errorformat']
550577
endif
551578

552579
silent lmake!
553580
let errors = getloclist(0)
554581

555582
call setloclist(0, old_loclist)
556-
let &makeprg = old_makeprg
557-
let &errorformat = old_errorformat
583+
let &l:makeprg = old_makeprg
584+
let &l:errorformat = old_errorformat
558585
let &shellpipe=old_shellpipe
559586
let &shell=old_shell
560587

561-
if !s:running_windows && s:uname =~ "FreeBSD"
588+
if s:OSSupportsShellpipeHack()
562589
redraw!
563590
endif
564591

@@ -611,7 +638,7 @@ function! SyntasticLoadChecker(checkers, ft)
611638

612639
if exists(opt_name)
613640
let opt_val = {opt_name}
614-
if index(a:checkers, opt_val) != -1 && executable(opt_val)
641+
if index(a:checkers, opt_val) != -1
615642
call s:LoadChecker(opt_val, a:ft)
616643
else
617644
echoerr &ft . " syntax not supported or not installed."

syntax_checkers/ada.vim

+132
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
"============================================================================
2+
"File: ada.vim
3+
"Description: Syntax checking plugin for syntastic.vim
4+
"Maintainer: Alfredo Di Napoli <[email protected]>
5+
"License: This program is free software. It comes without any warranty,
6+
" to the extent permitted by applicable law.
7+
"
8+
"============================================================================
9+
10+
" in order to also check header files add this to your .vimrc:
11+
" (this usually creates a .gch file in your source directory)
12+
"
13+
" let g:syntastic_ada_check_header = 1
14+
"
15+
" To disable the search of included header files after special
16+
" libraries like gtk and glib add this line to your .vimrc:
17+
"
18+
" let g:syntastic_ada_no_include_search = 1
19+
"
20+
" In order to add some custom include directories that should be added to the
21+
" gcc command line you can add those to the global variable
22+
" g:syntastic_ada_include_dirs. This list can be used like this:
23+
"
24+
" let g:syntastic_ada_include_dirs = [ 'includes', 'headers' ]
25+
"
26+
" To enable header files being re-checked on every file write add the
27+
" following line to your .vimrc. Otherwise the header files are checked only
28+
" one time on initially loading the file.
29+
" In order to force syntastic to refresh the header includes simply
30+
" unlet b:syntastic_ada_includes. Then the header files are being re-checked
31+
" on the next file write.
32+
"
33+
" let g:syntastic_ada_auto_refresh_includes = 1
34+
"
35+
" Alternatively you can set the buffer local variable b:syntastic_ada_cflags.
36+
" If this variable is set for the current buffer no search for additional
37+
" libraries is done. I.e. set the variable like this:
38+
"
39+
" let b:syntastic_ada_cflags = ' -I/usr/include/libsoup-2.4'
40+
"
41+
" Moreover it is possible to add additional compiler options to the syntax
42+
" checking execution via the variable 'g:syntastic_ada_compiler_options':
43+
"
44+
" let g:syntastic_ada_compiler_options = ' -std=c++0x'
45+
"
46+
" Additionally the setting 'g:syntastic_ada_config_file' allows you to define
47+
" a file that contains additional compiler arguments like include directories
48+
" or CFLAGS. The file is expected to contain one option per line. If none is
49+
" given the filename defaults to '.syntastic_ada_config':
50+
"
51+
" let g:syntastic_ada_config_file = '.config'
52+
"
53+
" Using the global variable 'g:syntastic_ada_remove_include_errors' you can
54+
" specify whether errors of files included via the
55+
" g:syntastic_ada_include_dirs' setting are removed from the result set:
56+
"
57+
" let g:syntastic_ada_remove_include_errors = 1
58+
59+
if exists('loaded_ada_syntax_checker')
60+
finish
61+
endif
62+
let loaded_ada_syntax_checker = 1
63+
64+
if !executable('gcc')
65+
finish
66+
endif
67+
68+
let s:save_cpo = &cpo
69+
set cpo&vim
70+
71+
if !exists('g:syntastic_ada_config_file')
72+
let g:syntastic_ada_config_file = '.syntastic_ada_config'
73+
endif
74+
75+
function! SyntaxCheckers_ada_GetLocList()
76+
let makeprg = 'gcc -c -fsyntax-only '
77+
let errorformat = '%-G%f:%s:,%f:%l:%c: %m,%f:%l: %m'
78+
79+
if exists('g:syntastic_ada_compiler_options')
80+
let makeprg .= g:syntastic_ada_compiler_options
81+
endif
82+
83+
let makeprg .= ' ' . shellescape(expand('%')) .
84+
\ ' ' . syntastic#c#GetIncludeDirs('ada')
85+
86+
if expand('%') =~? '\%(.h\|.hpp\|.hh\)$'
87+
if exists('g:syntastic_ada_check_header')
88+
let makeprg = 'g++ -c '.shellescape(expand('%')).
89+
\ ' ' . syntastic#c#GetIncludeDirs('ada')
90+
else
91+
return []
92+
endif
93+
endif
94+
95+
if !exists('b:syntastic_ada_cflags')
96+
if !exists('g:syntastic_ada_no_include_search') ||
97+
\ g:syntastic_ada_no_include_search != 1
98+
if exists('g:syntastic_ada_auto_refresh_includes') &&
99+
\ g:syntastic_ada_auto_refresh_includes != 0
100+
let makeprg .= syntastic#c#SearchHeaders()
101+
else
102+
if !exists('b:syntastic_ada_includes')
103+
let b:syntastic_ada_includes = syntastic#c#SearchHeaders()
104+
endif
105+
let makeprg .= b:syntastic_ada_includes
106+
endif
107+
endif
108+
else
109+
let makeprg .= b:syntastic_ada_cflags
110+
endif
111+
112+
" add optional config file parameters
113+
let makeprg .= ' ' . syntastic#c#ReadConfig(g:syntastic_ada_config_file)
114+
115+
" process makeprg
116+
let errors = SyntasticMake({ 'makeprg': makeprg,
117+
\ 'errorformat': errorformat })
118+
119+
" filter the processed errors if desired
120+
if exists('g:syntastic_ada_remove_include_errors') &&
121+
\ g:syntastic_ada_remove_include_errors != 0
122+
return filter(errors,
123+
\ 'has_key(v:val, "bufnr") && v:val["bufnr"]=='.bufnr(''))
124+
else
125+
return errors
126+
endif
127+
endfunction
128+
129+
let &cpo = s:save_cpo
130+
unlet s:save_cpo
131+
132+
" vim: set et sts=4 sw=4:

syntax_checkers/c.vim

+13-2
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@
5858
" setting are removed from the result set:
5959
"
6060
" let g:syntastic_c_remove_include_errors = 1
61+
"
62+
" Use the variable 'g:syntastic_c_errorformat' to override the default error
63+
" format:
64+
"
65+
" let g:syntastic_c_errorformat = '%f:%l:%c: %trror: %m'
6166

6267
if exists('loaded_c_syntax_checker')
6368
finish
@@ -84,7 +89,13 @@ function! SyntaxCheckers_c_GetLocList()
8489
let errorformat = '%-G%f:%s:,%-G%f:%l: %#error: %#(Each undeclared '.
8590
\ 'identifier is reported only%.%#,%-G%f:%l: %#error: %#for '.
8691
\ 'each function it appears%.%#,%-GIn file included%.%#,'.
87-
\ '%-G %#from %f:%l\,,%f:%l:%c: %m,%f:%l: %trror: %m,%f:%l: %m'
92+
\ '%-G %#from %f:%l\,,%f:%l:%c: %trror: %m,%f:%l:%c: '.
93+
\ '%tarning: %m,%f:%l:%c: %m,%f:%l: %trror: %m,'.
94+
\ '%f:%l: %tarning: %m,%f:%l: %m'
95+
96+
if exists('g:syntastic_c_errorformat')
97+
let errorformat = g:syntastic_c_errorformat
98+
endif
8899

89100
" add optional user-defined compiler options
90101
let makeprg .= g:syntastic_c_compiler_options
@@ -125,7 +136,7 @@ function! SyntaxCheckers_c_GetLocList()
125136
endif
126137

127138
" add optional config file parameters
128-
let makeprg .= syntastic#c#ReadConfig(g:syntastic_c_config_file)
139+
let makeprg .= ' '.syntastic#c#ReadConfig(g:syntastic_c_config_file)
129140

130141
" process makeprg
131142
let errors = SyntasticMake({ 'makeprg': makeprg,

syntax_checkers/co.vim

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
"============================================================================
2+
"File: co.vim
3+
"Description: Syntax checking plugin for syntastic.vim
4+
"Maintainer: Andrew Kelley <[email protected]>
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+
if exists("loaded_co_syntax_checker")
13+
finish
14+
endif
15+
let loaded_co_syntax_checker = 1
16+
17+
"bail if the user doesnt have coco installed
18+
if !executable("coco")
19+
finish
20+
endif
21+
22+
function! SyntaxCheckers_co_GetLocList()
23+
let makeprg = 'coco -c -o /tmp '.shellescape(expand('%'))
24+
let errorformat = '%EFailed at: %f,%ZSyntax%trror: %m on line %l,%EFailed at: %f,%Z%trror: Parse error on line %l: %m'
25+
26+
return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat })
27+
endfunction

0 commit comments

Comments
 (0)