GCC refactor.

This commit is contained in:
LCD 47 2013-05-21 10:03:04 +03:00
parent 792349fcc9
commit ea827bfa06
10 changed files with 278 additions and 699 deletions

View File

@ -6,51 +6,14 @@ let g:loaded_syntastic_c_autoload = 1
let s:save_cpo = &cpo
set cpo&vim
" initialize c/cpp syntax checker handlers
function! s:Init()
let s:handlers = []
let s:cflags = {}
call s:RegHandler('gtk', 'syntastic#c#CheckPKG',
\ ['gtk', 'gtk+-2.0', 'gtk+', 'glib-2.0', 'glib'])
call s:RegHandler('glib', 'syntastic#c#CheckPKG',
\ ['glib', 'glib-2.0', 'glib'])
call s:RegHandler('glade', 'syntastic#c#CheckPKG',
\ ['glade', 'libglade-2.0', 'libglade'])
call s:RegHandler('libsoup', 'syntastic#c#CheckPKG',
\ ['libsoup', 'libsoup-2.4', 'libsoup-2.2'])
call s:RegHandler('webkit', 'syntastic#c#CheckPKG',
\ ['webkit', 'webkit-1.0'])
call s:RegHandler('cairo', 'syntastic#c#CheckPKG',
\ ['cairo', 'cairo'])
call s:RegHandler('pango', 'syntastic#c#CheckPKG',
\ ['pango', 'pango'])
call s:RegHandler('libxml', 'syntastic#c#CheckPKG',
\ ['libxml', 'libxml-2.0', 'libxml'])
call s:RegHandler('freetype', 'syntastic#c#CheckPKG',
\ ['freetype', 'freetype2', 'freetype'])
call s:RegHandler('SDL', 'syntastic#c#CheckPKG',
\ ['sdl', 'sdl'])
call s:RegHandler('opengl', 'syntastic#c#CheckPKG',
\ ['opengl', 'gl'])
call s:RegHandler('ruby', 'syntastic#c#CheckRuby', [])
call s:RegHandler('Python\.h', 'syntastic#c#CheckPython', [])
call s:RegHandler('php\.h', 'syntastic#c#CheckPhp', [])
endfunction
" default include directories
let s:default_includes = [ '.', '..', 'include', 'includes',
\ '../include', '../includes' ]
" Public functions {{{1
" convenience function to determine the 'null device' parameter
" based on the current operating system
function! syntastic#c#GetNullDevice()
if has('win32')
return '-o nul'
elseif has('unix') || has('mac')
return '-o /dev/null'
endif
return ''
function! syntastic#c#NullOutput(ft)
let known_os = has('win32') || has('unix') || has('mac')
let opt_o = ft ==# 'd' ? '-of' : '-o '
return known_os ? opt_o . syntastic#util#DevNull() : ''
endfunction
" get the gcc include directory argument depending on the default
@ -112,7 +75,7 @@ function! syntastic#c#SearchHeaders()
let includes = ''
let files = []
let found = []
let lines = filter(getline(1, 100), 'v:val =~# "#\s*include"')
let lines = filter(getline(1, 100), 'v:val =~# "^\s*#\s*include"')
" search current buffer
for line in lines
@ -140,7 +103,7 @@ function! syntastic#c#SearchHeaders()
catch /E484/
continue
endtry
let lines = filter(lines, 'v:val =~# "#\s*include"')
let lines = filter(lines, 'v:val =~# "^\s*#\s*include"')
for handler in s:handlers
if index(found, handler["regex"]) != -1
continue
@ -159,6 +122,40 @@ function! syntastic#c#SearchHeaders()
return includes
endfunction
" Private functions {{{1
" initialize c/cpp syntax checker handlers
function! s:Init()
let s:handlers = []
let s:cflags = {}
call s:RegHandler('gtk', 'syntastic#c#CheckPKG',
\ ['gtk', 'gtk+-2.0', 'gtk+', 'glib-2.0', 'glib'])
call s:RegHandler('glib', 'syntastic#c#CheckPKG',
\ ['glib', 'glib-2.0', 'glib'])
call s:RegHandler('glade', 'syntastic#c#CheckPKG',
\ ['glade', 'libglade-2.0', 'libglade'])
call s:RegHandler('libsoup', 'syntastic#c#CheckPKG',
\ ['libsoup', 'libsoup-2.4', 'libsoup-2.2'])
call s:RegHandler('webkit', 'syntastic#c#CheckPKG',
\ ['webkit', 'webkit-1.0'])
call s:RegHandler('cairo', 'syntastic#c#CheckPKG',
\ ['cairo', 'cairo'])
call s:RegHandler('pango', 'syntastic#c#CheckPKG',
\ ['pango', 'pango'])
call s:RegHandler('libxml', 'syntastic#c#CheckPKG',
\ ['libxml', 'libxml-2.0', 'libxml'])
call s:RegHandler('freetype', 'syntastic#c#CheckPKG',
\ ['freetype', 'freetype2', 'freetype'])
call s:RegHandler('SDL', 'syntastic#c#CheckPKG',
\ ['sdl', 'sdl'])
call s:RegHandler('opengl', 'syntastic#c#CheckPKG',
\ ['opengl', 'gl'])
call s:RegHandler('ruby', 'syntastic#c#CheckRuby', [])
call s:RegHandler('Python\.h', 'syntastic#c#CheckPython', [])
call s:RegHandler('php\.h', 'syntastic#c#CheckPhp', [])
endfunction
" try to find library with 'pkg-config'
" search possible libraries from first to last given
" argument until one is found
@ -231,9 +228,15 @@ function! s:RegHandler(regex, function, args)
call add(s:handlers, handler)
endfunction
" }}}1
" default include directories
let s:default_includes = [ '.', '..', 'include', 'includes',
\ '../include', '../includes' ]
call s:Init()
let &cpo = s:save_cpo
unlet s:save_cpo
" vim: set et sts=4 sw=4:
" vim: set et sts=4 sw=4 fdm=marker:

View File

@ -0,0 +1,76 @@
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:

View File

@ -7,68 +7,6 @@
"
"============================================================================
" In order to also check header files add this to your .vimrc:
"
" let g:syntastic_ada_check_header = 1
"
" To disable the search of included header files after special
" libraries like gtk and glib add this line to your .vimrc:
"
" let g:syntastic_ada_no_include_search = 1
"
" To disable the include of the default include dirs (such as /usr/include)
" add this line to your .vimrc:
"
" let g:syntastic_ada_no_default_include_dirs = 1
"
" To enable header files being re-checked on every file write add the
" following line to your .vimrc. Otherwise the header files are checked only
" one time on initially loading the file.
" In order to force syntastic to refresh the header includes simply
" unlet b:syntastic_ada_includes. Then the header files are being re-checked
" on the next file write.
"
" let g:syntastic_ada_auto_refresh_includes = 1
"
" Alternatively you can set the buffer local variable b:syntastic_ada_cflags.
" If this variable is set for the current buffer no search for additional
" libraries is done. I.e. set the variable like this:
"
" let b:syntastic_ada_cflags = ' -I/usr/include/libsoup-2.4'
"
" In order to add some custom include directories that should be added to the
" gcc command line you can add those to the global variable
" g:syntastic_ada_include_dirs. This list can be used like this:
"
" let g:syntastic_ada_include_dirs = [ 'includes', 'headers' ]
"
" Moreover it is possible to add additional compiler options to the syntax
" checking execution via the variable 'g:syntastic_ada_compiler_options':
"
" let g:syntastic_ada_compiler_options = ' -std=c++0x'
"
" Additionally the setting 'g:syntastic_ada_config_file' allows you to define
" a file that contains additional compiler arguments like include directories
" or CFLAGS. The file is expected to contain one option per line. If none is
" given the filename defaults to '.syntastic_ada_config':
"
" let g:syntastic_ada_config_file = '.config'
"
" Using the global variable 'g:syntastic_ada_remove_include_errors' you can
" specify whether errors of files included via the
" g:syntastic_ada_include_dirs' setting are removed from the result set:
"
" let g:syntastic_ada_remove_include_errors = 1
"
" Use the variable 'g:syntastic_ada_errorformat' to override the default error
" format:
"
" let g:syntastic_ada_errorformat = '%f:%l:%c: %trror: %m'
"
" Set your compiler executable with e.g. (defaults to gcc)
"
" let g:syntastic_ada_compiler = 'gcc'
if exists('g:loaded_syntastic_ada_gcc_checker')
finish
endif
@ -94,68 +32,14 @@ if !exists('g:syntastic_ada_config_file')
endif
function! SyntaxCheckers_ada_gcc_GetLocList()
let makeprg = g:syntastic_ada_compiler . ' -c -x ada -fsyntax-only '
let errorformat = '%-G%f:%s:,%f:%l:%c: %m,%f:%l: %m'
if exists('g:syntastic_c_errorformat')
let errorformat = g:syntastic_c_errorformat
endif
" add optional user-defined compiler options
let makeprg .= g:syntastic_ada_compiler_options
let makeprg .= ' ' . shellescape(expand('%')) .
\ ' ' . syntastic#c#GetIncludeDirs('ada')
" determine whether to parse header files as well
if expand('%') =~? '\.ads$'
if exists('g:syntastic_ada_check_header')
let makeprg = g:syntastic_ada_compiler .
\ ' -c ' . shellescape(expand('%')) .
\ ' ' . g:syntastic_ada_compiler_options .
\ ' ' . syntastic#c#GetIncludeDirs('ada')
else
return []
endif
endif
" check if the user manually set some cflags
if !exists('b:syntastic_ada_cflags')
" check whether to search for include files at all
if !exists('g:syntastic_ada_no_include_search') ||
\ g:syntastic_ada_no_include_search != 1
" refresh the include file search if desired
if exists('g:syntastic_ada_auto_refresh_includes') &&
\ g:syntastic_ada_auto_refresh_includes != 0
let makeprg .= syntastic#c#SearchHeaders()
else
" search for header includes if not cached already
if !exists('b:syntastic_ada_includes')
let b:syntastic_ada_includes = syntastic#c#SearchHeaders()
endif
let makeprg .= b:syntastic_ada_includes
endif
endif
else
" use the user-defined cflags
let makeprg .= b:syntastic_ada_cflags
endif
" add optional config file parameters
let makeprg .= ' ' . syntastic#c#ReadConfig(g:syntastic_ada_config_file)
" process makeprg
let errors = SyntasticMake({ 'makeprg': makeprg,
\ 'errorformat': errorformat })
" filter the processed errors if desired
if exists('g:syntastic_ada_remove_include_errors') &&
\ g:syntastic_ada_remove_include_errors != 0
return filter(errors,
\ 'has_key(v:val, "bufnr") && v:val["bufnr"]=='.bufnr(''))
else
return errors
endif
return syntastic#gcc#GetLocList('ada', {
\ 'errorformat':
\ '%-G%f:%s:,' .
\ '%f:%l:%c: %m,' .
\ '%f:%l: %m',
\ 'makeprg_main': '-c -x ada -fsyntax-only',
\ 'makeprg_headers': '-x ada',
\ 'headers_pattern': '\.ads$' })
endfunction
call g:SyntasticRegistry.CreateAndRegisterChecker({

View File

@ -10,67 +10,6 @@
"
"============================================================================
" In order to also check header files add this to your .vimrc:
"
" let g:syntastic_c_check_header = 1
"
" To disable the search of included header files after special
" libraries like gtk and glib add this line to your .vimrc:
"
" let g:syntastic_c_no_include_search = 1
"
" To disable the include of the default include dirs (such as /usr/include)
" add this line to your .vimrc:
"
" let g:syntastic_c_no_default_include_dirs = 1
"
" To enable header files being re-checked on every file write add the
" following line to your .vimrc. Otherwise the header files are checked only
" one time on initially loading the file.
" In order to force syntastic to refresh the header includes simply
" unlet b:syntastic_c_includes. Then the header files are being re-checked on
" the next file write.
"
" let g:syntastic_c_auto_refresh_includes = 1
"
" Alternatively you can set the buffer local variable b:syntastic_c_cflags.
" If this variable is set for the current buffer no search for additional
" libraries is done. I.e. set the variable like this:
"
" let b:syntastic_c_cflags = ' -I/usr/include/libsoup-2.4'
"
" In order to add some custom include directories that should be added to the
" gcc command line you can add those to the global variable
" g:syntastic_c_include_dirs. This list can be used like this:
"
" let g:syntastic_c_include_dirs = [ 'includes', 'headers' ]
"
" Moreover it is possible to add additional compiler options to the syntax
" checking execution via the variable 'g:syntastic_c_compiler_options':
"
" let g:syntastic_c_compiler_options = ' -ansi'
"
" Additionally the setting 'g:syntastic_c_config_file' allows you to define a
" file that contains additional compiler arguments like include directories or
" CFLAGS. The file is expected to contain one option per line. If none is
" given the filename defaults to '.syntastic_c_config':
"
" let g:syntastic_c_config_file = '.config'
"
" Using the global variable 'g:syntastic_c_remove_include_errors' you can
" specify whether errors of files included via the g:syntastic_c_include_dirs'
" setting are removed from the result set:
"
" let g:syntastic_c_remove_include_errors = 1
"
" Use the variable 'g:syntastic_c_errorformat' to override the default error
" format:
"
" let g:syntastic_c_errorformat = '%f:%l:%c: %trror: %m'
"
" Set your compiler executable with e.g. (defaults to gcc)
"
" let g:syntastic_c_compiler = 'clang'
if exists('g:loaded_syntastic_c_gcc_checker')
finish
@ -97,8 +36,8 @@ if !exists('g:syntastic_c_config_file')
endif
function! SyntaxCheckers_c_gcc_GetLocList()
let makeprg = g:syntastic_c_compiler . ' -x c -fsyntax-only '
let errorformat =
return syntastic#gcc#GetLocList('c', {
\ 'errorformat':
\ '%-G%f:%s:,' .
\ '%-G%f:%l: %#error: %#(Each undeclared identifier is reported only%.%#,' .
\ '%-G%f:%l: %#error: %#for each function it appears%.%#,' .
@ -109,68 +48,9 @@ function! SyntaxCheckers_c_gcc_GetLocList()
\ '%f:%l:%c: %m,' .
\ '%f:%l: %trror: %m,' .
\ '%f:%l: %tarning: %m,'.
\ '%f:%l: %m'
if exists('g:syntastic_c_errorformat')
let errorformat = g:syntastic_c_errorformat
endif
" add optional user-defined compiler options
let makeprg .= g:syntastic_c_compiler_options
let makeprg .= ' ' . shellescape(expand('%')) .
\ ' ' . syntastic#c#GetIncludeDirs('c')
" determine whether to parse header files as well
if expand('%') =~? '\.h$'
if exists('g:syntastic_c_check_header')
let makeprg = g:syntastic_c_compiler .
\ ' -c ' . shellescape(expand('%')) .
\ ' ' . g:syntastic_c_compiler_options .
\ ' ' . syntastic#c#GetNullDevice() .
\ ' ' . syntastic#c#GetIncludeDirs('c')
else
return []
endif
endif
" check if the user manually set some cflags
if !exists('b:syntastic_c_cflags')
" check whether to search for include files at all
if !exists('g:syntastic_c_no_include_search') ||
\ g:syntastic_c_no_include_search != 1
" refresh the include file search if desired
if exists('g:syntastic_c_auto_refresh_includes') &&
\ g:syntastic_c_auto_refresh_includes != 0
let makeprg .= syntastic#c#SearchHeaders()
else
" search for header includes if not cached already
if !exists('b:syntastic_c_includes')
let b:syntastic_c_includes = syntastic#c#SearchHeaders()
endif
let makeprg .= b:syntastic_c_includes
endif
endif
else
" use the user-defined cflags
let makeprg .= b:syntastic_c_cflags
endif
" add optional config file parameters
let makeprg .= ' ' . syntastic#c#ReadConfig(g:syntastic_c_config_file)
" process makeprg
let errors = SyntasticMake({ 'makeprg': makeprg,
\ 'errorformat': errorformat })
" filter the processed errors if desired
if exists('g:syntastic_c_remove_include_errors') &&
\ g:syntastic_c_remove_include_errors != 0
return filter(errors,
\ 'has_key(v:val, "bufnr") && v:val["bufnr"]=='.bufnr(''))
else
return errors
endif
\ '%f:%l: %m',
\ 'makeprg_main': '-x c -fsyntax-only',
\ 'headers_pattern': '\.h$' })
endfunction
call g:SyntasticRegistry.CreateAndRegisterChecker({

View File

@ -10,68 +10,6 @@
"
"============================================================================
" In order to also check header files add this to your .vimrc:
"
" let g:syntastic_cpp_check_header = 1
"
" To disable the search of included header files after special
" libraries like gtk and glib add this line to your .vimrc:
"
" let g:syntastic_cpp_no_include_search = 1
"
" To disable the include of the default include dirs (such as /usr/include)
" add this line to your .vimrc:
"
" let g:syntastic_cpp_no_default_include_dirs = 1
"
" To enable header files being re-checked on every file write add the
" following line to your .vimrc. Otherwise the header files are checked only
" one time on initially loading the file.
" In order to force syntastic to refresh the header includes simply
" unlet b:syntastic_cpp_includes. Then the header files are being re-checked
" on the next file write.
"
" let g:syntastic_cpp_auto_refresh_includes = 1
"
" Alternatively you can set the buffer local variable b:syntastic_cpp_cflags.
" If this variable is set for the current buffer no search for additional
" libraries is done. I.e. set the variable like this:
"
" let b:syntastic_cpp_cflags = ' -I/usr/include/libsoup-2.4'
"
" In order to add some custom include directories that should be added to the
" gcc command line you can add those to the global variable
" g:syntastic_cpp_include_dirs. This list can be used like this:
"
" let g:syntastic_cpp_include_dirs = [ 'includes', 'headers' ]
"
" Moreover it is possible to add additional compiler options to the syntax
" checking execution via the variable 'g:syntastic_cpp_compiler_options':
"
" let g:syntastic_cpp_compiler_options = ' -std=c++0x'
"
" Additionally the setting 'g:syntastic_cpp_config_file' allows you to define
" a file that contains additional compiler arguments like include directories
" or CFLAGS. The file is expected to contain one option per line. If none is
" given the filename defaults to '.syntastic_cpp_config':
"
" let g:syntastic_cpp_config_file = '.config'
"
" Using the global variable 'g:syntastic_cpp_remove_include_errors' you can
" specify whether errors of files included via the
" g:syntastic_cpp_include_dirs' setting are removed from the result set:
"
" let g:syntastic_cpp_remove_include_errors = 1
"
" Use the variable 'g:syntastic_cpp_errorformat' to override the default error
" format:
"
" let g:syntastic_cpp_errorformat = '%f:%l:%c: %trror: %m'
"
" Set your compiler executable with e.g. (defaults to g++)
"
" let g:syntastic_cpp_compiler = 'clang++'
if exists('g:loaded_syntastic_cpp_gcc_checker')
finish
endif
@ -97,76 +35,17 @@ if !exists('g:syntastic_cpp_config_file')
endif
function! SyntaxCheckers_cpp_gcc_GetLocList()
let makeprg = g:syntastic_cpp_compiler . ' -x c++ -fsyntax-only '
let errorformat =
return syntastic#gcc#GetLocList('cpp', {
\ 'errorformat':
\ '%-G%f:%s:,' .
\ '%f:%l:%c: %trror: %m,' .
\ '%f:%l:%c: %tarning: %m,' .
\ '%f:%l:%c: %m,'.
\ '%f:%l: %trror: %m,'.
\ '%f:%l: %tarning: %m,'.
\ '%f:%l: %m'
if exists('g:syntastic_cpp_errorformat')
let errorformat = g:syntastic_cpp_errorformat
endif
" add optional user-defined compiler options
let makeprg .= g:syntastic_cpp_compiler_options
let makeprg .= ' ' . shellescape(expand('%')) .
\ ' ' . syntastic#c#GetIncludeDirs('cpp')
" determine whether to parse header files as well
if expand('%') =~? '\.\(h\|hpp\|hh\)$'
if exists('g:syntastic_cpp_check_header')
let makeprg = g:syntastic_cpp_compiler .
\ ' -c ' . shellescape(expand('%')) .
\ ' ' . g:syntastic_cpp_compiler_options .
\ ' ' . syntastic#c#GetNullDevice() .
\ ' ' . syntastic#c#GetIncludeDirs('cpp')
else
return []
endif
endif
" check if the user manually set some cflags
if !exists('b:syntastic_cpp_cflags')
" check whether to search for include files at all
if !exists('g:syntastic_cpp_no_include_search') ||
\ g:syntastic_cpp_no_include_search != 1
" refresh the include file search if desired
if exists('g:syntastic_cpp_auto_refresh_includes') &&
\ g:syntastic_cpp_auto_refresh_includes != 0
let makeprg .= syntastic#c#SearchHeaders()
else
" search for header includes if not cached already
if !exists('b:syntastic_cpp_includes')
let b:syntastic_cpp_includes = syntastic#c#SearchHeaders()
endif
let makeprg .= b:syntastic_cpp_includes
endif
endif
else
" use the user-defined cflags
let makeprg .= b:syntastic_cpp_cflags
endif
" add optional config file parameters
let makeprg .= ' ' . syntastic#c#ReadConfig(g:syntastic_cpp_config_file)
" process makeprg
let errors = SyntasticMake({ 'makeprg': makeprg,
\ 'errorformat': errorformat })
" filter the processed errors if desired
if exists('g:syntastic_cpp_remove_include_errors') &&
\ g:syntastic_cpp_remove_include_errors != 0
return filter(errors,
\ 'has_key(v:val, "bufnr") && v:val["bufnr"]=='.bufnr(''))
else
return errors
endif
\ '%f:%l: %m',
\ 'makeprg_main': '-x c++ -fsyntax-only',
\ 'headers_pattern': '\.\(h\|hpp\|hh\)$' })
endfunction
call g:SyntasticRegistry.CreateAndRegisterChecker({

View File

@ -15,68 +15,6 @@
"
"============================================================================
" In order to also check header files add this to your .vimrc:
"
" let g:syntastic_d_check_header = 1
"
" To disable the search of included header files after special
" libraries like gtk and glib add this line to your .vimrc:
"
" let g:syntastic_d_no_include_search = 1
"
" To disable the include of the default include dirs (such as /usr/include)
" add this line to your .vimrc:
"
" let g:syntastic_d_no_default_include_dirs = 1
"
" To enable header files being re-checked on every file write add the
" following line to your .vimrc. Otherwise the header files are checked only
" one time on initially loading the file.
" In order to force syntastic to refresh the header includes simply
" unlet b:syntastic_d_includes. Then the header files are being re-checked
" on the next file write.
"
" let g:syntastic_d_auto_refresh_includes = 1
"
" Alternatively you can set the buffer local variable b:syntastic_d_cflags.
" If this variable is set for the current buffer no search for additional
" libraries is done. I.e. set the variable like this:
"
" let b:syntastic_d_cflags = ' -I/usr/include/libsoup-2.4'
"
" In order to add some custom include directories that should be added to the
" dmd command line you can add those to the global variable
" g:syntastic_d_include_dirs. This list can be used like this:
"
" let g:syntastic_d_include_dirs = [ 'includes', 'headers' ]
"
" Moreover it is possible to add additional compiler options to the syntax
" checking execution via the variable 'g:syntastic_d_compiler_options':
"
" let g:syntastic_d_compiler_options = ' -std=c++0x'
"
" Additionally the setting 'g:syntastic_d_config_file' allows you to define
" a file that contains additional compiler arguments like include directories
" or CFLAGS. The file is expected to contain one option per line. If none is
" given the filename defaults to '.syntastic_d_config':
"
" let g:syntastic_d_config_file = '.config'
"
" Using the global variable 'g:syntastic_d_remove_include_errors' you can
" specify whether errors of files included via the
" g:syntastic_d_include_dirs' setting are removed from the result set:
"
" let g:syntastic_d_remove_include_errors = 1
"
" Use the variable 'g:syntastic_d_errorformat' to override the default error
" format:
"
" let g:syntastic_d_errorformat = '%f:%l:%c: %trror: %m'
"
" Set your compiler executable with e.g. (defaults to dmd)
"
" let g:syntastic_d_compiler = 'clang++'
if exists('g:loaded_syntastic_d_dmd_checker')
finish
endif
@ -102,69 +40,12 @@ if !exists('g:syntastic_d_config_file')
endif
function! SyntaxCheckers_d_dmd_GetLocList()
let makeprg = g:syntastic_d_compiler . ' -c -of' . syntastic#util#DevNull() . ' '
let errorformat = '%-G%f:%s:,%f(%l): %m,%f:%l: %m'
if exists('g:syntastic_d_errorformat')
let errorformat = g:syntastic_d_errorformat
endif
" add optional user-defined compiler options
let makeprg .= g:syntastic_d_compiler_options
let makeprg .= ' ' . shellescape(expand('%')) .
\ ' ' . syntastic#c#GetIncludeDirs('d')
" determine whether to parse header files as well
if expand('%') =~? '\.di$'
if exists('g:syntastic_d_check_header')
let makeprg = g:syntastic_d_compiler .
\ ' -c ' . shellescape(expand('%')) .
\ ' -of' . syntastic#util#DevNull() .
\ ' ' . g:syntastic_d_compiler_options .
\ ' ' . syntastic#c#GetIncludeDirs('d')
else
return []
endif
endif
" check if the user manually set some cflags
if !exists('b:syntastic_d_cflags')
" check whether to search for include files at all
if !exists('g:syntastic_d_no_include_search') ||
\ g:syntastic_d_no_include_search != 1
" refresh the include file search if desired
if exists('g:syntastic_d_auto_refresh_includes') &&
\ g:syntastic_d_auto_refresh_includes != 0
let makeprg .= syntastic#c#SearchHeaders()
else
" search for header includes if not cached already
if !exists('b:syntastic_d_includes')
let b:syntastic_d_includes = syntastic#c#SearchHeaders()
endif
let makeprg .= b:syntastic_d_includes
endif
endif
else
" use the user-defined cflags
let makeprg .= b:syntastic_d_cflags
endif
" add optional config file parameters
let makeprg .= ' ' . syntastic#c#ReadConfig(g:syntastic_d_config_file)
" process makeprg
let errors = SyntasticMake({ 'makeprg': makeprg,
\ 'errorformat': errorformat })
" filter the processed errors if desired
if exists('g:syntastic_d_remove_include_errors') &&
\ g:syntastic_d_remove_include_errors != 0
return filter(errors,
\ 'has_key(v:val, "bufnr") && v:val["bufnr"]=='.bufnr(''))
else
return errors
endif
return syntastic#gcc#GetLocList('d', {
\ 'errorformat':
\ '%-G%f:%s:,%f(%l): %m,' .
\ '%f:%l: %m',
\ 'makeprg_main': '-c',
\ 'headers_pattern': '\.di$' })
endfunction
call g:SyntasticRegistry.CreateAndRegisterChecker({

View File

@ -21,7 +21,7 @@ endfunction
function! SyntaxCheckers_llvm_llvm_GetLocList()
let makeprg = syntastic#makeprg#build({
\ 'exe': 'llc',
\ 'args': syntastic#c#GetNullDevice(),
\ 'args': syntastic#c#NullOutput('llvm'),
\ 'subchecker': 'llvm' })
let errorformat = 'llc: %f:%l:%c: %trror: %m'

