The location list returned by getloclist() may contain entries that are
not errorformat matches. By "definition", (see :help getqflist), matched
lines have the attribute "valid": 1 set, so only keep those lines in
error/warning list to avoid erroneous counts and strange behaviors.
Signed-off-by: Florent Bruneau <florent.bruneau@intersec.com>
This is needed to handle compound filetypes since we cant imply the
location of the syntax checker file from the filetype.
e.g. we want to load `syntax_checkers/python/pylint.vim`, but the
filetype is `python.django`. Previously this was causing `runtime
syntax_checkers/python.django/pylint.vim` to be executed.
* remove the public SyntasticHighlightErrors() function
* shift the above code into s:HighlightErrors(). This is called
automatically if g:syntastic_enable_highlighting is set
* to get the highlight regex we just look for a function called
Syntastic_<filetype>_GetHighlightRegex
* to force this function to be called, each error item must have the
'force_highlight_callback' key set
This code has one important functional change: now errors are *always*
highlighted if possible whereas previously they were only highlighted if
a call to SyntasticHighlightErrors was made.
There are many calls to s:Errors() and s:Warnings(), and previously the
location list was filtered once for each of these calls. This made vim
unusable when handling large location lists (with hundreds of entries).
Now we cache the errors and warnings explicitly when we cache the
location list.
Rework some of the minor methods so that they call s:Errors() or
s:Warnings() (which use the cached data) instead of calling
s:FilterLocList() directly (which is expensive).
Remove the call to deepcopy() and use some alternative logic instead.
This improves performance massively for large location lists. More
aggressive caching is needed really though since this function is called
multiple times to return the same data.
Javascript and json have multiple syntax checkers that can be loaded.
Previously the logic to determine which checker to load was basically
copied and pasted in both. The `go` checker will soon have more
than one option too so remove the duplication by sticking the
common code in the core.
init g:syntastic_check_on_open with the rest of the options - this means
we only check exists("...") once rather than every time the autocmd is
run. Plus it reads better IMO.
move some code out of AutoToggleLocList and into UpdateErrors so that
AutoToggleLocList is only responsible for displaying/hiding the location
list window
If a syntax checker returns items with blank 'type' keys, then make them
errors. This simplifies things since we were previously making the
assumption that empty types are errors anyway. It also fixes a bug in
EchoCurrentError() function that was due to not checking for a blank ty
pe.
This reverts commit e90aa61ca6.
The idea here was to only close the location list window if it could be
verified that it contained only syntastic data. This was done by
comparing the current location list with b:syntastic_loclist to see if
they are the same.
The problem is that, after we recheck errors, b:syntastic_loclist is
empty (if the user has fixed everything) so it doesnt match
getloclist(0) so we cant close it automatically.
Revert this for now and worry about the issue later - if a user
complains or if a new plugin that uses location lists comes up.
Conflicts:
plugin/syntastic.vim
This allows us to lazy init b:syntastic_loclist so we dont have to worry
about doing `if exists("b:syntastic_loclist")` anywhere.
Im a bit worried about doing things like
s:LocList()[0]['lnum']
since im not sure that that syntax is supported for older versions of
vim.
- changed BufLeave to BufWinLeave otherwise it would close when
jumping to loc list.
- extracted method that auto close/open location list based on
errors/settings and make sure it reopens loclist when buffer is
displayed (BufWinEnter) if needed.
Previously if we have errors displayed and we just want syntastic to
shut up, then we would use :SyntasticToggleMode but existing errors
would not be removed (ever).
So empty them out when we toggle modes.
When coming into active mode this will cause a check to be done which
will pick up errors as normal.
The gentoo vim syntax files use names like gentoo-mirrors, gentoo-metadata, etc.
This simple, and very ugly, fix makes it possible to write syntax checkers for
them.
Only clear the cmd window when it is displaying a message that we
echoed. Previously we were echoing a blank line every time the cursor
moved - this was clearing messages generated from other sources than
syntastic.
In the javascript:jshint checker the error messages are being returned
with a newline prefixed to the front. I have tried to fix this in the
errorformat - but I cant see anything that would cause it.
Im not sure if this is a one-off thing, but strip out all new lines here
just in case.