VIM + Syntastic: how to disable the checker?
Asked Answered
L

10

127

I'm using Syntastic which is enabled for my HTML files. Since I have a very big file with "validator w3" checkers enabled, GVIM or VIM became very slow while saving the file (:w).

Is it possible to toggle syntastic off temporally just for the current session?

Lyublin answered 17/11, 2013 at 12:21 Comment(1)
try let g:syntastic_disabled_filetypes=['html']Archdeaconry
K
178

Using :SyntasticToggleMode you can toggle Syntastic into passive mode, which will disable auto-checking. You can then check a file by running :SyntasticCheck instead.

For more, see :help syntastic-commands

On another note: if Syntastic is slow for you consider trying ale as an alternative. Unlike Syntastic it runs asynchronously, so even if it's slow it shouldn't hinder you.

Kyliekylila answered 17/11, 2013 at 18:51 Comment(3)
Is there any way to create a single alias or map a key to toggle this? I.e., :error or Ctrl+Shift/Alt+e toggles between :SyntasticCheck and :SyntasticToggleMode.Pampas
You can create an alias like this in the .vimrc: :command Sd SyntasticToggleMode Then in vi press :Sd and it will disable syntastic. More info on how to do that here: https://mcmap.net/q/141995/-how-to-create-an-alias-for-a-command-in-vimIslington
nice. heres a mapping to F6 if someone want to use it silent! nmap <F6> :SyntasticToggleMode<CR>Frit
H
97

I have disabled Syntastic by default and activate/disable error checking with the following in my .vimrc:

let g:syntastic_mode_map = { 'mode': 'passive', 'active_filetypes': [],'passive_filetypes': [] }
nnoremap <C-w>E :SyntasticCheck<CR>

When I need to use error checking I simply hit: ctrl-w E

Himalayas answered 29/1, 2014 at 14:57 Comment(7)
This is quite handy, thanks .. I have added the idea to my config. +1Ladd
I've added this to my .vimrc aswell. However if i press Ctrl-w E Syntastic pops up for a second and vanishes again. Any ideas what's going wrong and/or how to track this down?Sacrilegious
I think the mapping shouldn't have :SyntasticToggleMode<CR>, removing that should fix your issue @Anticom.Tango
@AchalDave Didn't fix it for me.Sacrilegious
Hm, no idea. Here's what my syntastic settings look like: github.com/achalddave/dotfiles/blob/…Tango
Seems like the e must be lowercase or it wouldn't work. Also, need to make sure to release control before pressing eLiggitt
To hide it again, we can do the same for a different key, e.g. nnoremap <C-w><C-e> :SyntasticReset<CR>Liggitt
K
34

Alternative to Jamie and gospes answers, one can disable the checker completely by specifying the checker like so:

let g:syntastic_html_checkers=['']

Also make sure the syntastic_check_on_open isn't set to 1, which will countermand the above line:

let g:syntastic_check_on_open = 0
Kandace answered 16/4, 2014 at 9:51 Comment(0)
S
11

You could turn Syntastic off for the entire session (as answered by Jamie Schembri), but if it's just a problem with the one "very big file", you may want to disable just the one buffer.

A few of the files I work on at my job are hopelessly non-PSR compliant. Most work just fine. I was looking for functionality to disable Syntastic for just those problem files. A simpler form of the 'SyntasticDisableToggle' solution outlined by the primary contributor works for me:

"disable syntastic on a per buffer basis (some work files blow it up)
function! SyntasticDisableBuffer()
    let b:syntastic_skip_checks = 1
    SyntasticReset
    echo 'Syntastic disabled for this buffer'
endfunction

command! SyntasticDisableBuffer call SyntasticDisableBuffer()

Because this doesn't affect other buffers, I can keep using this awesome plugin for any other (partially) compliant files I have open.

Sanctimony answered 18/4, 2016 at 0:29 Comment(0)
W
7

This doesn't directly address the question, but can help beyond the current session. If you have a file that you must edit often but which you know that you will always want to disable Syntastic on (e.g. it has thousands of errors and you intend not to fix them, and leaving it on results in UI slowdown), then permanently blacklisting it is very convenient.

