The location list must be set when calling :Errors since our cached
error list is associated with the buffer, but the vim loclist is
associated with the window.
So if the user closes a window, the vim loclist will get destroyed, but
our error list will still exist.
Closes#263
Since 7.3.449 trying to :lclose inside BufWinLeave result in E855:
$ vi -u /dev/null --noplugin -N
:autocmd BufWinLeave * if empty(&bt) | lclose | endif
:lexpr(':1:msg') | lopen | wincmd p | lclose
E855: Autocommands caused command to abort
$ vi -u /dev/null --noplugin -N
:autocmd BufWinLeave * if empty(&bt) | lclose | endif
:lexpr(':1:msg') | lopen | wincmd p | q
E855: Autocommands caused command to abort
Another issue with this autocmd is &bt in BufWinLeave may be different from
the buffer being unloaded (this is documented behaviour for BufWinLeave).
Replacing &bt with getbufvar(0+expand('<abuf>'), '&bt') solve this, but
doesn't fix issue with E855 completely (first of above examples with
:lclose is fixed, but second with :q is not fixed).
So, to work around E855 I've changed way to close location-list:
instead of closing it on BufWinLeave, it's closed on BufEnter into
location-list window if it's only buffer in current window.
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.
Use SyntasticWarning and SyntasticError highlight groups when calling
matchadd(). This makes it trivial to clear all of our highlights without
having to store IDs.
Stole this code from kevinw's pull request (#46)
Many of the syntax checkers were setting the 'bufnr' key for each
error manually and one was setting 'text' if it didnt exist too.
Add the 'defaults' option to SyntasticMake to set default values in the
returned error list - it only sets values if they are empty.
Move 2 functions further up syntastic.vim so that all public functions
are at the bottom - purely to be tidy.
Stick some comments on functions - most functions now have at least a
one liner explaining them.
Also, rename a variable in SyntasticHighlightErrors (since I had to look
at the log to figure out what it was).
Store error highlight IDs on a per window basis rather than per buffer.
This is needed as matchadd() adds highlights to the current window - not
buffer. This meant an error would occur when you open a file, create an
error that caused a highlight, then open the same file in a different
window - because it would call matchdelete() with an id that wasnt
defined for the current window.
This system has been superseded by the new mode map code. If requested
in future, some code may be added to manipulate the active/passive types
in the mode map at runtime to provide the same functionality.
This option will allow users to fine tune when automatic syntax checking
is done.
The option should be set to something like:
let g:syntastic_mode_map = { 'mode': 'active',
\ 'active_filetypes': [],
\ 'passive_filetypes': ['puppet'] }
g:syntastic_mode_map['mode'] can take one of 2 values - "active" or
"passive". When set to active, syntastic does automatic checking as
usual. When set to "passive" syntastic only checks when the user calls
:SyntasticCheck.
The exceptions to these rules are defined in "active_filetypes"
"passive_filetypes". In passive mode, automatic checks are still done
for all filetypes in the "active_filetypes" array. In active mode,
automatic checks are not done for any filetypes in the
"passive_filetypes" array.
I'd attempted to find something useful in the sh/csh/tcsh man pages to
get similar shell redirection that &>/>& does, but it appears that all
fds are redirected, not just stderr and stdout.
This allows a particular file type to be disabled but still be checked
when desired. Useful for syntax checks that take a few seconds like the
puppet one.
Add the syntastic_stl_format flag and doc it under
:help syntastic_stl_format. This allows the user to control what
information is displayed in the syntastic statusline flag.
g:syntastic_auto_loc now has the following possible options:
1 or "full_auto" or "fully_auto" behaves as normal, closing the loclist
when there are no errors and opening when there are errors.
2 or "semi_auto" will automatically close the loclist but _not_
automatically open it.
Previously, the location list didn't get populated unless the Errors
window was displayed. As a consequence there is no way to use :lnext
and :lprev to navigate the errors. This makes it so that the list is
populated if there are new errors/warnings.
Add these:
:SyntasticDisable [filetype]
:SyntasticEnable [filetype]
[filetype] defaults to the current filetype.
Add functions to bind the commands to.
Add g:syntastic_disabled_filetypes option to specify which filetypes
are disable by default.
this is to stop the multiple syntax checking invocations that were
occurring when &ft was being detected as compound eg ruby.sinatra. i.e.
the ft was getting set as ruby, then another autocommand was resetting
it to ruby.sinatra, causing the syntax checking to be run twice.