diff --git a/README.markdown b/README.markdown index d46b57d4..fb8423ef 100644 --- a/README.markdown +++ b/README.markdown @@ -25,14 +25,17 @@ demand, or automatically as files are saved. If syntax errors are detected, the user is notified and is happy because they didn't have to compile their code or execute their script to find them. -At the time of this writing, syntax checking plugins exist for ada, applescript, c, co, -coffee, coq, cpp, cs, css, cucumber, cuda, d, dart, docbk, elixir, erlang, eruby, fortran, -gentoo_metadata, go, haml, haskell, haxe, html, java, javascript, json, less, lisp, lua, matlab, -nasm, objc, ocaml, perl, php, puppet, python, rst, ruby, rust, sass/scss, scala, sh, slim, tcl, tex, -twig, typescript, vala, vhdl, xhtml, xml, xslt, yaml, z80, zpt, zsh +At the time of this writing, syntax checking plugins exist for Ada, +AppleScript, Bourne shell, C, C++, C#, CoffeeScript, Coco, Coq, CSS, +Cucumber, CUDA, D, Dart, DocBook, Elixir, Erlang, eRuby, Fortran, Gentoo +metadata, Go, Haml, Haskell, Haxe, HTML, Java, JavaScript, JSON, LESS, +LISP, LLVM intermediate language, Lua, MATLAB, NASM, Objective-C, +Objective-C++, OCaml, Perl, Perl POD, PHP, Puppet, Python, +reStructuredText, Ruby, Rust, SASS/SCSS, Scala, Slim, Tcl, TeX, Twig, +TypeScript, Vala, VHDL, xHtml, XML, XSLT, YAML, z80, Zope page +templates, zsh. -Screenshot ----------- +## Screenshot Below is a screenshot showing the methods that Syntastic uses to display syntax errors. Note that, in practise, you will only have a subset of these methods @@ -47,14 +50,12 @@ enabled. 5. Hover the mouse over a line containing an error and the error message is displayed as a balloon. 6. (not shown) Highlighting errors with syntax highlighting. Erroneous parts of lines can be highlighted. -Installation ------------- +## Installation 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 ----------------------------- +### 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 @@ -66,10 +67,9 @@ and the directories it needs: Next you *need to add this* to your ~/.vimrc: - call pathogen#infect() + execute pathogen#infect() -Step 2: Install syntastic as a pathogen bundle ----------------------------------------------- +### Step 2: Install syntastic as a pathogen bundle You now have pathogen installed and can put syntastic into ~/.vim/bundle like this: @@ -90,16 +90,14 @@ step 1 and make sure you did the following: 4. Have permissions to access all of these directories. -Google group ------------- +## Google group To get information or make suggestions check out the [google group](https://groups.google.com/group/vim-syntastic). -FAQ ---- +## FAQ -__Q. I installed syntastic but it isn't reporting any errors ...__ +__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`. Note that aliases do not work; the actual executable must be available in your `$PATH`. Symbolic links are okay. @@ -113,35 +111,47 @@ e.g. Previously there was `g:syntastic_phpcs_conf`, now you must use `g:syntasti See `:help syntastic-checker-options` for more information. +__Q. I run a chacker and the location list is not updated...__ + +A. By default, the location list is changed only when you run the `:Errors` command, in order to minimise conflicts with other plugins. If you want the location list to always be updated when you run the checkers, add this line to your vimrc: +```vim +let g:syntastic_always_populate_loc_list=1 +``` + __Q. How can I pass additional arguments to a checker?__ A. Almost all syntax checkers use the `syntastic#makeprg#build()` function. Those checkers that do can be configured using global variables. The general form of the global args variables are: - -`syntastic_[filetype]_[subchecker]_args` +```vim +syntastic_[filetype]_[subchecker]_args +``` So, If you wanted to pass "--my --args --here" to the ruby mri checker you would add this line to your vimrc: - -`let g:syntastic_ruby_mri_args="--my --args --here"` +```vim +let g:syntastic_ruby_mri_args="--my --args --here" +``` See `:help syntastic-checker-options` for more information. __Q. Syntastic supports several checkers for my filetype - how do I tell it which one(s) to use?__ A. Stick a line like this in your vimrc: - -`let g:syntastic__checkers=['']` +```vim +let g:syntastic__checkers=[''] +``` To see the list of checkers for your filetype, look in `syntax_checkers//`. e.g. Python has the following checkers: `flake8`, `pyflakes`, `pylint` and a native `python` checker. To tell syntastic to use `pylint`, you would use this setting: - -`let g:syntastic_python_checkers=['pylint']` +```vim +let g:syntastic_python_checkers=['pylint'] +``` Some filetypes, like PHP, have style checkers as well as syntax checkers. These can be chained together like this: - -`let g:syntastic_php_checkers=['php', 'phpcs', 'phpmd']` +```vim +let g:syntastic_php_checkers=['php', 'phpcs', 'phpmd'] +``` This is telling syntastic to run the `php` checker first, and if no errors are found, run `phpcs`, and then `phpmd`. @@ -149,11 +159,11 @@ __Q. How can I jump between the different errors without using the location list 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). +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. +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 [wiki](https://github.com/scrooloose/syntastic/wiki/Syntaxcheckers) to see what options are available. __Q. The error window is closed automatically when I :quit the current buffer but not when I :bdelete it?__ diff --git a/autoload/syntastic/util.vim b/autoload/syntastic/util.vim index e68f6c95..4e777b3d 100644 --- a/autoload/syntastic/util.vim +++ b/autoload/syntastic/util.vim @@ -43,18 +43,20 @@ function! syntastic#util#parseShebang() return {'exe': '', 'args': []} endfunction -" Verify that the 'installed' version is at the 'required' version, if not -" better. +" Run 'command' in a shell and parse output as a version string. +" Returns an array of version components. +function! syntastic#util#parseVersion(command) + return split(matchstr( system(a:command), '\v^\D*\zs\d+(\.\d+)+\ze' ), '\.') +endfunction + +" Verify that the 'installed' version is at least the 'required' version. " -" 'installed' and 'required' must be arrays. Only the -" first three elements (major, minor, patch) are looked at. -" -" Either array may be less than three elements. The "missing" elements -" will be assumed to be '0' for the purposes of checking. +" 'installed' and 'required' must be arrays. If they have different lengths, +" the "missing" elements will be assumed to be 0 for the purposes of checking. " " See http://semver.org for info about version numbers. function! syntastic#util#versionIsAtLeast(installed, required) - for index in [0,1,2] + for index in range(max([len(a:installed), len(a:required)])) if len(a:installed) <= index let installed_element = 0 else diff --git a/plugin/syntastic.vim b/plugin/syntastic.vim index 41c4a7d2..a03a5aed 100644 --- a/plugin/syntastic.vim +++ b/plugin/syntastic.vim @@ -133,9 +133,9 @@ function! s:UpdateErrors(auto_invoked, ...) let loclist = g:SyntasticLoclist.current() call s:notifiers.refresh(loclist) - if (g:syntastic_always_populate_loc_list || g:syntastic_auto_jump) && loclist.hasErrorsOrWarningsToDisplay() + if g:syntastic_always_populate_loc_list || g:syntastic_auto_jump call setloclist(0, loclist.filteredRaw()) - if g:syntastic_auto_jump + if g:syntastic_auto_jump && loclist.hasErrorsOrWarningsToDisplay() silent! lrewind endif endif @@ -354,7 +354,11 @@ function! SyntasticMake(options) endif " Apply ignore patterns - call filter(errors, '!s:IgnoreFile(bufname(str2nr(v:val["bufnr"])))') + let ignore = {} + for buf in syntastic#util#unique(map(copy(errors), 'v:val["bufnr"]')) + let ignore[buf] = s:IgnoreFile(bufname(str2nr(buf))) + endfor + call filter(errors, '!ignore[v:val["bufnr"]]') " Add subtype info if present. if has_key(a:options, 'subtype') diff --git a/plugin/syntastic/loclist.vim b/plugin/syntastic/loclist.vim index 1b9b5391..2dd0bd5a 100644 --- a/plugin/syntastic/loclist.vim +++ b/plugin/syntastic/loclist.vim @@ -133,8 +133,8 @@ endfunction "display the cached errors for this buf in the location list function! g:SyntasticLoclist.show() + call setloclist(0, self.filteredRaw()) if self.hasErrorsOrWarningsToDisplay() - call setloclist(0, self.filteredRaw()) let num = winnr() exec "lopen " . g:syntastic_loc_list_height if num != winnr() diff --git a/plugin/syntastic/registry.vim b/plugin/syntastic/registry.vim index 5fc01b65..07495f08 100644 --- a/plugin/syntastic/registry.vim +++ b/plugin/syntastic/registry.vim @@ -9,7 +9,11 @@ let s:defaultCheckers = { \ 'cpp': ['gcc'], \ 'html': ['tidy'], \ 'java': ['javac'], + \ 'javascript': ['jshint', 'jslint'], \ 'objc': ['gcc'], + \ 'objcpp': ['gcc'], + \ 'perl': ['perl'], + \ 'python': ['python', 'flake8', 'pylint'], \ 'php': ['php', 'phpcs', 'phpmd'], \ 'ruby': ['mri'] \ } diff --git a/syntax_checkers/c/checkpatch.vim b/syntax_checkers/c/checkpatch.vim index 90745ef7..15066bac 100644 --- a/syntax_checkers/c/checkpatch.vim +++ b/syntax_checkers/c/checkpatch.vim @@ -1,6 +1,6 @@ "============================================================================ "File: checkpatch.vim -"Description: Syntax checking plugin for syntastic.vim using checkpatch.pl +"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 @@ -8,10 +8,10 @@ " 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") +if exists("g:loaded_syntastic_c_checkpatch_checker") finish endif -let loaded_checkpatch_syntax_checker = 1 +let g:loaded_syntastic_c_checkpatch_checker = 1 " Bail if the user doesn't have `checkpatch.pl` or ./scripts/checkpatch.pl installed. if executable("checkpatch.pl") diff --git a/syntax_checkers/c/make.vim b/syntax_checkers/c/make.vim index 68557ac7..a0ccbf61 100644 --- a/syntax_checkers/c/make.vim +++ b/syntax_checkers/c/make.vim @@ -10,10 +10,10 @@ " "============================================================================ -if exists('loaded_make_syntax_checker') +if exists('g:loaded_syntastic_c_make_checker') finish endif -let loaded_make_syntax_checker = 1 +let g:loaded_syntastic_c_make_checker = 1 function SyntaxCheckers_c_make_IsAvailable() return executable('make') diff --git a/syntax_checkers/c/oclint.vim b/syntax_checkers/c/oclint.vim new file mode 100644 index 00000000..f51c5494 --- /dev/null +++ b/syntax_checkers/c/oclint.vim @@ -0,0 +1,57 @@ +"============================================================================ +"File: oclint.vim +"Description: Syntax checking plugin for syntastic.vim +"Maintainer: "UnCO" Lin +"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. +"============================================================================ +" +" The setting 'g:syntastic_oclint_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_oclint_config': +" +" let g:syntastic_oclint_config_file = '.config' + +if exists("g:loaded_syntastic_c_oclint_checker") + finish +endif +let g:loaded_syntastic_c_oclint_checker = 1 + +function! SyntaxCheckers_c_oclint_IsAvailable() + return executable("oclint") +endfunction + +if !exists('g:syntastic_oclint_config_file') + let g:syntastic_oclint_config_file = '.syntastic_oclint_config' +endif + +function! SyntaxCheckers_c_oclint_GetLocList() + let makeprg = syntastic#makeprg#build({ + \ 'exe': 'oclint', + \ 'args': '-text', + \ 'post_args': '-- -c' . syntastic#c#ReadConfig(g:syntastic_oclint_config_file), + \ 'subchecker': 'oclint' }) + + let errorformat = + \ '%E%f:%l:%c: %m P1 ,' . + \ '%E%f:%l:%c: %m P2 ,' . + \ '%W%f:%l:%c: %m P3 ,' . + \ '%E%f:%l:%c: fatal error: %m,' . + \ '%E%f:%l:%c: error: %m,' . + \ '%W%f:%l:%c: warning: %m,' . + \ '%-G%.%#' + + return SyntasticMake({ + \ 'makeprg': makeprg, + \ 'errorformat': errorformat, + \ 'subtype': 'Style', + \ 'postprocess': ['compressWhitespace', 'sort'] }) +endfunction + +call g:SyntasticRegistry.CreateAndRegisterChecker({ + \ 'filetype': 'c', + \ 'name': 'oclint'}) diff --git a/syntax_checkers/c/sparse.vim b/syntax_checkers/c/sparse.vim index 5db60241..f4d0013b 100644 --- a/syntax_checkers/c/sparse.vim +++ b/syntax_checkers/c/sparse.vim @@ -16,10 +16,10 @@ " " let g:syntastic_sparse_config_file = '.config' -if exists("loaded_sparse_syntax_checker") +if exists("g:loaded_syntastic_c_sparse_checker") finish endif -let loaded_sparse_syntax_checker = 1 +let g:loaded_syntastic_c_sparse_checker = 1 function! SyntaxCheckers_c_sparse_IsAvailable() return executable("sparse") diff --git a/syntax_checkers/c/splint.vim b/syntax_checkers/c/splint.vim index e71349e0..3fa92a7a 100644 --- a/syntax_checkers/c/splint.vim +++ b/syntax_checkers/c/splint.vim @@ -16,10 +16,10 @@ " " let g:syntastic_splint_config_file = '.config' -if exists("loaded_splint_syntax_checker") +if exists("g:loaded_syntastic_c_splint_checker") finish endif -let loaded_splint_syntax_checker = 1 +let g:loaded_syntastic_c_splint_checker = 1 function! SyntaxCheckers_c_splint_IsAvailable() return executable("splint") diff --git a/syntax_checkers/c/ycm.vim b/syntax_checkers/c/ycm.vim index bc35b7cf..5cce6fc5 100644 --- a/syntax_checkers/c/ycm.vim +++ b/syntax_checkers/c/ycm.vim @@ -10,10 +10,10 @@ " "============================================================================ -if exists("loaded_ycm_c_syntax_checker") +if exists("g:loaded_syntastic_c_ycm_checker") finish endif -let loaded_ycm_c_syntax_checker = 1 +let g:loaded_syntastic_c_ycm_checker = 1 function! SyntaxCheckers_c_ycm_IsAvailable() return exists('g:loaded_youcompleteme') diff --git a/syntax_checkers/coffee/coffee.vim b/syntax_checkers/coffee/coffee.vim index 039db208..aa965bb6 100644 --- a/syntax_checkers/coffee/coffee.vim +++ b/syntax_checkers/coffee/coffee.vim @@ -21,7 +21,6 @@ endfunction function! SyntaxCheckers_coffee_coffee_GetLocList() let makeprg = syntastic#makeprg#build({ \ 'exe': 'coffee', - \ 'args': '--lint', \ 'subchecker': 'coffee' }) let errorformat = \ '%E%f:%l:%c: %trror: %m,' . diff --git a/syntax_checkers/cpp/oclint.vim b/syntax_checkers/cpp/oclint.vim new file mode 100644 index 00000000..1586d835 --- /dev/null +++ b/syntax_checkers/cpp/oclint.vim @@ -0,0 +1,36 @@ +"============================================================================ +"File: oclint.vim +"Description: Syntax checking plugin for syntastic.vim +"Maintainer: "UnCO" Lin +"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. +"============================================================================ +" +" The setting 'g:syntastic_oclint_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_oclint_config': +" +" let g:syntastic_oclint_config_file = '.config' + +if exists("g:loaded_syntastic_cpp_oclint_checker") + finish +endif +let g:loaded_syntastic_cpp_oclint_checker = 1 + +runtime syntax_checkers/c/oclint.vim + +function! SyntaxCheckers_cpp_oclint_IsAvailable() + return SyntaxCheckers_c_oclint_IsAvailable() +endfunction + +function! SyntaxCheckers_cpp_oclint_GetLocList() + return SyntaxCheckers_c_oclint_GetLocList() +endfunction + +call g:SyntasticRegistry.CreateAndRegisterChecker({ + \ 'filetype': 'cpp', + \ 'name': 'oclint'}) diff --git a/syntax_checkers/cpp/ycm.vim b/syntax_checkers/cpp/ycm.vim index 97827a08..f7c19e95 100644 --- a/syntax_checkers/cpp/ycm.vim +++ b/syntax_checkers/cpp/ycm.vim @@ -10,10 +10,10 @@ " "============================================================================ -if exists("loaded_ycm_cpp_syntax_checker") +if exists("g:loaded_syntastic_cpp_ycm_checker") finish endif -let loaded_ycm_cpp_syntax_checker = 1 +let g:loaded_syntastic_cpp_ycm_checker = 1 runtime syntax_checkers/c/ycm.vim diff --git a/syntax_checkers/javascript/jshint.vim b/syntax_checkers/javascript/jshint.vim index 0101a701..9b10c180 100644 --- a/syntax_checkers/javascript/jshint.vim +++ b/syntax_checkers/javascript/jshint.vim @@ -36,8 +36,7 @@ function! SyntaxCheckers_javascript_jshint_GetLocList() endfunction function s:JshintNew() - let ver = matchlist(system('jshint --version'), '^\D*\(\d\+\)\.\(\d\+\)') - return (ver[1] > 1 || (ver[1] == 1 && ver[2] >= 1)) + return syntastic#util#versionIsAtLeast(syntastic#util#parseVersion('jshint --version'), [1, 1]) endfunction function s:Args() diff --git a/syntax_checkers/objc/oclint.vim b/syntax_checkers/objc/oclint.vim new file mode 100644 index 00000000..59a3996b --- /dev/null +++ b/syntax_checkers/objc/oclint.vim @@ -0,0 +1,36 @@ +"============================================================================ +"File: oclint.vim +"Description: Syntax checking plugin for syntastic.vim +"Maintainer: "UnCO" Lin +"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. +"============================================================================ +" +" The setting 'g:syntastic_oclint_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_oclint_config': +" +" let g:syntastic_oclint_config_file = '.config' + +if exists("g:loaded_syntastic_objc_oclint_checker") + finish +endif +let g:loaded_syntastic_objc_oclint_checker = 1 + +runtime syntax_checkers/c/oclint.vim + +function! SyntaxCheckers_objc_oclint_IsAvailable() + return SyntaxCheckers_c_oclint_IsAvailable() +endfunction + +function! SyntaxCheckers_objc_oclint_GetLocList() + return SyntaxCheckers_c_oclint_GetLocList() +endfunction + +call g:SyntasticRegistry.CreateAndRegisterChecker({ + \ 'filetype': 'objc', + \ 'name': 'oclint'}) diff --git a/syntax_checkers/objc/ycm.vim b/syntax_checkers/objc/ycm.vim index 1406dd83..a2250a3c 100644 --- a/syntax_checkers/objc/ycm.vim +++ b/syntax_checkers/objc/ycm.vim @@ -10,10 +10,10 @@ " "============================================================================ -if exists("loaded_ycm_objc_syntax_checker") +if exists("g:loaded_syntastic_objc_ycm_checker") finish endif -let loaded_ycm_objc_syntax_checker = 1 +let g:loaded_syntastic_objc_ycm_checker = 1 runtime syntax_checkers/c/ycm.vim diff --git a/syntax_checkers/objcpp/oclint.vim b/syntax_checkers/objcpp/oclint.vim new file mode 100644 index 00000000..9a02abb7 --- /dev/null +++ b/syntax_checkers/objcpp/oclint.vim @@ -0,0 +1,36 @@ +"============================================================================ +"File: oclint.vim +"Description: Syntax checking plugin for syntastic.vim +"Maintainer: "UnCO" Lin +"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. +"============================================================================ +" +" The setting 'g:syntastic_oclint_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_oclint_config': +" +" let g:syntastic_oclint_config_file = '.config' + +if exists("g:loaded_syntastic_objcpp_oclint_checker") + finish +endif +let g:loaded_syntastic_objcpp_oclint_checker = 1 + +runtime syntax_checkers/c/oclint.vim + +function! SyntaxCheckers_objcpp_oclint_IsAvailable() + return SyntaxCheckers_c_oclint_IsAvailable() +endfunction + +function! SyntaxCheckers_objcpp_oclint_GetLocList() + return SyntaxCheckers_c_oclint_GetLocList() +endfunction + +call g:SyntasticRegistry.CreateAndRegisterChecker({ + \ 'filetype': 'objcpp', + \ 'name': 'oclint'}) diff --git a/syntax_checkers/objcpp/ycm.vim b/syntax_checkers/objcpp/ycm.vim index 785a1994..14f73517 100644 --- a/syntax_checkers/objcpp/ycm.vim +++ b/syntax_checkers/objcpp/ycm.vim @@ -10,10 +10,10 @@ " "============================================================================ -if exists("loaded_ycm_objcpp_syntax_checker") +if exists("g:loaded_syntastic_objcpp_ycm_checker") finish endif -let loaded_ycm_objcpp_syntax_checker = 1 +let g:loaded_syntastic_objcpp_ycm_checker = 1 runtime syntax_checkers/c/ycm.vim diff --git a/syntax_checkers/puppet/puppetlint.vim b/syntax_checkers/puppet/puppetlint.vim index 72173859..32ccd901 100644 --- a/syntax_checkers/puppet/puppetlint.vim +++ b/syntax_checkers/puppet/puppetlint.vim @@ -33,19 +33,14 @@ endif 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, '\.') + let s:puppet_version = syntastic#util#parseVersion("puppet --version 2>/dev/null") endif return s:puppet_version endfunction 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, '\.') + let s:puppet_lint_version = syntastic#util#parseVersion("puppet-lint --version 2>/dev/null") endif return s:puppet_lint_version endfunction diff --git a/syntax_checkers/slim/slimrb.vim b/syntax_checkers/slim/slimrb.vim index d9c5849b..34220337 100644 --- a/syntax_checkers/slim/slimrb.vim +++ b/syntax_checkers/slim/slimrb.vim @@ -21,19 +21,16 @@ endfunction 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, '\.') + let s:slimrb_version = syntastic#util#parseVersion('slimrb --version 2>/dev/null') end return s:slimrb_version endfunction function! SyntaxCheckers_slim_slimrb_GetLocList() let makeprg = syntastic#makeprg#build({ - \ 'exe': 'slimrb', - \ 'args': '-c', - \ 'subchecker': 'slimrb' }) + \ 'exe': 'slimrb', + \ 'args': '-c', + \ 'subchecker': 'slimrb' }) if syntastic#util#versionIsAtLeast(s:SlimrbVersion(), [1,3,1]) let errorformat = \ '%C\ %#%f\, Line %l\, Column %c,'. diff --git a/syntax_checkers/text/atdtool.vim b/syntax_checkers/text/atdtool.vim new file mode 100644 index 00000000..0a687b2a --- /dev/null +++ b/syntax_checkers/text/atdtool.vim @@ -0,0 +1,50 @@ +"============================================================================ +"File: atdtool.vim +"Description: Syntax checking plugin for syntastic.vim +"Maintainer: LCD 47 +"License: This program is free software. It comes without any warranty, +" to the extent permitted by applicable law. You can redistribute +" it and/or modify it under the terms of the Do What The Fuck You +" Want To Public License, Version 2, as published by Sam Hocevar. +" See http://sam.zoy.org/wtfpl/COPYING for more details. +" +"============================================================================ + +if exists("g:loaded_syntastic_text_atdtool_checker") + finish +endif +let g:loaded_syntastic_text_atdtool_checker = 1 + +function! SyntaxCheckers_text_atdtool_IsAvailable() + return executable('atdtool') +endfunction + +function! SyntaxCheckers_text_atdtool_GetHighlightRegex(item) + return matchstr(a:item['text'], '\m "\zs[^"]\+\ze"\($\| | suggestions:\)') +endfunction + +function! SyntaxCheckers_text_atdtool_GetLocList() + let makeprg = syntastic#makeprg#build({ + \ 'exe': 'atdtool', + \ 'tail': '2>/dev/null', + \ 'subchecker': 'atdtool' }) + + let errorformat = + \ '%W%f:%l:%c: %m,'. + \ '%+C suggestions:%.%#' + + let loclist = SyntasticMake({ + \ 'makeprg': makeprg, + \ 'errorformat': errorformat, + \ 'subtype': 'Style' }) + + for n in range(len(loclist)) + let loclist[n]['text'] = substitute(loclist[n]['text'], '\n\s\+', ' | ', 'g') + endfor + + return loclist +endfunction + +call g:SyntasticRegistry.CreateAndRegisterChecker({ + \ 'filetype': 'text', + \ 'name': 'atdtool'}) diff --git a/syntax_checkers/vala/valac.vim b/syntax_checkers/vala/valac.vim index a7457235..b4ede28a 100644 --- a/syntax_checkers/vala/valac.vim +++ b/syntax_checkers/vala/valac.vim @@ -22,6 +22,11 @@ " "============================================================================ +if exists("g:loaded_syntastic_vala_valac_checker") + finish +endif +let g:loaded_syntastic_vala_valac_checker = 1 + function! SyntaxCheckers_vala_valac_IsAvailable() return executable('valac') endfunction diff --git a/syntax_checkers/vhdl/ghdl.vim b/syntax_checkers/vhdl/ghdl.vim index 57faa9de..4c7a39f7 100644 --- a/syntax_checkers/vhdl/ghdl.vim +++ b/syntax_checkers/vhdl/ghdl.vim @@ -9,10 +9,10 @@ " See http://sam.zoy.org/wtfpl/COPYING for more details. " "============================================================================ -if exists("loaded_vhdl_ghdl_syntax_checker") +if exists("g:loaded_syntastic_vhdl_ghdl_checker") finish endif -let loaded_vhdl_ghdl_syntax_checker = 1 +let g:loaded_syntastic_vhdl_ghdl_checker = 1 function! SyntaxCheckers_vhdl_ghdl_IsAvailable() return executable("ghdl")