From ea827bfa063f08fb2c746aa10f0e317cc00aa798 Mon Sep 17 00:00:00 2001 From: LCD 47 Date: Tue, 21 May 2013 10:03:04 +0300 Subject: [PATCH 01/17] GCC refactor. --- autoload/syntastic/c.vim | 93 ++++++++++---------- autoload/syntastic/gcc.vim | 76 ++++++++++++++++ syntax_checkers/ada/gcc.vim | 132 ++-------------------------- syntax_checkers/c/gcc.vim | 150 ++++---------------------------- syntax_checkers/cpp/gcc.vim | 143 +++--------------------------- syntax_checkers/d/dmd.vim | 131 ++-------------------------- syntax_checkers/llvm/llvm.vim | 2 +- syntax_checkers/objc/gcc.vim | 153 ++++----------------------------- syntax_checkers/objcpp/gcc.vim | 63 ++++++++++++++ syntax_checkers/objcpp/ycm.vim | 34 ++++++++ 10 files changed, 278 insertions(+), 699 deletions(-) create mode 100644 autoload/syntastic/gcc.vim create mode 100644 syntax_checkers/objcpp/gcc.vim create mode 100644 syntax_checkers/objcpp/ycm.vim diff --git a/autoload/syntastic/c.vim b/autoload/syntastic/c.vim index aac6fc38..06ce8ac1 100644 --- a/autoload/syntastic/c.vim +++ b/autoload/syntastic/c.vim @@ -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: diff --git a/autoload/syntastic/gcc.vim b/autoload/syntastic/gcc.vim new file mode 100644 index 00000000..c0fe109f --- /dev/null +++ b/autoload/syntastic/gcc.vim @@ -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: diff --git a/syntax_checkers/ada/gcc.vim b/syntax_checkers/ada/gcc.vim index 39001fd2..e9fd965f 100644 --- a/syntax_checkers/ada/gcc.vim +++ b/syntax_checkers/ada/gcc.vim @@ -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({ diff --git a/syntax_checkers/c/gcc.vim b/syntax_checkers/c/gcc.vim index b8d72e17..3cca035f 100644 --- a/syntax_checkers/c/gcc.vim +++ b/syntax_checkers/c/gcc.vim @@ -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,80 +36,21 @@ 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 = - \ '%-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' - - 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 + 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%.%#,' . + \ '%-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 c -fsyntax-only', + \ 'headers_pattern': '\.h$' }) endfunction call g:SyntasticRegistry.CreateAndRegisterChecker({ diff --git a/syntax_checkers/cpp/gcc.vim b/syntax_checkers/cpp/gcc.vim index 44178f19..930dc4ab 100644 --- a/syntax_checkers/cpp/gcc.vim +++ b/syntax_checkers/cpp/gcc.vim @@ -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 = - \ '%-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 + 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', + \ 'makeprg_main': '-x c++ -fsyntax-only', + \ 'headers_pattern': '\.\(h\|hpp\|hh\)$' }) endfunction call g:SyntasticRegistry.CreateAndRegisterChecker({ diff --git a/syntax_checkers/d/dmd.vim b/syntax_checkers/d/dmd.vim index 0cb1de71..7415f78c 100644 --- a/syntax_checkers/d/dmd.vim +++ b/syntax_checkers/d/dmd.vim @@ -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({ diff --git a/syntax_checkers/llvm/llvm.vim b/syntax_checkers/llvm/llvm.vim index 5a1f18ed..6bb3778c 100644 --- a/syntax_checkers/llvm/llvm.vim +++ b/syntax_checkers/llvm/llvm.vim @@ -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' diff --git a/syntax_checkers/objc/gcc.vim b/syntax_checkers/objc/gcc.vim index 0cd13586..a224b27d 100644 --- a/syntax_checkers/objc/gcc.vim +++ b/syntax_checkers/objc/gcc.vim @@ -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,80 +35,22 @@ 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 = - \ '%-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' - - 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 + 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%.%#,' . + \ '%-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({ diff --git a/syntax_checkers/objcpp/gcc.vim b/syntax_checkers/objcpp/gcc.vim new file mode 100644 index 00000000..8b6fb70b --- /dev/null +++ b/syntax_checkers/objcpp/gcc.vim @@ -0,0 +1,63 @@ +"============================================================================ +"File: objcpp.vim +"Description: Syntax checking plugin for syntastic.vim +"Maintainer: Gregor Uhlenheuer +"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: diff --git a/syntax_checkers/objcpp/ycm.vim b/syntax_checkers/objcpp/ycm.vim new file mode 100644 index 00000000..785a1994 --- /dev/null +++ b/syntax_checkers/objcpp/ycm.vim @@ -0,0 +1,34 @@ +"============================================================================ +"File: ycm.vim +"Description: Syntax checking plugin for syntastic.vim +"Maintainer: Val Markovic +"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'}) From f4a5842d180175c26211bfb9337918a84393feb7 Mon Sep 17 00:00:00 2001 From: LCD 47 Date: Tue, 21 May 2013 15:02:42 +0300 Subject: [PATCH 02/17] Small fixes. --- syntax_checkers/c/gcc.vim | 1 + syntax_checkers/cpp/gcc.vim | 1 + syntax_checkers/d/dmd.vim | 2 +- syntax_checkers/nasm/nasm.vim | 7 +------ 4 files changed, 4 insertions(+), 7 deletions(-) diff --git a/syntax_checkers/c/gcc.vim b/syntax_checkers/c/gcc.vim index 3cca035f..0d4885bd 100644 --- a/syntax_checkers/c/gcc.vim +++ b/syntax_checkers/c/gcc.vim @@ -50,6 +50,7 @@ function! SyntaxCheckers_c_gcc_GetLocList() \ '%f:%l: %tarning: %m,'. \ '%f:%l: %m', \ 'makeprg_main': '-x c -fsyntax-only', + \ 'makeprg_headers': '-x c', \ 'headers_pattern': '\.h$' }) endfunction diff --git a/syntax_checkers/cpp/gcc.vim b/syntax_checkers/cpp/gcc.vim index 930dc4ab..7f7e44c5 100644 --- a/syntax_checkers/cpp/gcc.vim +++ b/syntax_checkers/cpp/gcc.vim @@ -45,6 +45,7 @@ function! SyntaxCheckers_cpp_gcc_GetLocList() \ '%f:%l: %tarning: %m,'. \ '%f:%l: %m', \ 'makeprg_main': '-x c++ -fsyntax-only', + \ 'makeprg_headers': '-x c++', \ 'headers_pattern': '\.\(h\|hpp\|hh\)$' }) endfunction diff --git a/syntax_checkers/d/dmd.vim b/syntax_checkers/d/dmd.vim index 7415f78c..5c66e7a7 100644 --- a/syntax_checkers/d/dmd.vim +++ b/syntax_checkers/d/dmd.vim @@ -44,7 +44,7 @@ function! SyntaxCheckers_d_dmd_GetLocList() \ 'errorformat': \ '%-G%f:%s:,%f(%l): %m,' . \ '%f:%l: %m', - \ 'makeprg_main': '-c', + \ 'makeprg_main': '-c ' . syntastic#c#NullOutput('d'), \ 'headers_pattern': '\.di$' }) endfunction diff --git a/syntax_checkers/nasm/nasm.vim b/syntax_checkers/nasm/nasm.vim index 0cf0b51a..61a2b4ad 100644 --- a/syntax_checkers/nasm/nasm.vim +++ b/syntax_checkers/nasm/nasm.vim @@ -19,15 +19,10 @@ function! SyntaxCheckers_nasm_nasm_IsAvailable() endfunction function! SyntaxCheckers_nasm_nasm_GetLocList() - if has("win32") - let outfile="NUL" - else - let outfile="/dev/null" - endif let wd = shellescape(expand("%:p:h") . "/") let makeprg = syntastic#makeprg#build({ \ 'exe': 'nasm', - \ 'args': '-X gnu -f elf -I ' . wd . ' -o ' . outfile, + \ 'args': '-X gnu -f elf -I ' . wd . ' ' . syntastic#c#NullOutput('nasm'), \ 'subchecker': 'nasm' }) let errorformat = '%f:%l: %t%*[^:]: %m' return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat }) From a8be73d11334f657de87f088d5b0011ecbb5ddaf Mon Sep 17 00:00:00 2001 From: LCD 47 Date: Thu, 30 May 2013 19:44:12 +0300 Subject: [PATCH 03/17] Moved syntastic#gcc#GetLocList() to autoload/syntastic/c.vim. --- autoload/syntastic/c.vim | 64 ++++++++++++++++++++++++++++ autoload/syntastic/gcc.vim | 76 ---------------------------------- syntax_checkers/ada/gcc.vim | 2 +- syntax_checkers/c/gcc.vim | 2 +- syntax_checkers/c/oclint.vim | 2 +- syntax_checkers/cpp/gcc.vim | 2 +- syntax_checkers/d/dmd.vim | 2 +- syntax_checkers/objc/gcc.vim | 2 +- syntax_checkers/objcpp/gcc.vim | 2 +- 9 files changed, 71 insertions(+), 83 deletions(-) delete mode 100644 autoload/syntastic/gcc.vim diff --git a/autoload/syntastic/c.vim b/autoload/syntastic/c.vim index 06ce8ac1..ec0537d3 100644 --- a/autoload/syntastic/c.vim +++ b/autoload/syntastic/c.vim @@ -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 diff --git a/autoload/syntastic/gcc.vim b/autoload/syntastic/gcc.vim deleted file mode 100644 index c0fe109f..00000000 --- a/autoload/syntastic/gcc.vim +++ /dev/null @@ -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: diff --git a/syntax_checkers/ada/gcc.vim b/syntax_checkers/ada/gcc.vim index e9fd965f..7a11f7c5 100644 --- a/syntax_checkers/ada/gcc.vim +++ b/syntax_checkers/ada/gcc.vim @@ -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,' . diff --git a/syntax_checkers/c/gcc.vim b/syntax_checkers/c/gcc.vim index 0d4885bd..4dc1bfe7 100644 --- a/syntax_checkers/c/gcc.vim +++ b/syntax_checkers/c/gcc.vim @@ -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%.%#,' . diff --git a/syntax_checkers/c/oclint.vim b/syntax_checkers/c/oclint.vim index f51c5494..8944b75e 100644 --- a/syntax_checkers/c/oclint.vim +++ b/syntax_checkers/c/oclint.vim @@ -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 = diff --git a/syntax_checkers/cpp/gcc.vim b/syntax_checkers/cpp/gcc.vim index 7f7e44c5..c9b4f1b7 100644 --- a/syntax_checkers/cpp/gcc.vim +++ b/syntax_checkers/cpp/gcc.vim @@ -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,' . diff --git a/syntax_checkers/d/dmd.vim b/syntax_checkers/d/dmd.vim index 5c66e7a7..f69dbb1e 100644 --- a/syntax_checkers/d/dmd.vim +++ b/syntax_checkers/d/dmd.vim @@ -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', diff --git a/syntax_checkers/objc/gcc.vim b/syntax_checkers/objc/gcc.vim index a224b27d..e59d5c69 100644 --- a/syntax_checkers/objc/gcc.vim +++ b/syntax_checkers/objc/gcc.vim @@ -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%.%#,' . diff --git a/syntax_checkers/objcpp/gcc.vim b/syntax_checkers/objcpp/gcc.vim index 8b6fb70b..cab7efd4 100644 --- a/syntax_checkers/objcpp/gcc.vim +++ b/syntax_checkers/objcpp/gcc.vim @@ -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%.%#,' . From dbcaa992ac3d8ada8b7a84ba7bb049626e550fcf Mon Sep 17 00:00:00 2001 From: LCD 47 Date: Sun, 2 Jun 2013 13:28:49 +0300 Subject: [PATCH 04/17] Bug fix: nasm output. --- syntax_checkers/nasm/nasm.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/syntax_checkers/nasm/nasm.vim b/syntax_checkers/nasm/nasm.vim index 7b5020b6..2b508c24 100644 --- a/syntax_checkers/nasm/nasm.vim +++ b/syntax_checkers/nasm/nasm.vim @@ -22,7 +22,7 @@ function! SyntaxCheckers_nasm_nasm_GetLocList() let wd = shellescape(expand("%:p:h") . "/") let makeprg = syntastic#makeprg#build({ \ 'exe': 'nasm', - \ 'args': '-X gnu -f elf -I ' . wd . ' -o ' . outfile, + \ 'args': '-X gnu -f elf -I ' . wd . ' ' . syntastic#c#NullOutput('nasm'), \ 'filetype': 'nasm', \ 'subchecker': 'nasm' }) From b6f6abba862fbf84f0a0696ab1b36c8bd33b905d Mon Sep 17 00:00:00 2001 From: LCD 47 Date: Fri, 7 Jun 2013 21:18:29 +0300 Subject: [PATCH 05/17] Merge branch master. --- autoload/syntastic/c.vim | 7 +++--- syntax_checkers/c/checkpatch.vim | 6 +++-- syntax_checkers/coffee/coffee.vim | 2 +- syntax_checkers/cuda/nvcc.vim | 11 ++++++--- syntax_checkers/d/dmd.vim | 2 +- syntax_checkers/go/go.vim | 34 ++++++++++++++++++++------- syntax_checkers/llvm/llvm.vim | 2 +- syntax_checkers/nasm/nasm.vim | 2 +- syntax_checkers/ocaml/camlp4o.vim | 14 +++++------ syntax_checkers/puppet/puppetlint.vim | 4 ++-- syntax_checkers/slim/slimrb.vim | 2 +- syntax_checkers/text/atdtool.vim | 2 +- 12 files changed, 56 insertions(+), 32 deletions(-) diff --git a/autoload/syntastic/c.vim b/autoload/syntastic/c.vim index ec0537d3..9c2ad169 100644 --- a/autoload/syntastic/c.vim +++ b/autoload/syntastic/c.vim @@ -10,10 +10,9 @@ set cpo&vim " convenience function to determine the 'null device' parameter " based on the current operating system -function! syntastic#c#NullOutput(ft) +function! syntastic#c#NullOutput() let known_os = has('win32') || has('unix') || has('mac') - let opt_o = ft ==# 'd' ? '-of' : '-o ' - return known_os ? opt_o . syntastic#util#DevNull() : '' + return known_os ? '-o ' . syntastic#util#DevNull() : '' endfunction " get the gcc include directory argument depending on the default @@ -136,7 +135,7 @@ function! syntastic#c#GetLocList(filetype, options) \ ' ' . get(a:options, 'makeprg_headers', '') . \ ' ' . g:syntastic_{ft}_compiler_options . \ ' ' . syntastic#c#GetIncludeDirs(ft) . - \ ' ' . syntastic#c#NullOutput(ft) . + \ ' ' . syntastic#c#NullOutput() . \ ' -c ' . shellescape(expand('%')) else return [] diff --git a/syntax_checkers/c/checkpatch.vim b/syntax_checkers/c/checkpatch.vim index d87d57bd..dc5e95de 100644 --- a/syntax_checkers/c/checkpatch.vim +++ b/syntax_checkers/c/checkpatch.vim @@ -32,12 +32,14 @@ function! SyntaxCheckers_c_checkpatch_GetLocList() \ 'filetype': 'c', \ 'subchecker': 'checkpatch' }) - let errorformat = '%f:%l: %tARNING: %m,%f:%l: %tRROR: %m' + let errorformat = + \ '%f:%l: %tARNING: %m,' . + \ '%f:%l: %tRROR: %m' return SyntasticMake({ \ 'makeprg': makeprg, \ 'errorformat': errorformat, - \ 'defaults': {'bufnr': bufnr("")} }) + \ 'subtype': 'Style' }) endfunction call g:SyntasticRegistry.CreateAndRegisterChecker({ diff --git a/syntax_checkers/coffee/coffee.vim b/syntax_checkers/coffee/coffee.vim index c49d7c26..846180b9 100644 --- a/syntax_checkers/coffee/coffee.vim +++ b/syntax_checkers/coffee/coffee.vim @@ -19,7 +19,7 @@ let g:loaded_syntastic_coffee_coffee_checker=1 function! SyntaxCheckers_coffee_coffee_IsAvailable() return executable("coffee") && - \ syntastic#util#versionIsAtLeast(syntastic#util#parseVersion('coffee --version 2>/dev/null'), [1,6,2]) + \ syntastic#util#versionIsAtLeast(syntastic#util#parseVersion('coffee --version 2>' . syntastic#util#DevNull()), [1,6,2]) endfunction function! SyntaxCheckers_coffee_coffee_GetLocList() diff --git a/syntax_checkers/cuda/nvcc.vim b/syntax_checkers/cuda/nvcc.vim index d570152c..ee210aca 100644 --- a/syntax_checkers/cuda/nvcc.vim +++ b/syntax_checkers/cuda/nvcc.vim @@ -30,11 +30,13 @@ endfunction function! SyntaxCheckers_cuda_nvcc_GetLocList() if exists('g:syntastic_cuda_arch') - let arch_flag = '-arch='.g:syntastic_cuda_arch + let arch_flag = '-arch=' . g:syntastic_cuda_arch else let arch_flag = '' endif - let makeprg = 'nvcc '.arch_flag.' --cuda -O0 -I . -Xcompiler -fsyntax-only '.shellescape(expand('%')).' -o /dev/null' + let makeprg = + \ 'nvcc ' . arch_flag . ' --cuda -O0 -I . -Xcompiler -fsyntax-only ' . + \ shellescape(expand('%')) . ' ' . syntastic#c#NullOutput() let errorformat = \ '%*[^"]"%f"%*\D%l: %m,'. \ '"%f"%*\D%l: %m,'. @@ -53,7 +55,10 @@ function! SyntaxCheckers_cuda_nvcc_GetLocList() if expand('%') =~? '\%(.h\|.hpp\|.cuh\)$' if exists('g:syntastic_cuda_check_header') - let makeprg = 'echo > .syntastic_dummy.cu ; nvcc '.arch_flag.' --cuda -O0 -I . .syntastic_dummy.cu -Xcompiler -fsyntax-only -include '.shellescape(expand('%')).' -o /dev/null' + let makeprg = + \ 'echo > .syntastic_dummy.cu ; ' . + \ 'nvcc ' . arch_flag . ' --cuda -O0 -I . .syntastic_dummy.cu -Xcompiler -fsyntax-only -include ' . + \ shellescape(expand('%')) . ' ' . syntastic#c#NullOutput() else return [] endif diff --git a/syntax_checkers/d/dmd.vim b/syntax_checkers/d/dmd.vim index f69dbb1e..17baaeca 100644 --- a/syntax_checkers/d/dmd.vim +++ b/syntax_checkers/d/dmd.vim @@ -44,7 +44,7 @@ function! SyntaxCheckers_d_dmd_GetLocList() \ 'errorformat': \ '%-G%f:%s:,%f(%l): %m,' . \ '%f:%l: %m', - \ 'makeprg_main': '-c ' . syntastic#c#NullOutput('d'), + \ 'makeprg_main': '-c -of' . syntastic#util#DevNull(), \ 'headers_pattern': '\.di$' }) endfunction diff --git a/syntax_checkers/go/go.vim b/syntax_checkers/go/go.vim index 2534bcb5..fc07974f 100644 --- a/syntax_checkers/go/go.vim +++ b/syntax_checkers/go/go.vim @@ -25,10 +25,21 @@ function! SyntaxCheckers_go_go_GetLocList() " Check with gofmt first, since `go build` and `go test` might not report " syntax errors in the current file if another file with syntax error is " compiled first. - let makeprg = 'gofmt -l % 1>/dev/null' - let errorformat = '%f:%l:%c: %m,%-G%.%#' - let errors = SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat, 'defaults': {'type': 'e'} }) + let makeprg = syntastic#makeprg#build({ + \ 'exe': 'gofmt', + \ 'args': '-l', + \ 'tail': '1>' . syntastic#util#DevNull(), + \ 'filetype': 'go', + \ 'subchecker': 'go' }) + let errorformat = + \ '%f:%l:%c: %m,' . + \ '%-G%.%#' + + let errors = SyntasticMake({ + \ 'makeprg': makeprg, + \ 'errorformat': errorformat, + \ 'defaults': {'type': 'e'} }) if !empty(errors) return errors endif @@ -36,22 +47,29 @@ function! SyntaxCheckers_go_go_GetLocList() " Test files, i.e. files with a name ending in `_test.go`, are not " compiled by `go build`, therefore `go test` must be called for those. if match(expand('%'), '_test.go$') == -1 - let makeprg = 'go build -o /dev/null' + let makeprg = 'go build ' . syntastic#c#NullOutput() else - let makeprg = 'go test -c -o /dev/null' + let makeprg = 'go test -c ' . syntastic#c#NullOutput() endif - let errorformat = '%f:%l:%c:%m,%f:%l%m,%-G#%.%#' + + let errorformat = + \ '%f:%l:%c:%m,' . + \ '%f:%l%m,' . + \ '%-G#%.%#' " The go compiler needs to either be run with an import path as an " argument or directly from the package directory. Since figuring out " the poper import path is fickle, just pushd/popd to the package. let popd = getcwd() let pushd = expand('%:p:h') - " + " pushd exec 'lcd ' . fnameescape(pushd) - let errors = SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat }) + let errors = SyntasticMake({ + \ 'makeprg': makeprg, + \ 'errorformat': errorformat, + \ 'defaults': {'type': 'e'} }) " popd exec 'lcd ' . fnameescape(popd) diff --git a/syntax_checkers/llvm/llvm.vim b/syntax_checkers/llvm/llvm.vim index ea4fa04b..61d16fc1 100644 --- a/syntax_checkers/llvm/llvm.vim +++ b/syntax_checkers/llvm/llvm.vim @@ -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(), \ 'filetype': 'llvm', \ 'subchecker': 'llvm' }) diff --git a/syntax_checkers/nasm/nasm.vim b/syntax_checkers/nasm/nasm.vim index 2b508c24..8c425b55 100644 --- a/syntax_checkers/nasm/nasm.vim +++ b/syntax_checkers/nasm/nasm.vim @@ -22,7 +22,7 @@ function! SyntaxCheckers_nasm_nasm_GetLocList() let wd = shellescape(expand("%:p:h") . "/") let makeprg = syntastic#makeprg#build({ \ 'exe': 'nasm', - \ 'args': '-X gnu -f elf -I ' . wd . ' ' . syntastic#c#NullOutput('nasm'), + \ 'args': '-X gnu -f elf -I ' . wd . ' ' . syntastic#c#NullOutput(), \ 'filetype': 'nasm', \ 'subchecker': 'nasm' }) diff --git a/syntax_checkers/ocaml/camlp4o.vim b/syntax_checkers/ocaml/camlp4o.vim index 69d7494c..b498134c 100644 --- a/syntax_checkers/ocaml/camlp4o.vim +++ b/syntax_checkers/ocaml/camlp4o.vim @@ -112,16 +112,16 @@ function s:GetOcamlcMakeprg() if g:syntastic_ocaml_use_janestreet_core let build_cmd = "ocamlc -I " let build_cmd .= expand(g:syntastic_ocaml_janestreet_core_dir) - let build_cmd .= " -c ".expand('%') + let build_cmd .= " -c " . expand('%') return build_cmd else - return "ocamlc -c ". expand('%') + return "ocamlc -c " . expand('%') endif endfunction function s:GetOcamlBuildMakeprg() - return "ocamlbuild -quiet -no-log -tag annot,". s:ocamlpp. " -no-links -no-hygiene -no-sanitize ". - \ shellescape(expand('%:r')).".cmi" + return "ocamlbuild -quiet -no-log -tag annot," . s:ocamlpp . " -no-links -no-hygiene -no-sanitize " . + \ shellescape(expand('%:r')) . ".cmi" endfunction function s:GetOtherMakeprg() @@ -134,11 +134,11 @@ function s:GetOtherMakeprg() if match(extension, 'mly') >= 0 && executable("menhir") " ocamlyacc output can't be redirected, so use menhir - let makeprg = "menhir --only-preprocess ".shellescape(expand('%')) . " >/dev/null" + let makeprg = "menhir --only-preprocess " . shellescape(expand('%')) . " >" . syntastic#util#DevNull() elseif match(extension,'mll') >= 0 && executable("ocamllex") - let makeprg = "ocamllex -q -o /dev/null ".shellescape(expand('%')) + let makeprg = "ocamllex -q " . syntastic#c#NullOutput() . " " . shellescape(expand('%')) else - let makeprg = "camlp4o -o /dev/null ".shellescape(expand('%')) + let makeprg = "camlp4o " . syntastic#c#NullOutput() . " " . shellescape(expand('%')) endif return makeprg diff --git a/syntax_checkers/puppet/puppetlint.vim b/syntax_checkers/puppet/puppetlint.vim index 32ccd901..54f5b83b 100644 --- a/syntax_checkers/puppet/puppetlint.vim +++ b/syntax_checkers/puppet/puppetlint.vim @@ -33,14 +33,14 @@ endif function! s:PuppetVersion() if !exists("s:puppet_version") - let s:puppet_version = syntastic#util#parseVersion("puppet --version 2>/dev/null") + let s:puppet_version = syntastic#util#parseVersion("puppet --version 2>" . syntastic#util#DevNull()) endif return s:puppet_version endfunction function! s:PuppetLintVersion() if !exists("s:puppet_lint_version") - let s:puppet_lint_version = syntastic#util#parseVersion("puppet-lint --version 2>/dev/null") + let s:puppet_lint_version = syntastic#util#parseVersion("puppet-lint --version 2>" . syntastic#util#DevNull()) endif return s:puppet_lint_version endfunction diff --git a/syntax_checkers/slim/slimrb.vim b/syntax_checkers/slim/slimrb.vim index 106a1b51..2644decf 100644 --- a/syntax_checkers/slim/slimrb.vim +++ b/syntax_checkers/slim/slimrb.vim @@ -21,7 +21,7 @@ endfunction function! s:SlimrbVersion() if !exists('s:slimrb_version') - let s:slimrb_version = syntastic#util#parseVersion('slimrb --version 2>/dev/null') + let s:slimrb_version = syntastic#util#parseVersion('slimrb --version 2>' . syntastic#util#DevNull()) end return s:slimrb_version endfunction diff --git a/syntax_checkers/text/atdtool.vim b/syntax_checkers/text/atdtool.vim index 5cc99b87..bfccb7e6 100644 --- a/syntax_checkers/text/atdtool.vim +++ b/syntax_checkers/text/atdtool.vim @@ -31,7 +31,7 @@ endfunction function! SyntaxCheckers_text_atdtool_GetLocList() let makeprg = syntastic#makeprg#build({ \ 'exe': 'atdtool', - \ 'tail': '2>/dev/null', + \ 'tail': '2>' . syntastic#util#DevNull(), \ 'filetype': 'text', \ 'subchecker': 'atdtool' }) From 45f9e93b00ff355f7285e88473d581b4bf0f6d17 Mon Sep 17 00:00:00 2001 From: LCD 47 Date: Sat, 8 Jun 2013 11:09:39 +0300 Subject: [PATCH 06/17] Bug fix: proper escaping in config files. --- autoload/syntastic/c.vim | 259 ++++++++++++++++++------------------ autoload/syntastic/util.vim | 5 + 2 files changed, 135 insertions(+), 129 deletions(-) diff --git a/autoload/syntastic/c.vim b/autoload/syntastic/c.vim index 9c2ad169..993982e6 100644 --- a/autoload/syntastic/c.vim +++ b/autoload/syntastic/c.vim @@ -15,41 +15,28 @@ function! syntastic#c#NullOutput() return known_os ? '-o ' . syntastic#util#DevNull() : '' endfunction -" get the gcc include directory argument depending on the default -" includes and the optional user-defined 'g:syntastic_c_include_dirs' -function! syntastic#c#GetIncludeDirs(filetype) - let include_dirs = [] - - if !exists('g:syntastic_'.a:filetype.'_no_default_include_dirs') || - \ !g:syntastic_{a:filetype}_no_default_include_dirs - let include_dirs = copy(s:default_includes) - endif - - if exists('g:syntastic_'.a:filetype.'_include_dirs') - call extend(include_dirs, g:syntastic_{a:filetype}_include_dirs) - endif - - return join(map(syntastic#util#unique(include_dirs), '"-I" . v:val'), ' ') -endfunction - " read additional compiler flags from the given configuration file " the file format and its parsing mechanism is inspired by clang_complete function! syntastic#c#ReadConfig(file) " search in the current file's directory upwards let config = findfile(a:file, '.;') - if config == '' || !filereadable(config) | return '' | endif + if config == '' || !filereadable(config) + return '' + endif " convert filename into absolute path - let filepath = substitute(fnamemodify(config, ':p:h'), '\', '/', 'g') + let filepath = fnamemodify(config, ':p:h') " try to read config file try - let lines = map(readfile(config), - \ 'substitute(v:val, ''\'', ''/'', ''g'')') - catch /E484/ + let lines = readfile(config) + catch /^Vim\%((\a\+)\)\=:E484/ return '' endtry + " filter out empty lines and comments + call filter(lines, 'v:val !~ ''\v^(\s*#|$)''') + let parameters = [] for line in lines let matches = matchlist(line, '\C^\s*-I\s*\(\S\+\)') @@ -58,67 +45,14 @@ function! syntastic#c#ReadConfig(file) if match(matches[1], '^\%(/\|\a:\)') != -1 call add(parameters, '-I' . matches[1]) else - call add(parameters, '-I' . filepath . '/' . matches[1]) + call add(parameters, '-I' . filepath . syntastic#util#Slash() . matches[1]) endif else call add(parameters, line) endif endfor - return join(parameters, ' ') -endfunction - -" search the first 100 lines for include statements that are -" given in the handlers dictionary -function! syntastic#c#SearchHeaders() - let includes = '' - let files = [] - let found = [] - let lines = filter(getline(1, 100), 'v:val =~# "^\s*#\s*include"') - - " search current buffer - for line in lines - let file = matchstr(line, '"\zs\S\+\ze"') - if file != '' - call add(files, file) - continue - endif - for handler in s:handlers - if line =~# handler["regex"] - let includes .= call(handler["func"], handler["args"]) - call add(found, handler["regex"]) - break - endif - endfor - endfor - - " search included headers - for hfile in files - if hfile != '' - let filename = expand('%:p:h') . (has('win32') ? - \ '\' : '/') . hfile - try - let lines = readfile(filename, '', 100) - catch /E484/ - continue - endtry - let lines = filter(lines, 'v:val =~# "^\s*#\s*include"') - for handler in s:handlers - if index(found, handler["regex"]) != -1 - continue - endif - for line in lines - if line =~# handler["regex"] - let includes .= call(handler["func"], handler["args"]) - call add(found, handler["regex"]) - break - endif - endfor - endfor - endif - endfor - - return includes + return join(map(parameters, 'shellescape(fnameescape(v:val))'), ' ') endfunction " GetLocList() for C-like compilers @@ -134,7 +68,7 @@ function! syntastic#c#GetLocList(filetype, options) \ g:syntastic_{ft}_compiler . \ ' ' . get(a:options, 'makeprg_headers', '') . \ ' ' . g:syntastic_{ft}_compiler_options . - \ ' ' . syntastic#c#GetIncludeDirs(ft) . + \ ' ' . s:GetIncludeDirs(ft) . \ ' ' . syntastic#c#NullOutput() . \ ' -c ' . shellescape(expand('%')) else @@ -145,7 +79,7 @@ function! syntastic#c#GetLocList(filetype, options) \ g:syntastic_{ft}_compiler . \ ' ' . get(a:options, 'makeprg_main', '') . \ ' ' . g:syntastic_{ft}_compiler_options . - \ ' ' . syntastic#c#GetIncludeDirs(ft) . + \ ' ' . s:GetIncludeDirs(ft) . \ ' ' . shellescape(expand('%')) endif @@ -156,11 +90,11 @@ function! syntastic#c#GetLocList(filetype, options) 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() + let makeprg .= ' ' . s:SearchHeaders() else " search for header includes if not cached already if !exists('b:syntastic_' . ft . '_includes') - let b:syntastic_{ft}_includes = syntastic#c#SearchHeaders() + let b:syntastic_{ft}_includes = s:SearchHeaders() endif let makeprg .= ' ' . b:syntastic_{ft}_includes endif @@ -192,31 +126,94 @@ 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('cairo', 'syntastic#c#CheckPKG', ['cairo', 'cairo']) + call s:RegHandler('freetype', 'syntastic#c#CheckPKG', ['freetype', 'freetype2', 'freetype']) + call s:RegHandler('glade', 'syntastic#c#CheckPKG', ['glade', 'libglade-2.0', 'libglade']) + call s:RegHandler('glib', 'syntastic#c#CheckPKG', ['glib', 'glib-2.0', 'glib']) + call s:RegHandler('gtk', 'syntastic#c#CheckPKG', ['gtk', 'gtk+-2.0', 'gtk+', 'glib-2.0', 'glib']) + call s:RegHandler('libsoup', 'syntastic#c#CheckPKG', ['libsoup', 'libsoup-2.4', 'libsoup-2.2']) + call s:RegHandler('libxml', 'syntastic#c#CheckPKG', ['libxml', 'libxml-2.0', 'libxml']) + call s:RegHandler('pango', 'syntastic#c#CheckPKG', ['pango', 'pango']) + call s:RegHandler('SDL', 'syntastic#c#CheckPKG', ['sdl', 'sdl']) + call s:RegHandler('opengl', 'syntastic#c#CheckPKG', ['opengl', 'gl']) + call s:RegHandler('webkit', 'syntastic#c#CheckPKG', ['webkit', 'webkit-1.0']) + + call s:RegHandler('php\.h', 'syntastic#c#CheckPhp', []) call s:RegHandler('Python\.h', 'syntastic#c#CheckPython', []) - call s:RegHandler('php\.h', 'syntastic#c#CheckPhp', []) + call s:RegHandler('ruby', 'syntastic#c#CheckRuby', []) +endfunction + +" get the gcc include directory argument depending on the default +" includes and the optional user-defined 'g:syntastic_c_include_dirs' +function! s:GetIncludeDirs(filetype) + let include_dirs = [] + + if !exists('g:syntastic_'.a:filetype.'_no_default_include_dirs') || !g:syntastic_{a:filetype}_no_default_include_dirs + let include_dirs = copy(s:default_includes) + endif + + if exists('g:syntastic_'.a:filetype.'_include_dirs') + call extend(include_dirs, g:syntastic_{a:filetype}_include_dirs) + endif + + return join(map(syntastic#util#unique(include_dirs), 'shellescape(fnameescape("-I" . v:val))'), ' ') +endfunction + +" search the first 100 lines for include statements that are +" given in the handlers dictionary +function! s:SearchHeaders() + let includes = '' + let files = [] + let found = [] + let lines = filter(getline(1, 100), 'v:val =~# "^\s*#\s*include"') + + " search current buffer + for line in lines + let file = matchstr(line, '"\zs\S\+\ze"') + if file != '' + call add(files, file) + continue + endif + + for handler in s:handlers + if line =~# handler["regex"] + let includes .= call(handler["func"], handler["args"]) + call add(found, handler["regex"]) + break + endif + endfor + endfor + + " search included headers + for hfile in files + if hfile != '' + let filename = expand('%:p:h') . syntastic#util#Slash() . hfile + + try + let lines = readfile(filename, '', 100) + catch /^Vim\%((\a\+)\)\=:E484/ + continue + endtry + + let lines = filter(lines, 'v:val =~# "^\s*#\s*include"') + + for handler in s:handlers + if index(found, handler["regex"]) != -1 + continue + endif + + for line in lines + if line =~# handler["regex"] + let includes .= call(handler["func"], handler["args"]) + call add(found, handler["regex"]) + break + endif + endfor + endfor + endif + endfor + + return includes endfunction " try to find library with 'pkg-config' @@ -225,14 +222,14 @@ endfunction function! syntastic#c#CheckPKG(name, ...) if executable('pkg-config') if !has_key(s:cflags, a:name) - for i in range(a:0) - let l:cflags = system('pkg-config --cflags '.a:000[i]) + for pkg in a:000 + let pkg_flags = system('pkg-config --cflags ' . pkg) " since we cannot necessarily trust the pkg-config exit code " we have to check for an error output as well - if v:shell_error == 0 && l:cflags !~? 'not found' - let l:cflags = ' '.substitute(l:cflags, "\n", '', '') - let s:cflags[a:name] = l:cflags - return l:cflags + if v:shell_error == 0 && pkg_flags !~? 'not found' + let pkg_flags = ' ' . substitute(pkg_flags, "\n", '', '') + let s:cflags[a:name] = pkg_flags + return pkg_flags endif endfor else @@ -245,11 +242,11 @@ endfunction " try to find PHP includes with 'php-config' function! syntastic#c#CheckPhp() if executable('php-config') - if !exists('s:php_flags') - let s:php_flags = system('php-config --includes') - let s:php_flags = ' ' . substitute(s:php_flags, "\n", '', '') + if !has_key(s:cflags, 'php') + let s:cflags['php'] = system('php-config --includes') + let s:cflags['php'] = ' ' . substitute(s:cflags['php'], "\n", '', '') endif - return s:php_flags + return s:cflags['php'] endif return '' endfunction @@ -257,13 +254,12 @@ endfunction " try to find the ruby headers with 'rbconfig' function! syntastic#c#CheckRuby() if executable('ruby') - if !exists('s:ruby_flags') - let s:ruby_flags = system('ruby -r rbconfig -e ' - \ . '''puts Config::CONFIG["archdir"]''') - let s:ruby_flags = substitute(s:ruby_flags, "\n", '', '') - let s:ruby_flags = ' -I' . s:ruby_flags + if !has_key(s:cflags, 'ruby') + let s:cflags['ruby'] = system('ruby -r rbconfig -e ''puts Config::CONFIG["archdir"]''') + let s:cflags['ruby'] = substitute(s:cflags['ruby'], "\n", '', '') + let s:cflags['ruby'] = ' -I' . s:cflags['ruby'] endif - return s:ruby_flags + return s:cflags['ruby'] endif return '' endfunction @@ -271,13 +267,13 @@ endfunction " try to find the python headers with distutils function! syntastic#c#CheckPython() if executable('python') - if !exists('s:python_flags') - let s:python_flags = system('python -c ''from distutils import ' - \ . 'sysconfig; import sys; sys.stdout.write(sysconfig.get_python_inc())''') - let s:python_flags = substitute(s:python_flags, "\n", '', '') - let s:python_flags = ' -I' . s:python_flags + if !has_key(s:cflags, 'python') + let s:cflags['python'] = system('python -c ''from distutils import ' . + \ 'sysconfig; import sys; sys.stdout.write(sysconfig.get_python_inc())''') + let s:cflags['python'] = substitute(s:cflags['python'], "\n", '', '') + let s:cflags['python'] = ' -I' . s:cflags['python'] endif - return s:python_flags + return s:cflags['python'] endif return '' endfunction @@ -294,8 +290,13 @@ endfunction " }}}1 " default include directories -let s:default_includes = [ '.', '..', 'include', 'includes', - \ '../include', '../includes' ] +let s:default_includes = [ + \ '.', + \ '..', + \ 'include', + \ 'includes', + \ '..' . syntastic#util#Slash() . 'include', + \ '..' . syntastic#util#Slash() . 'includes' ] call s:Init() diff --git a/autoload/syntastic/util.vim b/autoload/syntastic/util.vim index 4e777b3d..b6f58d83 100644 --- a/autoload/syntastic/util.vim +++ b/autoload/syntastic/util.vim @@ -19,6 +19,11 @@ function! syntastic#util#DevNull() return '/dev/null' endfunction +" Get directory separator +function! syntastic#util#Slash() abort + return !exists("+shellslash") || &shellslash ? '/' : '\' +endfunction + "search the first 5 lines of the file for a magic number and return a map "containing the args and the executable " From c5aa22f4e47e07deb722bccfeea39fd82aa89b65 Mon Sep 17 00:00:00 2001 From: LCD 47 Date: Sat, 8 Jun 2013 11:33:18 +0300 Subject: [PATCH 07/17] Remove leading and trailing spaces when reading C config files. --- autoload/syntastic/c.vim | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/autoload/syntastic/c.vim b/autoload/syntastic/c.vim index 993982e6..10c9f297 100644 --- a/autoload/syntastic/c.vim +++ b/autoload/syntastic/c.vim @@ -37,6 +37,10 @@ function! syntastic#c#ReadConfig(file) " filter out empty lines and comments call filter(lines, 'v:val !~ ''\v^(\s*#|$)''') + " remove leading and trailing spaces + call map(lines, 'substitute(v:val, ''^\s\+'', "", "")') + call map(lines, 'substitute(v:val, ''\s\+$'', "", "")') + let parameters = [] for line in lines let matches = matchlist(line, '\C^\s*-I\s*\(\S\+\)') From f712fd959a85172f83f3c64c8dfa176c88bca950 Mon Sep 17 00:00:00 2001 From: LCD 47 Date: Mon, 17 Jun 2013 14:52:12 +0300 Subject: [PATCH 08/17] New checker: cobol/cobc (OpenCOBOL). --- README.markdown | 14 ++++----- syntax_checkers/cobol/cobc.vim | 52 ++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+), 7 deletions(-) create mode 100644 syntax_checkers/cobol/cobc.vim diff --git a/README.markdown b/README.markdown index fb8423ef..01fbf498 100644 --- a/README.markdown +++ b/README.markdown @@ -26,13 +26,13 @@ user is notified and is happy because they didn't have to compile their code or execute their script to find them. At the time of this writing, syntax checking plugins exist for Ada, -AppleScript, Bourne shell, C, C++, C#, CoffeeScript, Coco, Coq, CSS, -Cucumber, CUDA, D, Dart, DocBook, Elixir, Erlang, eRuby, Fortran, Gentoo -metadata, Go, Haml, Haskell, Haxe, HTML, Java, JavaScript, JSON, LESS, -LISP, LLVM intermediate language, Lua, MATLAB, NASM, Objective-C, -Objective-C++, OCaml, Perl, Perl POD, PHP, Puppet, Python, -reStructuredText, Ruby, Rust, SASS/SCSS, Scala, Slim, Tcl, TeX, Twig, -TypeScript, Vala, VHDL, xHtml, XML, XSLT, YAML, z80, Zope page +AppleScript, Bourne shell, C, C++, C#, COBOL, CoffeeScript, Coco, Coq, +CSS, Cucumber, CUDA, D, Dart, DocBook, Elixir, Erlang, eRuby, Fortran, +Gentoo metadata, Go, Haml, Haskell, Haxe, HTML, Java, JavaScript, +JSON, LESS, LISP, LLVM intermediate language, Lua, MATLAB, NASM, +Objective-C, Objective-C++, OCaml, Perl, Perl POD, PHP, Puppet, Python, +reStructuredText, Ruby, Rust, SASS/SCSS, Scala, Slim, Tcl, TeX, +Twig, TypeScript, Vala, VHDL, xHtml, XML, XSLT, YAML, z80, Zope page templates, zsh. ## Screenshot diff --git a/syntax_checkers/cobol/cobc.vim b/syntax_checkers/cobol/cobc.vim new file mode 100644 index 00000000..2a59ebd4 --- /dev/null +++ b/syntax_checkers/cobol/cobc.vim @@ -0,0 +1,52 @@ +"============================================================================ +"File: cobc.vim +"Description: Syntax checking plugin for syntastic.vim +"Maintainer: LCD 47 +"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_cobol_cobc_checker') + finish +endif +let g:loaded_syntastic_cobol_cobc_checker = 1 + +if !exists('g:syntastic_cobol_compiler') + let g:syntastic_cobol_compiler = 'cobc' +endif + +function! SyntaxCheckers_cobol_cobc_IsAvailable() + return executable(g:syntastic_cobol_compiler) +endfunction + +let s:save_cpo = &cpo +set cpo&vim + +if !exists('g:syntastic_cobol_compiler_options') + let g:syntastic_cobol_compiler_options = '' +endif + +if !exists('g:syntastic_cobol_config_file') + let g:syntastic_cobol_config_file = '.syntastic_cobol_config' +endif + +function! SyntaxCheckers_cobol_cobc_GetLocList() + return syntastic#c#GetLocList('cobol', { + \ 'errorformat': '%f:%l: %trror: %m', + \ 'makeprg_main': '-fsyntax-only', + \ 'headers_pattern': '^$' }) +endfunction + +call g:SyntasticRegistry.CreateAndRegisterChecker({ + \ 'filetype': 'cobol', + \ 'name': 'cobc'}) + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim: set et sts=4 sw=4: From f9c30c3215745354c6fc809cb4fc3db66c2f677c Mon Sep 17 00:00:00 2001 From: LCD 47 Date: Fri, 21 Jun 2013 11:42:14 +0300 Subject: [PATCH 09/17] Use default includes only with the C-like checkers. --- autoload/syntastic/c.vim | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/autoload/syntastic/c.vim b/autoload/syntastic/c.vim index 10c9f297..a0d2d53d 100644 --- a/autoload/syntastic/c.vim +++ b/autoload/syntastic/c.vim @@ -152,7 +152,9 @@ endfunction function! s:GetIncludeDirs(filetype) let include_dirs = [] - if !exists('g:syntastic_'.a:filetype.'_no_default_include_dirs') || !g:syntastic_{a:filetype}_no_default_include_dirs + if a:filetype =~# '\v^%(c|cpp|d|objc|objcpp)$' && + \ (!exists('g:syntastic_'.a:filetype.'_no_default_include_dirs') || + \ !g:syntastic_{a:filetype}_no_default_include_dirs) let include_dirs = copy(s:default_includes) endif From 907ef20e3cbf2676cad98dcfba0c8f57efc2c613 Mon Sep 17 00:00:00 2001 From: LCD 47 Date: Mon, 24 Jun 2013 11:46:27 +0300 Subject: [PATCH 10/17] New preprocess function "filterForeignErrors". Cleanup. --- autoload/syntastic/c.vim | 52 +++++++++++++----------------- autoload/syntastic/postprocess.vim | 5 +++ syntax_checkers/ada/gcc.vim | 6 ++-- syntax_checkers/c/gcc.vim | 6 ++-- syntax_checkers/cobol/cobc.vim | 3 +- syntax_checkers/cpp/gcc.vim | 6 ++-- syntax_checkers/d/dmd.vim | 4 +-- syntax_checkers/objc/gcc.vim | 6 ++-- syntax_checkers/objcpp/gcc.vim | 6 ++-- 9 files changed, 46 insertions(+), 48 deletions(-) diff --git a/autoload/syntastic/c.vim b/autoload/syntastic/c.vim index a0d2d53d..f5c0c0af 100644 --- a/autoload/syntastic/c.vim +++ b/autoload/syntastic/c.vim @@ -62,31 +62,20 @@ 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 has_key(a:options, 'header_names') && expand('%') =~? a:options['header_names'] 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 . - \ ' ' . s:GetIncludeDirs(ft) . - \ ' ' . syntastic#c#NullOutput() . - \ ' -c ' . shellescape(expand('%')) + let flags = get(a:options, 'header_flags', '') . ' -c ' . syntastic#c#NullOutput() else return [] endif else - let makeprg = - \ g:syntastic_{ft}_compiler . - \ ' ' . get(a:options, 'makeprg_main', '') . - \ ' ' . g:syntastic_{ft}_compiler_options . - \ ' ' . s:GetIncludeDirs(ft) . - \ ' ' . shellescape(expand('%')) + let flags = get(a:options, 'main_flags', '') endif + let flags .= ' ' . g:syntastic_{ft}_compiler_options . ' ' . s:GetIncludeDirs(ft) + " check if the user manually set some cflags if !exists('b:syntastic_' . ft . '_cflags') " check whether to search for include files at all @@ -94,33 +83,38 @@ function! syntastic#c#GetLocList(filetype, options) 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 .= ' ' . s:SearchHeaders() + let flags .= ' ' . s:SearchHeaders() else " search for header includes if not cached already if !exists('b:syntastic_' . ft . '_includes') let b:syntastic_{ft}_includes = s:SearchHeaders() endif - let makeprg .= ' ' . b:syntastic_{ft}_includes + let flags .= ' ' . b:syntastic_{ft}_includes endif endif endif else - " use the user-defined cflags - let makeprg .= ' ' . b:syntastic_{ft}_cflags + " user-defined cflags + let flags .= ' ' . b:syntastic_{ft}_cflags endif " add optional config file parameters - let makeprg .= ' ' . syntastic#c#ReadConfig(g:syntastic_{ft}_config_file) + let flags .= ' ' . syntastic#c#ReadConfig(g:syntastic_{ft}_config_file) + + let makeprg = g:syntastic_{ft}_compiler . ' ' . flags . ' ' . shellescape(expand('%')) + + let errorformat = exists('g:syntastic_' . ft . '_errorformat') ? + \ g:syntastic_{ft}_errorformat : a:options['errorformat'] + + let postprocess = + \ exists('g:syntastic_' . ft . '_remove_include_errors') && g:syntastic_{ft}_remove_include_errors ? + \ ['filterForeignErrors'] : [] " 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 + return SyntasticMake({ + \ 'makeprg': makeprg, + \ 'errorformat': errorformat, + \ 'postprocess': postprocess }) endfunction " Private functions {{{1 diff --git a/autoload/syntastic/postprocess.vim b/autoload/syntastic/postprocess.vim index 188a28a4..a944463e 100644 --- a/autoload/syntastic/postprocess.vim +++ b/autoload/syntastic/postprocess.vim @@ -53,6 +53,11 @@ function! syntastic#postprocess#cygwinRemoveCR(errors) return llist endfunction +" filter out errors referencing other files +function! syntastic#postprocess#filterForeignErrors(errors) + return filter(copy(a:errors), 'get(v:val, "bufnr") == ' . bufnr('')) +endfunction + let &cpo = s:save_cpo unlet s:save_cpo " vim: set et sts=4 sw=4: diff --git a/syntax_checkers/ada/gcc.vim b/syntax_checkers/ada/gcc.vim index 7a11f7c5..f74a4b2c 100644 --- a/syntax_checkers/ada/gcc.vim +++ b/syntax_checkers/ada/gcc.vim @@ -37,9 +37,9 @@ function! SyntaxCheckers_ada_gcc_GetLocList() \ '%-G%f:%s:,' . \ '%f:%l:%c: %m,' . \ '%f:%l: %m', - \ 'makeprg_main': '-c -x ada -fsyntax-only', - \ 'makeprg_headers': '-x ada', - \ 'headers_pattern': '\.ads$' }) + \ 'main_flags': '-c -x ada -fsyntax-only', + \ 'header_flags': '-x ada', + \ 'header_names': '\.ads$' }) endfunction call g:SyntasticRegistry.CreateAndRegisterChecker({ diff --git a/syntax_checkers/c/gcc.vim b/syntax_checkers/c/gcc.vim index 4dc1bfe7..42bb6b82 100644 --- a/syntax_checkers/c/gcc.vim +++ b/syntax_checkers/c/gcc.vim @@ -49,9 +49,9 @@ function! SyntaxCheckers_c_gcc_GetLocList() \ '%f:%l: %trror: %m,' . \ '%f:%l: %tarning: %m,'. \ '%f:%l: %m', - \ 'makeprg_main': '-x c -fsyntax-only', - \ 'makeprg_headers': '-x c', - \ 'headers_pattern': '\.h$' }) + \ 'main_flags': '-x c -fsyntax-only', + \ 'header_flags': '-x c', + \ 'header_names': '\.h$' }) endfunction call g:SyntasticRegistry.CreateAndRegisterChecker({ diff --git a/syntax_checkers/cobol/cobc.vim b/syntax_checkers/cobol/cobc.vim index 2a59ebd4..30306ce2 100644 --- a/syntax_checkers/cobol/cobc.vim +++ b/syntax_checkers/cobol/cobc.vim @@ -38,8 +38,7 @@ endif function! SyntaxCheckers_cobol_cobc_GetLocList() return syntastic#c#GetLocList('cobol', { \ 'errorformat': '%f:%l: %trror: %m', - \ 'makeprg_main': '-fsyntax-only', - \ 'headers_pattern': '^$' }) + \ 'main_flags': '-fsyntax-only' }) endfunction call g:SyntasticRegistry.CreateAndRegisterChecker({ diff --git a/syntax_checkers/cpp/gcc.vim b/syntax_checkers/cpp/gcc.vim index c9b4f1b7..b4295b64 100644 --- a/syntax_checkers/cpp/gcc.vim +++ b/syntax_checkers/cpp/gcc.vim @@ -44,9 +44,9 @@ function! SyntaxCheckers_cpp_gcc_GetLocList() \ '%f:%l: %trror: %m,'. \ '%f:%l: %tarning: %m,'. \ '%f:%l: %m', - \ 'makeprg_main': '-x c++ -fsyntax-only', - \ 'makeprg_headers': '-x c++', - \ 'headers_pattern': '\.\(h\|hpp\|hh\)$' }) + \ 'main_flags': '-x c++ -fsyntax-only', + \ 'header_flags': '-x c++', + \ 'header_names': '\.\(h\|hpp\|hh\)$' }) endfunction call g:SyntasticRegistry.CreateAndRegisterChecker({ diff --git a/syntax_checkers/d/dmd.vim b/syntax_checkers/d/dmd.vim index 17baaeca..73c258a3 100644 --- a/syntax_checkers/d/dmd.vim +++ b/syntax_checkers/d/dmd.vim @@ -44,8 +44,8 @@ function! SyntaxCheckers_d_dmd_GetLocList() \ 'errorformat': \ '%-G%f:%s:,%f(%l): %m,' . \ '%f:%l: %m', - \ 'makeprg_main': '-c -of' . syntastic#util#DevNull(), - \ 'headers_pattern': '\.di$' }) + \ 'main_flags': '-c -of' . syntastic#util#DevNull(), + \ 'header_names': '\.di$' }) endfunction call g:SyntasticRegistry.CreateAndRegisterChecker({ diff --git a/syntax_checkers/objc/gcc.vim b/syntax_checkers/objc/gcc.vim index e59d5c69..b913a602 100644 --- a/syntax_checkers/objc/gcc.vim +++ b/syntax_checkers/objc/gcc.vim @@ -48,9 +48,9 @@ function! SyntaxCheckers_objc_gcc_GetLocList() \ '%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$' }) + \ 'main_flags': '-x objective-c -fsyntax-only', + \ 'header_flags': '-x objective-c-header -lobjc', + \ 'header_names': '\.h$' }) endfunction call g:SyntasticRegistry.CreateAndRegisterChecker({ diff --git a/syntax_checkers/objcpp/gcc.vim b/syntax_checkers/objcpp/gcc.vim index cab7efd4..b5358b79 100644 --- a/syntax_checkers/objcpp/gcc.vim +++ b/syntax_checkers/objcpp/gcc.vim @@ -48,9 +48,9 @@ function! SyntaxCheckers_objcpp_gcc_GetLocList() \ '%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$' }) + \ 'main_flags': '-x objective-c++ -fsyntax-only', + \ 'header_flags': '-x objective-c++-header -lobjc', + \ 'header_names': '\.h$' }) endfunction call g:SyntasticRegistry.CreateAndRegisterChecker({ From 3e4501c1ffdf7eba579c26b039d3db88b1cf13e2 Mon Sep 17 00:00:00 2001 From: LCD 47 Date: Tue, 25 Jun 2013 09:59:07 +0300 Subject: [PATCH 11/17] More refactoring: add s:GetCheckerVar(). --- autoload/syntastic/c.vim | 37 ++++++++++++++++++++++------------ syntax_checkers/ada/gcc.vim | 6 +----- syntax_checkers/c/gcc.vim | 6 +----- syntax_checkers/cobol/cobc.vim | 6 +----- syntax_checkers/cpp/gcc.vim | 6 +----- syntax_checkers/d/dmd.vim | 6 +----- syntax_checkers/objc/gcc.vim | 6 +----- syntax_checkers/objcpp/gcc.vim | 6 +----- 8 files changed, 31 insertions(+), 48 deletions(-) diff --git a/autoload/syntastic/c.vim b/autoload/syntastic/c.vim index f5c0c0af..a56d657f 100644 --- a/autoload/syntastic/c.vim +++ b/autoload/syntastic/c.vim @@ -60,12 +60,13 @@ function! syntastic#c#ReadConfig(file) endfunction " GetLocList() for C-like compilers -function! syntastic#c#GetLocList(filetype, options) +function! syntastic#c#GetLocList(filetype, subchecker, options) let ft = a:filetype + let ck = a:subchecker " determine whether to parse header files as well if has_key(a:options, 'header_names') && expand('%') =~? a:options['header_names'] - if exists('g:syntastic_' . ft . '_check_header') && g:syntastic_{ft}_check_header + if s:GetCheckerVar('g', ft, ck, 'check_header', 0) let flags = get(a:options, 'header_flags', '') . ' -c ' . syntastic#c#NullOutput() else return [] @@ -74,15 +75,16 @@ function! syntastic#c#GetLocList(filetype, options) let flags = get(a:options, 'main_flags', '') endif - let flags .= ' ' . g:syntastic_{ft}_compiler_options . ' ' . s:GetIncludeDirs(ft) + let flags .= ' ' . s:GetCheckerVar('g', ft, ck, 'compiler_options', '') . ' ' . s:GetIncludeDirs(ft) " check if the user manually set some cflags - if !exists('b:syntastic_' . ft . '_cflags') + let b_cflags = s:GetCheckerVar('b', ft, ck, 'cflags', '') + if b_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 !s:GetCheckerVar('g', ft, ck, 'no_include_search', 0) 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 + if s:GetCheckerVar('g', ft, ck, 'auto_refresh_includes', 0) let flags .= ' ' . s:SearchHeaders() else " search for header includes if not cached already @@ -95,20 +97,17 @@ function! syntastic#c#GetLocList(filetype, options) endif else " user-defined cflags - let flags .= ' ' . b:syntastic_{ft}_cflags + let flags .= ' ' . b_cflags endif " add optional config file parameters - let flags .= ' ' . syntastic#c#ReadConfig(g:syntastic_{ft}_config_file) + let flags .= ' ' . syntastic#c#ReadConfig(s:GetCheckerVar('g', ft, ck, 'config_file', '.syntastic_' . ft . '_config')) let makeprg = g:syntastic_{ft}_compiler . ' ' . flags . ' ' . shellescape(expand('%')) - let errorformat = exists('g:syntastic_' . ft . '_errorformat') ? - \ g:syntastic_{ft}_errorformat : a:options['errorformat'] + let errorformat = s:GetCheckerVar('g', ft, ck, 'errorformat', a:options['errorformat']) - let postprocess = - \ exists('g:syntastic_' . ft . '_remove_include_errors') && g:syntastic_{ft}_remove_include_errors ? - \ ['filterForeignErrors'] : [] + let postprocess = s:GetCheckerVar('g', ft, ck, 'remove_include_errors', 0) ? ['filterForeignErrors'] : [] " process makeprg return SyntasticMake({ @@ -141,6 +140,18 @@ function! s:Init() call s:RegHandler('ruby', 'syntastic#c#CheckRuby', []) endfunction +" +function! s:GetCheckerVar(scope, filetype, subchecker, name, default) + let prefix = a:scope . ':' . 'syntastic_' + if exists(prefix . a:filetype . '_' . a:subchecker . '_' . a:name) + return {a:scope}:syntastic_{a:filetype}_{a:subchecker}_{a:name} + elseif exists(prefix . a:filetype . '_' . a:name) + return {a:scope}:syntastic_{a:filetype}_{a:name} + else + return a:default + endif +endfunction + " get the gcc include directory argument depending on the default " includes and the optional user-defined 'g:syntastic_c_include_dirs' function! s:GetIncludeDirs(filetype) diff --git a/syntax_checkers/ada/gcc.vim b/syntax_checkers/ada/gcc.vim index f74a4b2c..7562d609 100644 --- a/syntax_checkers/ada/gcc.vim +++ b/syntax_checkers/ada/gcc.vim @@ -27,12 +27,8 @@ if !exists('g:syntastic_ada_compiler_options') let g:syntastic_ada_compiler_options = '' endif -if !exists('g:syntastic_ada_config_file') - let g:syntastic_ada_config_file = '.syntastic_ada_config' -endif - function! SyntaxCheckers_ada_gcc_GetLocList() - return syntastic#c#GetLocList('ada', { + return syntastic#c#GetLocList('ada', 'gcc', { \ 'errorformat': \ '%-G%f:%s:,' . \ '%f:%l:%c: %m,' . diff --git a/syntax_checkers/c/gcc.vim b/syntax_checkers/c/gcc.vim index 42bb6b82..f0c577b5 100644 --- a/syntax_checkers/c/gcc.vim +++ b/syntax_checkers/c/gcc.vim @@ -31,12 +31,8 @@ if !exists('g:syntastic_c_compiler_options') let g:syntastic_c_compiler_options = '-std=gnu99' endif -if !exists('g:syntastic_c_config_file') - let g:syntastic_c_config_file = '.syntastic_c_config' -endif - function! SyntaxCheckers_c_gcc_GetLocList() - return syntastic#c#GetLocList('c', { + return syntastic#c#GetLocList('c', 'gcc', { \ 'errorformat': \ '%-G%f:%s:,' . \ '%-G%f:%l: %#error: %#(Each undeclared identifier is reported only%.%#,' . diff --git a/syntax_checkers/cobol/cobc.vim b/syntax_checkers/cobol/cobc.vim index 30306ce2..9399d432 100644 --- a/syntax_checkers/cobol/cobc.vim +++ b/syntax_checkers/cobol/cobc.vim @@ -31,12 +31,8 @@ if !exists('g:syntastic_cobol_compiler_options') let g:syntastic_cobol_compiler_options = '' endif -if !exists('g:syntastic_cobol_config_file') - let g:syntastic_cobol_config_file = '.syntastic_cobol_config' -endif - function! SyntaxCheckers_cobol_cobc_GetLocList() - return syntastic#c#GetLocList('cobol', { + return syntastic#c#GetLocList('cobol', 'cobc', { \ 'errorformat': '%f:%l: %trror: %m', \ 'main_flags': '-fsyntax-only' }) endfunction diff --git a/syntax_checkers/cpp/gcc.vim b/syntax_checkers/cpp/gcc.vim index b4295b64..64337927 100644 --- a/syntax_checkers/cpp/gcc.vim +++ b/syntax_checkers/cpp/gcc.vim @@ -30,12 +30,8 @@ if !exists('g:syntastic_cpp_compiler_options') let g:syntastic_cpp_compiler_options = '' endif -if !exists('g:syntastic_cpp_config_file') - let g:syntastic_cpp_config_file = '.syntastic_cpp_config' -endif - function! SyntaxCheckers_cpp_gcc_GetLocList() - return syntastic#c#GetLocList('cpp', { + return syntastic#c#GetLocList('cpp', 'gcc', { \ 'errorformat': \ '%-G%f:%s:,' . \ '%f:%l:%c: %trror: %m,' . diff --git a/syntax_checkers/d/dmd.vim b/syntax_checkers/d/dmd.vim index 73c258a3..1544caf7 100644 --- a/syntax_checkers/d/dmd.vim +++ b/syntax_checkers/d/dmd.vim @@ -35,12 +35,8 @@ if !exists('g:syntastic_d_compiler_options') let g:syntastic_d_compiler_options = '' endif -if !exists('g:syntastic_d_config_file') - let g:syntastic_d_config_file = '.syntastic_d_config' -endif - function! SyntaxCheckers_d_dmd_GetLocList() - return syntastic#c#GetLocList('d', { + return syntastic#c#GetLocList('d', 'dmd', { \ 'errorformat': \ '%-G%f:%s:,%f(%l): %m,' . \ '%f:%l: %m', diff --git a/syntax_checkers/objc/gcc.vim b/syntax_checkers/objc/gcc.vim index b913a602..52965e5d 100644 --- a/syntax_checkers/objc/gcc.vim +++ b/syntax_checkers/objc/gcc.vim @@ -30,12 +30,8 @@ if !exists('g:syntastic_objc_compiler_options') let g:syntastic_objc_compiler_options = '-std=gnu99' endif -if !exists('g:syntastic_objc_config_file') - let g:syntastic_objc_config_file = '.syntastic_objc_config' -endif - function! SyntaxCheckers_objc_gcc_GetLocList() - return syntastic#c#GetLocList('objc', { + return syntastic#c#GetLocList('objc', 'gcc', { \ 'errorformat': \ '%-G%f:%s:,' . \ '%-G%f:%l: %#error: %#(Each undeclared identifier is reported only%.%#,' . diff --git a/syntax_checkers/objcpp/gcc.vim b/syntax_checkers/objcpp/gcc.vim index b5358b79..c05166c9 100644 --- a/syntax_checkers/objcpp/gcc.vim +++ b/syntax_checkers/objcpp/gcc.vim @@ -30,12 +30,8 @@ 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#c#GetLocList('objcpp', { + return syntastic#c#GetLocList('objcpp', 'gcc', { \ 'errorformat': \ '%-G%f:%s:,' . \ '%-G%f:%l: %#error: %#(Each undeclared identifier is reported only%.%#,' . From 344701c9c384352f716a98517943ad279ed8332d Mon Sep 17 00:00:00 2001 From: LCD 47 Date: Wed, 26 Jun 2013 16:58:27 +0300 Subject: [PATCH 12/17] Change the gfortran checker to use syntastic#c#GetLocList(). --- syntax_checkers/fortran/gfortran.vim | 59 +++++++++++----------------- 1 file changed, 24 insertions(+), 35 deletions(-) diff --git a/syntax_checkers/fortran/gfortran.vim b/syntax_checkers/fortran/gfortran.vim index 0df45d3a..002ad9c3 100644 --- a/syntax_checkers/fortran/gfortran.vim +++ b/syntax_checkers/fortran/gfortran.vim @@ -7,14 +7,6 @@ " 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. -"Note: This syntax checker uses gfortran with the option -fsyntax-only -" to check for errors and warnings. Additional flags may be -" supplied through both local and global variables, -" b:syntastic_fortran_flags, -" g:syntastic_fortran_flags. -" This is particularly useful when the source requires module files -" in order to compile (that is when it needs modules defined in -" separate files). " "============================================================================ @@ -23,41 +15,38 @@ if exists("g:loaded_syntastic_fortran_gfortran_checker") endif let g:loaded_syntastic_fortran_gfortran_checker=1 -if !exists('g:syntastic_fortran_flags') - let g:syntastic_fortran_flags = '' +if !exists('g:syntastic_fortran_compiler') + let g:syntastic_fortran_compiler = 'gfortran' endif function! SyntaxCheckers_fortran_gfortran_IsAvailable() - return executable('gfortran') + return executable(g:syntastic_fortran_compiler) endfunction +let s:save_cpo = &cpo +set cpo&vim + +if !exists('g:syntastic_fortran_compiler_options') + let g:syntastic_fortran_compiler_options = '' +endif + function! SyntaxCheckers_fortran_gfortran_GetLocList() - let makeprg = syntastic#makeprg#build({ - \ 'exe': 'gfortran', - \ 'args': s:args(), - \ 'filetype': 'fortran', - \ 'subchecker': 'gfortran' }) - - let errorformat = - \ '%-C %#,'. - \ '%-C %#%.%#,'. - \ '%A%f:%l.%c:,'. - \ '%Z%m,'. - \ '%G%.%#' - - return SyntasticMake({ - \ 'makeprg': makeprg, - \ 'errorformat': errorformat }) -endfunction - -function s:args() - let rv = '-fsyntax-only ' . g:syntastic_fortran_flags - if exists('b:syntastic_fortran_flags') - let rv .= " " . b:syntastic_fortran_flags - endif - return rv + return syntastic#c#GetLocList('fortran', 'gfortran', { + \ 'errorformat': + \ '%-C %#,'. + \ '%-C %#%.%#,'. + \ '%A%f:%l.%c:,'. + \ '%Z%trror: %m,'. + \ '%Z%tarning: %m,'. + \ '%-G%.%#', + \ 'main_flags': '-fsyntax-only' }) endfunction call g:SyntasticRegistry.CreateAndRegisterChecker({ \ 'filetype': 'fortran', \ 'name': 'gfortran'}) + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim: set et sts=4 sw=4: From f641f68683089e9edf20251437b4182d1800659c Mon Sep 17 00:00:00 2001 From: LCD 47 Date: Fri, 28 Jun 2013 20:25:17 +0300 Subject: [PATCH 13/17] More refactoring: add s:GetCflags(). --- autoload/syntastic/c.vim | 101 ++++++++++++++++++++++----------------- 1 file changed, 56 insertions(+), 45 deletions(-) diff --git a/autoload/syntastic/c.vim b/autoload/syntastic/c.vim index a56d657f..9587a338 100644 --- a/autoload/syntastic/c.vim +++ b/autoload/syntastic/c.vim @@ -61,53 +61,18 @@ endfunction " GetLocList() for C-like compilers function! syntastic#c#GetLocList(filetype, subchecker, options) - let ft = a:filetype - let ck = a:subchecker + try + let flags = s:GetCflags(a:filetype, a:subchecker, a:options) + catch /\m\C^syntastic_skip_checks$/ + return [] + endtry - " determine whether to parse header files as well - if has_key(a:options, 'header_names') && expand('%') =~? a:options['header_names'] - if s:GetCheckerVar('g', ft, ck, 'check_header', 0) - let flags = get(a:options, 'header_flags', '') . ' -c ' . syntastic#c#NullOutput() - else - return [] - endif - else - let flags = get(a:options, 'main_flags', '') - endif + let makeprg = g:syntastic_{a:filetype}_compiler . ' ' . flags . ' ' . shellescape(expand('%')) - let flags .= ' ' . s:GetCheckerVar('g', ft, ck, 'compiler_options', '') . ' ' . s:GetIncludeDirs(ft) + let errorformat = s:GetCheckerVar('g', a:filetype, a:subchecker, 'errorformat', a:options['errorformat']) - " check if the user manually set some cflags - let b_cflags = s:GetCheckerVar('b', ft, ck, 'cflags', '') - if b_cflags == '' - " check whether to search for include files at all - if !s:GetCheckerVar('g', ft, ck, 'no_include_search', 0) - if ft ==# 'c' || ft ==# 'cpp' - " refresh the include file search if desired - if s:GetCheckerVar('g', ft, ck, 'auto_refresh_includes', 0) - let flags .= ' ' . s:SearchHeaders() - else - " search for header includes if not cached already - if !exists('b:syntastic_' . ft . '_includes') - let b:syntastic_{ft}_includes = s:SearchHeaders() - endif - let flags .= ' ' . b:syntastic_{ft}_includes - endif - endif - endif - else - " user-defined cflags - let flags .= ' ' . b_cflags - endif - - " add optional config file parameters - let flags .= ' ' . syntastic#c#ReadConfig(s:GetCheckerVar('g', ft, ck, 'config_file', '.syntastic_' . ft . '_config')) - - let makeprg = g:syntastic_{ft}_compiler . ' ' . flags . ' ' . shellescape(expand('%')) - - let errorformat = s:GetCheckerVar('g', ft, ck, 'errorformat', a:options['errorformat']) - - let postprocess = s:GetCheckerVar('g', ft, ck, 'remove_include_errors', 0) ? ['filterForeignErrors'] : [] + let postprocess = s:GetCheckerVar('g', a:filetype, a:subchecker, 'remove_include_errors', 0) ? + \ ['filterForeignErrors'] : [] " process makeprg return SyntasticMake({ @@ -140,7 +105,7 @@ function! s:Init() call s:RegHandler('ruby', 'syntastic#c#CheckRuby', []) endfunction -" +" resolve checker-related user variables function! s:GetCheckerVar(scope, filetype, subchecker, name, default) let prefix = a:scope . ':' . 'syntastic_' if exists(prefix . a:filetype . '_' . a:subchecker . '_' . a:name) @@ -152,6 +117,52 @@ function! s:GetCheckerVar(scope, filetype, subchecker, name, default) endif endfunction +" resolve user CFLAGS +function! s:GetCflags(ft, ck, opts) + " determine whether to parse header files as well + if has_key(a:opts, 'header_names') && expand('%') =~? a:opts['header_names'] + if s:GetCheckerVar('g', a:ft, a:ck, 'check_header', 0) + let flags = get(a:opts, 'header_flags', '') . ' -c ' . syntastic#c#NullOutput() + else + " checking headers when check_header is unset: bail out + throw 'syntastic_skip_checks' + endif + else + let flags = get(a:opts, 'main_flags', '') + endif + + let flags .= ' ' . s:GetCheckerVar('g', a:ft, a:ck, 'compiler_options', '') . ' ' . s:GetIncludeDirs(a:ft) + + " check if the user manually set some cflags + let b_cflags = s:GetCheckerVar('b', a:ft, a:ck, 'cflags', '') + if b_cflags == '' + " check whether to search for include files at all + if !s:GetCheckerVar('g', a:ft, a:ck, 'no_include_search', 0) + if a:ft ==# 'c' || a:ft ==# 'cpp' + " refresh the include file search if desired + if s:GetCheckerVar('g', a:ft, a:ck, 'auto_refresh_includes', 0) + let flags .= ' ' . s:SearchHeaders() + else + " search for header includes if not cached already + if !exists('b:syntastic_' . a:ft . '_includes') + let b:syntastic_{a:ft}_includes = s:SearchHeaders() + endif + let flags .= ' ' . b:syntastic_{a:ft}_includes + endif + endif + endif + else + " user-defined cflags + let flags .= ' ' . b_cflags + endif + + " add optional config file parameters + let config_file = s:GetCheckerVar('g', a:ft, a:ck, 'config_file', '.syntastic_' . a:ft . '_config') + let flags .= ' ' . syntastic#c#ReadConfig(config_file) + + return flags +endfunction + " get the gcc include directory argument depending on the default " includes and the optional user-defined 'g:syntastic_c_include_dirs' function! s:GetIncludeDirs(filetype) From fa961edac662d3749dfd3983cd9c8d406903fac2 Mon Sep 17 00:00:00 2001 From: LCD 47 Date: Thu, 4 Jul 2013 21:30:52 +0300 Subject: [PATCH 14/17] Merge branch 'master' into gcc_refactor --- autoload/syntastic/c.vim | 6 ++--- autoload/syntastic/util.vim | 10 +++++++ plugin/syntastic/makeprg_builder.vim | 2 +- syntax_checkers/cuda/nvcc.vim | 4 +-- syntax_checkers/erlang/erlang.vim | 6 ++--- syntax_checkers/eruby/erb.vim | 26 ++++++++++++------- syntax_checkers/eruby/ruby.vim | 2 +- syntax_checkers/haxe/haxe.vim | 2 +- syntax_checkers/html/tidy.vim | 6 ++--- syntax_checkers/html/validator.vim | 4 +-- syntax_checkers/html/w3.vim | 2 +- .../javascript/closurecompiler.vim | 2 +- syntax_checkers/nasm/nasm.vim | 2 +- syntax_checkers/ocaml/camlp4o.vim | 8 +++--- syntax_checkers/perl/perl.vim | 4 +-- syntax_checkers/python/python.vim | 2 +- 16 files changed, 53 insertions(+), 35 deletions(-) diff --git a/autoload/syntastic/c.vim b/autoload/syntastic/c.vim index 9587a338..137b8996 100644 --- a/autoload/syntastic/c.vim +++ b/autoload/syntastic/c.vim @@ -56,7 +56,7 @@ function! syntastic#c#ReadConfig(file) endif endfor - return join(map(parameters, 'shellescape(fnameescape(v:val))'), ' ') + return join(map(parameters, 'syntastic#util#shescape(fnameescape(v:val))'), ' ') endfunction " GetLocList() for C-like compilers @@ -67,7 +67,7 @@ function! syntastic#c#GetLocList(filetype, subchecker, options) return [] endtry - let makeprg = g:syntastic_{a:filetype}_compiler . ' ' . flags . ' ' . shellescape(expand('%')) + let makeprg = g:syntastic_{a:filetype}_compiler . ' ' . flags . ' ' . syntastic#util#shexpand('%') let errorformat = s:GetCheckerVar('g', a:filetype, a:subchecker, 'errorformat', a:options['errorformat']) @@ -178,7 +178,7 @@ function! s:GetIncludeDirs(filetype) call extend(include_dirs, g:syntastic_{a:filetype}_include_dirs) endif - return join(map(syntastic#util#unique(include_dirs), 'shellescape(fnameescape("-I" . v:val))'), ' ') + return join(map(syntastic#util#unique(include_dirs), 'syntastic#util#shescape(fnameescape("-I" . v:val))'), ' ') endfunction " search the first 100 lines for include statements that are diff --git a/autoload/syntastic/util.vim b/autoload/syntastic/util.vim index bfbdcfa4..cd6e67dc 100644 --- a/autoload/syntastic/util.vim +++ b/autoload/syntastic/util.vim @@ -137,6 +137,16 @@ function! syntastic#util#unique(list) return uniques endfunction +" A less noisy shellescape() +function! syntastic#util#shescape(string) + return a:string =~ '\m^[A-Za-z0-9_/.-]\+$' ? a:string : shellescape(a:string) +endfunction + +" A less noisy shellescape(expand()) +function! syntastic#util#shexpand(string) + return syntastic#util#shescape(expand(a:string)) +endfunction + function! syntastic#util#debug(msg) if g:syntastic_debug echomsg "syntastic: debug: " . a:msg diff --git a/plugin/syntastic/makeprg_builder.vim b/plugin/syntastic/makeprg_builder.vim index 4271a480..ef77efa9 100644 --- a/plugin/syntastic/makeprg_builder.vim +++ b/plugin/syntastic/makeprg_builder.vim @@ -33,7 +33,7 @@ endfunction function! g:SyntasticMakeprgBuilder.fname() if empty(self._fname) - return shellescape(expand("%")) + return syntastic#util#shexpand('%') else return self._fname endif diff --git a/syntax_checkers/cuda/nvcc.vim b/syntax_checkers/cuda/nvcc.vim index ee210aca..8303d2e0 100644 --- a/syntax_checkers/cuda/nvcc.vim +++ b/syntax_checkers/cuda/nvcc.vim @@ -36,7 +36,7 @@ function! SyntaxCheckers_cuda_nvcc_GetLocList() endif let makeprg = \ 'nvcc ' . arch_flag . ' --cuda -O0 -I . -Xcompiler -fsyntax-only ' . - \ shellescape(expand('%')) . ' ' . syntastic#c#NullOutput() + \ syntastic#util#shexpand('%') . ' ' . syntastic#c#NullOutput() let errorformat = \ '%*[^"]"%f"%*\D%l: %m,'. \ '"%f"%*\D%l: %m,'. @@ -58,7 +58,7 @@ function! SyntaxCheckers_cuda_nvcc_GetLocList() let makeprg = \ 'echo > .syntastic_dummy.cu ; ' . \ 'nvcc ' . arch_flag . ' --cuda -O0 -I . .syntastic_dummy.cu -Xcompiler -fsyntax-only -include ' . - \ shellescape(expand('%')) . ' ' . syntastic#c#NullOutput() + \ syntastic#util#shexpand('%') . ' ' . syntastic#c#NullOutput() else return [] endif diff --git a/syntax_checkers/erlang/erlang.vim b/syntax_checkers/erlang/erlang.vim index 1a0b2787..967b759d 100644 --- a/syntax_checkers/erlang/erlang.vim +++ b/syntax_checkers/erlang/erlang.vim @@ -32,12 +32,12 @@ function! SyntaxCheckers_erlang_escript_GetLocList() let shebang = getbufline(bufnr('%'), 1)[0] if len(shebang) > 0 if match(shebang, 'escript') >= 0 - let makeprg = 'escript -s '.shellescape(expand('%:p')) + let makeprg = 'escript -s ' . syntastic#util#shexpand('%:p') else - let makeprg = 'escript ' . s:check_file . ' '. shellescape(expand('%:p')).' '.g:syntastic_erlc_include_path + let makeprg = 'escript ' . s:check_file . ' ' . syntastic#util#shexpand('%:p') . ' ' . g:syntastic_erlc_include_path endif else - let makeprg = 'escript ' . s:check_file . ' ' . shellescape(expand('%:p')).' '.g:syntastic_erlc_include_path + let makeprg = 'escript ' . s:check_file . ' ' . syntastic#util#shexpand('%:p') . ' '. g:syntastic_erlc_include_path endif let errorformat = \ '%f:%l:\ %tarning:\ %m,'. diff --git a/syntax_checkers/eruby/erb.vim b/syntax_checkers/eruby/erb.vim index 74e0e6c5..06ac79bb 100644 --- a/syntax_checkers/eruby/erb.vim +++ b/syntax_checkers/eruby/erb.vim @@ -28,16 +28,24 @@ function! SyntaxCheckers_eruby_erb_IsAvailable() endfunction function! SyntaxCheckers_eruby_erb_GetLocList() - " TODO: fix the encoding trainwreck - " let enc = &fileencoding != '' ? &fileencoding : &encoding - let enc = '' + let exe = expand(g:syntastic_ruby_exec) + if !has('win32') + let exe = 'RUBYOPT= ' . exe + endif - let makeprg = syntastic#makeprg#build({ - \ 'exe': g:syntastic_erb_exec, - \ 'args': '-x -T -' . (enc ==# 'utf-8' ? ' -U' : ''), - \ 'tail': '\| ' . g:syntastic_ruby_exec . ' -c', - \ 'filetype': 'eruby', - \ 'subchecker': 'erb' }) + let fname = fnameescape(expand('%')) + + let enc = &fileencoding != '' ? &fileencoding : &encoding + let encoding_string = enc ==? 'utf-8' ? 'UTF-8' : 'BINARY' + + " TODO: fix the encoding trainwreck + let makeprg = + \ exe . ' -e ' . + \ syntastic#util#shescape('puts File.read("' . fname . + \ '", :encoding => "' . encoding_string . + \ '").gsub(''<\%='',''<\%'')') . + \ ' \| ' . g:syntastic_erb_exec . ' -x -T -' . + \ ' \| ' . exe . ' -c' let errorformat = \ '%-GSyntax OK,'. diff --git a/syntax_checkers/eruby/ruby.vim b/syntax_checkers/eruby/ruby.vim index d32dd6e6..e9503f7e 100644 --- a/syntax_checkers/eruby/ruby.vim +++ b/syntax_checkers/eruby/ruby.vim @@ -37,7 +37,7 @@ function! SyntaxCheckers_eruby_ruby_GetLocList() "gsub fixes issue #7, rails has it's own eruby syntax let makeprg = \ exe . ' -rerb -e ' . - \ shellescape('puts ERB.new(File.read("' . fname . + \ syntastic#util#shescape('puts ERB.new(File.read("' . fname . \ '", :encoding => "' . encoding_string . \ '").gsub(''<\%='',''<\%''), nil, ''-'').src') . \ ' \| ' . exe . ' -c' diff --git a/syntax_checkers/haxe/haxe.vim b/syntax_checkers/haxe/haxe.vim index fd9262c4..cffd5277 100644 --- a/syntax_checkers/haxe/haxe.vim +++ b/syntax_checkers/haxe/haxe.vim @@ -54,7 +54,7 @@ function! SyntaxCheckers_haxe_haxe_GetLocList() if !empty(hxml) let makeprg = syntastic#makeprg#build({ \ 'exe': 'haxe', - \ 'fname': shellescape(fnameescape(fnamemodify(hxml, ':t'))), + \ 'fname': syntastic#util#shescape(fnameescape(fnamemodify(hxml, ':t'))), \ 'filetype': 'haxe', \ 'subchecker': 'haxe' }) diff --git a/syntax_checkers/html/tidy.vim b/syntax_checkers/html/tidy.vim index 0f528026..45c06a79 100644 --- a/syntax_checkers/html/tidy.vim +++ b/syntax_checkers/html/tidy.vim @@ -74,9 +74,9 @@ endfunction function s:Args() let args = s:TidyEncOptByFenc() . - \ ' --new-blocklevel-tags ' . shellescape('main, section, article, aside, hgroup, header, footer, nav, figure, figcaption') . - \ ' --new-inline-tags ' . shellescape('video, audio, source, embed, mark, progress, meter, time, ruby, rt, rp, canvas, command, details, datalist') . - \ ' --new-empty-tags ' . shellescape('wbr, keygen') . + \ ' --new-blocklevel-tags ' . syntastic#util#shescape('main, section, article, aside, hgroup, header, footer, nav, figure, figcaption') . + \ ' --new-inline-tags ' . syntastic#util#shescape('video, audio, source, embed, mark, progress, meter, time, ruby, rt, rp, canvas, command, details, datalist') . + \ ' --new-empty-tags ' . syntastic#util#shescape('wbr, keygen') . \ ' -e' return args endfunction diff --git a/syntax_checkers/html/validator.vim b/syntax_checkers/html/validator.vim index bf41edee..7e24a17b 100644 --- a/syntax_checkers/html/validator.vim +++ b/syntax_checkers/html/validator.vim @@ -45,7 +45,7 @@ if !exists('g:syntastic_html_validator_nsfilter') let g:syntastic_html_validator_nsfilter = '' endif -let s:decoder = 'awk -f ' . shellescape(expand(':p:h') . '/validator_decode.awk') +let s:decoder = 'awk -f ' . syntastic#util#shescape(expand(':p:h') . '/validator_decode.awk') function! SyntaxCheckers_html_validator_IsAvailable() return executable('curl') && executable('awk') @@ -55,7 +55,7 @@ function! SyntaxCheckers_html_validator_GetLocList() let makeprg = 'curl -s --compressed -F out=gnu -F asciiquotes=yes' . \ (!empty(g:syntastic_html_validator_parser) ? ' -F parser=' . g:syntastic_html_validator_parser : '') . \ (!empty(g:syntastic_html_validator_nsfilter) ? ' -F nsfilter=' . g:syntastic_html_validator_nsfilter : '') . - \ ' -F doc=@' . shellescape(expand('%')) . '\;type=text/html\;filename=' . shellescape(expand('%')) . ' ' . + \ ' -F doc=@' . syntastic#util#shexpand('%') . '\;type=text/html\;filename=' . syntastic#util#shexpand('%') . ' ' . \ g:syntastic_html_validator_api . ' \| ' . s:decoder let errorformat = \ '%E"%f":%l: %trror: %m,' . diff --git a/syntax_checkers/html/w3.vim b/syntax_checkers/html/w3.vim index 7bb0fcd0..c9bc8688 100644 --- a/syntax_checkers/html/w3.vim +++ b/syntax_checkers/html/w3.vim @@ -32,7 +32,7 @@ endfunction function! SyntaxCheckers_html_w3_GetLocList() let makeprg = 'curl -s -F output=json ' . - \ '-F uploaded_file=@' . shellescape(expand('%:p')) . '\;type=text/html ' . + \ '-F uploaded_file=@' . syntastic#util#shexpand('%:p') . '\;type=text/html ' . \ g:syntastic_html_w3_api let errorformat = \ '%A %\+{,' . diff --git a/syntax_checkers/javascript/closurecompiler.vim b/syntax_checkers/javascript/closurecompiler.vim index f15f6060..6c55f4f2 100644 --- a/syntax_checkers/javascript/closurecompiler.vim +++ b/syntax_checkers/javascript/closurecompiler.vim @@ -38,7 +38,7 @@ function! SyntaxCheckers_javascript_closurecompiler_GetLocList() if exists("g:syntastic_javascript_closure_compiler_file_list") let file_list = join(readfile(g:syntastic_javascript_closure_compiler_file_list), ' ') else - let file_list = shellescape(expand('%')) + let file_list = syntastic#util#shexpand('%') endif let makeprg = syntastic#makeprg#build({ diff --git a/syntax_checkers/nasm/nasm.vim b/syntax_checkers/nasm/nasm.vim index 8c425b55..8476b515 100644 --- a/syntax_checkers/nasm/nasm.vim +++ b/syntax_checkers/nasm/nasm.vim @@ -19,7 +19,7 @@ function! SyntaxCheckers_nasm_nasm_IsAvailable() endfunction function! SyntaxCheckers_nasm_nasm_GetLocList() - let wd = shellescape(expand("%:p:h") . "/") + let wd = syntastic#util#shescape(expand("%:p:h") . "/") let makeprg = syntastic#makeprg#build({ \ 'exe': 'nasm', \ 'args': '-X gnu -f elf -I ' . wd . ' ' . syntastic#c#NullOutput(), diff --git a/syntax_checkers/ocaml/camlp4o.vim b/syntax_checkers/ocaml/camlp4o.vim index b498134c..35242125 100644 --- a/syntax_checkers/ocaml/camlp4o.vim +++ b/syntax_checkers/ocaml/camlp4o.vim @@ -121,7 +121,7 @@ endfunction function s:GetOcamlBuildMakeprg() return "ocamlbuild -quiet -no-log -tag annot," . s:ocamlpp . " -no-links -no-hygiene -no-sanitize " . - \ shellescape(expand('%:r')) . ".cmi" + \ syntastic#util#shexpand('%:r') . ".cmi" endfunction function s:GetOtherMakeprg() @@ -134,11 +134,11 @@ function s:GetOtherMakeprg() if match(extension, 'mly') >= 0 && executable("menhir") " ocamlyacc output can't be redirected, so use menhir - let makeprg = "menhir --only-preprocess " . shellescape(expand('%')) . " >" . syntastic#util#DevNull() + let makeprg = "menhir --only-preprocess " . syntastic#util#shexpand('%') . " >" . syntastic#util#DevNull() elseif match(extension,'mll') >= 0 && executable("ocamllex") - let makeprg = "ocamllex -q " . syntastic#c#NullOutput() . " " . shellescape(expand('%')) + let makeprg = "ocamllex -q " . syntastic#c#NullOutput() . " " . syntastic#util#shexpand('%') else - let makeprg = "camlp4o " . syntastic#c#NullOutput() . " " . shellescape(expand('%')) + let makeprg = "camlp4o " . syntastic#c#NullOutput() . " " . syntastic#util#shexpand('%') endif return makeprg diff --git a/syntax_checkers/perl/perl.vim b/syntax_checkers/perl/perl.vim index 67316da3..d88437dd 100644 --- a/syntax_checkers/perl/perl.vim +++ b/syntax_checkers/perl/perl.vim @@ -41,7 +41,7 @@ endfunction if !exists("g:syntastic_perl_efm_program") let g:syntastic_perl_efm_program = \ g:syntastic_perl_interpreter . ' ' . - \ shellescape(expand(':p:h') . '/efm_perl.pl') . + \ syntastic#util#shescape(expand(':p:h') . '/efm_perl.pl') . \ ' -c -w' endif @@ -50,7 +50,7 @@ function! SyntaxCheckers_perl_perl_GetLocList() if exists("g:syntastic_perl_lib_path") let makeprg .= ' -I' . g:syntastic_perl_lib_path endif - let makeprg .= ' ' . shellescape(expand('%')) . s:ExtraMakeprgArgs() + let makeprg .= ' ' . syntastic#util#shexpand('%') . s:ExtraMakeprgArgs() let errorformat = '%t:%f:%l:%m' diff --git a/syntax_checkers/python/python.vim b/syntax_checkers/python/python.vim index 7169a6f6..eff1696b 100644 --- a/syntax_checkers/python/python.vim +++ b/syntax_checkers/python/python.vim @@ -22,7 +22,7 @@ function! SyntaxCheckers_python_python_GetLocList() let makeprg = syntastic#makeprg#build({ \ 'exe': 'python', \ 'args': '-c', - \ 'fname': shellescape("compile(open(" . fname . ").read(), " . fname . ", 'exec')"), + \ 'fname': syntastic#util#shescape("compile(open(" . fname . ").read(), " . fname . ", 'exec')"), \ 'filetype': 'python', \ 'subchecker': 'python' }) From 8aafac34d26706f6bc2117f0ee0307f662ed06ac Mon Sep 17 00:00:00 2001 From: LCD 47 Date: Fri, 12 Jul 2013 08:11:20 +0300 Subject: [PATCH 15/17] Cleanup. --- autoload/syntastic/c.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/autoload/syntastic/c.vim b/autoload/syntastic/c.vim index 137b8996..ac54186f 100644 --- a/autoload/syntastic/c.vim +++ b/autoload/syntastic/c.vim @@ -63,7 +63,7 @@ endfunction function! syntastic#c#GetLocList(filetype, subchecker, options) try let flags = s:GetCflags(a:filetype, a:subchecker, a:options) - catch /\m\C^syntastic_skip_checks$/ + catch /\m\C^Syntastic: skip checks$/ return [] endtry @@ -125,7 +125,7 @@ function! s:GetCflags(ft, ck, opts) let flags = get(a:opts, 'header_flags', '') . ' -c ' . syntastic#c#NullOutput() else " checking headers when check_header is unset: bail out - throw 'syntastic_skip_checks' + throw 'Syntastic: skip checks' endif else let flags = get(a:opts, 'main_flags', '') From 5c75519bc841cd4ed737503d333d7b4e86a7a61a Mon Sep 17 00:00:00 2001 From: LCD 47 Date: Wed, 7 Aug 2013 20:41:50 +0300 Subject: [PATCH 16/17] Add verilator checker for verilog. --- README.markdown | 4 +-- syntax_checkers/verilog/verilator.vim | 42 +++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 syntax_checkers/verilog/verilator.vim diff --git a/README.markdown b/README.markdown index 7c43d3fc..3227e5b0 100644 --- a/README.markdown +++ b/README.markdown @@ -32,8 +32,8 @@ Fortran, Gentoo metadata, Go, Haml, Haskell, Haxe, HSS, HTML, Java, JavaScript, JSON, LESS, LISP, LLVM intermediate language, Lua, MATLAB, NASM, Objective-C, Objective-C++, OCaml, Perl, Perl POD, PHP, Puppet, Python, reStructuredText, Ruby, Rust, SASS/SCSS, Scala, Slim, Tcl, TeX, -Twig, TypeScript, Vala, VHDL, xHtml, XML, XSLT, YAML, z80, Zope page -templates, zsh. +Twig, TypeScript, Vala, Verilog, VHDL, xHtml, XML, XSLT, YAML, z80, Zope +page templates, zsh. ## Screenshot diff --git a/syntax_checkers/verilog/verilator.vim b/syntax_checkers/verilog/verilator.vim new file mode 100644 index 00000000..0bad01b3 --- /dev/null +++ b/syntax_checkers/verilog/verilator.vim @@ -0,0 +1,42 @@ +"============================================================================ +"File: verilator.vim +"Description: Syntax checking plugin for syntastic.vim +"Maintainer: Kocha +"============================================================================ + +if exists("g:loaded_syntastic_verilog_verilator_checker") + finish +endif +let g:loaded_syntastic_verilog_verilator_checker = 1 + +if !exists('g:syntastic_verilog_compiler') + let g:syntastic_verilog_compiler = 'verilator' +endif + +let s:save_cpo = &cpo +set cpo&vim + +function! SyntaxCheckers_verilog_verilator_IsAvailable() + return executable(g:syntastic_verilog_compiler) +endfunction + +if !exists('g:syntastic_verilog_compiler_options') + let g:syntastic_verilog_compiler_options = '-Wall' +endif + +function! SyntaxCheckers_verilog_verilator_GetLocList() + return syntastic#c#GetLocList('verilog', 'verilator', { + \ 'errorformat': + \ '%%%trror-%\=%\w%#: %f:%l: %m,' . + \ '%%%tarning-%\=%\w%#: %f:%l: %m', + \ 'main_flags': '--lint-only' }) +endfunction + +call g:SyntasticRegistry.CreateAndRegisterChecker({ + \ 'filetype': 'verilog', + \ 'name': 'verilator'}) + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim: set et sts=4 sw=4: From 561e2c9431a3caabd32dc8a035e5dcfb6648d0cd Mon Sep 17 00:00:00 2001 From: LCD 47 Date: Mon, 12 Aug 2013 18:00:37 +0300 Subject: [PATCH 17/17] Minor bug fix in asciidoc checker. --- syntax_checkers/asciidoc/asciidoc.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/syntax_checkers/asciidoc/asciidoc.vim b/syntax_checkers/asciidoc/asciidoc.vim index 0f0f955f..faa907cb 100644 --- a/syntax_checkers/asciidoc/asciidoc.vim +++ b/syntax_checkers/asciidoc/asciidoc.vim @@ -22,7 +22,7 @@ endfunction function! SyntaxCheckers_asciidoc_asciidoc_GetLocList() let makeprg = syntastic#makeprg#build({ \ 'exe': 'asciidoc', - \ 'args': syntastic#c#GetNullDevice(), + \ 'args': syntastic#c#NullOutput(), \ 'filetype': 'asciidoc', \ 'subchecker': 'asciidoc' })