Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Sep 20, 2023. It is now read-only.

Commit e0b8e87

Browse files
committed
refactor all the syntax checkers to use the new API and dir layout
1 parent 58ba8d3 commit e0b8e87

89 files changed

Lines changed: 617 additions & 506 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

plugin/syntastic/checker.vim

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,19 @@ let g:SyntasticChecker = {}
1010
function! g:SyntasticChecker.New(args)
1111
let newObj = copy(self)
1212

13-
let newObj._locListFunc = a:args['loclistFunc']
14-
let newObj._isAvailableFunc = a:args['isAvailableFunc']
1513
let newObj._filetype = a:args['filetype']
1614
let newObj._name = a:args['name']
1715

18-
let newObj._highlightRegexFunc = get(a:args, 'highlightRegexFunc', '')
16+
17+
let prefix = 'SyntaxCheckers_' . newObj._filetype . '_' . newObj._name . '_'
18+
let newObj._locListFunc = function(prefix . 'GetLocList')
19+
let newObj._isAvailableFunc = function(prefix . 'IsAvailable')
20+
21+
if exists('*' . prefix . 'GetHighlightRegex')
22+
let newObj._highlightRegexFunc = function(prefix. 'GetHighlightRegex')
23+
else
24+
let newObj._highlightRegexFunc = ''
25+
endif
1926

2027
return newObj
2128
endfunction
Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,11 @@ if !exists('g:syntastic_ada_config_file')
6767
let g:syntastic_ada_config_file = '.syntastic_ada_config'
6868
endif
6969

70-
function! SyntaxCheckers_ada_GetLocList()
70+
function! SyntaxCheckers_ada_gcc_IsAvailable()
71+
return executable('gcc')
72+
endfunction
73+
74+
function! SyntaxCheckers_ada_gcc_GetLocList()
7175
let makeprg = 'gcc -c -fsyntax-only '
7276
let errorformat = '%-G%f:%s:,%f:%l:%c: %m,%f:%l: %m'
7377

@@ -121,6 +125,10 @@ function! SyntaxCheckers_ada_GetLocList()
121125
endif
122126
endfunction
123127

128+
call g:SyntasticRegistry.CreateAndRegisterChecker({
129+
\ 'filetype': 'ada',
130+
\ 'name': 'gcc'})
131+
124132
let &cpo = s:save_cpo
125133
unlet s:save_cpo
126134

syntax_checkers/applescript.vim renamed to syntax_checkers/applescript/osacompile.vim

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,19 @@
2424
" Hocevar. See http://sam.zoy.org/wtfpl/COPYING for more details.
2525
"
2626
"============================================================================
27+
function! SyntaxCheckers_applescript_osacompile_IsAvailable()
28+
return executable('osacompile')
29+
endfunction
2730

28-
"bail if the user doesnt have osacompile installed
29-
if !executable("osacompile")
30-
finish
31-
endif
32-
33-
function! SyntaxCheckers_applescript_GetLocList()
31+
function! SyntaxCheckers_applescript_osacompile_GetLocList()
3432
let makeprg = syntastic#makeprg#build({
3533
\ 'exe': 'osacompile',
3634
\ 'args': '-o ' . tempname() . '.scpt ' })
3735
let errorformat = '%f:%l:%m'
3836

3937
return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat })
4038
endfunction
39+
40+
call g:SyntasticRegistry.CreateAndRegisterChecker({
41+
\ 'filetype': 'applescript',
42+
\ 'name': 'osacompile'})

syntax_checkers/c/checkpatch.vim

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,26 @@ if executable("checkpatch.pl")
1818
let g:syntastic_c_checker_checkpatch_location = 'checkpatch.pl'
1919
elseif executable("./scripts/checkpatch.pl")
2020
let g:syntastic_c_checker_checkpatch_location = './scripts/checkpatch.pl'
21-
else
22-
finish
2321
endif
2422

