sponsor Vim development Vim logo Vim Book Ad

checksyntax : Check for syntax erros when saving a file (php, ruby, tex ...)

 script karma  Rating 84/36, Downloaded by 4194    Comments, bugs, improvements  Vim wiki

created by
Tom Link
 
script type
utility
 
description
http://github.com/tomtom/checksyntax_vim

The checksyntax plugin runs an external syntax checker for the current buffer
whenever the buffer is saved (by calling the |:CheckSyntax| command). Syntax
errors are managed as location or quickfix lists. If any syntax error occurs,
the |location-list| is opened (users can redefine |CheckSyntaxFail()| to change
this behaviour). You can use any |location-list| related command to navigate
the list of syntax errors.

If vimscript #2584 is installed, lines containing syntax errors will be marked
with signs.

By default, |:CheckSyntax| is mapped to <F5> (if not mapped already),
and automatically executed when saving the buffer. The |:CheckSyntax|
command takes one optional argument: the mode (default: &filetype).
<C-F5> will run all syntax checkers for a given filetype if multiple
alternatives are defined and installed on your computer.

As the plugin doesn't provide syntax checks by its own. This is done by
an external syntax checker that has to be installed on your computer.

For the following filetypes, syntax checkers are pre-defined:

    c, cpp :: Check syntax via splint
    html :: Check syntax via tidy
    javascript :: Check syntax via jslint, jshint, jsl, or gjslint
    java :: Check syntax via jlint or javaCheckstyle
    lua :: Parse file (luac -p)
    php  :: Check syntax (php -l)
    phpp :: Parse a file (php -f) (alternative php checker)
    python :: Check file with pyflakes
    pylint :: Use the pylint compiler plugin (alternative python checker)
    r :: Check syntax (lint::lint, svTools::lint)
    ruby :: Check syntax (ruby -c; no auto-checks)
    tex, latex :: Parse file (chktex -q -v0; no auto-checks)
    xml, docbk :: Check syntax via xmllint

See the autoload/checksyntax/defs/ directory for a complete list of
supported syntax checkers. See |g:checksyntax| also for how to define
your own syntax checkers.
 
install details
Edit the vba file and type: >

    :so %

See :help vimball for details.

