*checksyntax.txt*   checksyntax -- Check syntax when saving a file (php, ruby, tex ...)
                    Author: Tom Link, micathom at gmail com

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.

By default, |:CheckSyntax| is mapped to <F5> (if not mapped already), and 
automatically executed when saving the buffer. If multiple syntax checkers are 
defined for the given filetype, this will by default invoke the preferred (see 
|g:checksyntax#preferred|) or first good (i.e. installed) syntax checker for a 
given filetype.

:CheckSyntax! (with the optional <bang>) or <C-F5> will run all supported 
syntax checkers for a given filetype if multiple syntax checkers are defined 
for a given filetype and if the software is installed on your computer.

In order to automatically run a syntax check when saving a file, please set 
|g:checksyntax#auto_enable_rx| to an appropriate value. If the variable is set 
to '.', which matches all filetypes, automatic syntax checks are enabled for 
all supported filetypes. Automatic checks are equivalent to running 
|:CheckSyntax| with no <bang>.

The syntax checks are performed by external syntax checker. This software has 
to be installed on your computer. Pre-defined syntax checkers are:

  c, cpp       ... Use splint
  html         ... Use tidy
  java         ... Use
                    jlint (http://jlint.sourceforge.net),
                    checkstyle (http://checkstyle.sourceforge.net),
                    pmd (http://pmd.sourceforge.net)
  javascript   ... Use jshint, esprima, gjslint, jslint, jsl, pmd
  lua          ... Use luac (run luac -p)
  php          ... Use php (run php -l)
  python       ... Use pyflakes or pylint
  r            ... Use codetools::checkUsage, lint::lint, or 
                   svTools::lint
  ruby         ... Use ruby (run ruby -c)
  tex, latex   ... Use chktex (run chktex -q -v0)
  typescript   ... Use tsc
  viki         ... Use deplate
  xhtml        ... Use tidy
  xml, docbk   ... Use xmllint, pmd

Syntax checker definitions are kept in:
autoload/checksyntax/defs/{&filetype}.vim

Run this command to find out, which filetypes are supported: >

  :echo globpath(&rtp, 'autoload/checksyntax/defs/*.vim')


Credits:

This plugin was originally based on Klaus Horsten's php_console 
(vimscript #779) and it is the successor of php_check_syntax.vim 
(vimscript #1272).


-----------------------------------------------------------------------
Install~

Edit the vba file and type: >

    :so %

See :help vimball for details. If you have difficulties or use vim 7.0, 
please make sure, you have the current version of vimball (vimscript 
#1502) installed or update your runtime.

Optional enhancements:

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

Experimental: If AsyncCommand (vimscript #3431) is installed, syntax checks can 
be peformed asynchronously -- see also |g:checksyntax#run_alternatives|, 
|g:checksyntax#run_all_alternatives| and |g:checksyntax#async_runner|. This 
requires a version of vim with |clientserver| support and |v:servername| to be 
set (for vim see also |--servername|).


========================================================================
Contents~

        :CheckSyntax ........................................... |:CheckSyntax|
        g:checksyntax_key_single ............................... |g:checksyntax_key_single|
        g:checksyntax_key_all .................................. |g:checksyntax_key_all|
        g:checksyntax_auto ..................................... |g:checksyntax_auto|
        g:checksyntax_enable_syntax ............................ |g:checksyntax_enable_syntax|
        g:checksyntax#auto_enable_rx ........................... |g:checksyntax#auto_enable_rx|
        g:checksyntax#auto_disable_rx .......................... |g:checksyntax#auto_disable_rx|
        g:checksyntax#show_cmd ................................. |g:checksyntax#show_cmd|
        g:checksyntax#lines_expr ............................... |g:checksyntax#lines_expr|
        g:checksyntax#preferred ................................ |g:checksyntax#preferred|
        g:checksyntax#async_runner ............................. |g:checksyntax#async_runner|
        :CheckSyntaxStatus ..................................... |:CheckSyntaxStatus|
        g:checksyntax#run_alternatives ......................... |g:checksyntax#run_alternatives|
        g:checksyntax#run_all_alternatives ..................... |g:checksyntax#run_all_alternatives|
        g:checksyntax#windows .................................. |g:checksyntax#windows|
        g:checksyntax#null ..................................... |g:checksyntax#null|
        g:checksyntax#cygwin_path_rx ........................... |g:checksyntax#cygwin_path_rx|
        g:checksyntax#cygwin_expr .............................. |g:checksyntax#cygwin_expr|
        g:checksyntax#check_cygpath ............................ |g:checksyntax#check_cygpath|
        CheckSyntaxSucceed ..................................... |CheckSyntaxSucceed()|
        CheckSyntaxFail ........................................ |CheckSyntaxFail()|
        g:checksyntax#prototypes ............................... |g:checksyntax#prototypes|
        checksyntax#AddChecker ................................. |checksyntax#AddChecker()|
        checksyntax#GetChecker ................................. |checksyntax#GetChecker()|
        checksyntax#Check ...................................... |checksyntax#Check()|
        checksyntax#AddJob ..................................... |checksyntax#AddJob()|
        checksyntax#RemoveJob .................................. |checksyntax#RemoveJob()|
        checksyntax#Status ..................................... |checksyntax#Status()|
        checksyntax#GetList .................................... |checksyntax#GetList()|
        checksyntax#NullOutput ................................. |checksyntax#NullOutput()|
        checksyntax#MaybeUseCygpath ............................ |checksyntax#MaybeUseCygpath()|
        checksyntax#SetupSyntax ................................ |checksyntax#SetupSyntax()|
        checksyntax#defs#xml#pmd_args .......................... |checksyntax#defs#xml#pmd_args|
        g:checksyntax#defs#r#progname .......................... |g:checksyntax#defs#r#progname|
        g:checksyntax#defs#r#options ........................... |g:checksyntax#defs#r#options|
        g:checksyntax#defs#r#checkUsage_options ................ |g:checksyntax#defs#r#checkUsage_options|
        g:checksyntax#defs#r#checkUsage_ignore_undefined_rx .... |g:checksyntax#defs#r#checkUsage_ignore_undefined_rx|
        g:checksyntax#defs#r#checkUsage_ignore_functions ....... |g:checksyntax#defs#r#checkUsage_ignore_functions|
        g:checksyntax#defs#r#checkUsage_search_other_buffers ... |g:checksyntax#defs#r#checkUsage_search_other_buffers|
        g:checksyntax#defs#php#cmd ............................. |g:checksyntax#defs#php#cmd|
        g:checksyntax#defs#php#args ............................ |g:checksyntax#defs#php#args|
        g:checksyntax#defs#haxe#haxe ........................... |g:checksyntax#defs#haxe#haxe|
        g:checksyntax#defs#haxe#hxml_files ..................... |g:checksyntax#defs#haxe#hxml_files|
        checksyntax#defs#haxe#Cmd .............................. |checksyntax#defs#haxe#Cmd()|
        g:checksyntax#defs#javascript#closure .................. |g:checksyntax#defs#javascript#closure|
        g:checksyntax#defs#javascript#closure_warnings ......... |g:checksyntax#defs#javascript#closure_warnings|
        g:checksyntax#defs#javascript#pmd_args ................. |g:checksyntax#defs#javascript#pmd_args|
        g:checksyntax#defs#ruby#interpreter .................... |g:checksyntax#defs#ruby#interpreter|
        g:checksyntax#defs#scala#scalastyle .................... |g:checksyntax#defs#scala#scalastyle|
        checksyntax#defs#scala#Cmd ............................. |checksyntax#defs#scala#Cmd()|
        checksyntax#defs#java#pmd_rulesets ..................... |checksyntax#defs#java#pmd_rulesets|
        checksyntax#defs#java#pmd_args ......................... |checksyntax#defs#java#pmd_args|
        checksyntax#defs#java#Jlint ............................ |checksyntax#defs#java#Jlint()|
        g:checksyntax#pmd#cmd .................................. |g:checksyntax#pmd#cmd|
        g:checksyntax#pmd#args ................................. |g:checksyntax#pmd#args|
        checksyntax#pmd#Cmd .................................... |checksyntax#pmd#Cmd()|
        checksyntax#async#asyncaddon#Run ....................... |checksyntax#async#asyncaddon#Run()|
        checksyntax#async#asynccommand#Run ..................... |checksyntax#async#asynccommand#Run()|


========================================================================
plugin/checksyntax.vim~

                                                    *:CheckSyntax*
CheckSyntax[!] [NAME]
    Check the current buffer's syntax (type defaults to &filetype).
    Or use NAME instead of &filetype.

    With the bang !, run all alternatives (see 
    |g:checksyntax#run_alternatives|).

                                                    *g:checksyntax_key_single*
g:checksyntax_key_single       (default: '<F5>')
    Map for running the preferred syntax checkers on the current 
    buffer.

                                                    *g:checksyntax_key_all*
g:checksyntax_key_all          (default: '<C-F5>')
    Map for running all suitable syntax checkers on the current 
    buffer.

                                                    *g:checksyntax_auto*
g:checksyntax_auto             (default: 1)
    If 1, enable automatic syntax checks after saving a file.
    If 2, enable automatic syntax checks when saving and loading a 
    file.
    NOTE: This variable must be customized in vimrc before loading 
    this plugin.

    See also |g:checksyntax|, |g:checksyntax#auto_enable_rx| and 
    |g:checksyntax#auto_disable_rx|.

                                                    *g:checksyntax_enable_syntax*
g:checksyntax_enable_syntax    (default: [])
    A list of filetypes for which frequent beginner errors will be 
    highlighted by matching lines against |regexp|s defined in the 
    file `autoload/checksyntax/syntax/{FILETYPE}.vim`.

    See :echo globpath(&rtp, 'autoload/checksyntax/syntax/*.vim') for 
    supported filetypes/checks.

    The variable can also be buffer-local. In this case all named 
    types will be loaded.

    E.g. in order to enable highlighting trailing whitespace, use: >

      let b:checksyntax_enable_syntax = ['trailing_whitespace']

<   If you want to enable this for all file of filetype X, add this 
    line to in `after/syntax/X.vim`.


========================================================================
autoload/checksyntax.vim~

                                                    *g:checksyntax#auto_enable_rx*
g:checksyntax#auto_enable_rx   (default: '')
    Enable automatic checking for filetypes matching this rx.
    Set to "." to enable for all filetypes.
    This requires |g:checksyntax_auto| to be > 0.
    This variable overrules any filetype-specific settings in 
    |g:checksyntax|.

                                                    *g:checksyntax#auto_disable_rx*
g:checksyntax#auto_disable_rx  (default: '')
    Disable automatic checking for filetypes matching this rx.
    Set to "." to disable for all filetypes.
    This requires |g:checksyntax_auto| to be > 0.
    This variable overrules any filetype-specific settings in 
    |g:checksyntax|.

                                                    *g:checksyntax#show_cmd*
g:checksyntax#show_cmd         (default: {'qfl': 'copen', 'loc': 'lopen'})
    A dictionary of VIM commands that are used to display the qf/loc 
    lists.
    If empty, do nothing.

                                                    *g:checksyntax#lines_expr*
g:checksyntax#lines_expr       (default: '')
    A vim expression that determines the number of lines of the 
    qfl/loc window. If empty, don't set the size.
    A useful value is: >
      let g:checksyntax#lines_expr = 'min([&previewheight, &lines / 2, len(getloclist(0))])'
<

                                                    *g:checksyntax#preferred*
g:checksyntax#preferred        (default: {'xml': '.'})
    A dictionary of 'filetype' => |regexp|.
    If only one alternative should be run (see 
    |g:checksyntax#run_alternatives|), check only those syntax 
    checkers whose names matches |regexp|.

                                                    *g:checksyntax#async_runner*
g:checksyntax#async_runner     (default: has('clientserver') && !empty(v:servername) && exists(':AsyncMake') ? 'asynccommand' : '')
    Supported values:
      asynccommand ... Use the AsyncCommand plugin

                                                    *:CheckSyntaxStatus*
:CheckSyntaxStatus
    Show status information (pending async tasks).

                                                    *g:checksyntax#run_alternatives*
g:checksyntax#run_alternatives (default: 'first' . (!empty(g:checksyntax#async_runner) ? ' async' : ''))
    How to handle alternatives. Possible values:

        first ... Use the first valid entry
        all   ... Run all valid alternatives one after another

    Alternatively, the following flag can be added in order to change 
    how the alternatives are run:

        async ... Run alternatives asynchronously (see also 
                  |g:checksyntax#async_runner|)

                                                    *g:checksyntax#run_all_alternatives*
g:checksyntax#run_all_alternatives (default: 'all' . (!empty(g:checksyntax#async_runner) ? ' async' : ''))
    How to run "all" alternatives -- e.g., when calling the 
    |:CheckSyntax| command with a bang.

                                                    *g:checksyntax#windows*
g:checksyntax#windows          (default: &shell !~ 'sh' && (has('win16') || has('win32') || has('win64')))

                                                    *g:checksyntax#null*
g:checksyntax#null             (default: g:checksyntax#windows ? 'NUL' : (filereadable('/dev/null') ? '/dev/null' : ''))

                                                    *g:checksyntax#cygwin_path_rx*
g:checksyntax#cygwin_path_rx   (default: '/cygwin/')
    If a full windows filename (with slashes instead of backslashes) 
    matches this |regexp|, it is assumed to be a cygwin executable.

                                                    *g:checksyntax#cygwin_expr*
g:checksyntax#cygwin_expr      (default: '"bash -c ''". escape(%s, "''\\") ."''"')
    For cygwin binaries, convert command calls using this vim 
    expression.

                                                    *g:checksyntax#check_cygpath*
g:checksyntax#check_cygpath    (default: g:checksyntax#windows && s:Executable('cygpath'))
    If true, check whether we have to convert a path via cyppath -- 
    see |checksyntax#MaybeUseCygpath|

                                                    *CheckSyntaxSucceed()*
CheckSyntaxSucceed(type, manually)
    This function is called when no syntax errors were found.

                                                    *CheckSyntaxFail()*
CheckSyntaxFail(type, manually, bg)
    This function is called when a syntax error was found.

                                                    *g:checksyntax#prototypes*
g:checksyntax#prototypes       (default: {'loc': {}, 'qfl': {}})
    Contains prototype definitions for syntax checkers that use the 
    |location-list| ("loc") or the |quixfix|-list.

                                                    *checksyntax#AddChecker()*
checksyntax#AddChecker(filetype, ...)
    Define a syntax checker definition for a given filetype.
    If filetype ends with "?", add only if no checker with the given name 
    is defined.

    A checker definition is a dictionary with the following fields:

    Mandatory (either one of the following):

      cmd ........ A shell command used as 'makeprg' to check the file.
      cmdexpr .... A vim expression that returns the cmd
      compiler ... A vim compiler that is used to check the file.
      exec ....... A vim command used to check the file (deprecated; use 
                   cmdexpr & process_list instead)

    Optional:

      efm  ....... An 'errorformat' string.
      prepare .... An ex command that is run before doing anything.
      ignore_nr .. A list of error numbers that should be ignored.
      listtype ... Either loc (default) or qfl
      include .... Include another definition
      process_list .. Process a list of issues
      if ......... An expression to test *once* whether a syntax checker 
                   should be used.
      if_executable .. Test whether an application is executable.
      buffers .... Keep results only for either "current", "listed", or 
                   "all" buffers
      compiler_args .. Internal use
      cmd_args ... Internal use

    Optional top-level fields:

      auto ....... Run automatically when saving a file (see also 
                   |g:checksyntax#auto_enable_rx| and 
                   |g:checksyntax#auto_disable_rx|)
      modified ... The name of a pseudo-filetype that should be used if 
                   the buffer was modified
      run_alternatives ... A string that defines how to run 
                   alternatives (overrides 
                   |g:checksyntax#run_alternatives|).

    Top-level fields affect how syntax checkers for a filetype are run.

                                                    *checksyntax#GetChecker()*
checksyntax#GetChecker(filetype, ...)

                                                    *checksyntax#Check()*
checksyntax#Check(manually, ?bang='', ?filetype=&ft, ?background=1)
    Perform a syntax check.
    If bang is not empty, run all alternatives (see 
    |g:checksyntax#run_alternatives|).
    If filetype is empty, the current buffer's 'filetype' will be used.
    If background is true, display the list of issues in the background, 
    i.e. the active window will keep the focus.

                                                    *checksyntax#AddJob()*
checksyntax#AddJob(make_def)

                                                    *checksyntax#RemoveJob()*
checksyntax#RemoveJob(job_id)

                                                    *checksyntax#Status()*
checksyntax#Status()

                                                    *checksyntax#GetList()*
checksyntax#GetList(name, make_def, type)

                                                    *checksyntax#NullOutput()*
checksyntax#NullOutput(flag)

                                                    *checksyntax#MaybeUseCygpath()*
checksyntax#MaybeUseCygpath(cmd)
    If cmd seems to be a cygwin executable, use cygpath to convert 
    filenames. This assumes that cygwin's which command returns full 
    filenames for non-cygwin executables.

                                                    *checksyntax#SetupSyntax()*
checksyntax#SetupSyntax(syntax)


========================================================================
autoload/checksyntax/defs/xml.vim~

                                                    *checksyntax#defs#xml#pmd_args*
checksyntax#defs#xml#pmd_args  (default: '')


========================================================================
autoload/checksyntax/defs/r.vim~


Syntax checkers for R:

  codetools::checkUsageEnv ... Requires http://cran.r-project.org/web/packages/codetools/
  lint::lint ... Requires http://cran.r-project.org/web/packages/lint/
  svTools::lint ... Requires http://cran.r-project.org/web/packages/svTools/

                                                    *g:checksyntax#defs#r#progname*
g:checksyntax#defs#r#progname  (default: executable('Rterm') ? 'Rterm' : 'R')

                                                    *g:checksyntax#defs#r#options*
g:checksyntax#defs#r#options   (default: '--slave --ess --restore --no-save -e "%s" --args')

                                                    *g:checksyntax#defs#r#checkUsage_options*
g:checksyntax#defs#r#checkUsage_options (default: 'all = TRUE')
    Optons passed to codetools::checkUsageEnv.
    Must not be empty.

                                                    *g:checksyntax#defs#r#checkUsage_ignore_undefined_rx*
g:checksyntax#defs#r#checkUsage_ignore_undefined_rx (default: '')
    A |/\V| regexp pattern of names that should be ignored, when 
    codetools::checkUsageEnv reports "no visible global function 
    definition".

                                                    *g:checksyntax#defs#r#checkUsage_ignore_functions*
g:checksyntax#defs#r#checkUsage_ignore_functions (default: [])
    A list of function names that will be ignored when parsing the 
    result list from codetools::checkUsageEnv.

                                                    *g:checksyntax#defs#r#checkUsage_search_other_buffers*
g:checksyntax#defs#r#checkUsage_search_other_buffers (default: 0)
    If 2, also search other buffers for patterns returned by 
    codetools::checkUsageEnv. This may cause unreponsive behaviour.

    If 1, show unidentifiable patterns as is.

    If 0, remove unidentifiable patterns.


========================================================================
autoload/checksyntax/defs/php.vim~

                                                    *g:checksyntax#defs#php#cmd*
g:checksyntax#defs#php#cmd     (default: 'php')

                                                    *g:checksyntax#defs#php#args*
g:checksyntax#defs#php#args    (default: '-l -n -d display_errors=1 -d error_log= -d error_reporting=E_ALL')
    Displaying errors for php files is surprisingly fragile since it 
    depends on the php version and the php.ini file. If you get 
    duplicate errors or no errors at all, change the command-line 
    arguments defined with this variable. Please consider the 
    information kindly collected by Björn Oelke:

      Somehow the values in the php.ini and those passed via '--define' 
      seem to be independent, so either value in checksyntax' def file 
      seems to be a problem with one of the possible values in the 
      php.ini:

      | cmd | php.ini | Errors |
      +-----+---------+--------+
      | 1   | On      | 2      |
      | 0   | On      | 1      |
      | 1   | Off     | 1      |
      | 0   | Off     | 0      |

      There's an additional flag in the manpage called '--no-php-ini', 
      that could solve the problem.

    You can run `php -i | grep display_errors` to find out if 
    display_errors is On because of the php.ini. By default, the 
    setting in php.ini is ignored ("-n" command-line flag).


========================================================================
autoload/checksyntax/defs/haxe.vim~

                                                    *g:checksyntax#defs#haxe#haxe*
g:checksyntax#defs#haxe#haxe   (default: executable('haxe') ? 'haxe' : '')
    Filename of the haxe executable.

                                                    *g:checksyntax#defs#haxe#hxml_files*
g:checksyntax#defs#haxe#hxml_files (default: ['compile.hxml'])

                                                    *checksyntax#defs#haxe#Cmd()*
checksyntax#defs#haxe#Cmd()


========================================================================
autoload/checksyntax/defs/javascript.vim~

                                                    *g:checksyntax#defs#javascript#closure*
g:checksyntax#defs#javascript#closure (default: '')
    If non-empty, enable some checks via closure compiler.

                                                    *g:checksyntax#defs#javascript#closure_warnings*
g:checksyntax#defs#javascript#closure_warnings (default: ['const', 'constantProperty', 'checkRegExp', 'strictModuleDepCheck', 'visibility'])

                                                    *g:checksyntax#defs#javascript#pmd_args*
g:checksyntax#defs#javascript#pmd_args (default: '')


========================================================================
autoload/checksyntax/defs/ruby.vim~

                                                    *g:checksyntax#defs#ruby#interpreter*
g:checksyntax#defs#ruby#interpreter (default: system('ruby --version'))


========================================================================
autoload/checksyntax/defs/scala.vim~

                                                    *g:checksyntax#defs#scala#scalastyle*
g:checksyntax#defs#scala#scalastyle (default: '')
    The command to invoke scalastyle -- see http://www.scalastyle.org 
    and especially http://www.scalastyle.org/command-line.html

                                                    *checksyntax#defs#scala#Cmd()*
checksyntax#defs#scala#Cmd()


========================================================================
autoload/checksyntax/defs/java.vim~

                                                    *checksyntax#defs#java#pmd_rulesets*
checksyntax#defs#java#pmd_rulesets (default: [...])

                                                    *checksyntax#defs#java#pmd_args*
checksyntax#defs#java#pmd_args (default: '')

                                                    *checksyntax#defs#java#Jlint()*
checksyntax#defs#java#Jlint()


========================================================================
autoload/checksyntax/pmd.vim~

                                                    *g:checksyntax#pmd#cmd*
g:checksyntax#pmd#cmd          (default: '')
    The command to run pmd.

                                                    *g:checksyntax#pmd#args*
g:checksyntax#pmd#args         (default: '-f text')

                                                    *checksyntax#pmd#Cmd()*
checksyntax#pmd#Cmd(language, args, rulesets)


========================================================================
autoload/checksyntax/syntax/vim.vim~


                                                    *checksyntax_enable_syntax-vim*
Simple syntax checks for the vim 'filetype'~

Setting |g:checksyntax_enable_syntax| enables the following checks:

- Assignment in |:if| expression
- `else if` instead of |:elseif|
- Propably wrong arguments for |bufnr()| or |winnr()|
- Don't ignore/simplify the return value of |exists()| for cmdnames
- Calls like exists('fnname()')
- Don't write exists('foo'). If it's a variable, make the scope explicit 
  (like `g:foo`). Otherwise it was an error anyway.
- Variables with scope (|g:|, |l:|, |a:var| etc.) in function 
  argument position


========================================================================
autoload/checksyntax/async/asyncaddon.vim~

                                                    *checksyntax#async#asyncaddon#Run()*
checksyntax#async#asyncaddon#Run(cmd, make_def)


========================================================================
autoload/checksyntax/async/asynccommand.vim~

                                                    *checksyntax#async#asynccommand#Run()*
checksyntax#async#asynccommand#Run(cmd, make_def)



vim:tw=78:fo=tcq2:isk=!-~,^*,^|,^":ts=8:ft=help:norl:
