Add 2 classes: SyntasticChecker and SyntasticRegistry.
SyntasticChecker represents a checker. It holds funcrefs to the checker
func, the highlight regex func and a new `isAvailable()` func (that
essentially just checks if the checker exe is installed)
SyntasticRegistry is responsible for:
* loading checkers
* storing checkers
* fetching the checkers to use according to availability and the users
settings
Motivation/benefits:
* in the current system only one checker can be loaded per filetype
* syntax checkers cant be "chained" together
* the system is hard to add features to since fundamental concepts like
syntax checkers and location lists arent represented explicitly
Things left to do:
* add a call to g:SyntasticRegistry.CreateAndRegisterChecker() to all
checkers
* add an `isAvailable` function to all checkers
* move all checkers into `syntax_checkers/filetype/checkername.vim` -
g:SyntasticRegistry assumes this layout, and its a good idea anyway
for consistency and it makes it easier for users to add their own
checkers
Things to do after all of the above:
* add a LocationList class and move all the filtering functions onto it
* possibly add an Error class that wraps up each item in a loc list
Random notes:
* with the new system you can select the checkers to use with e.g.
`let g:syntastic_python_checkers=['flake8', 'pylint']`
This will try flake8 first, and if no errors are detected it will move
onto pylint.
update makeprg builder:
* it now accepts `fname`, `tail`, and `post_args` params.
* add some doc above syntastic#makeprg#build
* update a bunch of checkers to use the new params
Still have quite a few checkers that arent using makeprg#build.
Including all c* and a few other c-like checkers. And PHP.
Not to worried about c* as these checkers are complicated and probably
justify having their own logic to build makeprgs.
Make all the easy updates. There are still quite a few to do, but in
doing these ones I can see that syntastic#makeprg#build() needs to
accept a few more options. Namely:
* "postargs" that appear after the filename
* "tail" that appears after everything - used for things like
redirecting output and piping to grep/sed/etc
* the filename itself - only the java checkers needed this since they
specify the directory of the file to check as well
There are still a few other things to do as well:
* remove the options from the checkers that are now provided by
syntastic#makeprg#build implicitly - i.e. the checker exe and args.
* also, we need to doc the above implicit checker options
Using the scala compiler instead of the interpreter to check the syntax
means that an error will not be raised if there is a package
decleration.
Also, stopping the compiler after the parser stage stops errors being
raised when importing from other files in your project.
The problem
---
Some people want to change the syntax checker args and/or executable.
Currently they have to create their own checker to do this.
Solution
---
Create a standard API for building a makeprg that allows users to set
global variables to override the exe or args.
This API is in use in the coffee and python/flake8 checkers - as
proofs of concept.
So, if the user wanted to change the args that get passed to `flake8`
they can now set `let g:syntastic_python_flake8_args="--foo --bar"` in
their vimrc. Similarly they could set `let
g:syntastic_python_flake8_exe='python foo.py'`
In simple case it just miss warnings:
$ echo '$a=5;' | perl syntax_checkers/efm_perl.pl -c -w -
(nothing, while it should be this:)
W:-:1:Name "main::a" used only once: possible typo
In complex cases with some other errors it show crazy warnings
in crazy line numbers.
Use case when efm_perl run on STDIN can be found in issue#261.
If the shebang contains -T, then the makeprg looks like:
perl '/path/to/efm_perl.pl' -c -w '/tmp/foo.pl' -Tc
Mods to syntastic#util#ParseMagicNumber
* rename it to ParseShebang (since this name seems more common)
* return an empty result set rather than 0 so callers dont have to
check if empty()
That way, the files are properly treated as C/C++ even when they don't
have the standard file extension
Signed-off-by: Florent Bruneau <florent.bruneau@intersec.com>
Previously we were only loading "official" checkers that had been added
to syntastic. Now we load any checker that is in the right directory.
This allows anyone to add custom checkers to any filetype that uses
`SyntasticLoadChecker()`
The advantage to this is that no 3rd party modules are required. People
new to Python probably won't have flake8/pyflakes/pylint installed. This
will get them basic syntax checking (no linting) out of the box.
Since we're only using ghc to check and lint the file and not actually create output, we can pass -fno-code which omits code generation and speeds up the check quite a bit.