How to selectively disable checkers for certain file types when using syntastic in vim?
Asked Answered
N

3

7

For example, HTML partial templates are being flagged with tons of errors but they are supposed to be fragments of a complete HTML doc.

Nano answered 4/8, 2015 at 19:54 Comment(1)
Try :help syntastic-quickstart and :help 'syntastic_mode_map'.Mercenary
T
15

In your .vimrc:

let g:syntastic_mode_map = {
    \ "mode": "active",
    \ "passive_filetypes": ["go"] }

This sets Syntastic to active mode (checks are made on save or open) but not for, in this case, Go files, which will be checked only when explicitly running :SyntasticCheck. Just change the array of passive_filetypes to whatever you need.

Thrombosis answered 6/8, 2015 at 5:51 Comment(1)
Is this the correct way to specify the array? "passive_filetypes": ["go", "html"] ?Nano
C
1

In .vimrc to ignore .env file for example:

let g:syntastic_ignore_files = ['.env']

From the :help syntastic:

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$']

There's also another one, syntastic_<filetype>_<checker>_quiet_messages:

Finally, variables 'g:syntastic___quiet_messages' can be used to filter out some of the messages produced by specific checkers. The effect is identical to that of |syntastic_quiet_messages|, except only messages from the corresponding checkers are filtered. Example: >

let g:syntastic_python_pylama_quiet_messages = {"type": "style","regex": '\m\[C03\d\d\]' }

Conviction answered 14/7, 2021 at 17:23 Comment(0)
R
0

You may be able to edit the settings for your particular HTML linter/checker but you can also add the following to your .vimrc or enter as a command:

au BufNewFile,BufRead *.html set b:syntastic_skip_checks = 1

au is autocommand, such that when a .html buffer is opened, syntastic skips checking it. The b: prefix only applies to the current buffer.

Recapitulation answered 4/8, 2015 at 21:19 Comment(2)
This works, sort of, but it definitely isn't how you're supposed to do it, and it also isn't the proper use for b:syntastic_skip_checks. Read about passive filetypes in the manual instead.Mercenary
Thanks for the pointer. Am I right in assuming that the arrays of types in syntastic_mode_map can be used to define just the exceptions to active checking ?Nano

© 2022 - 2024 — McMap. All rights reserved.