As the plugin doesn't provide syntax checks by its own, the external
syntax checker has to be installed on your computer.
 

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
checksyntax.vba 2.03 2013-01-06 7.0 Tom Link - Included missing files in vba (fixes #16)
MD5 checksum: 40c9ea31d916db1ff5f22ec1c4af14c3
checksyntax.vba 2.02 2012-11-23 7.0 Tom Link - Support for perl (by TheAthlete)
- s:Make(): Echo v:exception & v:throwpoint
- checksyntax#Alternative(): Copy top-level properties
- Don't change the checker definition when dealing with alternatives (reported by techlivezheng)
MD5 checksum: d2d95bcff1d039497bc9c95cdb7a0ea1
checksyntax.vba 2.01 2012-08-28 7.0 Tom Link - Extra syntax checker definitions was prematurely removed after running a single syntax checker
- Facilitate customization of maps (g:checksyntax_key_single, g:checksyntax_key_all)
- process_list attribute for syntax checker definitions
- Support for R (lint::lint, svTools::lint)
- s:Executable(): Run executable() only once
- SyntasticLoadChecker(): Accept filetype as optional argument
- Support for jshint
MD5 checksum: 617a9cc8fd1fac7533e75b721106f2ad
checksyntax.vba 2.00 2012-08-27 7.0 Tom Link - Enable syntax checks when loading a file (disabled by default)
- g:checksyntax#auto_mode: Default auto mode (fixes #10)
- g:checksyntax#debug
- s:GetDef(ft): Remove syntax checker definition if the command is not executable
- Fix duplicate errors (closes bug #7)
- checksyntax#auto_mode: 0 disable, 1 enable, 2 force (fixes #12)
- checksyntax: "if" and "alternatives" fields; removed g:checksyntax_javascript
- define g:checksyntax in plugin/checksyntax.vim in order to facilitate customisation
- s:GetDef(ft): If empty(rv), check if the rest of alternatives is empty
- Move syntax checker definitions to autoload/checksyntax/&filetype.vim
- php: run with php -l -d error_log= -d error_reporting=E_PARSE
- Remove outdated references to failrx and okrx
- Move syntax checker definitions to autoload/checksyntax/defs/
- Experimental support for syntastic syntax checkers.
- debug message
- Support for SyntasticLoadChecker()
- checksyntax#Require(): Return 0 if filetype is empty
- efm for jruby (see https://github.com/tomtom/checksyntax_vim/pull/13)
- Run php with "-d display_errors=0" (fixes #7)
- php: Use -d display_errors=0
- checksyntax#syntastic#Require(): Make sure not to replace existing defintions
- Experimental: Prepare for running all valid alternatives
- Prepare for run_alternatives == "all"
- Javascript: Support for jslint (fixes #14)
- Run multiple syntax checkers (fixes #15)
- javascript: Remove run_alternatives = all
- Improved running all alternatives
- Improved support for syntastic syntax checkers (in conjunction with run_alternatives == all)
- :CheckSyntax! runs all alternatives (not the alternative syntax checker); use g:checksyntax#preferred for selecting the preferred checker
- checksyntax#Name(): Also consider the value of compiler
- s:CompleteItem(): Improved display of error message
- checksyntax#Alternative(): Define an alternative
- Updated syntax checker definitions for java, php, python
- checksyntax#syntastic#Require(): Use checksyntax#Alternative()
- checksyntax#syntastic#Require(): handle yet undefined filetypes
- Syntastic: Improved display of the checker name
- Support for bash -n
- Call bash -n only if shell =~ bash
- Facilitate configuration of g:checksyntax#prototypes.
- Map <c-f5> to CheckSyntax!
MD5 checksum: dfe8b09008f5106fdf7886d4c4cd5fb6
checksyntax.vba 1.03 2012-01-21 7.0 Tom Link - checksyntax#Check: Check &modified before anything else
- .gitignore
- Support for "modified" property
- Check executable() when setting the *.auto property.
- When eclim is installed: Set g:checksyntax.php.auto, not b:checksyntax.php.auto
- Do not map `<F5>` if it is used already.
- Use either location list (default) or optionally the quickfix list
- CheckSyntaxFail(): call .Open(); fixes #6
- Tackle issue #7 ... maybe
- php is now forced to display parse errors even when in production mode
- Rename s:prototypes to g:checksyntax#prototypes
MD5 checksum: dfe8b09008f5106fdf7886d4c4cd5fb6
checksyntax.vba 1.01 2011-05-26 7.0 Tom Link - checksyntax#Check: Check &modified before anything else
- .gitignore
- Support for "modified" property
- Check executable() when setting the *.auto property.
- When eclim is installed: Set g:checksyntax.php.auto, not b:checksyntax.php.auto
- Do not map `<F5>` if it is used already.
- Use either location list (default) or optionally the quickfix list
- CheckSyntaxFail(): call .Open(); fixes #6
MD5 checksum: 4425f1434baa8795fbccec38721eef67
checksyntax.vba 1.01 2010-11-11 7.0 Tom Link - Experimental support for python: pyflakes, pylint
- redraw before calling CheckSyntaxSucceed/CheckSyntaxFail
- Make sure we're in the right buffer
MD5 checksum: f94781c5748200e809a28562a692ed6b
checksyntax.vba 1.0 2010-10-29 7.0 Tom Link - checksyntax_compiler_{&ft} & checksyntax_cmd_{&ft} variables can be buffer local
- The info maintained as g:checksyntax_* variables is now kept in a dictionary named g:checksyntax
- Support for gjslint
- Some bug fixes (e.g. tidy)
checksyntax.vba.gz 0.5 2009-09-26 7.0 Tom Link - use vim compilers if available (e.g., tidy, xmllint ...)
- Support for jsl (javascript lint).
- Support for jlint.
- Support for lua (thanks to norman)
- Don't automatically check php files if eclim is installed.
- Allow auto_* parameters to be buffer local.
- FIX: Unlet current_compiler, use g:current_compiler
- FIX: garbled screen: use redraw! (thanks to Vincent de Lau)
- FIX: makeprg was restored in the wrong window
checksyntax.zip 0.3 2005-12-12 6.0 Tom Link Initial upload
ip used for rating: 54.224.75.101

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
   
SourceForge.net Logo