diff --git a/LICENCE b/LICENCE new file mode 100644 index 00000000..8b1a9d81 --- /dev/null +++ b/LICENCE @@ -0,0 +1,13 @@ + DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + Version 2, December 2004 + +Copyright (C) 2004 Sam Hocevar + +Everyone is permitted to copy and distribute verbatim or modified +copies of this license document, and changing it is allowed as long +as the name is changed. + + DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. You just DO WHAT THE FUCK YOU WANT TO. diff --git a/README.markdown b/README.markdown index 78f97c6d..4528d5eb 100644 --- a/README.markdown +++ b/README.markdown @@ -2,7 +2,7 @@ / \,,_ .'| ,{{| /}}}}/_.' _____________________________________________ }}}}` '{{' '. / \ - {{{{{ _ ;, \ / Gentlemen, \ + {{{{{ _ ;, \ / Ladies and Gentlemen, \ ,}}}}}} /o`\ ` ;) | | {{{{{{ / ( | this is ... | }}}}}} | \ | | @@ -50,12 +50,44 @@ enabled. Installation ------------ -[pathogen.vim](https://github.com/tpope/vim-pathogen) is the recommended way to install syntastic. +Installing syntastic is easy but first you need to have the pathogen plugin installed. If you already +have pathogen working then skip Step 1 and go to Step 2. + +Step 1: Install pathogen.vim +---------------------------- + +First I'll show you how to install tpope's [pathogen.vim](https://github.com/tpope/vim-pathogen) so that +it's easy to install syntastic. Do this in your Terminal so that you get the pathogen.vim file +and the directories it needs: + + mkdir -p ~/.vim/autoload ~/.vim/bundle; \ + curl -so ~/.vim/autoload/pathogen.vim \ + https://raw.github.com/tpope/vim-pathogen/master/autoload/pathogen.vim + +Next you *need to add this* to your ~/.vimrc: + + call pathogen#infect() + +Step 2: Install syntastic as a pathogen bundle +---------------------------------------------- + +You now have pathogen installed and can put syntastic into ~/.vim/bundle like this: + cd ~/.vim/bundle git clone https://github.com/scrooloose/syntastic.git -Then reload vim, run `:Helptags`, and check out `:help syntastic.txt`. +Quit vim and start it back up to reload it, then type: + + :Helptags + +If you get an error when you do this, then you probably didn't install pathogen right. Go back to +step 1 and make sure you did the following: + +1. Created both the ~/.vim/autoload and ~/.vim/bundle directories. +2. Added the "call pathogen#infect()" line to your ~/.vimrc file +3. Did the git clone of syntastic inside ~/.vim/bundle +4. Have permissions to access all of these directories. Google group @@ -69,10 +101,19 @@ FAQ __Q. I installed syntastic but it isn't reporting any errors ...__ -A. The most likely reason is that the syntax checker that it requires isn't installed. For example: python requires either `flake8`, `pyflakes` or `pylint` to be installed and in `$PATH`. To see which executable is required, just look in `syntax_checkers/.vim`. +A. The most likely reason is that the syntax checker that it requires isn't installed. For example: python requires either `flake8`, `pyflakes` or `pylint` to be installed and in `$PATH`. To see which executable is required, just look in `syntax_checkers/.vim`. Note that aliases do not work; the actual executable must be available in your `$PATH`. Symbolic links are okay. Another reason it could fail is that the error output for the syntax checker may have changed. In this case, make sure you have the latest version of the syntax checker installed. If it still fails then create an issue - or better yet, create a pull request. +__Q. How can I jump between the different errors without using the location list at the bottom of the window?__ + +A. Vim provides several built in commands for this. See `:help :lnext` and `:help :lprev`. + +If you use these commands a lot then you may want to add shortcut mappings to your vimrc, or install something like [unimpaired](https://github.com/tpope/vim-unimpaired) - which provides such mappings (among other things). + +__Q. A syntax checker is giving me unwanted/strange style tips??__ + +A. Some filetypes (e.g. php) have style checkers as well as syntax checkers. You can usually configure the options that are passed to the style checkers, or just disable them. Take a look at the syntax checker integration file (e.g. `syntax_checkers/php.vim`) to see what options are available. Changelog --------- diff --git a/autoload/syntastic/c.vim b/autoload/syntastic/c.vim index 8d329490..f52e806a 100644 --- a/autoload/syntastic/c.vim +++ b/autoload/syntastic/c.vim @@ -53,10 +53,26 @@ function! s:Unique(list) return l endfunction +" 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 '' +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 = copy(s:default_includes) + 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) diff --git a/autoload/syntastic/util.vim b/autoload/syntastic/util.vim new file mode 100644 index 00000000..e570484c --- /dev/null +++ b/autoload/syntastic/util.vim @@ -0,0 +1,42 @@ +if exists("g:loaded_syntastic_util_autoload") + finish +endif +let g:loaded_syntastic_util_autoload = 1 + +let s:save_cpo = &cpo +set cpo&vim + +function! syntastic#util#DevNull() + if has('win32') + return 'NUL' + endif + return '/dev/null' +endfunction + +"search the first 5 lines of the file for a magic number and return a map +"containing the args and the executable +" +"e.g. +" +"#!/usr/bin/perl -f -bar +" +"returns +" +"{'exe': '/usr/bin/perl', 'args': ['-f', '-bar']} +function! syntastic#util#ParseShebang() + for lnum in range(1,5) + let line = getline(lnum) + + if line =~ '^#!' + let exe = matchstr(line, '^#!\s*\zs[^ \t]*') + let args = split(matchstr(line, '^#!\s*[^ \t]*\zs.*')) + return {'exe': exe, 'args': args} + endif + endfor + + return {'exe': '', 'args': []} +endfunction + +let &cpo = s:save_cpo +unlet s:save_cpo +" vim: set et sts=4 sw=4: diff --git a/doc/syntastic.txt b/doc/syntastic.txt index f0cede36..519b8146 100644 --- a/doc/syntastic.txt +++ b/doc/syntastic.txt @@ -163,6 +163,20 @@ syntax errors: > let g:syntastic_enable_signs=1 < + *'syntastic_error_symbol'* *'syntastic_style_error_symbol'* + *'syntastic_warning_symbol'* *'syntastic_style_warning_symbol'* +Use this option to control what the syntastic |:sign| text contains. Several +error symobls can be customized: + syntastic_error_symbol - For syntax errors, defaults to '>>' + syntastic_style_error_symbol - For style errors, defaults to 'S>' + syntastic_warning_symbol - For syntax warnings, defaults to '>>' + syntastic_style_warning_symbol - For style warnings, defaults to 'S>' + +Example: > + let g:syntastic_error_symbol='✗' + let g:syntastic_warning_symbol='âš ' +< + *'syntastic_enable_balloons'* Default: 1 Use this option to tell syntastic whether to display error messages in balloons @@ -260,7 +274,7 @@ this option has the following effects: Default: [Syntax: line:%F (%t)] Use this option to control what the syntastic statusline text contains. Several -magic flags are availble to insert information: +magic flags are available to insert information: %e - number of errors %w - number of warnings %t - total number of warnings and errors @@ -340,7 +354,7 @@ The author of syntastic is a mighty wild stallion, hear him roar! > < He likes to trot around in the back yard reading his emails and sipping a -scolding hot cup of Earl Grey. Email him at martin.grenfell at gmail dot com. +scalding hot cup of Earl Grey. Email him at martin.grenfell at gmail dot com. He can also be found trolling the #vim channel on the freenode IRC network as scrooloose. diff --git a/plugin/syntastic.vim b/plugin/syntastic.vim index c26d2d32..df8fae19 100644 --- a/plugin/syntastic.vim +++ b/plugin/syntastic.vim @@ -19,13 +19,26 @@ let g:loaded_syntastic_plugin = 1 let s:running_windows = has("win16") || has("win32") -if !s:running_windows - let s:uname = system('uname') -endif - if !exists("g:syntastic_enable_signs") let g:syntastic_enable_signs = 1 endif + +if !exists("g:syntastic_error_symbol") + let g:syntastic_error_symbol = '>>' +endif + +if !exists("g:syntastic_warning_symbol") + let g:syntastic_warning_symbol = '>>' +endif + +if !exists("g:syntastic_style_error_symbol") + let g:syntastic_style_error_symbol = 'S>' +endif + +if !exists("g:syntastic_style_warning_symbol") + let g:syntastic_style_warning_symbol = 'S>' +endif + if !has('signs') let g:syntastic_enable_signs = 0 endif @@ -41,6 +54,11 @@ if !exists("g:syntastic_enable_highlighting") let g:syntastic_enable_highlighting = 1 endif +" highlighting requires getmatches introduced in 7.1.040 +if v:version < 701 || (v:version == 701 && !has('patch040')) + let g:syntastic_enable_highlighting = 0 +endif + if !exists("g:syntastic_echo_current_error") let g:syntastic_echo_current_error = 1 endif @@ -115,9 +133,7 @@ function! s:UpdateErrors(auto_invoked) call s:CacheErrors() end - if s:BufHasErrorsOrWarningsToDisplay() - call setloclist(0, s:LocList()) - endif + call setloclist(0, s:LocList()) if g:syntastic_enable_balloons call s:RefreshBalloons() @@ -128,7 +144,7 @@ function! s:UpdateErrors(auto_invoked) endif if g:syntastic_enable_highlighting - call s:HightlightErrors() + call s:HighlightErrors() endif if g:syntastic_auto_jump && s:BufHasErrorsOrWarningsToDisplay() @@ -183,7 +199,7 @@ function! s:CacheErrors() "functions legally for filetypes like "gentoo-metadata" let fts = substitute(&ft, '-', '_', 'g') for ft in split(fts, '\.') - if s:Checkable(ft) + if SyntasticCheckable(ft) let errors = SyntaxCheckers_{ft}_GetLocList() "keep only lines that effectively match an error/warning let errors = s:FilterLocList({'valid': 1}, errors) @@ -226,7 +242,10 @@ function! s:ModeMapAllowsAutoChecking() endfunction function! s:BufHasErrorsOrWarningsToDisplay() - return len(s:Errors()) || (!g:syntastic_quiet_warnings && !empty(s:LocList())) + if empty(s:LocList()) + return 0 + endif + return len(s:Errors()) || !g:syntastic_quiet_warnings endfunction function! s:Errors() @@ -274,10 +293,10 @@ endfunction if g:syntastic_enable_signs "define the signs used to display syntax and style errors/warns - sign define SyntasticError text=>> texthl=error - sign define SyntasticWarning text=>> texthl=todo - sign define SyntasticStyleError text=S> texthl=error - sign define SyntasticStyleWarning text=S> texthl=todo + exe 'sign define SyntasticError text='.g:syntastic_error_symbol.' texthl=error' + exe 'sign define SyntasticWarning text='.g:syntastic_warning_symbol.' texthl=todo' + exe 'sign define SyntasticStyleError text='.g:syntastic_style_error_symbol.' texthl=error' + exe 'sign define SyntasticStyleWarning text='.g:syntastic_style_warning_symbol.' texthl=todo' endif "start counting sign ids at 5000, start here to hopefully avoid conflicting @@ -348,6 +367,7 @@ endfunction "display the cached errors for this buf in the location list function! s:ShowLocList() if !empty(s:LocList()) + call setloclist(0, s:LocList()) let num = winnr() exec "lopen " . g:syntastic_loc_list_height if num != winnr() @@ -373,7 +393,7 @@ endfunction " "If the 'force_highlight_callback' key is set for an error item, then invoke "the callback even if it can be highlighted automatically. -function! s:HightlightErrors() +function! s:HighlightErrors() call s:ClearErrorHighlights() let fts = substitute(&ft, '-', '_', 'g') @@ -410,16 +430,6 @@ function! s:ClearErrorHighlights() endfor endfunction -"check if a syntax checker exists for the given filetype - and attempt to -"load one -function! s:Checkable(ft) - if !exists("g:loaded_" . a:ft . "_syntax_checker") - exec "runtime syntax_checkers/" . a:ft . ".vim" - endif - - return exists("*SyntaxCheckers_". a:ft ."_GetLocList") -endfunction - "set up error ballons for the current set of errors function! s:RefreshBalloons() let b:syntastic_balloons = {} @@ -436,7 +446,10 @@ function! s:WideMsg(msg) let old_ruler = &ruler let old_showcmd = &showcmd - let msg = strpart(a:msg, 0, winwidth(0)-1) + "convert tabs to spaces so that the tabs count towards the window width + "as the proper amount of characters + let msg = substitute(a:msg, "\t", repeat(" ", &tabstop), "g") + let msg = strpart(msg, 0, winwidth(0)-1) "This is here because it is possible for some error messages to begin with "\n which will cause a "press enter" prompt. I have noticed this in the @@ -480,6 +493,64 @@ function! s:LoadChecker(checker, ft) exec "runtime syntax_checkers/" . a:ft . "/" . a:checker . ".vim" endfunction +"the script changes &shellpipe and &shell to stop the screen flicking when +"shelling out to syntax checkers. Not all OSs support the hacks though +function! s:OSSupportsShellpipeHack() + return !s:running_windows && (s:uname() !~ "FreeBSD") && (s:uname() !~ "OpenBSD") +endfunction + +function! s:IsRedrawRequiredAfterMake() + return !s:running_windows && (s:uname() =~ "FreeBSD" || s:uname() =~ "OpenBSD") +endfunction + +function! s:uname() + if !exists('s:uname') + let s:uname = system('uname') + endif + return s:uname +endfunction + +"find all syntax checkers matching `&rtp/syntax_checkers/a:ft/*.vim` +function s:FindCheckersForFt(ft) + let checkers = [] + for ft_checker_fname in split(globpath(&runtimepath, "syntax_checkers/" . a:ft . "/*.vim"), '\n') + let checker_name = fnamemodify(ft_checker_fname, ':t:r') + call add(checkers, checker_name) + endfor + + return checkers +endfunction + +"check if a syntax checker exists for the given filetype - and attempt to +"load one +function! SyntasticCheckable(ft) + "users can just define a syntax checking function and it will override the + "syntastic default + if exists("*SyntaxCheckers_". a:ft ."_GetLocList") + return 1 + endif + + if !exists("g:loaded_" . a:ft . "_syntax_checker") + exec "runtime syntax_checkers/" . a:ft . ".vim" + let {"g:loaded_" . a:ft . "_syntax_checker"} = 1 + endif + + return exists("*SyntaxCheckers_". a:ft ."_GetLocList") +endfunction + +"the args must be arrays of the form [major, minor, macro] +function SyntasticIsVersionAtLeast(installed, required) + if a:installed[0] != a:required[0] + return a:installed[0] > a:required[0] + endif + + if a:installed[1] != a:required[1] + return a:installed[1] > a:required[1] + endif + + return a:installed[2] >= a:required[2] +endfunction + "return a string representing the state of buffer according to "g:syntastic_stl_format " @@ -544,7 +615,7 @@ function! SyntasticMake(options) let old_shell = &shell let old_errorformat = &l:errorformat - if !s:running_windows && (s:uname !~ "FreeBSD") + if s:OSSupportsShellpipeHack() "this is a hack to stop the screen needing to be ':redraw'n when "when :lmake is run. Otherwise the screen flickers annoyingly let &shellpipe='&>' @@ -568,7 +639,7 @@ function! SyntasticMake(options) let &shellpipe=old_shellpipe let &shell=old_shell - if !s:running_windows && s:uname =~ "FreeBSD" + if s:IsRedrawRequiredAfterMake() redraw! endif @@ -604,30 +675,36 @@ function! SyntasticAddToErrors(errors, options) return a:errors endfunction -"take a list of syntax checkers for the current filetype and load the right -"one based on the global settings and checker executable availabity +"find all checkers for the given filetype and load the right one based on the +"global settings and checker executable availabity " -"a:checkers should be a list of syntax checker names. These names are assumed -"to be the names of the vim syntax checker files that should be sourced, as -"well as the names of the actual syntax checker executables. The checkers -"should be listed in order of default preference. +"Find all files matching `&rtp/syntax_checkers/a:ft/*.vim`. These files should +"contain syntastic syntax checkers. The file names are also assumed to be the +"names of syntax checker executables. +" +"e.g. ~/.vim/syntax_checkers/python/flake8.vim is a syntax checker for python +"that calls the `flake8` executable. " "a:ft should be the filetype for the checkers being loaded " -"if a option called 'g:syntastic_{a:ft}_checker' exists then attempt to -"load the checker that it points to -function! SyntasticLoadChecker(checkers, ft) +"If a option called 'g:syntastic_{a:ft}_checker' exists then attempt to +"load the checker that it points to. +" +"e.g. let g:syntastic_python_checker="flake8" will tell syntastic to use +"flake8 for python. +function! SyntasticLoadChecker(ft) let opt_name = "g:syntastic_" . a:ft . "_checker" + let checkers = s:FindCheckersForFt(&ft) if exists(opt_name) let opt_val = {opt_name} - if index(a:checkers, opt_val) != -1 && executable(opt_val) + if index(checkers, opt_val) != -1 call s:LoadChecker(opt_val, a:ft) else echoerr &ft . " syntax not supported or not installed." endif else - for checker in a:checkers + for checker in checkers if executable(checker) return s:LoadChecker(checker, a:ft) endif diff --git a/syntax_checkers/ada.vim b/syntax_checkers/ada.vim new file mode 100644 index 00000000..ea78ce12 --- /dev/null +++ b/syntax_checkers/ada.vim @@ -0,0 +1,127 @@ +"============================================================================ +"File: ada.vim +"Description: Syntax checking plugin for syntastic.vim +"Maintainer: Alfredo Di Napoli +"License: This program is free software. It comes without any warranty, +" to the extent permitted by applicable law. +" +"============================================================================ + +" 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_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 +" +" 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' ] +" +" 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' +" +" 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 + +if !executable('gcc') + finish +endif + +let s:save_cpo = &cpo +set cpo&vim + +if !exists('g:syntastic_ada_config_file') + let g:syntastic_ada_config_file = '.syntastic_ada_config' +endif + +function! SyntaxCheckers_ada_GetLocList() + let makeprg = 'gcc -c -fsyntax-only ' + let errorformat = '%-G%f:%s:,%f:%l:%c: %m,%f:%l: %m' + + if exists('g:syntastic_ada_compiler_options') + let makeprg .= g:syntastic_ada_compiler_options + endif + + let makeprg .= ' ' . shellescape(expand('%')) . + \ ' ' . syntastic#c#GetIncludeDirs('ada') + + if expand('%') =~? '\%(.h\|.hpp\|.hh\)$' + if exists('g:syntastic_ada_check_header') + let makeprg = 'g++ -c '.shellescape(expand('%')). + \ ' ' . syntastic#c#GetIncludeDirs('ada') + else + return [] + endif + endif + + if !exists('b:syntastic_ada_cflags') + if !exists('g:syntastic_ada_no_include_search') || + \ g:syntastic_ada_no_include_search != 1 + if exists('g:syntastic_ada_auto_refresh_includes') && + \ g:syntastic_ada_auto_refresh_includes != 0 + let makeprg .= syntastic#c#SearchHeaders() + else + if !exists('b:syntastic_ada_includes') + let b:syntastic_ada_includes = syntastic#c#SearchHeaders() + endif + let makeprg .= b:syntastic_ada_includes + endif + endif + else + 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 +endfunction + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim: set et sts=4 sw=4: diff --git a/syntax_checkers/applescript.vim b/syntax_checkers/applescript.vim index eb7a6f28..1a4dd784 100644 --- a/syntax_checkers/applescript.vim +++ b/syntax_checkers/applescript.vim @@ -25,11 +25,6 @@ " "============================================================================ -if exists("loaded_applescript_syntax_checker") - finish -endif -let loaded_applescript_syntax_checker = 1 - "bail if the user doesnt have osacompile installed if !executable("osacompile") finish diff --git a/syntax_checkers/c.vim b/syntax_checkers/c.vim index a2cedfb5..66352496 100644 --- a/syntax_checkers/c.vim +++ b/syntax_checkers/c.vim @@ -1,7 +1,7 @@ "============================================================================ "File: c.vim "Description: Syntax checking plugin for syntastic.vim -"Maintainer: Gregor Uhlenheuer +"Maintainer: Martin Grenfell "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 @@ -10,138 +10,26 @@ " "============================================================================ -" 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_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 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 - -if exists('loaded_c_syntax_checker') - finish -endif -let loaded_c_syntax_checker = 1 - -if !executable('gcc') - finish +if !exists('g:syntastic_c_checker') + let g:syntastic_c_checker = "gcc" endif -let s:save_cpo = &cpo -set cpo&vim - -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_GetLocList() - let makeprg = 'gcc -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: %m,%f:%l: %trror: %m,%f:%l: %m' - - " 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 = 'gcc -c '.shellescape(expand('%')). - \ ' '.syntastic#c#GetIncludeDirs('c') - else - return [] - endif +if g:syntastic_c_checker == "gcc" || g:syntastic_c_checker == "clang" + if executable(g:syntastic_c_checker) + runtime! syntax_checkers/c/gcc.vim 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 +elseif g:syntastic_c_checker == "checkpatch" + if executable("checkpatch.pl") || executable("./scripts/checkpatch.pl") + runtime! syntax_checkers/c/checkpatch.vim 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 +elseif g:syntastic_c_checker == "checkpatch-kernel-only" + if executable("./scripts/checkpatch.pl") + runtime! syntax_checkers/c/checkpatch.vim + elseif executable("gcc") + runtime! syntax_checkers/c/gcc.vim endif -endfunction - -let &cpo = s:save_cpo -unlet s:save_cpo - -" vim: set et sts=4 sw=4: +elseif g:syntastic_c_checker == "sparse" + if executable("cgcc") + runtime! syntax_checkers/c/sparse.vim + endif +endif diff --git a/syntax_checkers/c/checkpatch.vim b/syntax_checkers/c/checkpatch.vim new file mode 100644 index 00000000..8d9f9bac --- /dev/null +++ b/syntax_checkers/c/checkpatch.vim @@ -0,0 +1,35 @@ +"============================================================================ +"File: checkpatch.vim +"Description: Syntax checking plugin for syntastic.vim using checkpatch.pl +"Maintainer: Daniel Walker +"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_checkpatch_syntax_checker") + finish +endif +let loaded_checkpatch_syntax_checker = 1 + +" Bail if the user doesn't have `checkpatch.pl` or ./scripts/checkpatch.pl installed. +if executable("checkpatch.pl") + let g:syntastic_c_checker_checkpatch_location = 'checkpatch.pl' +elseif executable("./scripts/checkpatch.pl") + let g:syntastic_c_checker_checkpatch_location = './scripts/checkpatch.pl' +else + finish +endif + +function! SyntaxCheckers_c_GetLocList() + let makeprg = g:syntastic_c_checker_checkpatch_location + let makeprg .= " --no-summary --no-tree --terse --file ".shellescape(expand('%')) + + let errorformat = '%f:%l: %tARNING: %m,%f:%l: %tRROR: %m' + + let loclist = SyntasticMake({ 'makeprg': makeprg, + \ 'errorformat': errorformat, + \ 'defaults': {'bufnr': bufnr("")} }) + return loclist +endfunction diff --git a/syntax_checkers/c/gcc.vim b/syntax_checkers/c/gcc.vim new file mode 100644 index 00000000..a481e46f --- /dev/null +++ b/syntax_checkers/c/gcc.vim @@ -0,0 +1,165 @@ +"============================================================================ +"File: c.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. +" +"============================================================================ + +" 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' + +if exists('loaded_gcc_syntax_checker') + finish +endif +let loaded_gcc_syntax_checker = 1 + +if !executable(g:syntastic_c_checker) + finish +endif + +let s:save_cpo = &cpo +set cpo&vim + +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_GetLocList() + let makeprg = g:syntastic_c_checker . ' -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_checker + \ ' -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 +endfunction + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim: set et sts=4 sw=4: diff --git a/syntax_checkers/c/sparse.vim b/syntax_checkers/c/sparse.vim new file mode 100644 index 00000000..d0e95309 --- /dev/null +++ b/syntax_checkers/c/sparse.vim @@ -0,0 +1,34 @@ +"============================================================================ +"File: sparse.vim +"Description: Syntax checking plugin for syntastic.vim using sparse.pl +"Maintainer: Daniel Walker +"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_sparse_syntax_checker") + finish +endif +let loaded_sparse_syntax_checker = 1 + +" Bail if the user doesn't have `sparse.pl` or ./scripts/checkpatch.pl installed. +if !executable("sparse") + finish +endif + +function! SyntaxCheckers_c_GetLocList() + let makeprg = "sparse " + + let makeprg .= ' '.syntastic#c#ReadConfig(g:syntastic_sparse_config_file).' ' + + let makeprg .= shellescape(expand('%')) + + let errorformat = '%f:%l:%c: %trror: %m,%f:%l:%c: %tarning: %m,' + + let loclist = SyntasticMake({ 'makeprg': makeprg, + \ 'errorformat': errorformat, + \ 'defaults': {'bufnr': bufnr("")} }) + return loclist +endfunction diff --git a/syntax_checkers/co.vim b/syntax_checkers/co.vim new file mode 100644 index 00000000..9d0dc27d --- /dev/null +++ b/syntax_checkers/co.vim @@ -0,0 +1,23 @@ +"============================================================================ +"File: co.vim +"Description: Syntax checking plugin for syntastic.vim +"Maintainer: Andrew Kelley +"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. +" +"============================================================================ + +"bail if the user doesnt have coco installed +if !executable("coco") + finish +endif + +function! SyntaxCheckers_co_GetLocList() + let makeprg = 'coco -c -o /tmp '.shellescape(expand('%')) + let errorformat = '%EFailed at: %f,%ZSyntax%trror: %m on line %l,%EFailed at: %f,%Z%trror: Parse error on line %l: %m' + + return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat }) +endfunction diff --git a/syntax_checkers/coffee.vim b/syntax_checkers/coffee.vim index 59dca752..a5f011e6 100644 --- a/syntax_checkers/coffee.vim +++ b/syntax_checkers/coffee.vim @@ -9,19 +9,37 @@ " See http://sam.zoy.org/wtfpl/COPYING for more details. " "============================================================================ -if exists("loaded_coffee_syntax_checker") - finish -endif -let loaded_coffee_syntax_checker = 1 "bail if the user doesnt have coffee installed if !executable("coffee") finish endif +if !exists('g:syntastic_coffee_lint_options') + let g:syntastic_coffee_lint_options = "" +endif + + function! SyntaxCheckers_coffee_GetLocList() let makeprg = 'coffee -c -l -o /tmp '.shellescape(expand('%')) let errorformat = 'Syntax%trror: In %f\, %m on line %l,%EError: In %f\, Parse error on line %l: %m,%EError: In %f\, %m on line %l,%W%f(%l): lint warning: %m,%-Z%p^,%W%f(%l): warning: %m,%-Z%p^,%E%f(%l): SyntaxError: %m,%-Z%p^,%-G%.%#' - return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat }) + let coffee_results = SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat }) + + if !empty(coffee_results) + return coffee_results + endif + + if executable("coffeelint") + return s:GetCoffeeLintErrors() + endif + + return [] +endfunction + +function s:GetCoffeeLintErrors() + let coffeelint = 'coffeelint --csv '.g:syntastic_coffee_lint_options.' '.shellescape(expand('%')) + let lint_results = SyntasticMake({ 'makeprg': coffeelint, 'errorformat': '%f\,%l\,%trror\,%m', 'subtype': 'Style' }) + + return lint_results endfunction diff --git a/syntax_checkers/cpp.vim b/syntax_checkers/cpp.vim index 16bebde3..7be44e37 100644 --- a/syntax_checkers/cpp.vim +++ b/syntax_checkers/cpp.vim @@ -11,7 +11,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_cpp_check_header = 1 " @@ -20,6 +19,11 @@ " " 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 +" " 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: @@ -58,13 +62,25 @@ " 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('loaded_cpp_syntax_checker') - finish +if !exists('g:syntastic_cpp_compiler') + let g:syntastic_cpp_compiler = 'g++' endif -let loaded_cpp_syntax_checker = 1 -if !executable('g++') +if !exists('g:syntastic_cpp_compiler_options') + let g:syntastic_cpp_compiler_options = '' +endif + +if !executable(g:syntastic_cpp_compiler) finish endif @@ -76,11 +92,14 @@ if !exists('g:syntastic_cpp_config_file') endif function! SyntaxCheckers_cpp_GetLocList() - let makeprg = 'g++ -fsyntax-only ' - let errorformat = '%-G%f:%s:,%f:%l:%c: %m,%f:%l: %m' + let makeprg = g:syntastic_cpp_compiler . ' -x c++ -fsyntax-only ' . + \ g:syntastic_cpp_compiler_options + 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_compiler_options') - let makeprg .= g:syntastic_cpp_compiler_options + if exists('g:syntastic_cpp_errorformat') + let errorformat = g:syntastic_cpp_errorformat endif let makeprg .= ' ' . shellescape(expand('%')) . @@ -88,7 +107,9 @@ function! SyntaxCheckers_cpp_GetLocList() if expand('%') =~? '\%(.h\|.hpp\|.hh\)$' if exists('g:syntastic_cpp_check_header') - let makeprg = 'g++ -c '.shellescape(expand('%')). + let makeprg = g:syntastic_cpp_compiler.' -c '.shellescape(expand('%')) . + \ ' ' . g:syntastic_cpp_compiler_options . + \ ' ' . syntastic#c#GetNullDevice() . \ ' ' . syntastic#c#GetIncludeDirs('cpp') else return [] diff --git a/syntax_checkers/cs.vim b/syntax_checkers/cs.vim new file mode 100644 index 00000000..46e1e8ca --- /dev/null +++ b/syntax_checkers/cs.vim @@ -0,0 +1,25 @@ +"============================================================================ +"File: cs.vim +"Description: Syntax checking plugin for syntastic.vim +"Maintainer: Daniel Walker +"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 !executable('mcs') + finish +endif + +function! SyntaxCheckers_cs_GetLocList() + let makeprg = "mcs --parse ".shellescape(expand('%')) + let errorformat = '%f(%l\,%c): %trror %m' + let loclist = SyntasticMake({ 'makeprg': makeprg, + \ 'errorformat': errorformat, + \ 'defaults': {'bufnr': bufnr("")} }) + return loclist +endfunction + diff --git a/syntax_checkers/css.vim b/syntax_checkers/css.vim index 99a16b86..f5d4190a 100644 --- a/syntax_checkers/css.vim +++ b/syntax_checkers/css.vim @@ -8,10 +8,15 @@ " Want To Public License, Version 2, as published by Sam Hocevar. " See http://sam.zoy.org/wtfpl/COPYING for more details. "============================================================================ -if exists("loaded_css_syntax_checker") - finish +" +" Specify additional options to csslint with this option. e.g. to disable +" warnings: +" +" let g:syntastic_csslint_options = "--warnings=none" + +if !exists('g:syntastic_csslint_options') + let g:syntastic_csslint_options = "" endif -let loaded_css_syntax_checker = 1 " Bail if the user doesn't have `csslint` installed. if !executable("csslint") @@ -19,7 +24,8 @@ if !executable("csslint") endif function! SyntaxCheckers_css_GetLocList() - let makeprg = 'csslint --format=compact '.shellescape(expand('%')) + let makeprg = 'csslint --format=compact '.g:syntastic_csslint_options.' '. + \ shellescape(expand('%')) " Print CSS Lint's error/warning messages from compact format. Ignores blank lines. let errorformat = '%-G,%-G%f: lint free!,%f: line %l\, col %c\, %trror - %m,%f: line %l\, col %c\, %tarning - %m,%f: line %l\, col %c\, %m,' diff --git a/syntax_checkers/cucumber.vim b/syntax_checkers/cucumber.vim index c9a87e15..39f57d29 100644 --- a/syntax_checkers/cucumber.vim +++ b/syntax_checkers/cucumber.vim @@ -9,10 +9,6 @@ " See http://sam.zoy.org/wtfpl/COPYING for more details. " "============================================================================ -if exists("loaded_cucumber_syntax_checker") - finish -endif -let loaded_cucumber_syntax_checker = 1 "bail if the user doesnt have cucumber installed if !executable("cucumber") diff --git a/syntax_checkers/cuda.vim b/syntax_checkers/cuda.vim index 816505eb..3712f1cd 100644 --- a/syntax_checkers/cuda.vim +++ b/syntax_checkers/cuda.vim @@ -11,23 +11,30 @@ " " let g:syntastic_cuda_check_header = 1 -if exists('loaded_cuda_syntax_checker') - finish -endif -let loaded_cuda_syntax_checker = 1 +" By default, nvcc and thus syntastic, defaults to the most basic architecture. +" This can produce false errors if the developer intends to compile for newer +" hardware and use newer features, eg. double precision numbers. To pass a +" specific target arch to nvcc, e.g. add the following to your .vimrc: +" +" let g:syntastic_cuda_arch = "sm_20" if !executable('nvcc') finish endif function! SyntaxCheckers_cuda_GetLocList() - let makeprg = 'nvcc --cuda -O0 -I . -Xcompiler -fsyntax-only '.shellescape(expand('%')).' -o /dev/null' + if exists('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 errorformat = '%-G%f:%s:,%f:%l:%c: %m,%f:%l: %m' let errorformat = '%*[^"]"%f"%*\D%l: %m,"%f"%*\D%l: %m,%-G%f:%l: (Each undeclared identifier is reported only once,%-G%f:%l: for each function it appears in.),%f:%l:%c:%m,%f(%l):%m,%f:%l:%m,"%f"\, line %l%*\D%c%*[^ ] %m,%D%*\a[%*\d]: Entering directory `%f'',%X%*\a[%*\d]: Leaving directory `%f'',%D%*\a: Entering directory `%f'',%X%*\a: Leaving directory `%f'',%DMaking %*\a in %f,%f|%l| %m' if expand('%') =~? '\%(.h\|.hpp\|.cuh\)$' if exists('g:syntastic_cuda_check_header') - let makeprg = 'echo > .syntastic_dummy.cu ; nvcc --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('%')).' -o /dev/null' else return [] endif diff --git a/syntax_checkers/d.vim b/syntax_checkers/d.vim new file mode 100644 index 00000000..5212115d --- /dev/null +++ b/syntax_checkers/d.vim @@ -0,0 +1,135 @@ +"============================================================================ +"File: d.vim +"Description: Syntax checking plugin for syntastic.vim +"Maintainer: Alfredo Di Napoli +"License: Based on the original work of Gregor Uhlenheuer and his +" cpp.vim checker so credits are dued. +" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +" EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +" OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +" NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +" HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +" WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +" FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +" OTHER DEALINGS IN THE SOFTWARE. +" +"============================================================================ + +" 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_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 +" +" 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_d_include_dirs. This list can be used like this: +" +" let g:syntastic_d_include_dirs = [ 'includes', 'headers' ] +" +" 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' +" +" 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 + +if !executable('dmd') + finish +endif + +let s:save_cpo = &cpo +set cpo&vim + +if !exists('g:syntastic_d_config_file') + let g:syntastic_d_config_file = '.syntastic_d_config' +endif + +function! SyntaxCheckers_d_GetLocList() + let makeprg = 'dmd -of/dev/null -c ' + let errorformat = '%-G%f:%s:,%f(%l): %m,%f:%l: %m' + + if exists('g:syntastic_d_compiler_options') + let makeprg .= g:syntastic_d_compiler_options + endif + + let makeprg .= ' ' . shellescape(expand('%')) . + \ ' ' . syntastic#c#GetIncludeDirs('d') + + if expand('%') =~? '\%(.di\)$' + if exists('g:syntastic_d_check_header') + let makeprg = 'dmd -c '.shellescape(expand('%')). + \ ' ' . syntastic#c#GetIncludeDirs('d') + else + return [] + endif + endif + + if !exists('b:syntastic_d_cflags') + if !exists('g:syntastic_d_no_include_search') || + \ g:syntastic_d_no_include_search != 1 + if exists('g:syntastic_d_auto_refresh_includes') && + \ g:syntastic_d_auto_refresh_includes != 0 + let makeprg .= syntastic#c#SearchHeaders() + else + if !exists('b:syntastic_d_includes') + let b:syntastic_d_includes = syntastic#c#SearchHeaders() + endif + let makeprg .= b:syntastic_d_includes + endif + endif + else + 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 +endfunction + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim: set et sts=4 sw=4: diff --git a/syntax_checkers/docbk.vim b/syntax_checkers/docbk.vim index cd360e4a..b0a9f919 100644 --- a/syntax_checkers/docbk.vim +++ b/syntax_checkers/docbk.vim @@ -9,10 +9,6 @@ " See http://sam.zoy.org/wtfpl/COPYING for more details. " "============================================================================ -if exists("loaded_docbk_syntax_checker") - finish -endif -let loaded_docbk_syntax_checker = 1 "bail if the user doesnt have tidy or grep installed if !executable("xmllint") @@ -21,7 +17,7 @@ endif function! SyntaxCheckers_docbk_GetLocList() - let makeprg="xmllint --xinclude --noout --postvalid ".shellescape(expand(%:p)) + let makeprg="xmllint --xinclude --noout --postvalid ".shellescape(expand("%:p")) let errorformat='%E%f:%l: parser error : %m,%W%f:%l: parser warning : %m,%E%f:%l:%.%# validity error : %m,%W%f:%l:%.%# validity warning : %m,%-Z%p^,%-C%.%#,%-G%.%#' let loclist = SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat }) diff --git a/syntax_checkers/efm_perl.pl b/syntax_checkers/efm_perl.pl index 570d6e76..a224f40f 100644 --- a/syntax_checkers/efm_perl.pl +++ b/syntax_checkers/efm_perl.pl @@ -1,9 +1,9 @@ -#!/usr/bin/perl -w - +#!/usr/bin/perl # vimparse.pl - Reformats the error messages of the Perl interpreter for use # with the quickfix mode of Vim # -# Copyright (©) 2001 by Jörg Ziefle +# Copyright (c) 2001 by Jörg Ziefle +# Copyright (c) 2012 Eric Harmon # You may use and distribute this software under the same terms as Perl itself. # # Usage: put one of the two configurations below in your ~/.vimrc (without the @@ -13,25 +13,27 @@ # Program is run interactively with 'perl -w': # # set makeprg=$HOME/bin/vimparse.pl\ %\ $* -# set errorformat=%f:%l:%m +# set errorformat=%t:%f:%l:%m # # Program is only compiled with 'perl -wc': # # set makeprg=$HOME/bin/vimparse.pl\ -c\ %\ $* -# set errorformat=%f:%l:%m +# set errorformat=%t:%f:%l:%m # # Usage: -# vimparse.pl [-c] [-f ] [programargs] +# vimparse.pl [-c] [-w] [-f ] [programargs] # # -c compile only, don't run (perl -wc) +# -w output warnings as warnings instead of errors (slightly slower) # -f write errors to # # Example usages: # * From the command line: # vimparse.pl program.pl # -# vimparse.pl -c -f errorfile program.pl +# vimparse.pl -c -w -f errorfile program.pl # Then run vim -q errorfile to edit the errors with Vim. +# This uses the custom errorformat: %t:%f:%l:%m. # # * From Vim: # Edit in Vim (and save, if you don't have autowrite on), then @@ -39,6 +41,9 @@ # to error check. # # Version history: +# 0.3 (05/31/2012): +# * Added support for the seperate display of warnings +# * Switched output format to %t:%f:%l:%m to support error levels # 0.2 (04/12/2001): # * First public version (sent to Bram) # * -c command line option for compiling only @@ -60,15 +65,15 @@ # # Tested under SunOS 5.7 with Perl 5.6.0. Let me know if it's not working for # you. - +use warnings; use strict; use Getopt::Std; -use vars qw/$opt_c $opt_f $opt_h/; # needed for Getopt in combination with use strict 'vars' +use vars qw/$opt_I $opt_c $opt_w $opt_f $opt_h/; # needed for Getopt in combination with use strict 'vars' use constant VERSION => 0.2; -getopts('cf:h'); +getopts('cwf:hI:'); &usage if $opt_h; # not necessarily needed, but good for further extension @@ -86,20 +91,34 @@ my $handle = (defined $opt_f ? \*FILE : \*STDOUT); (my $file = shift) or &usage; # display usage if no filename is supplied my $args = (@ARGV ? ' ' . join ' ', @ARGV : ''); -my @lines = `perl @{[defined $opt_c ? '-c ' : '' ]} -w "$file$args" 2>&1`; +my $libs = join ' ', map {"-I$_"} split ',', $opt_I; +my @error_lines = `perl $libs @{[defined $opt_c ? '-c ' : '' ]} @{[defined $opt_w ? '-X ' : '-Mwarnings ']} "$file$args" 2>&1`; + +my @lines = map { "E:$_" } @error_lines; + +my @warn_lines; +if(defined($opt_w)) { + @warn_lines = `perl $libs @{[defined $opt_c ? '-c ' : '' ]} -Mwarnings "$file$args" 2>&1`; +} + +# Any new errors must be warnings +foreach my $line (@warn_lines) { + if(!grep { $_ eq $line } @error_lines) { + push(@lines, "W:$line"); + } +} my $errors = 0; foreach my $line (@lines) { chomp($line); - my ($file, $lineno, $message, $rest); + my ($file, $lineno, $message, $rest, $severity); - if ($line =~ /^(.*)\sat\s(.*)\sline\s(\d+)(\.|,\snear\s\".*\")$/) { - - ($message, $file, $lineno, $rest) = ($1, $2, $3, $4); + if ($line =~ /^([EW]):(.*)\sat\s(.*)\sline\s(\d+)(.*)$/) { + ($severity, $message, $file, $lineno, $rest) = ($1, $2, $3, $4, $5); $errors++; $message .= $rest if ($rest =~ s/^,//); - print $handle "$file:$lineno:$message\n"; + print $handle "$severity:$file:$lineno:$message\n"; } else { next }; @@ -129,18 +148,21 @@ sub usage { (local $0 = $0) =~ s/^.*\/([^\/]+)$/$1/; # remove path from name of program print<] [programargs] + $0 [-c] [-w] [-f ] [programargs] - -c compile only, don't run (executes 'perl -wc') + -c compile only, don't run (executes 'perl -c') + -w output warnings as warnings instead of errors (slightly slower) -f write errors to + -I specify \@INC/#include directory Examples: * At the command line: $0 program.pl Displays output on STDOUT. - $0 -c -f errorfile program.pl + $0 -c -w -f errorfile program.pl Then run 'vim -q errorfile' to edit the errors with Vim. + This uses the custom errorformat: %t:%f:%l:%m. * In Vim: Edit in Vim (and save, if you don't have autowrite on), then diff --git a/syntax_checkers/elixir.vim b/syntax_checkers/elixir.vim new file mode 100644 index 00000000..3cfeafcf --- /dev/null +++ b/syntax_checkers/elixir.vim @@ -0,0 +1,26 @@ +"============================================================================ +"File: elixir.vim +"Description: Syntax checking plugin for syntastic.vim +"Maintainer: Richard Ramsden +"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 !executable('elixir') + finish +endif + +function! SyntaxCheckers_elixir_GetLocList() + let makeprg = 'elixir ' . shellescape(expand('%')) + let errorformat = '** %*[^\ ] %f:%l: %m' + + let elixir_results = SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat }) + + if !empty(elixir_results) + return elixir_results + endif +endfunction diff --git a/syntax_checkers/erlang.vim b/syntax_checkers/erlang.vim index d7dceaef..2951388c 100644 --- a/syntax_checkers/erlang.vim +++ b/syntax_checkers/erlang.vim @@ -9,10 +9,6 @@ " See http://sam.zoy.org/wtfpl/COPYING for more details. " "============================================================================ -if exists("loaded_erlang_syntax_checker") - finish -endif -let loaded_erlang_syntax_checker = 1 "bail if the user doesnt have escript installed if !executable("escript") @@ -20,6 +16,10 @@ if !executable("escript") endif let s:check_file = expand(':p:h') . '/erlang_check_file.erl' +if !exists("g:syntastic_erlc_include_path") + let g:syntastic_erlc_include_path="" +endif + function! SyntaxCheckers_erlang_GetLocList() let extension = expand('%:e') @@ -31,10 +31,10 @@ function! SyntaxCheckers_erlang_GetLocList() if match(shebang, 'escript') >= 0 let makeprg = 'escript -s '.shellescape(expand('%:p')) else - let makeprg = s:check_file . ' '. shellescape(expand('%:p')) + let makeprg = s:check_file . ' '. shellescape(expand('%:p')).' '.g:syntastic_erlc_include_path endif else - let makeprg = s:check_file . ' ' . shellescape(expand('%:p')) + let makeprg = s:check_file . ' ' . shellescape(expand('%:p')).' '.g:syntastic_erlc_include_path endif let errorformat = '%f:%l:\ %tarning:\ %m,%E%f:%l:\ %m' diff --git a/syntax_checkers/erlang_check_file.erl b/syntax_checkers/erlang_check_file.erl index 8a85bf61..f4da8f93 100755 --- a/syntax_checkers/erlang_check_file.erl +++ b/syntax_checkers/erlang_check_file.erl @@ -1,6 +1,10 @@ #!/usr/bin/env escript -export([main/1]). +main([FileName| LibDirs=[_|_]]) -> + code:add_pathsa(LibDirs), + main([FileName]); + main([FileName]) -> compile:file(FileName, [warn_obsolete_guard, warn_unused_import, @@ -8,5 +12,7 @@ main([FileName]) -> warn_export_vars, strong_validation, report, - {i, filename:dirname(FileName) ++ "/../include"} + {i, filename:dirname(FileName) ++ "/../include"}, + {i, filename:dirname(FileName) ++ "/../deps"}, + {i, filename:dirname(FileName) ++ "/../../../deps"} ]). diff --git a/syntax_checkers/eruby.vim b/syntax_checkers/eruby.vim index 52cec3a3..ecc71952 100644 --- a/syntax_checkers/eruby.vim +++ b/syntax_checkers/eruby.vim @@ -9,26 +9,28 @@ " See http://sam.zoy.org/wtfpl/COPYING for more details. " "============================================================================ -if exists("loaded_eruby_syntax_checker") - finish -endif -let loaded_eruby_syntax_checker = 1 -"bail if the user doesnt have ruby or cat installed -if !executable("ruby") || !executable("cat") +if !exists("g:syntastic_ruby_exec") + let g:syntastic_ruby_exec = "ruby" +endif + +"bail if the user doesnt have ruby installed +if !executable(expand(g:syntastic_ruby_exec)) finish endif function! SyntaxCheckers_eruby_GetLocList() - if has('win32') - let makeprg='sed "s/<\%=/<\%/g" '. shellescape(expand("%")) . ' \| ruby -e "require \"erb\"; puts ERB.new(ARGF.read, nil, \"-\").src" \| ruby -c' - else - let makeprg='sed "s/<\%=/<\%/g" '. shellescape(expand("%")) . ' \| RUBYOPT= ruby -e "require \"erb\"; puts ERB.new(ARGF.read, nil, \"-\").src" \| RUBYOPT= ruby -c' + let ruby_exec=expand(g:syntastic_ruby_exec) + if !has('win32') + let ruby_exec='RUBYOPT= ' . ruby_exec endif - let errorformat='%-GSyntax OK,%E-:%l: syntax error\, %m,%Z%p^,%W-:%l: warning: %m,%Z%p^,%-C%.%#' - return SyntasticMake({ 'makeprg': makeprg, - \ 'errorformat': errorformat, - \ 'defaults': {'bufnr': bufnr("")} }) + "gsub fixes issue #7 rails has it's own eruby syntax + let makeprg=ruby_exec . ' -rerb -e "puts ERB.new(File.read(''' . + \ (expand("%")) . + \ ''').gsub(''<\%='',''<\%''), nil, ''-'').src" \| ' . ruby_exec . ' -c' + let errorformat='%-GSyntax OK,%E-:%l: syntax error\, %m,%Z%p^,%W-:%l: warning: %m,%Z%p^,%-C%.%#' + + return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat}) endfunction diff --git a/syntax_checkers/fortran.vim b/syntax_checkers/fortran.vim index ee176f26..ff17c2ac 100644 --- a/syntax_checkers/fortran.vim +++ b/syntax_checkers/fortran.vim @@ -18,11 +18,6 @@ " "============================================================================ -if exists("loaded_fortran_syntax_checker") - finish -endif -let loaded_fortran_syntax_checker = 1 - "bail if the user doesnt have fortran installed if !executable("gfortran") finish diff --git a/syntax_checkers/gentoo_metadata.vim b/syntax_checkers/gentoo_metadata.vim index d016a887..0626714f 100644 --- a/syntax_checkers/gentoo_metadata.vim +++ b/syntax_checkers/gentoo_metadata.vim @@ -20,11 +20,6 @@ " See xmlcatalog(1) and http://www.xmlsoft.org/catalog.html for more " information. -if exists("loaded_gentoo_metadata_syntax_checker") - finish -endif -let loaded_gentoo_metadata_syntax_checker = 1 - "bail if the user doesn't have xmllint installed if !executable("xmllint") finish diff --git a/syntax_checkers/go.vim b/syntax_checkers/go.vim index b48d07d5..712b656d 100644 --- a/syntax_checkers/go.vim +++ b/syntax_checkers/go.vim @@ -13,10 +13,5 @@ " If g:syntastic_go_checker is not set, just use the first syntax " checker that we find installed. "============================================================================ -if exists("loaded_go_syntax_checker") - finish -endif -let loaded_go_syntax_checker = 1 -let s:supported_checkers = ["go", "6g", "gofmt"] -call SyntasticLoadChecker(s:supported_checkers, 'go') +call SyntasticLoadChecker('go') diff --git a/syntax_checkers/go/go.vim b/syntax_checkers/go/go.vim index 8b3dd5ca..ddb32a93 100644 --- a/syntax_checkers/go/go.vim +++ b/syntax_checkers/go/go.vim @@ -1,6 +1,6 @@ "============================================================================ "File: go.vim -"Description: Check go syntax using 'go build' +"Description: Check go syntax using 'gofmt -l' followed by 'go [build|test]' "Maintainer: Kamil Kisiel "License: This program is free software. It comes without any warranty, " to the extent permitted by applicable law. You can redistribute @@ -8,10 +8,44 @@ " Want To Public License, Version 2, as published by Sam Hocevar. " See http://sam.zoy.org/wtfpl/COPYING for more details. " +" This syntax checker does not reformat your source code. +" Use a BufWritePre autocommand to that end: +" autocmd FileType go autocmd BufWritePre Fmt "============================================================================ function! SyntaxCheckers_go_GetLocList() - let makeprg = 'go build -o /dev/null' + " 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'} }) + + if !empty(errors) + return errors + endif + + " 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' + else + let makeprg = 'go test -c -o /dev/null' + endif let errorformat = '%f:%l:%c:%m,%f:%l%m,%-G#%.%#' - return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat }) + " 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 }) + + " popd + exec 'lcd ' . fnameescape(popd) + + return errors endfunction diff --git a/syntax_checkers/go/gofmt.vim b/syntax_checkers/go/gofmt.vim index 77abe7e8..982beaa9 100644 --- a/syntax_checkers/go/gofmt.vim +++ b/syntax_checkers/go/gofmt.vim @@ -1,6 +1,6 @@ "============================================================================ "File: gofmt.vim -"Description: Check go syntax using gofmt +"Description: Check go syntax using 'gofmt -l' "Maintainer: Brandon Thomson "License: This program is free software. It comes without any warranty, " to the extent permitted by applicable law. You can redistribute @@ -8,9 +8,12 @@ " Want To Public License, Version 2, as published by Sam Hocevar. " See http://sam.zoy.org/wtfpl/COPYING for more details. " +" This syntax checker does not reformat your source code. +" Use a BufWritePre autocommand to that end: +" autocmd FileType go autocmd BufWritePre Fmt "============================================================================ function! SyntaxCheckers_go_GetLocList() - let makeprg = 'gofmt %' + let makeprg = 'gofmt -l % 1>/dev/null' let errorformat = '%f:%l:%c: %m,%-G%.%#' return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat, 'defaults': {'type': 'e'} }) endfunction diff --git a/syntax_checkers/haml.vim b/syntax_checkers/haml.vim index b9ad6ad1..d4d2e88e 100644 --- a/syntax_checkers/haml.vim +++ b/syntax_checkers/haml.vim @@ -9,10 +9,6 @@ " See http://sam.zoy.org/wtfpl/COPYING for more details. " "============================================================================ -if exists("loaded_haml_syntax_checker") - finish -endif -let loaded_haml_syntax_checker = 1 "bail if the user doesnt have the haml binary installed if !executable("haml") diff --git a/syntax_checkers/haskell.vim b/syntax_checkers/haskell.vim index 45e97dbb..3f029795 100644 --- a/syntax_checkers/haskell.vim +++ b/syntax_checkers/haskell.vim @@ -9,34 +9,19 @@ " See http://sam.zoy.org/wtfpl/COPYING for more details. " "============================================================================ -if exists("loaded_haskell_syntax_checker") - finish + +if !exists('g:syntastic_haskell_checker') + if executable('hdevtools') + runtime! syntax_checkers/haskell/hdevtools.vim + elseif executable('ghc-mod') + runtime! syntax_checkers/haskell/ghc-mod.vim + endif +elseif g:syntastic_haskell_checker == 'hdevtools' + if executable('hdevtools') + runtime! syntax_checkers/haskell/hdevtools.vim + endif +elseif g:syntastic_haskell_checker == 'ghc-mod' + if executable('ghc-mod') + runtime! syntax_checkers/haskell/ghc-mod.vim + endif endif -let loaded_haskell_syntax_checker = 1 - -"bail if the user doesnt have ghc-mod installed -if !executable("ghc-mod") - finish -endif - -if !exists('g:syntastic_haskell_checker_args') - let g:syntastic_haskell_checker_args = '--hlintOpt="--language=XmlSyntax"' -endif - -function! SyntaxCheckers_haskell_GetLocList() - let ghcmod = 'ghc-mod ' . g:syntastic_haskell_checker_args - let makeprg = - \ "{ ". - \ ghcmod . " check ". shellescape(expand('%')) . "; " . - \ ghcmod . " lint " . shellescape(expand('%')) . ";" . - \ " }" - let errorformat = '%-G\\s%#,%f:%l:%c:%trror: %m,%f:%l:%c:%tarning: %m,'. - \ '%f:%l:%c: %trror: %m,%f:%l:%c: %tarning: %m,%f:%l:%c:%m,'. - \ '%E%f:%l:%c:,%Z%m,' - - return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat }) -endfunction - -function! SyntaxCheckers_lhaskell_GetLocList() - return SyntaxCheckers_haskell_GetLocList() -endfunction diff --git a/syntax_checkers/haskell/ghc-mod.vim b/syntax_checkers/haskell/ghc-mod.vim new file mode 100644 index 00000000..9b06ae65 --- /dev/null +++ b/syntax_checkers/haskell/ghc-mod.vim @@ -0,0 +1,33 @@ +"============================================================================ +"File: ghc-mod.vim +"Description: Syntax checking plugin for syntastic.vim +"Maintainer: Anthony Carapetis +"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:syntastic_haskell_checker_args') + let g:syntastic_haskell_checker_args = '--ghcOpt="-fno-code" --hlintOpt="--language=XmlSyntax"' +endif + +function! SyntaxCheckers_haskell_GetLocList() + let ghcmod = 'ghc-mod ' . g:syntastic_haskell_checker_args + let makeprg = + \ "{ ". + \ ghcmod . " check ". shellescape(expand('%')) . "; " . + \ ghcmod . " lint " . shellescape(expand('%')) . ";" . + \ " }" + let errorformat = '%-G\\s%#,%f:%l:%c:%trror: %m,%f:%l:%c:%tarning: %m,'. + \ '%f:%l:%c: %trror: %m,%f:%l:%c: %tarning: %m,%f:%l:%c:%m,'. + \ '%E%f:%l:%c:,%Z%m,' + + return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat }) +endfunction + +function! SyntaxCheckers_lhaskell_GetLocList() + return SyntaxCheckers_haskell_GetLocList() +endfunction diff --git a/syntax_checkers/haskell/hdevtools.vim b/syntax_checkers/haskell/hdevtools.vim new file mode 100644 index 00000000..31fb95cd --- /dev/null +++ b/syntax_checkers/haskell/hdevtools.vim @@ -0,0 +1,30 @@ +"============================================================================ +"File: hdevtools.vim +"Description: Syntax checking plugin for syntastic.vim +"Maintainer: Anthony Carapetis +"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. +" +"============================================================================ + +function! SyntaxCheckers_haskell_GetLocList() + let makeprg = 'hdevtools check ' . get(g:, 'hdevtools_options', '') . + \ ' ' . shellescape(expand('%')) + + let errorformat= '\%-Z\ %#,'. + \ '%W%f:%l:%c:\ Warning:\ %m,'. + \ '%E%f:%l:%c:\ %m,'. + \ '%E%>%f:%l:%c:,'. + \ '%+C\ \ %#%m,'. + \ '%W%>%f:%l:%c:,'. + \ '%+C\ \ %#%tarning:\ %m,' + + return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat }) +endfunction + +function! SyntaxCheckers_lhaskell_GetLocList() + return SyntaxCheckers_haskell_GetLocList() +endfunction diff --git a/syntax_checkers/haxe.vim b/syntax_checkers/haxe.vim index 22183ee5..2bddbd72 100644 --- a/syntax_checkers/haxe.vim +++ b/syntax_checkers/haxe.vim @@ -9,10 +9,6 @@ " See http://sam.zoy.org/wtfpl/COPYING for more details. " "============================================================================ -if exists("loaded_haxe_syntax_checker") - finish -endif -let loaded_haxe_syntax_checker = 1 "bail if the user doesn't have haxe installed if !executable("haxe") diff --git a/syntax_checkers/html.vim b/syntax_checkers/html.vim index 4aace247..a6a09014 100644 --- a/syntax_checkers/html.vim +++ b/syntax_checkers/html.vim @@ -9,10 +9,6 @@ " See http://sam.zoy.org/wtfpl/COPYING for more details. " "============================================================================ -if exists("loaded_html_syntax_checker") - finish -endif -let loaded_html_syntax_checker = 1 if !exists('g:syntastic_html_checker') let g:syntastic_html_checker = "tidy" diff --git a/syntax_checkers/html/tidy.vim b/syntax_checkers/html/tidy.vim index 5e52f80d..f48fae78 100644 --- a/syntax_checkers/html/tidy.vim +++ b/syntax_checkers/html/tidy.vim @@ -50,7 +50,7 @@ endfunction function! SyntaxCheckers_html_GetLocList() let encopt = s:TidyEncOptByFenc() - let makeprg="tidy ".encopt." --new-blocklevel-tags ".shellescape('section, article, aside, hgroup, header, footer, nav, figure, figcaption')." --new-inline-tags ".shellescape('video, audio, embed, mark, progress, meter, time, ruby, rt, rp, canvas, command, details, datalist')." --new-empty-tags ".shellescape('wbr, keygen')." -e ".shellescape(expand('%'))." 2>&1" + let makeprg="tidy ".encopt." --new-blocklevel-tags ".shellescape('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')." -e ".shellescape(expand('%'))." 2>&1" let errorformat='%Wline %l column %c - Warning: %m,%Eline %l column %c - Error: %m,%-G%.%#,%-G%.%#' let loclist = SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat }) diff --git a/syntax_checkers/java.vim b/syntax_checkers/java.vim index 8d9b247c..7208ac26 100644 --- a/syntax_checkers/java.vim +++ b/syntax_checkers/java.vim @@ -1,28 +1,18 @@ "============================================================================ "File: java.vim -"Description: Syntax checking plugin for syntastic.vim -"Maintainer: Jochen Keil +"Description: Figures out which java syntax checker (if any) to load +" from the java directory. +"Maintainer: Dmitry Geurkov "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. " +" Use g:syntastic_java_checker option to specify which java syntax checker +" should be used (see below for a list of supported checkers). +" If g:syntastic_java_checker is not set, just use the first syntax +" checker that we find installed. "============================================================================ -function! SyntaxCheckers_java_GetLocList() - let makeprg = 'javac -Xlint ' - \. expand ( '%:p:h' ) . '/' . expand ( '%:t' ) - \. ' 2>&1 \| ' - \. 'sed -e "s\|' - \. expand ( '%:t' ) - \. '\|' - \. expand ( '%:p:h' ) . '/' . expand ( '%:t' ) - \. '\|"' - - " unashamedly stolen from *errorformat-javac* (quickfix.txt) - let errorformat = '%A%f:%l:\ %m,%+Z%p^,%+C%.%#,%-G%.%#' - - return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat }) - -endfunction +call SyntasticLoadChecker('java') diff --git a/syntax_checkers/java/checkstyle.vim b/syntax_checkers/java/checkstyle.vim new file mode 100644 index 00000000..e4bdd6e7 --- /dev/null +++ b/syntax_checkers/java/checkstyle.vim @@ -0,0 +1,33 @@ +"============================================================================ +"File: checkstyle.vim +"Description: Syntax checking plugin for syntastic.vim +"Maintainer: Dmitry Geurkov +"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. +" +" Tested with checkstyle 5.5 +"============================================================================ +if !exists("g:syntastic_java_checkstyle_classpath") + let g:syntastic_java_checkstyle_classpath = 'checkstyle-5.5-all.jar' +endif + +if !exists("g:syntastic_java_checkstyle_conf_file") + let g:syntastic_java_checkstyle_conf_file = 'sun_checks.xml' +endif + +function! SyntaxCheckers_java_GetLocList() + + let makeprg = 'java -cp ' . g:syntastic_java_checkstyle_classpath . ' com.puppycrawl.tools.checkstyle.Main -c ' + \. g:syntastic_java_checkstyle_conf_file . ' ' + \. expand ( '%:p:h' ) . '/' . expand ( '%:t' ) + \. ' 2>&1 ' + + " check style format + let errorformat = '%f:%l:%c:\ %m,%f:%l:\ %m' + + return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat }) + +endfunction diff --git a/syntax_checkers/java/javac.vim b/syntax_checkers/java/javac.vim new file mode 100644 index 00000000..17f867b5 --- /dev/null +++ b/syntax_checkers/java/javac.vim @@ -0,0 +1,227 @@ +"============================================================================ +"File: javac.vim +"Description: Syntax checking plugin for syntastic.vim +"Maintainer: Jochen Keil +" Dmitry Geurkov +"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. +" +"============================================================================ + +" Global Options +if !exists("g:syntastic_java_javac_executable") + let g:syntastic_java_javac_executable = 'javac' +endif + +if !exists("g:syntastic_java_javac_options") + let g:syntastic_java_javac_options = '-Xlint' +endif + +if !exists("g:syntastic_java_javac_classpath") + let g:syntastic_java_javac_classpath = '' +endif + +if !exists("g:syntastic_java_javac_delete_output") + let g:syntastic_java_javac_delete_output = 1 +endif + +if !exists("g:syntastic_java_javac_temp_dir") + if has('win32') || has('win64') + let g:syntastic_java_javac_temp_dir = $TEMP."\\vim-syntastic-javac" + else + let g:syntastic_java_javac_temp_dir = '/tmp/vim-syntastic-javac' + endif +endif + +if !exists("g:syntastic_java_javac_autoload_maven_classpath") + let g:syntastic_java_javac_autoload_maven_classpath = 1 +endif + +if !exists('g:syntastic_java_javac_config_file_enabled') + let g:syntastic_java_javac_config_file_enabled = 0 +endif + +if !exists('g:syntastic_java_javac_config_file') + let g:syntastic_java_javac_config_file = '.syntastic_javac_config' +endif + +" Internal variables, do not ovveride those +if !exists("g:syntastic_java_javac_maven_pom_cwd") + let g:syntastic_java_javac_maven_pom_cwd = '' +endif + +if !exists("g:syntastic_java_javac_maven_pom_ftime") + let g:syntastic_java_javac_maven_pom_ftime = 0 +endif + +if !exists("g:syntastic_java_javac_maven_pom_classpath") + let g:syntastic_java_javac_maven_pom_classpath = '' +endif + +" recursively remove directory and all it's sub-directories +function! s:RemoveDir(dir) + if isdirectory(a:dir) + for f in split(globpath(a:dir,'*'),"\n") + call s:RemoveDir(f) + endfor + silent! call system('rmdir '.a:dir) + else + silent! call delete(a:dir) + endif +endfunction + +function! s:AddToClasspath(classpath,path) + if a:path == '' + return a:classpath + endif + if a:classpath != '' && a:path != '' + if has('win32') || has('win64') + return a:classpath . ";" . a:path + else + return a:classpath . ":" . a:path + endif + else + return a:path + endif +endfunction + +function! s:LoadClasspathFromConfigFile() + if filereadable(g:syntastic_java_javac_config_file) + let path = '' + let lines = readfile(g:syntastic_java_javac_config_file) + for l in lines + if l != '' + let path .= l."\n" + endif + endfor + return path + else + return '' + endif +endfunction + +function! s:SaveClasspath() + let path = '' + let lines = getline(1,line('$')) + " save classpath to config file + if g:syntastic_java_javac_config_file_enabled + call writefile(lines,g:syntastic_java_javac_config_file) + endif + for l in lines + if l != '' + let path .= l."\n" + endif + endfor + let g:syntastic_java_javac_classpath = path + let &modified = 0 +endfunction + +function! s:EditClasspath() + let command = 'syntastic javac classpath' + let winnr = bufwinnr('^' . command . '$') + if winnr < 0 + let pathlist = split(g:syntastic_java_javac_classpath,"\n") + execute (len(pathlist)+5) . 'sp ' . fnameescape(command) + au BufWriteCmd call s:SaveClasspath() | bwipeout + setlocal buftype=acwrite bufhidden=wipe nobuflisted noswapfile nowrap number + for p in pathlist | call append(line('$')-1,p) | endfor + else + execute winnr . 'wincmd w' + endif +endfunction +command! SyntasticJavacEditClasspath call s:EditClasspath() + +function! s:GetMavenClasspath() + if filereadable('pom.xml') + if g:syntastic_java_javac_maven_pom_ftime != getftime('pom.xml') || g:syntastic_java_javac_maven_pom_cwd != getcwd() + let mvn_classpath_output = split(system('mvn dependency:build-classpath'),"\n") + let class_path_next = 0 + for line in mvn_classpath_output + if class_path_next == 1 + let mvn_classpath = line + break + endif + if match(line,'Dependencies classpath:') >= 0 + let class_path_next = 1 + endif + endfor + let mvn_classpath = s:AddToClasspath(mvn_classpath,'target/classes') + let g:syntastic_java_javac_maven_pom_cwd = getcwd() + let g:syntastic_java_javac_maven_pom_ftime = getftime('pom.xml') + let g:syntastic_java_javac_maven_pom_classpath = mvn_classpath + endif + return g:syntastic_java_javac_maven_pom_classpath + endif + return '' +endfunction + +function! SyntaxCheckers_java_GetLocList() + + let javac_opts = g:syntastic_java_javac_options + + if g:syntastic_java_javac_delete_output + let output_dir = g:syntastic_java_javac_temp_dir + let javac_opts .= ' -d ' .output_dir + endif + + " load classpath from config file + if g:syntastic_java_javac_config_file_enabled + let loaded_classpath = s:LoadClasspathFromConfigFile() + if loaded_classpath != '' + let g:syntastic_java_javac_classpath = loaded_classpath + endif + endif + + let javac_classpath = '' + + " add classpathes to javac_classpath + for path in split(g:syntastic_java_javac_classpath,"\n") + if path != '' + let ps = glob(path,0,1) + if type(ps) == type([]) + for p in ps + if p != '' | let javac_classpath = s:AddToClasspath(javac_classpath,p) | endif + endfor + else + let javac_classpath = s:AddToClasspath(javac_classpath,ps) + endif + endif + endfor + + if g:syntastic_java_javac_autoload_maven_classpath + let maven_classpath = s:GetMavenClasspath() + let javac_classpath = s:AddToClasspath(javac_classpath,maven_classpath) + endif + + if javac_classpath != '' + let javac_opts .= ' -cp ' . javac_classpath + endif + + + " path seperator + if has('win32') || has('win64') + let sep = "\\" + else + let sep = '/' + endif + + let makeprg = g:syntastic_java_javac_executable . ' '. javac_opts . ' ' + \. '"'.expand ( '%:p:h' ) . sep . expand ( '%:t' ).'"' + \. ' 2>&1 ' + + " unashamedly stolen from *errorformat-javac* (quickfix.txt) and modified to include error types + let errorformat = '%E%f:%l:\ error:\ %m,%W%f:%l:\ warning:\ %m,%A%f:%l:\ %m,%+Z%p^,%+C%.%#,%-G%.%#' + + if g:syntastic_java_javac_delete_output + silent! call mkdir(output_dir,'p') + endif + let r = SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat }) + if g:syntastic_java_javac_delete_output + call s:RemoveDir(output_dir) + endif + return r + +endfunction diff --git a/syntax_checkers/javascript.vim b/syntax_checkers/javascript.vim index 3d5236c4..28561a5a 100644 --- a/syntax_checkers/javascript.vim +++ b/syntax_checkers/javascript.vim @@ -14,10 +14,5 @@ " If g:syntastic_javascript_checker is not set, just use the first syntax " checker that we find installed. "============================================================================ -if exists("loaded_javascript_syntax_checker") - finish -endif -let loaded_javascript_syntax_checker = 1 -let s:supported_checkers = ["gjslint", "jslint", "jsl", "jshint"] -call SyntasticLoadChecker(s:supported_checkers, 'javascript') +call SyntasticLoadChecker('javascript') diff --git a/syntax_checkers/javascript/closurecompiler.vim b/syntax_checkers/javascript/closurecompiler.vim new file mode 100644 index 00000000..422a65fa --- /dev/null +++ b/syntax_checkers/javascript/closurecompiler.vim @@ -0,0 +1,43 @@ +"============================================================================ +"File: closurecompiler.vim +"Description: Javascript syntax checker - using Google Closure Compiler +"Maintainer: Motohiro Takayama +"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. +"============================================================================ +" +" To enable this plugin, edit the .vimrc like this: +" +" let g:syntastic_javascript_checker = "closurecompiler" +" +" and set the path to the Google Closure Compiler: +" +" let g:syntastic_javascript_closure_compiler_path = '/path/to/google-closure-compiler.jar' +" +" It takes additional options for Google Closure Compiler with the variable +" g:syntastic_javascript_closure_compiler_options. +" + +if !exists("g:syntastic_javascript_closure_compiler_options") + let g:syntastic_javascript_closure_compiler_options = "" +endif + +"bail if the user does not specify the path to closure compiler. +if !exists("g:syntastic_javascript_closure_compiler_path") + finish +endif + +function! SyntaxCheckers_javascript_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('%')) + endif + + let makeprg = 'java -jar ' . g:syntastic_javascript_closure_compiler_path . ' ' . g:syntastic_javascript_closure_compiler_options . ' --js ' . file_list + let errorformat = '%-GOK,%E%f:%l: ERROR - %m,%Z%p^,%W%f:%l: WARNING - %m,%Z%p^' + return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat }) +endfunction diff --git a/syntax_checkers/javascript/jsl.vim b/syntax_checkers/javascript/jsl.vim index 36c7efc5..a4a68ae1 100644 --- a/syntax_checkers/javascript/jsl.vim +++ b/syntax_checkers/javascript/jsl.vim @@ -12,8 +12,16 @@ if !exists("g:syntastic_javascript_jsl_conf") let g:syntastic_javascript_jsl_conf = "" endif +function s:ConfFlag() + if !empty(g:syntastic_javascript_jsl_conf) + return "-conf " . g:syntastic_javascript_jsl_conf + endif + + return "" +endfunction + function! SyntaxCheckers_javascript_GetLocList() - let makeprg = "jsl " . g:syntastic_javascript_jsl_conf . " -nologo -nofilelisting -nosummary -nocontext -process ".shellescape(expand('%')) + let makeprg = "jsl " . s:ConfFlag() . " -nologo -nofilelisting -nosummary -nocontext -process ".shellescape(expand('%')) let errorformat='%W%f(%l): lint warning: %m,%-Z%p^,%W%f(%l): warning: %m,%-Z%p^,%E%f(%l): SyntaxError: %m,%-Z%p^,%-G' return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat }) endfunction diff --git a/syntax_checkers/json.vim b/syntax_checkers/json.vim index 1c2b3c99..e6a1f25a 100644 --- a/syntax_checkers/json.vim +++ b/syntax_checkers/json.vim @@ -14,10 +14,5 @@ " If g:syntastic_json_checker is not set, just use the first syntax " checker that we find installed. "============================================================================ -if exists("loaded_json_syntax_checker") - finish -endif -let loaded_json_syntax_checker = 1 -let s:supported_checkers = ["jsonlint", "jsonval"] -call SyntasticLoadChecker(s:supported_checkers, 'json') +call SyntasticLoadChecker('json') diff --git a/syntax_checkers/less-lint.coffee b/syntax_checkers/less-lint.coffee new file mode 100644 index 00000000..0b05e4a7 --- /dev/null +++ b/syntax_checkers/less-lint.coffee @@ -0,0 +1,41 @@ +#!/usr/bin/env node + +fs = require 'fs' +less = require 'less' +args = process.argv.slice(1) +options = {} + +args = args.filter (arg) -> + match = arg.match(/^-I(.+)$/) + if match + options.paths.push(match[1]); + return false + + match = arg.match(/^--?([a-z][\-0-9a-z]*)(?:=([^\s]+))?$/i) + if match + arg = match[1] + else + return arg + + switch arg + when 'strict-imports' then options.strictImports = true + when 'include-path' + options.paths = match[2].split(if os.type().match(/Windows/) then ';' else ':') + .map (p) -> + if p + return path.resolve(process.cwd(), p) + when 'O0' then options.optimization = 0 + when 'O1' then options.optimization = 1 + when 'O2' then options.optimization = 2 + +options.filename = args[1] + +parser = new(less.Parser) options + +fs.readFile(options.filename, 'utf-8', (err,data) -> + parser.parse(data, (err, tree) -> + if err + less.writeError err + process.exit(1) + ) +) diff --git a/syntax_checkers/less-lint.js b/syntax_checkers/less-lint.js new file mode 100644 index 00000000..5abc653c --- /dev/null +++ b/syntax_checkers/less-lint.js @@ -0,0 +1,57 @@ +// Generated by CoffeeScript 1.3.3 +(function() { + var args, fs, less, options, parser; + + fs = require('fs'); + + less = require('less'); + + args = process.argv.slice(1); + + options = {}; + + args = args.filter(function(arg) { + var match; + match = arg.match(/^-I(.+)$/); + if (match) { + options.paths.push(match[1]); + return false; + } + match = arg.match(/^--?([a-z][\-0-9a-z]*)(?:=([^\s]+))?$/i); + if (match) { + arg = match[1]; + } else { + return arg; + } + switch (arg) { + case 'strict-imports': + return options.strictImports = true; + case 'include-path': + return options.paths = match[2].split(os.type().match(/Windows/) ? ';' : ':').map(function(p) { + if (p) { + return path.resolve(process.cwd(), p); + } + }); + case 'O0': + return options.optimization = 0; + case 'O1': + return options.optimization = 1; + case 'O2': + return options.optimization = 2; + } + }); + + options.filename = args[1]; + + parser = new less.Parser(options); + + fs.readFile(options.filename, 'utf-8', function(err, data) { + return parser.parse(data, function(err, tree) { + if (err) { + less.writeError(err); + return process.exit(1); + } + }); + }); + +}).call(this); diff --git a/syntax_checkers/less.vim b/syntax_checkers/less.vim index 1338ffda..5f92f74a 100644 --- a/syntax_checkers/less.vim +++ b/syntax_checkers/less.vim @@ -9,10 +9,13 @@ " See http://sam.zoy.org/wtfpl/COPYING for more details. " "============================================================================ -if exists("loaded_less_syntax_checker") - finish -endif -let loaded_less_syntax_checker = 1 + +" To send additional options to less use the variable g:syntastic_less_options. +" The default is +" let g:syntastic_less_options = "--no-color" +" +" To use less-lint instead of less set the variable +" g:syntastic_less_use_less_lint. "bail if the user doesnt have the lessc binary installed if !executable("lessc") @@ -23,13 +26,20 @@ if !exists("g:syntastic_less_options") let g:syntastic_less_options = "--no-color" endif -function! SyntaxCheckers_less_GetLocList() - let makeprg = 'lessc '. g:syntastic_less_options .' '. shellescape(expand('%')) . ' /dev/null' +if !exists("g:syntastic_less_use_less_lint") + let g:syntastic_less_use_less_lint = 0 +endif - "lessc >= 1.2 +if g:syntastic_less_use_less_lint + let s:check_file = 'node ' . expand(':p:h') . '/less-lint.js' +else + let s:check_file = 'lessc' +end + +function! SyntaxCheckers_less_GetLocList() + let makeprg = s:check_file . ' ' . g:syntastic_less_options . ' ' . + \ shellescape(expand('%')) . ' ' . syntastic#util#DevNull() let errorformat = '%m in %f:%l:%c' - "lessc < 1.2 - let errorformat .= ', Syntax %trror on line %l in %f,Syntax %trror on line %l,! Syntax %trror: on line %l: %m,%-G%.%#' return SyntasticMake({ 'makeprg': makeprg, \ 'errorformat': errorformat, diff --git a/syntax_checkers/lisp.vim b/syntax_checkers/lisp.vim new file mode 100644 index 00000000..9a16a550 --- /dev/null +++ b/syntax_checkers/lisp.vim @@ -0,0 +1,26 @@ +"============================================================================ +"File: lisp.vim +"Description: Syntax checking plugin for syntastic.vim +"Maintainer: Karl Yngve LervÃ¥g +"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. +" +"============================================================================ + +" Bail if the user doesnt have clisp installed +if !executable("clisp") + finish +endif + +function! SyntaxCheckers_lisp_GetLocList() + let makeprg = 'clisp -c ' . shellescape(expand('%')) + let makeprg .= ' -o /tmp/clisp-vim-compiled-file' + let efm = '%-G;%.%#,' + let efm .= '%W%>WARNING:%.%#line %l : %m,%C %#%m,' + let efm .= '%E%>The following functions were %m,%Z %m,' + let efm .= '%-G%.%#' + return SyntasticMake({ 'makeprg': makeprg, 'errorformat': efm }) +endfunction diff --git a/syntax_checkers/lua.vim b/syntax_checkers/lua.vim index 1fe37459..d6351c78 100644 --- a/syntax_checkers/lua.vim +++ b/syntax_checkers/lua.vim @@ -10,11 +10,6 @@ " "============================================================================ -if exists('loaded_lua_syntax_checker') - finish -endif -let loaded_lua_syntax_checker = 1 - " check if the lua compiler is installed if !executable('luac') finish diff --git a/syntax_checkers/matlab.vim b/syntax_checkers/matlab.vim index 595b3125..ca33c410 100644 --- a/syntax_checkers/matlab.vim +++ b/syntax_checkers/matlab.vim @@ -10,11 +10,6 @@ " "============================================================================ -if exists("loaded_matlab_syntax_checker") - finish -endif -let loaded_matlab_syntax_checker = 1 - "bail if the user doesn't have mlint installed if !executable("mlint") finish diff --git a/syntax_checkers/nasm.vim b/syntax_checkers/nasm.vim index f42cc8c6..41e38b61 100644 --- a/syntax_checkers/nasm.vim +++ b/syntax_checkers/nasm.vim @@ -9,10 +9,6 @@ " See http://sam.zoy.org/wtfpl/COPYING for more details. " "============================================================================ -if exists("loaded_nasm_syntax_checker") - finish -endif -let loaded_nasm_syntax_checker = 1 "bail if the user doesnt have nasm installed if !executable("nasm") diff --git a/syntax_checkers/objc.vim b/syntax_checkers/objc.vim new file mode 100644 index 00000000..c532e10f --- /dev/null +++ b/syntax_checkers/objc.vim @@ -0,0 +1,155 @@ +"============================================================================ +"File: objc.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. +" +"============================================================================ + +" 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 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' + +if !executable('gcc') + finish +endif + +let s:save_cpo = &cpo +set cpo&vim + +if !exists('g:syntastic_objc_compiler_options') + let g:syntastic_objc_compiler_options = '' +endif + +if !exists('g:syntastic_objc_config_file') + let g:syntastic_objc_config_file = '.syntastic_objc_config' +endif + +function! SyntaxCheckers_objc_GetLocList() + let makeprg = 'gcc -fsyntax-only -lobjc' + 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_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('c') + + " determine whether to parse header files as well + if expand('%') =~? '.h$' + if exists('g:syntastic_objc_check_header') + let makeprg = 'gcc -c '.shellescape(expand('%')). + \ ' '.syntastic#c#GetIncludeDirs('c') + 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 +endfunction + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim: set et sts=4 sw=4: diff --git a/syntax_checkers/ocaml.vim b/syntax_checkers/ocaml.vim index 6a2470f4..e8c886fd 100644 --- a/syntax_checkers/ocaml.vim +++ b/syntax_checkers/ocaml.vim @@ -10,6 +10,20 @@ " "============================================================================ " +" The more reliable way to check for a single .ml file is to use ocamlc. +" You can do that setting this in your .vimrc: +" +" let g:syntastic_ocaml_use_ocamlc = 1 +" It's possible to use ocamlc in conjuction with Jane Street's Core. In order +" to do that, you have to specify this in your .vimrc: +" +" let g:syntastic_ocaml_use_janestreet_core = 1 +" let g:syntastic_ocaml_janestreet_core_dir = +" +" Where path is the path to your core installation (usually a collection of +" .cmx and .cmxa files). +" +" " By default the camlp4o preprocessor is used to check the syntax of .ml, and .mli files, " ocamllex is used to check .mll files and menhir is used to check .mly files. " The output is all redirected to /dev/null, nothing is written to the disk. @@ -34,11 +48,6 @@ " For best results your current directory should be the project root " (same situation if you want useful output from :make). -if exists("loaded_ocaml_syntax_checker") - finish -endif -let loaded_ocaml_syntax_checker = 1 - if exists('g:syntastic_ocaml_camlp4r') && \ g:syntastic_ocaml_camlp4r != 0 let s:ocamlpp="camlp4r" @@ -51,30 +60,24 @@ if !executable(s:ocamlpp) finish endif +if !exists('g:syntastic_ocaml_use_ocamlc') || !executable('ocamlc') + let g:syntastic_ocaml_use_ocamlc = 0 +endif + +if !exists('g:syntastic_ocaml_use_janestreet_core') + let g:syntastic_ocaml_use_ocamlc = 0 +endif + +if !exists('g:syntastic_ocaml_use_ocamlbuild') || !executable("ocamlbuild") + let g:syntastic_ocaml_use_ocamlbuild = 0 +endif + function! SyntaxCheckers_ocaml_GetLocList() - if exists('g:syntastic_ocaml_use_ocamlbuild') && - \ g:syntastic_ocaml_use_ocamlbuild != 0 && - \ executable("ocamlbuild") && - \ isdirectory('_build') - let makeprg = "ocamlbuild -quiet -no-log -tag annot,". s:ocamlpp. " -no-links -no-hygiene -no-sanitize ". - \ shellescape(expand('%:r')).".cmi" - else - let extension = expand('%:e') - if match(extension, 'mly') >= 0 - " ocamlyacc output can't be redirected, so use menhir - if !executable("menhir") - return [] - endif - let makeprg = "menhir --only-preprocess ".shellescape(expand('%')) . " >/dev/null" - elseif match(extension,'mll') >= 0 - if !executable("ocamllex") - return [] - endif - let makeprg = "ocamllex -q -o /dev/null ".shellescape(expand('%')) - else - let makeprg = "camlp4o -o /dev/null ".shellescape(expand('%')) - endif + let makeprg = s:GetMakeprg() + if makeprg == "" + return [] endif + let errorformat = '%AFile "%f"\, line %l\, characters %c-%*\d:,'. \ '%AFile "%f"\, line %l\, characters %c-%*\d (end at line %*\d\, character %*\d):,'. \ '%AFile "%f"\, line %l\, character %c:,'. @@ -87,3 +90,51 @@ function! SyntaxCheckers_ocaml_GetLocList() return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat }) endfunction + +function s:GetMakeprg() + if g:syntastic_ocaml_use_ocamlc + return s:GetOcamlcMakeprg() + endif + + if g:syntastic_ocaml_use_ocamlbuild && isdirectory('_build') + return s:GetOcamlBuildMakeprg() + endif + + return s:GetOtherMakeprg() +endfunction + +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('%') + return build_cmd + else + 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" +endfunction + +function s:GetOtherMakeprg() + "TODO: give this function a better name? + " + "TODO: should use throw/catch instead of returning an empty makeprg + + let extension = expand('%:e') + let makeprg = "" + + 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" + elseif match(extension,'mll') >= 0 && executable("ocamllex") + let makeprg = "ocamllex -q -o /dev/null ".shellescape(expand('%')) + else + let makeprg = "camlp4o -o /dev/null ".shellescape(expand('%')) + endif + + return makeprg +endfunction diff --git a/syntax_checkers/perl.vim b/syntax_checkers/perl.vim index e8aa5777..b1baa333 100644 --- a/syntax_checkers/perl.vim +++ b/syntax_checkers/perl.vim @@ -1,7 +1,8 @@ "============================================================================ "File: perl.vim "Description: Syntax checking plugin for syntastic.vim -"Maintainer: Anthony Carapetis +"Maintainer: Anthony Carapetis , +" Eric Harmon "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 @@ -9,21 +10,48 @@ " See http://sam.zoy.org/wtfpl/COPYING for more details. " "============================================================================ -if exists("loaded_perl_syntax_checker") - finish -endif -let loaded_perl_syntax_checker = 1 +" +" In order to add some custom lib directories that should be added to the +" perl command line you can add those to the global variable +" g:syntastic_perl_lib_path. +" +" let g:syntastic_perl_lib_path = './lib' +" +" To use your own perl error output munger script, use the +" g:syntastic_perl_efm_program option. Any command line parameters should be +" included in the variable declaration. The program should expect a single +" parameter; the fully qualified filename of the file to be checked. +" +" let g:syntastic_perl_efm_program = "foo.pl -o -m -g" +" "bail if the user doesnt have perl installed if !executable("perl") finish endif -let s:checker = 'perl ' . shellescape(expand(':p:h') . '/efm_perl.pl') . ' -c' +if !exists("g:syntastic_perl_efm_program") + let g:syntastic_perl_efm_program = 'perl ' . shellescape(expand(':p:h') . '/efm_perl.pl') . ' -c -w' +endif function! SyntaxCheckers_perl_GetLocList() - let makeprg = s:checker . ' ' . shellescape(expand('%')) - let errorformat = '%f:%l:%m' + if exists("g:syntastic_perl_lib_path") + let makeprg = g:syntastic_perl_efm_program . ' -I' . g:syntastic_perl_lib_path . ' ' . shellescape(expand('%')) + else + let makeprg = g:syntastic_perl_efm_program . ' ' . shellescape(expand('%')) + endif + let makeprg .= s:ExtraMakeprgArgs() + + let errorformat = '%t:%f:%l:%m' return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat }) endfunction + +function! s:ExtraMakeprgArgs() + let shebang = syntastic#util#ParseShebang() + if index(shebang['args'], '-T') != -1 + return ' -Tc' + endif + + return '' +endfunction diff --git a/syntax_checkers/php.vim b/syntax_checkers/php.vim index a2c909d9..0e3ef44a 100644 --- a/syntax_checkers/php.vim +++ b/syntax_checkers/php.vim @@ -9,10 +9,18 @@ " See http://sam.zoy.org/wtfpl/COPYING for more details. " "============================================================================ -if exists("loaded_php_syntax_checker") - finish -endif -let loaded_php_syntax_checker = 1 +" +"This syntax checker is composed of three checkers: +" - php -l +" - phpcs (see http://pear.php.net/package/PHP_CodeSniffer) +" - phpmd (see http://phpmd.org) +" +"If any of these checkers are installed then they will be used. Phpcs and +"Phpmd are 'style checkers' and will only be called if `php -l` doesnt find +"any syntax errors. +" +"There are options below to config and disable phpcs and phpmd. + "bail if the user doesnt have php installed if !executable("php") @@ -24,10 +32,21 @@ if !exists("g:syntastic_phpcs_conf") let g:syntastic_phpcs_conf = "" endif -if !exists("g:syntastic_phpcs_disable") +if !exists("g:syntastic_phpcs_disable") || !executable('phpcs') let g:syntastic_phpcs_disable = 0 endif + +if !exists("g:syntastic_phpmd_disable") || !executable('phpmd') + let g:syntastic_phpmd_disable = 0 +endif + + +"Support passing selected rules to phpmd +if !exists("g:syntastic_phpmd_rules") + let g:syntastic_phpmd_rules = "codesize,design,unusedcode,naming" +endif + function! SyntaxCheckers_php_GetHighlightRegex(item) let unexpected = matchstr(a:item['text'], "unexpected '[^']\\+'") if len(unexpected) < 1 @@ -37,16 +56,19 @@ function! SyntaxCheckers_php_GetHighlightRegex(item) endfunction function! SyntaxCheckers_php_GetLocList() - - let errors = [] - - let makeprg = "php -l -d error_reporting=E_ALL -d display_errors=0 -d error_log='' ".shellescape(expand('%')) - let errorformat='%-GNo syntax errors detected in%.%#,PHP Parse error: %#syntax %trror\, %m in %f on line %l,PHP Fatal %trror: %m in %f on line %l,%-GErrors parsing %.%#,%-G\s%#,Parse error: %#syntax %trror\, %m in %f on line %l,Fatal %trror: %m in %f on line %l,PHP Parse %trror: %m in %f on line %l' + let makeprg = "php -l -d error_reporting=E_ALL -d display_errors=1 -d log_errors=0 ".shellescape(expand('%')) + let errorformat='%-GNo syntax errors detected in%.%#,Parse error: %#syntax %trror\ , %m in %f on line %l,Parse %trror: %m in %f on line %l,Fatal %trror: %m in %f on line %l,%-G\s%#,%-GErrors parsing %.%#' let errors = SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat }) - if empty(errors) && !g:syntastic_phpcs_disable && executable("phpcs") - let errors = errors + s:GetPHPCSErrors() - endif + if empty(errors) + if !g:syntastic_phpcs_disable + let errors = errors + s:GetPHPCSErrors() + endif + + if !g:syntastic_phpmd_disable + let errors = errors + s:GetPHPMDErrors() + endif + end return errors endfunction @@ -56,3 +78,10 @@ function! s:GetPHPCSErrors() let errorformat = '%-GFile\,Line\,Column\,Type\,Message\,Source\,Severity,"%f"\,%l\,%c\,%t%*[a-zA-Z]\,"%m"\,%*[a-zA-Z0-9_.-]\,%*[0-9]' return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat, 'subtype': 'Style' }) endfunction + +"Helper function. This one runs and parses phpmd tool output. +function! s:GetPHPMDErrors() + let makeprg = "phpmd " . shellescape(expand('%')) . " text " . g:syntastic_phpmd_rules + let errorformat = '%E%f:%l%m' + return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat, 'subtype' : 'Style' }) +endfunction diff --git a/syntax_checkers/puppet.vim b/syntax_checkers/puppet.vim index fdfc6a3c..9f180f6d 100644 --- a/syntax_checkers/puppet.vim +++ b/syntax_checkers/puppet.vim @@ -9,16 +9,16 @@ " See http://sam.zoy.org/wtfpl/COPYING for more details. " "============================================================================ -if exists("loaded_puppet_syntax_checker") - finish -endif -let loaded_puppet_syntax_checker = 1 "bail if the user doesnt have puppet installed if !executable("puppet") finish endif +if !exists("g:syntastic_puppet_validate_disable") + let g:syntastic_puppet_validate_disable = 0 +endif + if !exists("g:syntastic_puppet_lint_disable") let g:syntastic_puppet_lint_disable = 0 endif @@ -27,61 +27,76 @@ if !executable("puppet-lint") let g:syntastic_puppet_lint_disable = 1 endif -function! s:PuppetExtractVersion() - let output = system("puppet --version") - let output = substitute(output, '\n$', '', '') - return split(output, '\.') +function! s:PuppetVersion() + if !exists("s:puppet_version") + let output = system("puppet --version 2>/dev/null") + let output = substitute(output, '\n$', '', '') + let s:puppet_version = split(output, '\.') + endif + return s:puppet_version endfunction -function! s:PuppetLintExtractVersion() - let output = system("puppet-lint --version") - let output = substitute(output, '\n$', '', '') - let output = substitute(output, '^puppet-lint ', '', 'i') - return split(output, '\.') +function! s:PuppetLintVersion() + if !exists("s:puppet_lint_version") + let output = system("puppet-lint --version 2>/dev/null") + let output = substitute(output, '\n$', '', '') + let output = substitute(output, '^puppet-lint ', '', 'i') + let s:puppet_lint_version = split(output, '\.') + endif + return s:puppet_lint_version endfunction -let s:puppetVersion = s:PuppetExtractVersion() -let s:lintVersion = s:PuppetLintExtractVersion() - -if !(s:lintVersion[0] >= '0' && s:lintVersion[1] >= '1' && s:lintVersion[2] >= '10') - let g:syntastic_puppet_lint_disable = 1 -endif +if !g:syntastic_puppet_lint_disable + if !SyntasticIsVersionAtLeast(s:PuppetLintVersion(), [0,1,10]) + let g:syntastic_puppet_lint_disable = 1 + endif +end function! s:getPuppetLintErrors() - let makeprg = 'puppet-lint --log-format "\%{KIND} [\%{check}] \%{message} at \%{fullpath}:\%{linenumber}" '.shellescape(expand('%')) + if !exists("g:syntastic_puppet_lint_arguments") + let g:syntastic_puppet_lint_arguments = '' + endif + + let makeprg = 'puppet-lint --log-format "\%{KIND} [\%{check}] \%{message} at \%{fullpath}:\%{linenumber}" '.g:syntastic_puppet_lint_arguments.shellescape(expand('%')) let errorformat = '%t%*[a-zA-Z] %m at %f:%l' return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat, 'subtype': 'Style' }) endfunction -function! s:getPuppetMakeprg() +function! s:getPuppetMakeprg() "If puppet is >= version 2.7 then use the new executable - if s:puppetVersion[0] >= '2' && s:puppetVersion[1] >= '7' + if SyntasticIsVersionAtLeast(s:PuppetVersion(), [2,7,0]) let makeprg = 'puppet parser validate ' . \ shellescape(expand('%')) . \ ' --color=false' - - "add --ignoreimport for versions < 2.7.10 - if s:puppetVersion[2] < '10' - let makeprg .= ' --ignoreimport' - endif - else - let makeprg = 'puppet --color=false --parseonly --ignoreimport '.shellescape(expand('%')) + let makeprg = 'puppet --color=false --parseonly '.shellescape(expand('%')) endif return makeprg endfunction -function! SyntaxCheckers_puppet_GetLocList() - - let makeprg = s:getPuppetMakeprg() - +function! s:getPuppetEfm() "some versions of puppet (e.g. 2.7.10) output the message below if there "are any syntax errors let errorformat = '%-Gerr: Try ''puppet help parser validate'' for usage,' let errorformat .= 'err: Could not parse for environment %*[a-z]: %m at %f:%l' - let errors = SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat }) - + "Puppet 3.0.0 changes this from "err:" to "Error:" + "reset errorformat in that case + if SyntasticIsVersionAtLeast(s:PuppetVersion(), [3,0,0]) + let errorformat = '%-GError: Try ''puppet help parser validate'' for usage,' + let errorformat .= 'Error: Could not parse for environment %*[a-z]: %m at %f:%l' + endif + + return errorformat +endfunction + +function! SyntaxCheckers_puppet_GetLocList() + let errors = [] + + if !g:syntastic_puppet_validate_disable + let errors = errors + SyntasticMake({ 'makeprg': s:getPuppetMakeprg(), 'errorformat': s:getPuppetEfm() }) + endif + if !g:syntastic_puppet_lint_disable let errors = errors + s:getPuppetLintErrors() endif diff --git a/syntax_checkers/python.vim b/syntax_checkers/python.vim index 863e0642..f8e17c9f 100644 --- a/syntax_checkers/python.vim +++ b/syntax_checkers/python.vim @@ -14,14 +14,8 @@ " in your .vimrc. Default is flake8. "============================================================================ -if exists("loaded_python_syntax_checker") - finish -endif -let loaded_python_syntax_checker = 1 - if !exists('g:syntastic_python_checker_args') let g:syntastic_python_checker_args = '' endif -let s:supported_checkers = ["flake8", "pyflakes", "pylint"] -call SyntasticLoadChecker(s:supported_checkers, 'python') +call SyntasticLoadChecker('python') diff --git a/syntax_checkers/python/flake8.vim b/syntax_checkers/python/flake8.vim index 497f3595..cd32cff2 100644 --- a/syntax_checkers/python/flake8.vim +++ b/syntax_checkers/python/flake8.vim @@ -23,6 +23,6 @@ endfunction function! SyntaxCheckers_python_GetLocList() let makeprg = 'flake8 '.g:syntastic_python_checker_args.' '.shellescape(expand('%')) - let errorformat = '%E%f:%l: could not compile,%-Z%p^,%E%f:%l:%c: %m,%E%f:%l: %m,%-G%.%#' + let errorformat = '%E%f:%l: could not compile,%-Z%p^,%E%f:%l:%c: %m,%W%f:%l: %m,%-G%.%#' return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat }) endfunction diff --git a/syntax_checkers/python/pylint.vim b/syntax_checkers/python/pylint.vim index 64adbc5f..fd35e08a 100644 --- a/syntax_checkers/python/pylint.vim +++ b/syntax_checkers/python/pylint.vim @@ -7,8 +7,8 @@ function! SyntaxCheckers_python_GetLocList() let makeprg = 'pylint '.g:syntastic_python_checker_args.' -f parseable -r n -i y ' . \ shellescape(expand('%')) . - \ ' 2>&1 \| sed ''s_: \[[RC]_: \[W_''' . - \ ' \| sed ''s_: \[[F]_:\ \[E_''' - let errorformat = '%f:%l: [%t%n%.%#] %m,%f:%l: [%t%.%#] %m,%Z,%-GNo config%m' + \ ' 2>&1 \| sed ''s_: \[\([RCW]\)_: \[W] \[\1_''' . + \ ' \| sed ''s_: \[\([FE]\)_:\ \[E] \[\1_''' + let errorformat = '%f:%l: [%t] %m,%Z,%-GNo config %m' return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat }) endfunction diff --git a/syntax_checkers/python/python.vim b/syntax_checkers/python/python.vim new file mode 100644 index 00000000..d58271fb --- /dev/null +++ b/syntax_checkers/python/python.vim @@ -0,0 +1,27 @@ +"============================================================================ +"File: python.vim +"Description: Syntax checking plugin for syntastic.vim +"Author: Artem Nezvigin +" +" `errorformat` derived from: +" http://www.vim.org/scripts/download_script.php?src_id=1392 +" +"============================================================================ + +function! SyntaxCheckers_python_GetLocList() + let l:path = shellescape(expand('%')) + let l:cmd = "compile(open(" . l:path . ").read(), " . l:path . ", 'exec')" + let l:makeprg = 'python -c "' . l:cmd . '"' + + let l:errorformat = + \ "\%A\ \ File\ \"%f\"\\\,\ line\ %l\\\,%m," . + \ "\%C\ \ \ \ %.%#," . + \ "\%+Z%.%#Error\:\ %.%#," . + \ "\%A\ \ File\ \"%f\"\\\,\ line\ %l," . + \ "\%+C\ \ %.%#," . + \ "\%-C%p^," . + \ "\%Z%m," . + \ "\%-G%.%#" + + return SyntasticMake({ 'makeprg': l:makeprg, 'errorformat': l:errorformat }) +endfunction diff --git a/syntax_checkers/rst.vim b/syntax_checkers/rst.vim index 848e47da..7ccdba32 100644 --- a/syntax_checkers/rst.vim +++ b/syntax_checkers/rst.vim @@ -13,11 +13,6 @@ " We use rst2pseudoxml.py, as it is ever so marginally faster than the other " rst2${x} tools in docutils. -if exists("loaded_rst_syntax_checker") - finish -endif -let loaded_rst_syntax_checker = 1 - "bail if the user doesn't have rst2pseudoxml.py installed if !executable("rst2pseudoxml.py") finish @@ -25,7 +20,7 @@ endif function! SyntaxCheckers_rst_GetLocList() let makeprg = 'rst2pseudoxml.py --report=2 --exit-status=1 ' . - \ shellescape(expand('%')) . ' /dev/null' + \ shellescape(expand('%')) . ' ' . syntastic#util#DevNull() let errorformat = '%f:%l:\ (%tNFO/1)\ %m, \%f:%l:\ (%tARNING/2)\ %m, diff --git a/syntax_checkers/ruby.vim b/syntax_checkers/ruby.vim index 17d00ca5..183da6a3 100644 --- a/syntax_checkers/ruby.vim +++ b/syntax_checkers/ruby.vim @@ -13,15 +13,6 @@ "Use the g:syntastic_ruby_checker option to specify which checker to load - "set it to "jruby" to load the jruby checker. "============================================================================ -if exists("loaded_ruby_syntax_checker") - finish -endif -let loaded_ruby_syntax_checker = 1 - -"bail if the user doesnt have ruby installed -if !executable("ruby") - finish -endif if !exists("g:syntastic_ruby_checker") let g:syntastic_ruby_checker = "mri" diff --git a/syntax_checkers/ruby/jruby.vim b/syntax_checkers/ruby/jruby.vim index bec5168a..b3c416df 100644 --- a/syntax_checkers/ruby/jruby.vim +++ b/syntax_checkers/ruby/jruby.vim @@ -10,7 +10,12 @@ " "============================================================================ function! SyntaxCheckers_ruby_GetLocList() - "let makeprg = '' - "let errorformat = '' - "return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat }) + if has('win32') + let makeprg = 'jruby -W1 -T1 -c '.shellescape(expand('%')) + else + let makeprg = 'RUBYOPT= jruby -W1 -c '.shellescape(expand('%')) + endif + let errorformat = '%-GSyntax OK for %f,%ESyntaxError in %f:%l: syntax error\, %m,%Z%p^,%W%f:%l: warning: %m,%Z%p^,%W%f:%l: %m,%-C%.%#' + + return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat }) endfunction diff --git a/syntax_checkers/ruby/mri.vim b/syntax_checkers/ruby/mri.vim index ee72b5a0..d2f93335 100644 --- a/syntax_checkers/ruby/mri.vim +++ b/syntax_checkers/ruby/mri.vim @@ -9,14 +9,44 @@ " See http://sam.zoy.org/wtfpl/COPYING for more details. " "============================================================================ -function! SyntaxCheckers_ruby_GetLocList() - " we cannot set RUBYOPT on windows like that - if has('win32') - let makeprg = 'ruby -W1 -T1 -c '.shellescape(expand('%')) - else - let makeprg = 'RUBYOPT= ruby -W1 -c '.shellescape(expand('%')) +function! s:FindRubyExec() + if executable("rvm") + return system("rvm tools identifier") endif - let errorformat = '%-GSyntax OK,%E%f:%l: syntax error\, %m,%Z%p^,%W%f:%l: warning: %m,%Z%p^,%W%f:%l: %m,%-C%.%#' + return "ruby" +endfunction + +if !exists("g:syntastic_ruby_exec") + let g:syntastic_ruby_exec = s:FindRubyExec() +endif + +"bail if the user doesnt have ruby installed where they said it is +if !executable(expand(g:syntastic_ruby_exec)) + finish +endif + +function! SyntaxCheckers_ruby_GetLocList() + let makeprg = expand(g:syntastic_ruby_exec).' -w -T1 -c '.shellescape(expand('%')) + if !has('win32') + let makeprg = 'RUBYOPT= ' . makeprg + endif + + "this is a hack to filter out a repeated useless warning in rspec files + "containing lines like + " + " foo.should == 'bar' + " + "Which always generate the warning below. Note that ruby >= 1.9.3 includes + "the word "possibly" in the warning + let errorformat = '%-G%.%#warning: %\(possibly %\)%\?useless use of == in void context' + + " filter out lines starting with ... + " long lines are truncated and wrapped in ... %p then returns the wrong + " column offset + let errorformat .= ',%-G%\%.%\%.%\%.%.%#' + + let errorformat .= ',%-GSyntax OK,%E%f:%l: syntax error\, %m' + let errorformat .= ',%Z%p^,%W%f:%l: warning: %m,%Z%p^,%W%f:%l: %m,%-C%.%#' return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat }) endfunction diff --git a/syntax_checkers/rust.vim b/syntax_checkers/rust.vim index fef48e8f..356e9b45 100644 --- a/syntax_checkers/rust.vim +++ b/syntax_checkers/rust.vim @@ -9,10 +9,6 @@ " See http://sam.zoy.org/wtfpl/COPYING for more details. " "============================================================================ -if exists("loaded_rust_syntax_checker") - finish -endif -let loaded_rust_syntax_checker = 1 "bail if the user doesnt have rustc installed if !executable("rustc") diff --git a/syntax_checkers/sass.vim b/syntax_checkers/sass.vim index 23bf345c..b9eed048 100644 --- a/syntax_checkers/sass.vim +++ b/syntax_checkers/sass.vim @@ -9,16 +9,21 @@ " See http://sam.zoy.org/wtfpl/COPYING for more details. " "============================================================================ -if exists("loaded_sass_syntax_checker") - finish -endif -let loaded_sass_syntax_checker = 1 "bail if the user doesnt have the sass binary installed if !executable("sass") finish endif +"sass caching for large files drastically speeds up the checking, but store it +"in a temp location otherwise sass puts .sass_cache dirs in the users project +let s:sass_cache_location = tempname() + +"By default do not check partials as unknown variables are a syntax error +if !exists("g:syntastic_sass_check_partials") + let g:syntastic_sass_check_partials = 0 +endif + "use compass imports if available let s:imports = "" if executable("compass") @@ -26,7 +31,10 @@ if executable("compass") endif function! SyntaxCheckers_sass_GetLocList() - let makeprg='sass '.s:imports.' --check '.shellescape(expand('%')) + if !g:syntastic_sass_check_partials && expand('%:t')[0] == '_' + return [] + end + let makeprg='sass --cache-location '.s:sass_cache_location.' '.s:imports.' --check '.shellescape(expand('%')) let errorformat = '%ESyntax %trror:%m,%C on line %l of %f,%Z%.%#' let errorformat .= ',%Wwarning on line %l:,%Z%m,Syntax %trror on line %l: %m' let loclist = SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat }) diff --git a/syntax_checkers/scala.vim b/syntax_checkers/scala.vim index f6f05af0..3332dda9 100644 --- a/syntax_checkers/scala.vim +++ b/syntax_checkers/scala.vim @@ -9,10 +9,6 @@ " See http://sam.zoy.org/wtfpl/COPYING for more details. " "============================================================================ -if exists("loaded_scala_syntax_checker") - finish -endif -let loaded_scala_syntax_checker = 1 "bail if the user doesnt have the scala binary installed if !executable("scala") diff --git a/syntax_checkers/scss.vim b/syntax_checkers/scss.vim index d3ae5e79..1e627c53 100644 --- a/syntax_checkers/scss.vim +++ b/syntax_checkers/scss.vim @@ -10,10 +10,6 @@ " See http://sam.zoy.org/wtfpl/COPYING for more details. " "============================================================================ -if exists("loaded_scss_syntax_checker") - finish -endif -let loaded_scss_syntax_checker = 1 "bail if the user doesnt have the sass binary installed if !executable("sass") diff --git a/syntax_checkers/sh.vim b/syntax_checkers/sh.vim index 5b55172b..4f0a1d9d 100644 --- a/syntax_checkers/sh.vim +++ b/syntax_checkers/sh.vim @@ -9,10 +9,6 @@ " See http://sam.zoy.org/wtfpl/COPYING for more details. " "============================================================================ -if exists('loaded_sh_syntax_checker') - finish -endif -let loaded_sh_syntax_checker = 1 function! s:GetShell() if !exists('b:shell') || b:shell == "" @@ -31,22 +27,29 @@ function! s:GetShell() return b:shell endfunction -function! SyntaxCheckers_sh_GetLocList() - if len(s:GetShell()) == 0 || !executable(s:GetShell()) +function! s:ForwardToZshChecker() + if SyntasticCheckable('zsh') + return SyntaxCheckers_zsh_GetLocList() + else return [] endif - let output = split(system(s:GetShell().' -n '.shellescape(expand('%'))), '\n') - if v:shell_error != 0 - let result = [] - for err_line in output - let line = substitute(err_line, '^[^:]*:\D\{-}\(\d\+\):.*', '\1', '') - let msg = substitute(err_line, '^[^:]*:\D\{-}\d\+: \(.*\)', '\1', '') - call add(result, {'lnum' : line, - \ 'text' : msg, - \ 'bufnr': bufnr(''), - \ 'type': 'E' }) - endfor - return result - endif - return [] + +endfunction + +function! s:IsShellValid() + return len(s:GetShell()) > 0 && executable(s:GetShell()) +endfunction + +function! SyntaxCheckers_sh_GetLocList() + if s:GetShell() == 'zsh' + return s:ForwardToZshChecker() + endif + + if !s:IsShellValid() + return [] + endif + + let makeprg = s:GetShell() . ' -n ' . shellescape(expand('%')) + let errorformat = '%f: line %l: %m' + return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat}) endfunction diff --git a/syntax_checkers/slim.vim b/syntax_checkers/slim.vim new file mode 100644 index 00000000..dc12bf63 --- /dev/null +++ b/syntax_checkers/slim.vim @@ -0,0 +1,36 @@ +"============================================================================ +"File: slim.vim +"Description: Syntax checking plugin for syntastic.vim +"Maintainer: Martin Grenfell +"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. +" +"============================================================================ + +"bail if the user doesnt have the slim binary installed +if !executable("slimrb") + finish +endif + +function! s:SlimrbVersion() + if !exists('s:slimrb_version') + let output = system("slimrb --version 2>/dev/null") + let output = substitute(output, '\n$', '', '') + let output = substitute(output, '^slim ', '', 'i') + let s:slimrb_version = split(output, '\.') + end + return s:slimrb_version +endfunction + +function! SyntaxCheckers_slim_GetLocList() + let makeprg = "slimrb -c " . shellescape(expand("%")) + if SyntasticIsVersionAtLeast(s:SlimrbVersion(), [1,3,1]) + let errorformat = '%C\ %#%f\, Line %l\, Column %c,%-G\ %.%#,%ESlim::Parser::SyntaxError: %m,%+C%.%#' + else + let errorformat = '%C\ %#%f\, Line %l,%-G\ %.%#,%ESlim::Parser::SyntaxError: %m,%+C%.%#' + endif + return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat }) +endfunction diff --git a/syntax_checkers/tcl.vim b/syntax_checkers/tcl.vim index 83b5df39..d3428fe2 100644 --- a/syntax_checkers/tcl.vim +++ b/syntax_checkers/tcl.vim @@ -10,11 +10,6 @@ " "============================================================================ -if exists("loaded_tcl_syntax_checker") - finish -endif -let loaded_tcl_syntax_checker = 1 - "bail if the user doesnt have tclsh installed if !executable("tclsh") finish diff --git a/syntax_checkers/tex.vim b/syntax_checkers/tex.vim index 4369f4ca..8fb4dc3d 100644 --- a/syntax_checkers/tex.vim +++ b/syntax_checkers/tex.vim @@ -9,10 +9,6 @@ " See http://sam.zoy.org/wtfpl/COPYING for more details. " "============================================================================ -if exists("loaded_tex_syntax_checker") - finish -endif -let loaded_tex_syntax_checker = 1 "bail if the user doesnt have lacheck installed if !executable("lacheck") diff --git a/syntax_checkers/typescript.vim b/syntax_checkers/typescript.vim new file mode 100644 index 00000000..ab25363d --- /dev/null +++ b/syntax_checkers/typescript.vim @@ -0,0 +1,16 @@ +"============================================================================ +"File: typescript.vim +"Description: TypeScript syntax checker. For TypeScript v0.8.0 +"Maintainer: Bill Casarin +"============================================================================ + +"bail if the user doesnt have tsc installed +if !executable("tsc") + finish +endif + +function! SyntaxCheckers_typescript_GetLocList() + let makeprg = 'tsc ' . shellescape(expand("%")) . ' --out ' . syntastic#util#DevNull() + let errorformat = '%f %#(%l\,%c): %m' + return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat }) +endfunction diff --git a/syntax_checkers/vala.vim b/syntax_checkers/vala.vim index 855ca044..315a16ab 100644 --- a/syntax_checkers/vala.vim +++ b/syntax_checkers/vala.vim @@ -22,11 +22,6 @@ " "============================================================================ -if exists('loaded_vala_syntax_checker') - finish -endif -let loaded_vala_syntax_checker = 1 - if !executable('valac') finish endif diff --git a/syntax_checkers/xhtml.vim b/syntax_checkers/xhtml.vim index 80d981a3..b6862711 100644 --- a/syntax_checkers/xhtml.vim +++ b/syntax_checkers/xhtml.vim @@ -9,10 +9,6 @@ " See http://sam.zoy.org/wtfpl/COPYING for more details. " "============================================================================ -if exists("loaded_xhtml_syntax_checker") - finish -endif -let loaded_xhtml_syntax_checker = 1 "bail if the user doesnt have tidy or grep installed if !executable("tidy") diff --git a/syntax_checkers/xml.vim b/syntax_checkers/xml.vim index 55c0cdd3..9569a967 100644 --- a/syntax_checkers/xml.vim +++ b/syntax_checkers/xml.vim @@ -14,11 +14,6 @@ " and allow you to validate XML data without network access, see xmlcatalog(1) " and http://www.xmlsoft.org/catalog.html for more information. -if exists("loaded_xml_syntax_checker") - finish -endif -let loaded_xml_syntax_checker = 1 - "bail if the user doesnt have tidy or grep installed if !executable("xmllint") finish diff --git a/syntax_checkers/xslt.vim b/syntax_checkers/xslt.vim index b9b3cac8..750a79b5 100644 --- a/syntax_checkers/xslt.vim +++ b/syntax_checkers/xslt.vim @@ -9,10 +9,6 @@ " See http://sam.zoy.org/wtfpl/COPYING for more details. " "============================================================================ -if exists("loaded_xslt_syntax_checker") - finish -endif -let loaded_xslt_syntax_checker = 1 "bail if the user doesnt have tidy or grep installed if !executable("xmllint") diff --git a/syntax_checkers/yaml.vim b/syntax_checkers/yaml.vim index f45d849b..b0271a76 100644 --- a/syntax_checkers/yaml.vim +++ b/syntax_checkers/yaml.vim @@ -9,13 +9,9 @@ " See http://sam.zoy.org/wtfpl/COPYING for more details. " " -"Installation: $ npm install -g js-yaml.bin +"Installation: $ npm install -g js-yaml " "============================================================================ -if exists("loaded_yaml_syntax_checker") - finish -endif -let loaded_yaml_syntax_checker = 1 if !executable("js-yaml") finish diff --git a/syntax_checkers/z80.vim b/syntax_checkers/z80.vim index 15cba23b..f5564e83 100644 --- a/syntax_checkers/z80.vim +++ b/syntax_checkers/z80.vim @@ -9,10 +9,6 @@ " See http://sam.zoy.org/wtfpl/COPYING for more details. " "============================================================================ -if exists("loaded_z80_syntax_checker") - finish -endif -let loaded_z80_syntax_checker = 1 "bail if the user doesnt have z80_syntax_checker.py installed "To obtain this application there are two solutions: diff --git a/syntax_checkers/zpt.vim b/syntax_checkers/zpt.vim index 0b0063bf..7696f155 100644 --- a/syntax_checkers/zpt.vim +++ b/syntax_checkers/zpt.vim @@ -19,11 +19,6 @@ " Then install the zptlint program, found on pypi: " http://pypi.python.org/pypi/zptlint -if exists("loaded_zpt_syntax_checker") - finish -endif -let loaded_zpt_syntax_checker = 1 - " Bail if the user doesn't have zptlint installed if !executable("zptlint") finish diff --git a/syntax_checkers/go/6g.vim b/syntax_checkers/zsh.vim similarity index 68% rename from syntax_checkers/go/6g.vim rename to syntax_checkers/zsh.vim index 1a4249ed..832c204a 100644 --- a/syntax_checkers/go/6g.vim +++ b/syntax_checkers/zsh.vim @@ -1,7 +1,7 @@ "============================================================================ -"File: 6g.vim +"File: zsh.vim "Description: Syntax checking plugin for syntastic.vim -"Maintainer: Sam Nguyen +"Maintainer: Martin Grenfell "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 @@ -9,9 +9,14 @@ " See http://sam.zoy.org/wtfpl/COPYING for more details. " "============================================================================ -function! SyntaxCheckers_go_GetLocList() - let makeprg = '6g -o /dev/null %' - let errorformat = '%E%f:%l: %m' - return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat }) +"bail if the user doesnt have zsh installed +if !executable("zsh") + finish +endif + +function! SyntaxCheckers_zsh_GetLocList() + let makeprg = 'zsh -n ' . shellescape(expand('%')) + let errorformat = '%f:%l: %m' + return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat}) endfunction