Moved syntastic#gcc#GetLocList() to autoload/syntastic/c.vim.
This commit is contained in:
parent
4a6ece567a
commit
a8be73d113
@ -122,6 +122,70 @@ function! syntastic#c#SearchHeaders()
|
||||
return includes
|
||||
endfunction
|
||||
|
||||
" GetLocList() for C-like compilers
|
||||
function! syntastic#c#GetLocList(filetype, options)
|
||||
let ft = a:filetype
|
||||
let errorformat = exists('g:syntastic_' . ft . '_errorformat') ?
|
||||
\ g:syntastic_{ft}_errorformat : a:options['errorformat']
|
||||
|
||||
" determine whether to parse header files as well
|
||||
if expand('%') =~? a:options['headers_pattern']
|
||||
if exists('g:syntastic_' . ft . '_check_header') && g:syntastic_{ft}_check_header
|
||||
let makeprg =
|
||||
\ g:syntastic_{ft}_compiler .
|
||||
\ ' ' . get(a:options, 'makeprg_headers', '') .
|
||||
\ ' ' . g:syntastic_{ft}_compiler_options .
|
||||
\ ' ' . syntastic#c#GetIncludeDirs(ft) .
|
||||
\ ' ' . syntastic#c#NullOutput(ft) .
|
||||
\ ' -c ' . shellescape(expand('%'))
|
||||
else
|
||||
return []
|
||||
endif
|
||||
else
|
||||
let makeprg =
|
||||
\ g:syntastic_{ft}_compiler .
|
||||
\ ' ' . get(a:options, 'makeprg_main', '') .
|
||||
\ ' ' . g:syntastic_{ft}_compiler_options .
|
||||
\ ' ' . syntastic#c#GetIncludeDirs(ft) .
|
||||
\ ' ' . shellescape(expand('%'))
|
||||
endif
|
||||
|
||||
" check if the user manually set some cflags
|
||||
if !exists('b:syntastic_' . ft . '_cflags')
|
||||
" check whether to search for include files at all
|
||||
if !exists('g:syntastic_' . ft . '_no_include_search') || !g:syntastic_{ft}_no_include_search
|
||||
if ft ==# 'c' || ft ==# 'cpp'
|
||||
" refresh the include file search if desired
|
||||
if exists('g:syntastic_' . ft . '_auto_refresh_includes') && g:syntastic_{ft}_auto_refresh_includes
|
||||
let makeprg .= ' ' . syntastic#c#SearchHeaders()
|
||||
else
|
||||
" search for header includes if not cached already
|
||||
if !exists('b:syntastic_' . ft . '_includes')
|
||||
let b:syntastic_{ft}_includes = syntastic#c#SearchHeaders()
|
||||
endif
|
||||
let makeprg .= ' ' . b:syntastic_{ft}_includes
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
else
|
||||
" use the user-defined cflags
|
||||
let makeprg .= ' ' . b:syntastic_{ft}_cflags
|
||||
endif
|
||||
|
||||
" add optional config file parameters
|
||||
let makeprg .= ' ' . syntastic#c#ReadConfig(g:syntastic_{ft}_config_file)
|
||||
|
||||
" process makeprg
|
||||
let errors = SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat })
|
||||
|
||||
" filter the processed errors if desired
|
||||
if exists('g:syntastic_' . ft . '_remove_include_errors') && g:syntastic_{ft}_remove_include_errors
|
||||
call filter(errors, 'get(v:val, "bufnr") == ' . bufnr(''))
|
||||
endif
|
||||
|
||||
return errors
|
||||
endfunction
|
||||
|
||||
" Private functions {{{1
|
||||
|
||||
" initialize c/cpp syntax checker handlers
|
||||
|
@ -1,76 +0,0 @@
|
||||
if exists("g:loaded_syntastic_gcc_autoload")
|
||||
finish
|
||||
endif
|
||||
let g:loaded_syntastic_gcc_autoload = 1
|
||||
|
||||
let s:save_cpo = &cpo
|
||||
set cpo&vim
|
||||
|
||||
|
||||
function! syntastic#gcc#GetLocList(filetype, options)
|
||||
let ft = a:filetype
|
||||
let errorformat = exists('g:syntastic_' . ft . '_errorformat') ?
|
||||
\ g:syntastic_{ft}_errorformat : a:options['errorformat']
|
||||
|
||||
" determine whether to parse header files as well
|
||||
if expand('%') =~? a:options['headers_pattern']
|
||||
if exists('g:syntastic_' . ft . '_check_header') && g:syntastic_{ft}_check_header
|
||||
let makeprg =
|
||||
\ g:syntastic_{ft}_compiler .
|
||||
\ ' ' . get(a:options, 'makeprg_headers', '') .
|
||||
\ ' ' . g:syntastic_{ft}_compiler_options .
|
||||
\ ' ' . syntastic#c#GetIncludeDirs(ft) .
|
||||
\ ' ' . syntastic#c#NullOutput(ft) .
|
||||
\ ' -c ' . shellescape(expand('%'))
|
||||
else
|
||||
return []
|
||||
endif
|
||||
else
|
||||
let makeprg =
|
||||
\ g:syntastic_{ft}_compiler .
|
||||
\ ' ' . get(a:options, 'makeprg_main', '') .
|
||||
\ ' ' . g:syntastic_{ft}_compiler_options .
|
||||
\ ' ' . syntastic#c#GetIncludeDirs(ft) .
|
||||
\ ' ' . shellescape(expand('%'))
|
||||
endif
|
||||
|
||||
" check if the user manually set some cflags
|
||||
if !exists('b:syntastic_' . ft . '_cflags')
|
||||
" check whether to search for include files at all
|
||||
if !exists('g:syntastic_' . ft . '_no_include_search') || !g:syntastic_{ft}_no_include_search
|
||||
if ft ==# 'c' || ft ==# 'cpp'
|
||||
" refresh the include file search if desired
|
||||
if exists('g:syntastic_' . ft . '_auto_refresh_includes') && g:syntastic_{ft}_auto_refresh_includes
|
||||
let makeprg .= ' ' . syntastic#c#SearchHeaders()
|
||||
else
|
||||
" search for header includes if not cached already
|
||||
if !exists('b:syntastic_' . ft . '_includes')
|
||||
let b:syntastic_{ft}_includes = syntastic#c#SearchHeaders()
|
||||
endif
|
||||
let makeprg .= ' ' . b:syntastic_{ft}_includes
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
else
|
||||
" use the user-defined cflags
|
||||
let makeprg .= ' ' . b:syntastic_{ft}_cflags
|
||||
endif
|
||||
|
||||
" add optional config file parameters
|
||||
let makeprg .= ' ' . syntastic#c#ReadConfig(g:syntastic_{ft}_config_file)
|
||||
|
||||
" process makeprg
|
||||
let errors = SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat })
|
||||
|
||||
" filter the processed errors if desired
|
||||
if exists('g:syntastic_' . ft . '_remove_include_errors') && g:syntastic_{ft}_remove_include_errors
|
||||
call filter(errors, 'get(v:val, "bufnr") == ' . bufnr(''))
|
||||
endif
|
||||
|
||||
return errors
|
||||
endfunction
|
||||
|
||||
let &cpo = s:save_cpo
|
||||
unlet s:save_cpo
|
||||
|
||||
" vim: set et sts=4 sw=4 fdm=marker:
|
@ -32,7 +32,7 @@ if !exists('g:syntastic_ada_config_file')
|
||||
endif
|
||||
|
||||
function! SyntaxCheckers_ada_gcc_GetLocList()
|
||||
return syntastic#gcc#GetLocList('ada', {
|
||||
return syntastic#c#GetLocList('ada', {
|
||||
\ 'errorformat':
|
||||
\ '%-G%f:%s:,' .
|
||||
\ '%f:%l:%c: %m,' .
|
||||
|
@ -36,7 +36,7 @@ if !exists('g:syntastic_c_config_file')
|
||||
endif
|
||||
|
||||
function! SyntaxCheckers_c_gcc_GetLocList()
|
||||
return syntastic#gcc#GetLocList('c', {
|
||||
return syntastic#c#GetLocList('c', {
|
||||
\ 'errorformat':
|
||||
\ '%-G%f:%s:,' .
|
||||
\ '%-G%f:%l: %#error: %#(Each undeclared identifier is reported only%.%#,' .
|
||||
|
@ -33,7 +33,7 @@ function! SyntaxCheckers_c_oclint_GetLocList()
|
||||
let makeprg = syntastic#makeprg#build({
|
||||
\ 'exe': 'oclint',
|
||||
\ 'args': '-text',
|
||||
\ 'post_args': '-- -c' . syntastic#c#ReadConfig(g:syntastic_oclint_config_file),
|
||||
\ 'post_args': '-- -c ' . syntastic#c#ReadConfig(g:syntastic_oclint_config_file),
|
||||
\ 'subchecker': 'oclint' })
|
||||
|
||||
let errorformat =
|
||||
|
@ -35,7 +35,7 @@ if !exists('g:syntastic_cpp_config_file')
|
||||
endif
|
||||
|
||||
function! SyntaxCheckers_cpp_gcc_GetLocList()
|
||||
return syntastic#gcc#GetLocList('cpp', {
|
||||
return syntastic#c#GetLocList('cpp', {
|
||||
\ 'errorformat':
|
||||
\ '%-G%f:%s:,' .
|
||||
\ '%f:%l:%c: %trror: %m,' .
|
||||
|
@ -40,7 +40,7 @@ if !exists('g:syntastic_d_config_file')
|
||||
endif
|
||||
|
||||
function! SyntaxCheckers_d_dmd_GetLocList()
|
||||
return syntastic#gcc#GetLocList('d', {
|
||||
return syntastic#c#GetLocList('d', {
|
||||
\ 'errorformat':
|
||||
\ '%-G%f:%s:,%f(%l): %m,' .
|
||||
\ '%f:%l: %m',
|
||||
|
@ -35,7 +35,7 @@ if !exists('g:syntastic_objc_config_file')
|
||||
endif
|
||||
|
||||
function! SyntaxCheckers_objc_gcc_GetLocList()
|
||||
return syntastic#gcc#GetLocList('objc', {
|
||||
return syntastic#c#GetLocList('objc', {
|
||||
\ 'errorformat':
|
||||
\ '%-G%f:%s:,' .
|
||||
\ '%-G%f:%l: %#error: %#(Each undeclared identifier is reported only%.%#,' .
|
||||
|
@ -35,7 +35,7 @@ if !exists('g:syntastic_objcpp_config_file')
|
||||
endif
|
||||
|
||||
function! SyntaxCheckers_objcpp_gcc_GetLocList()
|
||||
return syntastic#gcc#GetLocList('objcpp', {
|
||||
return syntastic#c#GetLocList('objcpp', {
|
||||
\ 'errorformat':
|
||||
\ '%-G%f:%s:,' .
|
||||
\ '%-G%f:%l: %#error: %#(Each undeclared identifier is reported only%.%#,' .
|
||||
|
Loading…
x
Reference in New Issue
Block a user