25-
function! SyntaxCheckers_c_GetLocList()
23+
function SyntaxCheckers_c_checkpatch_IsAvailable()
24+
exists("g:syntastic_c_checker_checkpatch_location")
25+
endfunction
26+
27+
28+
function! SyntaxCheckers_c_checkpatch_GetLocList()
2629
let makeprg = syntastic#makeprg#build({
2730
\ 'exe': g:syntastic_c_checker_checkpatch_location,
2831
\ 'args': '--no-summary --no-tree --terse --file',
2932
\ 'subchecker': 'checkpatch' })
3033

3134
let errorformat = '%f:%l: %tARNING: %m,%f:%l: %tRROR: %m'
3235

33-
let oclist = SyntasticMake({ 'makeprg': makeprg,
34-
\ 'errorformat': errorformat,
35-
\ 'defaults': {'bufnr': bufnr("")} })
36-
return loclist
36+
return SyntasticMake({ 'makeprg': makeprg,
37+
\ 'errorformat': errorformat,
38+
\ 'defaults': {'bufnr': bufnr("")} })
3739
endfunction
40+
41+
call g:SyntasticRegistry.CreateAndRegisterChecker({
42+
\ 'filetype': 'c',
43+
\ 'name': 'checkpatch'})

syntax_checkers/c/gcc.vim

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ if exists('loaded_gcc_syntax_checker')
7373
endif
7474
let loaded_gcc_syntax_checker = 1
7575

76-
if !executable(g:syntastic_c_checker)
77-
finish
76+
function SyntaxCheckers_c_gcc_IsAvailable()
77+
return executable(g:syntastic_c_checker)
7878
endif
7979

8080
let s:save_cpo = &cpo
@@ -88,7 +88,7 @@ if !exists('g:syntastic_c_config_file')
8888
let g:syntastic_c_config_file = '.syntastic_c_config'
8989
endif
9090

91-
function! SyntaxCheckers_c_GetLocList()
91+
function! SyntaxCheckers_c_gcc_GetLocList()
9292
let makeprg = g:syntastic_c_checker . ' -x c -fsyntax-only '
9393
let errorformat = '%-G%f:%s:,%-G%f:%l: %#error: %#(Each undeclared '.
9494
\ 'identifier is reported only%.%#,%-G%f:%l: %#error: %#for '.
@@ -159,6 +159,10 @@ function! SyntaxCheckers_c_GetLocList()
159159
endif
160160
endfunction
161161

162+
call g:SyntasticRegistry.CreateAndRegisterChecker({
163+
\ 'filetype': 'c',
164+
\ 'name': 'gcc'})
165+
162166
let &cpo = s:save_cpo
163167
unlet s:save_cpo
164168

syntax_checkers/c/sparse.vim

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,11 @@ if exists("loaded_sparse_syntax_checker")
1313
endif
1414
let loaded_sparse_syntax_checker = 1
1515

16-
" Bail if the user doesn't have `sparse.pl` or ./scripts/checkpatch.pl installed.
17-
if !executable("sparse")
18-
finish
19-
endif
16+
function! SyntaxCheckers_c_sparse_IsAvailable()
17+
return executable("sparse")
18+
endfunction
2019

21-
function! SyntaxCheckers_c_GetLocList()
20+
function! SyntaxCheckers_c_sparse_GetLocList()
2221
let makeprg = syntastic#makeprg#build({
2322
\ 'exe': 'sparse',
2423
\ 'args': syntastic#c#ReadConfig(g:syntastic_sparse_config_file) })
@@ -31,3 +30,7 @@ function! SyntaxCheckers_c_GetLocList()
3130
\ 'defaults': {'bufnr': bufnr("")} })
3231
return loclist
3332
endfunction
33+
34+
call g:SyntasticRegistry.CreateAndRegisterChecker({
35+
\ 'filetype': 'c',
36+
\ 'name': 'sparse'})
Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,19 @@ if !executable("coco")
1515
finish
1616
endif
1717

18-
function! SyntaxCheckers_co_GetLocList()
18+
function! SyntaxCheckers_co_coco_GetLocList()
19+
return executable('coco')
20+
endfunction
21+
22+
function! SyntaxCheckers_co_coco_GetLocList()
1923
let makeprg = syntastic#makeprg#build({
2024
\ 'exe': 'coco',
2125
\ 'args': '-c -o /tmp' })
2226
let errorformat = '%EFailed at: %f,%ZSyntax%trror: %m on line %l,%EFailed at: %f,%Z%trror: Parse error on line %l: %m'
2327

2428
return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat })
2529
endfunction
30+
31+
call g:SyntasticRegistry.CreateAndRegisterChecker({
32+
\ 'filetype': 'co',
33+
\ 'name': 'coco'})
Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,17 @@
1010
"
1111
"============================================================================
1212

13-
"bail if the user doesnt have coffee installed
14-
if !executable("coffee")
15-
finish
16-
endif
1713

1814
if !exists('g:syntastic_coffee_lint_options')
1915
let g:syntastic_coffee_lint_options = ""
2016
endif
2117

2218

23-
function! SyntaxCheckers_coffee_GetLocList()
19+
function! SyntaxCheckers_coffee_coffee_IsAvailable()
20+
return executable("coffee") && executable('coffeelint')
21+
endfunction
22+
23+
function! SyntaxCheckers_coffee_coffee_GetLocList()
2424
let makeprg = syntastic#makeprg#build({
2525
\ 'exe': 'coffee',
2626
\ 'args': '-c -l -o /tmp' })
@@ -45,3 +45,7 @@ function s:GetCoffeeLintErrors()
4545

4646
return lint_results
4747
endfunction
48+
49+
call g:SyntasticRegistry.CreateAndRegisterChecker({
50+
\ 'filetype': 'coffee',
51+
\ 'name': 'coffee'})
Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,18 +80,18 @@ if !exists('g:syntastic_cpp_compiler_options')
8080
let g:syntastic_cpp_compiler_options = ''
8181
endif
8282

83-
if !executable(g:syntastic_cpp_compiler)
84-
finish
85-
endif
86-
8783
let s:save_cpo = &cpo
8884
set cpo&vim
8985

9086
if !exists('g:syntastic_cpp_config_file')
9187
let g:syntastic_cpp_config_file = '.syntastic_cpp_config'
9288
endif
9389

94-
function! SyntaxCheckers_cpp_GetLocList()
90+
function! SyntaxCheckers_cpp_gpp_IsAvailable()
91+
return executable(g:syntastic_cpp_compiler)
92+
endfunction
93+
94+
function! SyntaxCheckers_cpp_gpp_GetLocList()
9595
let makeprg = g:syntastic_cpp_compiler . ' -x c++ -fsyntax-only ' .
9696
\ g:syntastic_cpp_compiler_options
9797
let errorformat = '%-G%f:%s:,%f:%l:%c: %trror: %m,%f:%l:%c: %tarning: '.
@@ -150,6 +150,10 @@ function! SyntaxCheckers_cpp_GetLocList()
150150
endif
151151
endfunction
152152

153+
call g:SyntasticRegistry.CreateAndRegisterChecker({
154+
\ 'filetype': 'cpp',
155+
\ 'name': 'gpp'})
156+
153157
let &cpo = s:save_cpo
154158
unlet s:save_cpo
155159

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010
"
1111
"============================================================================
1212

13-
if !executable('mcs')
14-
finish
15-
endif
13+
function! SyntaxCheckers_cs_mcs_IsAvailable()
14+
return executable('mcs')
15+
endfunction
1616

17-
function! SyntaxCheckers_cs_GetLocList()
17+
function! SyntaxCheckers_cs_mcs_GetLocList()
1818
let makeprg = syntastic#makeprg#build({
1919
\ 'exe': 'mcs',
2020
\ 'args': '--parse' })
@@ -24,3 +24,6 @@ function! SyntaxCheckers_cs_GetLocList()
2424
\ 'defaults': {'bufnr': bufnr("")} })
2525
endfunction
2626

27+
call g:SyntasticRegistry.CreateAndRegisterChecker({
28+
\ 'filetype': 'cs',
29+
\ 'name': 'mcs'})

0 commit comments

Comments
 (0)