Permalink
Browse files

Add the Syntastic syntax-checking plugin, from https://github.com/scr…

  • Loading branch information...
1 parent 6832c45 commit 6074fcde417ebd71f085fc7bbf4e6202f81306a7 @matzko committed Sep 6, 2012
Showing with 4,721 additions and 0 deletions.
  1. +160 −0 bundle/syntastic/README.markdown
  2. BIN bundle/syntastic/_assets/screenshot_1.png
  3. +234 −0 bundle/syntastic/autoload/syntastic/c.vim
  4. +588 −0 bundle/syntastic/doc/syntastic.txt
  5. +655 −0 bundle/syntastic/plugin/syntastic.vim
  6. +132 −0 bundle/syntastic/syntax_checkers/ada.vim
  7. +43 −0 bundle/syntastic/syntax_checkers/applescript.vim
  8. +158 −0 bundle/syntastic/syntax_checkers/c.vim
  9. +27 −0 bundle/syntastic/syntax_checkers/co.vim
  10. +49 −0 bundle/syntastic/syntax_checkers/coffee.vim
  11. +154 −0 bundle/syntastic/syntax_checkers/cpp.vim
  12. +42 −0 bundle/syntastic/syntax_checkers/css.vim
  13. +27 −0 bundle/syntastic/syntax_checkers/cucumber.vim
  14. +49 −0 bundle/syntastic/syntax_checkers/cuda.vim
  15. +140 −0 bundle/syntastic/syntax_checkers/d.vim
  16. +29 −0 bundle/syntastic/syntax_checkers/docbk.vim
  17. +175 −0 bundle/syntastic/syntax_checkers/efm_perl.pl
  18. +42 −0 bundle/syntastic/syntax_checkers/erlang.vim
  19. +12 −0 bundle/syntastic/syntax_checkers/erlang_check_file.erl
  20. +34 −0 bundle/syntastic/syntax_checkers/eruby.vim
  21. +44 −0 bundle/syntastic/syntax_checkers/fortran.vim
  22. +37 −0 bundle/syntastic/syntax_checkers/gentoo_metadata.vim
  23. +22 −0 bundle/syntastic/syntax_checkers/go.vim
  24. +17 −0 bundle/syntastic/syntax_checkers/go/6g.vim
  25. +17 −0 bundle/syntastic/syntax_checkers/go/go.vim
  26. +16 −0 bundle/syntastic/syntax_checkers/go/gofmt.vim
  27. +26 −0 bundle/syntastic/syntax_checkers/haml.vim
  28. +42 −0 bundle/syntastic/syntax_checkers/haskell.vim
  29. +55 −0 bundle/syntastic/syntax_checkers/haxe.vim
  30. +29 −0 bundle/syntastic/syntax_checkers/html.vim
  31. +74 −0 bundle/syntastic/syntax_checkers/html/tidy.vim
  32. +32 −0 bundle/syntastic/syntax_checkers/html/w3.vim
  33. +28 −0 bundle/syntastic/syntax_checkers/java.vim
  34. +23 −0 bundle/syntastic/syntax_checkers/javascript.vim
  35. +43 −0 bundle/syntastic/syntax_checkers/javascript/closurecompiler.vim
  36. +20 −0 bundle/syntastic/syntax_checkers/javascript/gjslint.vim
  37. +21 −0 bundle/syntastic/syntax_checkers/javascript/jshint.vim
  38. +20 −0 bundle/syntastic/syntax_checkers/javascript/jsl.vim
  39. +28 −0 bundle/syntastic/syntax_checkers/javascript/jslint.vim
  40. +23 −0 bundle/syntastic/syntax_checkers/json.vim
  41. +16 −0 bundle/syntastic/syntax_checkers/json/jsonlint.vim
  42. +17 −0 bundle/syntastic/syntax_checkers/json/jsonval.vim
  43. +38 −0 bundle/syntastic/syntax_checkers/less.vim
  44. +31 −0 bundle/syntastic/syntax_checkers/lisp.vim
  45. +55 −0 bundle/syntastic/syntax_checkers/lua.vim
  46. +28 −0 bundle/syntastic/syntax_checkers/matlab.vim
  47. +32 −0 bundle/syntastic/syntax_checkers/nasm.vim
  48. +145 −0 bundle/syntastic/syntax_checkers/ocaml.vim
  49. +50 −0 bundle/syntastic/syntax_checkers/perl.vim
  50. +58 −0 bundle/syntastic/syntax_checkers/php.vim
  51. +120 −0 bundle/syntastic/syntax_checkers/puppet.vim
  52. +27 −0 bundle/syntastic/syntax_checkers/python.vim
  53. +28 −0 bundle/syntastic/syntax_checkers/python/flake8.vim
  54. +34 −0 bundle/syntastic/syntax_checkers/python/pyflakes.vim
  55. +14 −0 bundle/syntastic/syntax_checkers/python/pylint.vim
  56. +37 −0 bundle/syntastic/syntax_checkers/rst.vim
  57. +34 −0 bundle/syntastic/syntax_checkers/ruby.vim
  58. +21 −0 bundle/syntastic/syntax_checkers/ruby/jruby.vim
  59. +15 −0 bundle/syntastic/syntax_checkers/ruby/macruby.vim
  60. +29 −0 bundle/syntastic/syntax_checkers/ruby/mri.vim
  61. +33 −0 bundle/syntastic/syntax_checkers/rust.vim
  62. +35 −0 bundle/syntastic/syntax_checkers/sass.vim
  63. +33 −0 bundle/syntastic/syntax_checkers/scala.vim
  64. +27 −0 bundle/syntastic/syntax_checkers/scss.vim
  65. +52 −0 bundle/syntastic/syntax_checkers/sh.vim
  66. +28 −0 bundle/syntastic/syntax_checkers/tcl.vim
  67. +26 −0 bundle/syntastic/syntax_checkers/tex.vim
  68. +68 −0 bundle/syntastic/syntax_checkers/vala.vim
  69. +46 −0 bundle/syntastic/syntax_checkers/xhtml.vim
  70. +42 −0 bundle/syntastic/syntax_checkers/xml.vim
  71. +38 −0 bundle/syntastic/syntax_checkers/xslt.vim
  72. +30 −0 bundle/syntastic/syntax_checkers/yaml.vim
  73. +31 −0 bundle/syntastic/syntax_checkers/z80.vim
  74. +36 −0 bundle/syntastic/syntax_checkers/zpt.vim
