Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
4.5k views
in Technique[技术] by (71.8m points)

visual studio code - How to enable real-time linting while typing with rust-analyzer in VSCode?

I have rust-analyzer extension in VSCode.

In settings I only changed Rust-analyzer ? Check On Save: Command from check to clippy (this shouldn't matter).

Problem is I don't see errors when I type, only after I save.

Typed (no error):

typing

Saved (can see error):

saved

Can it be changed?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Problem is I don't see errors when I type, only after I save.

Rust-analyzer does not support real-time linting (yet?).

In short, rust-analyzer essentially runs cargo check. For small projects this can be quite fast. However, as project sizes increase, this can take significantly more time, which makes it unfeasible to check in real-time.

See also issue #4185 and "Drawbacks" on the "First Release" post.


The next best thing you can do (as you already know), is to use "check on save":

"rust-analyzer.checkOnSave.enable": true

(which is enabled by default in the VSCode extension)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...