Reputation: 3974
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?
Upvotes: 128
Views: 69606
Reputation: 3937
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
Upvotes: 97
Reputation: 6279
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
Upvotes: 0
Reputation: 6075
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.
Upvotes: 178
Reputation: 61
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>
Upvotes: 6
Reputation: 2728
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/']
Upvotes: 0
Reputation: 43427
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$']
Upvotes: 7
Reputation: 135
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.
Upvotes: 11
Reputation: 14103
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
Upvotes: 34
Reputation: 567
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.
Upvotes: 4
Reputation: 141
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'}
Upvotes: 7