View File

@ -10,69 +10,6 @@
"
"============================================================================
" In order to also check header files add this to your .vimrc:
" (this usually creates a .gch file in your source directory)
"
" let g:syntastic_objc_check_header = 1
"
" To disable the search of included header files after special
" libraries like gtk and glib add this line to your .vimrc:
"
" let g:syntastic_objc_no_include_search = 1
"
" To disable the include of the default include dirs (such as /usr/include)
" add this line to your .vimrc:
"
" let g:syntastic_objc_no_default_include_dirs = 1
"
" To enable header files being re-checked on every file write add the
" following line to your .vimrc. Otherwise the header files are checked only
" one time on initially loading the file.
" In order to force syntastic to refresh the header includes simply
" unlet b:syntastic_objc_includes. Then the header files are being re-checked on
" the next file write.
"
" let g:syntastic_objc_auto_refresh_includes = 1
"
" Alternatively you can set the buffer local variable b:syntastic_objc_cflags.
" If this variable is set for the current buffer no search for additional
" libraries is done. I.e. set the variable like this:
"
" let b:syntastic_objc_cflags = ' -I/usr/include/libsoup-2.4'
"
" In order to add some custom include directories that should be added to the
" gcc command line you can add those to the global variable
" g:syntastic_objc_include_dirs. This list can be used like this:
"
" let g:syntastic_objc_include_dirs = [ 'includes', 'headers' ]
"
" Moreover it is possible to add additional compiler options to the syntax
" checking execution via the variable 'g:syntastic_objc_compiler_options':
"
" let g:syntastic_objc_compiler_options = ' -ansi'
"
" Additionally the setting 'g:syntastic_objc_config_file' allows you to define a
" file that contains additional compiler arguments like include directories or
" CFLAGS. The file is expected to contain one option per line. If none is
" given the filename defaults to '.syntastic_objc_config':
"
" let g:syntastic_objc_config_file = '.config'
"
" Using the global variable 'g:syntastic_objc_remove_include_errors' you can
" specify whether errors of files included via the g:syntastic_objc_include_dirs'
" setting are removed from the result set:
"
" let g:syntastic_objc_remove_include_errors = 1
"
" Use the variable 'g:syntastic_objc_errorformat' to override the default error
" format:
"
" let g:syntastic_objc_errorformat = '%f:%l:%c: %trror: %m'
"
" Set your compiler executable with e.g. (defaults to gcc)
"
" let g:syntastic_objc_compiler = 'clang'
if exists('g:loaded_syntastic_objc_gcc_checker')
finish
endif
@ -98,8 +35,8 @@ if !exists('g:syntastic_objc_config_file')
endif
function! SyntaxCheckers_objc_gcc_GetLocList()
let makeprg = g:syntastic_objc_compiler . ' -x objective-c -fsyntax-only -lobjc'
let errorformat =
return syntastic#gcc#GetLocList('objc', {
\ 'errorformat':
\ '%-G%f:%s:,' .
\ '%-G%f:%l: %#error: %#(Each undeclared identifier is reported only%.%#,' .
\ '%-G%f:%l: %#error: %#for each function it appears%.%#,' .
@ -110,68 +47,10 @@ function! SyntaxCheckers_objc_gcc_GetLocList()
\ '%f:%l:%c: %m,' .
\ '%f:%l: %trror: %m,' .
\ '%f:%l: %tarning: %m,' .
\ '%f:%l: %m'
if exists('g:syntastic_objc_errorformat')
let errorformat = g:syntastic_objc_errorformat
endif
" add optional user-defined compiler options
let makeprg .= g:syntastic_objc_compiler_options
let makeprg .= ' ' . shellescape(expand('%')) .
\ ' ' . syntastic#c#GetIncludeDirs('objc')
" determine whether to parse header files as well
if expand('%') =~? '\.h$'
if exists('g:syntastic_objc_check_header')
let makeprg = g:syntastic_objc_compiler .
\ ' -x objective-c-header ' .
\ ' -c ' . shellescape(expand('%')) .
\ ' ' . g:syntastic_objc_compiler_options .
\ ' ' . syntastic#c#GetIncludeDirs('objc')
else
return []
endif
endif
" check if the user manually set some cflags
if !exists('b:syntastic_objc_cflags')
" check whether to search for include files at all
if !exists('g:syntastic_objc_no_include_search') ||
\ g:syntastic_objc_no_include_search != 1
" refresh the include file search if desired
if exists('g:syntastic_objc_auto_refresh_includes') &&
\ g:syntastic_objc_auto_refresh_includes != 0
let makeprg .= syntastic#c#SearchHeaders()
else
" search for header includes if not cached already
if !exists('b:syntastic_objc_includes')
let b:syntastic_objc_includes = syntastic#c#SearchHeaders()
endif
let makeprg .= b:syntastic_objc_includes
endif
endif
else
" use the user-defined cflags
let makeprg .= b:syntastic_objc_cflags
endif
" add optional config file parameters
let makeprg .= ' ' . syntastic#c#ReadConfig(g:syntastic_objc_config_file)
" process makeprg
let errors = SyntasticMake({ 'makeprg': makeprg,
\ 'errorformat': errorformat })
" filter the processed errors if desired
if exists('g:syntastic_objc_remove_include_errors') &&
\ g:syntastic_objc_remove_include_errors != 0
return filter(errors,
\ 'has_key(v:val, "bufnr") && v:val["bufnr"]=='.bufnr(''))
else
return errors
endif
\ '%f:%l: %m',
\ 'makeprg_main': '-x objective-c -fsyntax-only',
\ 'makeprg_headers': '-x objective-c-header -lobjc',
\ 'headers_pattern': '\.h$' })
endfunction
call g:SyntasticRegistry.CreateAndRegisterChecker({

View File

@ -0,0 +1,63 @@
"============================================================================
"File: objcpp.vim
"Description: Syntax checking plugin for syntastic.vim
"Maintainer: Gregor Uhlenheuer <kongo2002 at gmail dot com>
"License: This program is free software. It comes without any warranty,
" to the extent permitted by applicable law. You can redistribute
" it and/or modify it under the terms of the Do What The Fuck You
" Want To Public License, Version 2, as published by Sam Hocevar.
" See http://sam.zoy.org/wtfpl/COPYING for more details.
"
"============================================================================
if exists('g:loaded_syntastic_objcpp_gcc_checker')
finish
endif
let g:loaded_syntastic_objcpp_gcc_checker = 1
if !exists('g:syntastic_objcpp_compiler')
let g:syntastic_objcpp_compiler = 'gcc'
endif
function! SyntaxCheckers_objcpp_gcc_IsAvailable()
return executable(g:syntastic_objcpp_compiler)
endfunction
let s:save_cpo = &cpo
set cpo&vim
if !exists('g:syntastic_objcpp_compiler_options')
let g:syntastic_objcpp_compiler_options = '-std=gnu99'
endif
if !exists('g:syntastic_objcpp_config_file')
let g:syntastic_objcpp_config_file = '.syntastic_objcpp_config'
endif
function! SyntaxCheckers_objcpp_gcc_GetLocList()
return syntastic#gcc#GetLocList('objcpp', {
\ 'errorformat':
\ '%-G%f:%s:,' .
\ '%-G%f:%l: %#error: %#(Each undeclared identifier is reported only%.%#,' .
\ '%-G%f:%l: %#error: %#for each function it appears%.%#,' .
\ '%-GIn file included%.%#,'.
\ '%-G %#from %f:%l\,,' .
\ '%f:%l:%c: %trror: %m,' .
\ '%f:%l:%c: %tarning: %m,' .
\ '%f:%l:%c: %m,' .
\ '%f:%l: %trror: %m,' .
\ '%f:%l: %tarning: %m,' .
\ '%f:%l: %m',
\ 'makeprg_main': '-x objective-c++ -fsyntax-only',
\ 'makeprg_headers': '-x objective-c++-header -lobjc',
\ 'headers_pattern': '\.h$' })
endfunction
call g:SyntasticRegistry.CreateAndRegisterChecker({
\ 'filetype': 'objcpp',
\ 'name': 'gcc'})
let &cpo = s:save_cpo
unlet s:save_cpo
" vim: set et sts=4 sw=4:

View File

@ -0,0 +1,34 @@
"============================================================================
"File: ycm.vim
"Description: Syntax checking plugin for syntastic.vim
"Maintainer: Val Markovic <val at markovic dot io>
"License: This program is free software. It comes without any warranty,
" to the extent permitted by applicable law. You can redistribute
" it and/or modify it under the terms of the Do What The Fuck You
" Want To Public License, Version 2, as published by Sam Hocevar.
" See http://sam.zoy.org/wtfpl/COPYING for more details.
"
"============================================================================
if exists("loaded_ycm_objcpp_syntax_checker")
finish
endif
let loaded_ycm_objcpp_syntax_checker = 1
runtime syntax_checkers/c/ycm.vim
function! SyntaxCheckers_objcpp_ycm_IsAvailable()
return SyntaxCheckers_c_ycm_IsAvailable()
endfunction
if !exists('g:loaded_youcompleteme')
finish
endif
function! SyntaxCheckers_objcpp_ycm_GetLocList()
return SyntaxCheckers_c_ycm_GetLocList()
endfunction
call g:SyntasticRegistry.CreateAndRegisterChecker({
\ 'filetype': 'objcpp',
\ 'name': 'ycm'})