@@ -0,0 +1,160 @@
+ ,
+ / \,,_ .'|
+ ,{{| /}}}}/_.' _____________________________________________
+ }}}}` '{{' '. / \
+ {{{{{ _ ;, \ / Gentlemen, \
+ ,}}}}}} /o`\ ` ;) | |
+ {{{{{{ / ( | this is ... |
+ }}}}}} | \ | |
+ {{{{{{{{ \ \ | |
+ }}}}}}}}} '.__ _ | | _____ __ __ _ |
+ {{{{{{{{ /`._ (_\ / | / ___/__ ______ / /_____ ______/ /_(_)____ |
+ }}}}}}' | //___/ --=: \__ \/ / / / __ \/ __/ __ `/ ___/ __/ / ___/ |
+ jgs `{{{{` | '--' | ___/ / /_/ / / / / /_/ /_/ (__ ) /_/ / /__ |
+ }}}` | /____/\__, /_/ /_/\__/\__,_/____/\__/_/\___/ |
+ | /____/ |
+ | /
+ \_____________________________________________/
+
+
+
+
+Syntastic is a syntax checking plugin that runs files through external syntax
+checkers and displays any resulting errors to the user. This can be done on
+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 applescript, c,
+coffee, cpp, css, cucumber, cuda, docbk, erlang, eruby, fortran,
+gentoo_metadata, go, haml, haskell, html, javascript, json, less, lua, matlab,
+perl, php, puppet, python, rst, ruby, sass/scss, sh, tcl, tex, vala, xhtml,
+xml, xslt, yaml, zpt
+
+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
+enabled.
+
+![Screenshot 1](https://github.com/scrooloose/syntastic/raw/master/_assets/screenshot_1.png)
+
+1. Errors are loaded into the location list for the corresponding window.
+2. When the cursor is on a line containing an error, the error message is echoed in the command window.
+3. Signs are placed beside lines with errors - note that warnings are displayed in a different color.
+4. There is a configurable statusline flag you can include in your statusline config.
+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
+------------
+
+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
+
+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
+------------
+
+To get information or make suggestions check out the [google group](https://groups.google.com/group/vim-syntastic).
+
+
+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/<filetype>.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 serveral 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 [unimpared](https://github.com/tpope/vim-unimpaired) - which provides such mappings (among other things).
+
+Changelog
+---------
+2.3.0 (16-feb-2012)
+
+ * Add syntastic_loc_list_height option
+ * Allow errors to have a "subtype" that is signed differently to standard
+ errors. Currently geared towards differentiating style errors from
+ syntax errors. Currently implemented for phpcs (technosophos).
+ * New checkers for:
+ * yaml
+ * haxe (davidB)
+ * ocaml (edwintorok)
+ * pylint (parantapa)
+ * rust (cjab)
+ * Updates to existing checkers:
+ * jslint
+ * jshint (gillesruppert)
+ * fortran (bmattern)
+ * sass
+ * html (darcyparker)
+ * coffee (darcyparker)
+ * docbk (darcyparker)
+ * xml
+ * xslt
+ * less (irrationalfab)
+ * php (AD7six, technosophos)
+ * cuda
+ * python (mitchellh, pneff)
+ * perl (Anthony Carapetis)
+ * c (naoina, zsprackett)
+ * puppet (frimik)
+
+2.2.0 (24-dec-2011)
+
+ * only do syntax checks when files are saved (not when first opened) - add g:syntastic_check_on_open option to get the old behavior back
+ * bug fix with echoing error messages; fixes incompatability with cmd-t (datanoise)
+ * dont allow warnings to mask errors when signing/echoing errors (ashikase)
+ * auto close location list when leaving buffer. (millermedeiros)
+ * update errors appropriately when :SyntasticToggleMode is called
+ * updates/fixes to existing checkers:
+ * javascript/jshint (millermedeiros)
+ * javascript/jslint
+ * c (kongo2002)
+ * Support for new filetypes:
+ * JSON (millermedeiros, tocer)
+ * rst (reStructuredText files) (JNRowe)
+ * gentoo-metadata (JNRowe)
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1,234 @@
+if exists("g:loaded_syntastic_c_autoload")
+ finish
+endif
+let g:loaded_syntastic_c_autoload = 1
+
+let s:save_cpo = &cpo
+set cpo&vim
+
+" initialize c/cpp syntax checker handlers
+function! s:Init()
+ let s:handlers = []
+ let s:cflags = {}
+
+ call s:RegHandler('gtk', 'syntastic#c#CheckPKG',
+ \ ['gtk', 'gtk+-2.0', 'gtk+', 'glib-2.0', 'glib'])
+ call s:RegHandler('glib', 'syntastic#c#CheckPKG',
+ \ ['glib', 'glib-2.0', 'glib'])
+ call s:RegHandler('glade', 'syntastic#c#CheckPKG',
+ \ ['glade', 'libglade-2.0', 'libglade'])
+ call s:RegHandler('libsoup', 'syntastic#c#CheckPKG',
+ \ ['libsoup', 'libsoup-2.4', 'libsoup-2.2'])
+ call s:RegHandler('webkit', 'syntastic#c#CheckPKG',
+ \ ['webkit', 'webkit-1.0'])
+ call s:RegHandler('cairo', 'syntastic#c#CheckPKG',
+ \ ['cairo', 'cairo'])
+ call s:RegHandler('pango', 'syntastic#c#CheckPKG',
+ \ ['pango', 'pango'])
+ call s:RegHandler('libxml', 'syntastic#c#CheckPKG',
+ \ ['libxml', 'libxml-2.0', 'libxml'])
+ call s:RegHandler('freetype', 'syntastic#c#CheckPKG',
+ \ ['freetype', 'freetype2', 'freetype'])
+ call s:RegHandler('SDL', 'syntastic#c#CheckPKG',
+ \ ['sdl', 'sdl'])
+ call s:RegHandler('opengl', 'syntastic#c#CheckPKG',
+ \ ['opengl', 'gl'])
+ call s:RegHandler('ruby', 'syntastic#c#CheckRuby', [])
+ call s:RegHandler('Python\.h', 'syntastic#c#CheckPython', [])
+ call s:RegHandler('php\.h', 'syntastic#c#CheckPhp', [])
+endfunction
+
+" default include directories
+let s:default_includes = [ '.', '..', 'include', 'includes',
+ \ '../include', '../includes' ]
+
+" uniquify the input list
+function! s:Unique(list)
+ let l = []
+ for elem in a:list
+ if index(l, elem) == -1
+ let l = add(l, elem)
+ endif
+ endfor
+ return l
+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)
+
+ if exists('g:syntastic_'.a:filetype.'_include_dirs')
+ call extend(include_dirs, g:syntastic_{a:filetype}_include_dirs)
+ endif
+
+ return join(map(s:Unique(include_dirs), '"-I" . v:val'), ' ')
+endfunction
+
+" read additional compiler flags from the given configuration file
+" the file format and its parsing mechanism is inspired by clang_complete
+function! syntastic#c#ReadConfig(file)
+ " search in the current file's directory upwards
+ let config = findfile(a:file, '.;')
+ if config == '' || !filereadable(config) | return '' | endif
+
+ " convert filename into absolute path
+ let filepath = substitute(fnamemodify(config, ':p:h'), '\', '/', 'g')
+
+ " try to read config file
+ try
+ let lines = map(readfile(config),
+ \ 'substitute(v:val, ''\'', ''/'', ''g'')')
+ catch /E484/
+ return ''
+ endtry
+
+ let parameters = []
+ for line in lines
+ let matches = matchlist(line, '^\s*-I\s*\(\S\+\)')
+ if matches != [] && matches[1] != ''
+ " this one looks like an absolute path
+ if match(matches[1], '^\%(/\|\a:\)') != -1
+ call add(parameters, '-I' . matches[1])
+ else
+ call add(parameters, '-I' . filepath . '/' . matches[1])
+ endif
+ else
+ call add(parameters, line)
+ endif
+ endfor
+
+ return join(parameters, ' ')
+endfunction
+
+" search the first 100 lines for include statements that are
+" given in the handlers dictionary
+function! syntastic#c#SearchHeaders()
+ let includes = ''
+ let files = []
+ let found = []
+ let lines = filter(getline(1, 100), 'v:val =~# "#\s*include"')
+
+ " search current buffer
+ for line in lines
+ let file = matchstr(line, '"\zs\S\+\ze"')
+ if file != ''
+ call add(files, file)
+ continue
+ endif
+ for handler in s:handlers
+ if line =~# handler["regex"]
+ let includes .= call(handler["func"], handler["args"])
+ call add(found, handler["regex"])
+ break
+ endif
+ endfor
+ endfor
+
+ " search included headers
+ for hfile in files
+ if hfile != ''
+ let filename = expand('%:p:h') . (has('win32') ?
+ \ '\' : '/') . hfile
+ try
+ let lines = readfile(filename, '', 100)
+ catch /E484/
+ continue
+ endtry
+ let lines = filter(lines, 'v:val =~# "#\s*include"')
+ for handler in s:handlers
+ if index(found, handler["regex"]) != -1
+ continue
+ endif
+ for line in lines
+ if line =~# handler["regex"]
+ let includes .= call(handler["func"], handler["args"])
+ call add(found, handler["regex"])
+ break
+ endif
+ endfor
+ endfor
+ endif
+ endfor
+
+ return includes
+endfunction
+
+" try to find library with 'pkg-config'
+" search possible libraries from first to last given
+" argument until one is found
+function! syntastic#c#CheckPKG(name, ...)
+ if executable('pkg-config')
+ if !has_key(s:cflags, a:name)
+ for i in range(a:0)
+ let l:cflags = system('pkg-config --cflags '.a:000[i])
+ " since we cannot necessarily trust the pkg-config exit code
+ " we have to check for an error output as well
+ if v:shell_error == 0 && l:cflags !~? 'not found'
+ let l:cflags = ' '.substitute(l:cflags, "\n", '', '')
+ let s:cflags[a:name] = l:cflags
+ return l:cflags
+ endif
+ endfor
+ else
+ return s:cflags[a:name]
+ endif
+ endif
+ return ''
+endfunction
+
+" try to find PHP includes with 'php-config'
+function! syntastic#c#CheckPhp()
+ if executable('php-config')
+ if !exists('s:php_flags')
+ let s:php_flags = system('php-config --includes')
+ let s:php_flags = ' ' . substitute(s:php_flags, "\n", '', '')
+ endif
+ return s:php_flags
+ endif
+ return ''
+endfunction
+
+" try to find the ruby headers with 'rbconfig'
+function! syntastic#c#CheckRuby()
+ if executable('ruby')
+ if !exists('s:ruby_flags')
+ let s:ruby_flags = system('ruby -r rbconfig -e '
+ \ . '''puts Config::CONFIG["archdir"]''')
+ let s:ruby_flags = substitute(s:ruby_flags, "\n", '', '')
+ let s:ruby_flags = ' -I' . s:ruby_flags
+ endif
+ return s:ruby_flags
+ endif
+ return ''
+endfunction
+
+" try to find the python headers with distutils
+function! syntastic#c#CheckPython()
+ if executable('python')
+ if !exists('s:python_flags')
+ let s:python_flags = system('python -c ''from distutils import '
+ \ . 'sysconfig; import sys; sys.stdout.write(sysconfig.get_python_inc())''')
+ let s:python_flags = substitute(s:python_flags, "\n", '', '')
+ let s:python_flags = ' -I' . s:python_flags
+ endif
+ return s:python_flags
+ endif
+ return ''
+endfunction
+
+" return a handler dictionary object
+function! s:RegHandler(regex, function, args)
+ let handler = {}
+ let handler["regex"] = a:regex
+ let handler["func"] = function(a:function)
+ let handler["args"] = a:args
+ call add(s:handlers, handler)
+endfunction
+
+call s:Init()
+
+let &cpo = s:save_cpo
+unlet s:save_cpo
+
+" vim: set et sts=4 sw=4:
Oops, something went wrong.

0 comments on commit 6074fcd

Please sign in to comment.