Make Syntastic close just the error window
Asked Answered
M

4

32

I've got the (Mac)Vim Syntastic plugin installed via Janus. When I open the :Errors window to view the reason for syntax errors, it shrinks the file with the errors to one line and uses the rest of the real estate for the Errors window.

Is there a way to make it hog less room for errors and more importantly, how do I close just the Errors window? The usual :q closes both the Errors window AND the original file, even if the cursor is in the Errors window. (That's not 100% correct -- it gratefully does not close the file if the file hasn't yet been saved).

Muco answered 23/9, 2013 at 14:38 Comment(0)
S
45

Syntastic uses the location list (a window-local variant of the quickfix list), so a :lclose will close it, but keep the other buffers.

As per syntastic's help pages, the initial height can be configured:

:let g:syntastic_loc_list_height=5

But I suspect that your intrusive Janus distribution has a hand in that. Vim "distributions" like spf-13 and Janus lure you with a quick install and out of the box settings, but you pay the price with increased complexity (you need to understand both Vim's runtime loading scheme and the arbitrary conventions of the distribution) and inflexibility (the distribution may make some things easier, but other things very difficult). Vim is incredibly customizable, using someone else's customization makes no sense.

Strake answered 23/9, 2013 at 14:54 Comment(1)
Actually, the 'let' command worked as well... I just missed that in the docs (I was focused on the other problem when I checked them). Big thanks! I've certainly come across the advice to drop Janus but its the only reason I'm still using vim (I've tried the 'fresh' approach about a dozen times over a dozen years and just came away hating vim). Unfortunately, it means I ask a bunch of dumb questions here but people have been pretty nice about it, even if my questions are a bit annoying.Muco
G
21

The command to close the Syntastic error window is:

:SyntasticReset
Graptolite answered 14/10, 2016 at 9:24 Comment(1)
This command will fail depending on the buffer you're in (e.g., if your cursor is in the location window itself, it is a no-op)Chuckhole
A
3

Syntastic gets confused when you're juggling multiple buffers on one screen so here's a script that will collect information about the situation, then do the right thing:

function JustCloseSyntasticWindow()
    "Check which buffer we are in, and if not, return to the main one:
    if &ft == "qf"
        normal ZZ
    endif
    "Since different buffers have different command spaces, check if we've
    "escaped the other buffer and then tell syntastic to stop.
    if &ft != "qf"
       SyntasticReset
       " --- or ----
       SyntasticToggleMode
    endif
endfunction

au FileType buffer1_ft nnoremap :yourcmd<CR>:call JustCloseSyntasticWindow()<cr>

au FileType main_win_ft nnoremap :yourcmd<CR>:call JustCloseSyntasticWindow()<cr>

Don't be shy on the duct tape for this job, it's the only thing holding the unit together.

Aurangzeb answered 26/12, 2018 at 16:53 Comment(0)
L
2

You can use :lclose to close it.

Litt answered 2/12, 2019 at 4:35 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.