在 vim 中使用 syntastic 时,如何有选择地禁用某些文件类型的检查器?

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

例如,HTML 部分模板被标记为大量错误,但它们应该是完整 HTML 文档的片段。

您可以为您的特定 HTML linter/checker 编辑设置,但您也可以将以下内容添加到您的 .vimrc 或作为命令输入:

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

au 是自动命令,因此当打开 .html 缓冲区时,syntastic 会跳过检查它。 b: 前缀仅适用于当前缓冲区。

在你的.vimrc中:

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

这会将 Syntastic 设置为活动模式(在保存或打开时进行检查)但不适用于 Go 文件,在这种情况下,Go 文件仅在显式 运行 :SyntasticCheck 时才会被检查。只需将 passive_filetypes 的数组更改为您需要的数组即可。

.vimrc中忽略.env文件例如:

let g:syntastic_ignore_files = ['.env']

来自: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$']

还有一个,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\]' }