To do this, use the syntastic_ignore_files option. It's tucked away in the help, but you can use regexes with this feature to blacklist files.

                                                    'syntastic_ignore_files'
Default: []
Use this option to specify files that syntastic should never check.  It's a
list of regular-expression patterns.  The full paths of files (see ::p) are
matched against these patterns, and the matches are case sensitive. Use \c
to specify case insensitive patterns.  Example:
    let g:syntastic_ignore_files = ['\m^/usr/include/', '\m\c\.h$']
Warchaw answered 30/9, 2015 at 5:13 Comment(2)
Works great! Not what the question was asking for though. Here's a +1 for being useful.Bethany
Thanks, I used this to prevent checking of temporary bash files when editing command lines with C-X C-E: let g:syntastic_ignore_files = ['\m^/tmp/bash-.*']Palmate
L
7

The following settings worked for me.

let g:syntastic_mode_map = { 'mode': 'passive', 'active_filetypes':   [],'passive_filetypes': [] }
noremap <C-w>e :SyntasticCheck<CR>
noremap <C-w>f :SyntasticToggleMode<CR>

Ctrl-w + e shall enable checking
Ctrl-w + f shall disable checking 

To disable warnings use: 
let g:syntastic_quiet_messages={'level':'warnings'}
Lakshmi answered 1/12, 2015 at 7:44 Comment(0)
G
6

Similarly to those mentioned by a few others, here's a vimrc segment that will turn off Syntastic by default, but maps a button (here, F10) to check the current file, and uses the same button as a toggle to turn off the checks. It's a little slow, but works.

let g:syntastic_check_on_open = 0                                                                                 
let g:syntastic_check_on_wq = 0
let g:syntastic_mode_map = {'mode':'passive'}
nnoremap <F10> :SyntasticCheck<CR> :SyntasticToggleMode<CR> :w<CR>
Geniagenial answered 2/4, 2018 at 13:49 Comment(0)
M
4

Another option to turn off checking for a single buffer (regardless of filetype) is to use :let b:syntastic_mode="passive". Since it isn't a toggle, it will work even if the buffer is currently in passive mode.

If you want to temporarily turn off checking of all filetypes in all buffers, you can use :bufdo let b:syntastic_mode="passive". I have setup mappings to turn off/on checking of all buffers:

nnoremap <leader>sN :bufdo let b:syntastic_mode="passive"<cr>
nnoremap <leader>sY :bufdo unlet b:syntastic_mode<cr>

This is particularly helpful when doing :wqa with a lot of open buffers.

Milldam answered 19/1, 2016 at 17:51 Comment(0)
U
0

Thanks for Steven Lu, I can ignore the files of Ansible Roles, now.

" ignore files of Ansible Roles.
let g:syntastic_ignore_files = ['\m^roles/']
Unintelligible answered 11/12, 2016 at 7:39 Comment(0)
B
0

I'm using Ale and Syntastic mainly because Rust Ale support is not very good yet. In my case I'm using vim-plug package manager, I setup so that it will not enable any of these automatically. I use a toggle strategy instead.

In my case I want Ale by default, and Syntastic for Rust

In plugin portion of vimrc I did this

Plug 'w0rp/ale', { 'on': 'ALEToggle' }
Plug 'vim-syntastic/syntastic', { 'on': 'SyntasticToggleMode' }

Afterwards I set a bind to enable linter, (I use l as mnemoic for linter)

nnoremap <leader>l :ALEToggle<CR>

For Rust I override the same bind

au FileType rust noremap <buffer> <leader>l :SyntasticToggleMode<CR>

Also I had to remove the statusline stuff from my vimrc otherwise I get errors when loading it with Syntastic disabled

" Syntastic stuff
"set statusline+=%#warningmsg#
"set statusline+=%{SyntasticStatuslineFlag()}
"set statusline+=%*

let g:rustfmt_autosave = 1
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 1
let g:syntastic_check_on_open = 1
let g:syntastic_check_on_wq = 0
" Syntastic stuff

Regards

Blanc answered 29/3, 2020 at 12:46 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.