How to set up syntastic for vim?

2020-02-28 06:42发布

So I git cloned the repository to ~/.vim/bundle and had pathogen installed. I can be sure pathogen works fine since my other plugins in bundle are all working fine. After googling for a while, it seems that syntastic should work out of box for c code. I also checked that I have all the executables specified in syntastic/syntax_checkers/c/.

Here is a part of my .vimrc file:

" syntastic
let g:syntastic_auto_loc_list=1
let g:syntastic_disabled_filetypes=['html']
let g:syntastic_enable_signs=1

When I open a *.c file and do :SyntasticCheck, nothing happens. There is no errors complaining command not found, so syntastic is loaded. However, even if the *.c file that's currently opened contains errors syntax error, syntastic is not showing anything.

It is the first time I use syntastic so I don't really know the correct way to invoke it.

I also tried :SyntasticCheck [c] and I get the following error message:

Error detected while processing function <SNR>_22_UpdateErrors..<SNR>22_CacheErrors:
line 16:
E121: Undefined variable: checkers
E15: Invalid expression: checkers

Can someone tell me what I did wrong and how to invoke syntastic? Thanks!

标签: vim syntastic
4条回答
Fickle 薄情
2楼-- · 2020-02-28 07:15

Installing clang and/or ctags packages fixed this for me

查看更多
一夜七次
3楼-- · 2020-02-28 07:16

I don't really understand the reason, but when I re-installed the YouCompleteMe plugin for vim with ./install.sh --clang-completer. Syntastic works like charm.

查看更多
smile是对你的礼貌
4楼-- · 2020-02-28 07:28

Try adding this to your vimrc:

let g:syntastic_check_on_open=1
let g:syntastic_enable_signs=1

(This is lifted straight from my vimrc, which has some other Syntastic settings if you'd like.)

查看更多
beautiful°
5楼-- · 2020-02-28 07:36

I did two things and then Syntastic started to behave as expected with JS files and ESlint. Can't tell which one did the trick:

1- In the project's directory ran eslint --init.

2- Started vim opening the file without the -S flag.

Before it failed silently, no errors and no diagnostics. This is how ESlint behaves when there is no configuration file.

查看更多
登录 后发表回答