在rust.cc社區中有一個關於rust編輯器的討論(話說很多人要學一個新語言,都會立即考慮編輯器的問題,包括我在內),主要關注的是,智能提示(這個真的太重要了)。大家討論下來有幾個選擇
1. eclipse
2. vs code(我用過,目前支持語言高亮顯示,但沒有智能提示,還是不順手)
3.emacs (GNU的創始人作品,再次向開源致敬)
4.SolidOak (我用過,體驗很不好)
5.atom (我最后選用了這個工具,是GitHub出品的,據說VS Code也是基於atom做的實現),配合racer做智能提示,還有linter-rust 做語法檢查。整體使用體驗是:很好,很強大
最終的效果如下
首先肯定是要先安裝atom,可以通過 https://atom.io/
然后,按照下面的幫助進行安裝配置
https://atom.io/packages/racer
- Ensure you have the Atom package language-rust installed and active. 安裝一個package(language-rust),這里又有一個有意思的package manager:apm ,參考 https://atom.io/packages/language-rust
- Ensure you have Racer properly installed. 然后安裝racer,參考 https://github.com/phildawes/racer,有意思的是整個工具本來就是用rust寫的,所以你可以下載源代碼(使用git)后,使用cargo build 進行編譯即可
- Ensure you have a copy of the rustc source code extracted on your disk. 需要下載rustc的源代碼,並且解壓縮到本地磁盤。參考 https://www.rust-lang.org/install.html和 https://github.com/rust-lang/rust
我是直接用git獲取了 https://github.com/rust-lang/rust 然后保存到本地一個目錄,例如
- Install this package via Atom's package manager: 通過命令或者配置工具安裝racer
- go to
Preferences > Packages
, search forracer
, and install it - OR use the command line
apm install racer
).
- go to
最后,要進行一些配置