1、Subline Text 3html
1. 插件下載:
Ctrl+Shift+P 調用命令面板,咱們就會找到一些以「Package Control:」開頭的命令,找到 Install Package (安裝擴展),肯定後出現命令行,
輸入:Rust ,找到插件,確認安裝
輸入:RustAutoComplete,找到racer插件,確認安裝
輸入:RustCodeFormatter 格式化插件,順便安裝
Ctrl+Shift+P 調用命令面板,輸入:Package Control: List Package,顯示列出已安裝的插件
2. 插件配置
編輯 Sublime 下的插件包管理下的 RustAutoComplete 下的 Settings - User ,寫入
git
{ // racer.exe絕對路徑 "racer": "D:/RustPath/racer/target/debug/racer.exe", // rust源碼文件路徑 "search_paths": [ "D:/RustPath/source/rust-nightly-src/rust-nightly/src" ] }
其實文件就在:Sublime Text的Packages\User目錄下(我機器是C:\Users\XXX\AppData\Roaming\Sublime Text 3\Packages\User)github
2、Eclipse
1. 推薦下載推薦你們下載的是這個開發C/C++的Eclipse版本,自帶了CDT插件。
2. 打開Eclipse,「help」--> "Install news software" --> 輸入地址 "https://rustdt.github.io/releases/" --> 選擇「RustDT Project」--> 接下都一路Next下去就能夠。
該插件開源地址:https://github.com/RustDT/RustDT。
3. 配置Rust,打開「Windows」-->「Preferences」->「Rust」,配置Rust的安裝地址,本機源碼地址,本機racer地址。
4. 打開Rust開發視圖。web
5. 新建工程,「File」--> 「New」--> 直接選擇"Rust Cargo Project",輸入工程名字完成建立。
它這個建立一樣是調用cargo的命令來建立,即如命令執行「cargo new hello_world --bin」json
6. 編譯運行工程,點菜單欄的「Run」,選擇「Run configuraions」(或者點開工具欄中的綠色三角形運行按鈕,旁邊還有個下拉圖標,點開選擇「Run configuraion」)
雙擊「Rust Application」,在Program path選擇編譯好的Hello World可執行文件,以下圖。再點擊 Run 便可在Console中看到 Hello, world!,其實,若是你選中項目名稱,直接「Run」--> 「Run As」,會有一項「 1 Rust Application」供你選擇,它也會直接識別你工程下的main.rs,並加載運行。api
3、Atom
參考文章:http://www.cnblogs.com/chenxizhang/p/4759921.html
1. 安裝插件支持
打開「File」--> 「Setting」--> 「Install」,在搜索框輸入「Rust」,會列出多個Rust相關的插件包,可選擇安裝的有「language-rust」,「linter-rust」,「rust-api-docs-helper」,"racer"。
「language-rust」代碼高亮
「linter-rust」語法檢查,在打開或保存文件的時候會自動調用
「build「 一個編譯工程的插件,經過配置腳本,配置源目錄、目標目錄信息等
「build-cargo」經過cargo的進行Build工程,前提是你已經安裝好 了」build「,這個插件只在build基礎上添加了cargo的功能
「racer「 智能提示安全
2. 配置插件
(1)「racer「 插件
打開「File」--> 「Setting」--> 「Packages」, 在已安裝插件包列表中,點中racer插件,在插件設置中
「Path to Racer executable」中填入:D:\RustPath\racer\target\debug\racer.exe
「Path to Racer source code directory」中填入:D:\RustPath\source\src
(2)「build-cargo」插件
「Path to Cargo executable」中填入:C:\Program Files\Rust stable 1.5\bin\cargo.exe,默認會讀取Path中Rust的配置,因此通常不須要本身再填
完畢後,按F9能夠build工程了,這必需是帶有cargo.toml的工程才能夠,另外在左下方有cargo的命令能夠點擊選擇使用,執行命令成功後會在下面閃現出執行結果。編輯器
(3)「linter-rust」插件
「Cargo Path 」中填入:C:\Program Files\Rust stable 1.5\bin\cargo.exe
以上插件安裝完畢,那麼你就能夠在Atom上進行完整的建立工程、編寫代碼、編譯和運行代碼了。工具
4、Visual Studio Code
1. 下載地址:https://code.visualstudio.com/download, 安裝過程很少說,從安全完畢進行配置開始
2. VS Code的各類官方插件下載地址:https://marketplace.visualstudio.com/#VSCode
(1)Rust的插件的官網介紹。
在頁面上找到「Languages」部分,通常這裏看不到Rust的插件,點「see more」進去,找到Rust語言的插件,點開,地址以下:
https://marketplace.visualstudio.com/items/saviorisdead.RustyCode
咱們能夠在這個頁面看如何使用這個插件,這個插件還包含了racer,只須要配置下路徑便可。
(2)打開VS Code的命令行,能夠用F1或者Ctrl+Shift+p,輸入「ext」,在即時顯示的下拉菜單裏選擇「Extensions:Install Extension」, 會有從左到右閃現的光標表示等待載入可安裝插件列表,固然也能夠「Ctrl+p」,直接輸入「ext install」,而後按空格,也會出現閃現光標等待載入可安裝插件列表,載入過程比較慢,且任何其它操做都會打斷這個載入過程,這個比較坑爹。
(3)在可安裝列表顯示後,繼續敲入「rust」,可過濾到Rust的開發插件「Rust code 」,點選該插件並點擊「Install Now」按鈕,並開始了安裝過程,安裝完畢後點「Restart」重啓後可生效。
(4)「File」-->「Preferences」-->「User Setting」,打開後窗口左邊既會顯示default setting,也會顯示settings.json頁面,咱們在這個json頁面加入以下內容:
開發工具
{ "editor.fontSize": 18, "rust.racerPath": "D:/RustPath/racer/target/debug\racer.exe", // Specifies path to Racer binary if it's not in PATH "rust.rustLangSrcPath": "D:/RustPath/source/src", // Specifies path to /src directory of local copy of Rust sources "rust.rustfmtPath": null, // Specifies path to Rustfmt binary if it's not in PATH "rust.cargoPath": "C:/Program Files/Rust stable 1.5/bin/cargo.exe", // Specifies path to Cargo binary if it's not in PATH "rust.formatOnSave": false // Turn on/off autoformatting file on save (EXPERIMENTAL) }
若是你須要安裝格式化工具,你能夠去以下地址下載,是rust開發,能夠用rust編譯出可執行文件出來,並將文件地址填到上面的配置文件中。
Rustfmt:https://github.com/rust-lang-nursery/rustfmt
編輯器默認的字體太笑,能夠順便修改的默認大小,將"editor.fontSize": 18 也添加到上述配置文件中。
都說Visual Studio Code是基於Atom開發的,怎麼Atom打開工具的速度比Visual Studio Code慢了2倍不止。
(5)插件已經安裝完畢,若是使用VS Code對工程進行編譯呢?
首先VS Code 並無直接提供對rust開發工程功能,咱們必須本身手動,要麼我的打開命令行執行cargo命令,要麼按以下方法進行設置。
A. 創建Build任務,使用「Command+Shift+P」打開命令行,輸入「task」,在即時顯示的下拉菜單裏選擇「Configure Task Runner」,打開任務創建配置文件tasks.json,使用/**/屏蔽原有的樣例,填以下面的配置:
{ "version": "0.1.0", "command": "cargo", "isShellCommand": true, "tasks": [ { "taskName": "build", "isBuildCommand": true, "showOutput": "always", "problemMatcher": { "owner": "rust", "fileLocation": [ "relative", "${workspaceRoot}" ], "pattern": { "regexp": "^(.*):(\\d+):(\\d+):\\s+(\\d+):(\\d+)\\s+(warning|error):\\s+(.*)$", "file": 1, "line": 2, "column": 3, "endLine": 4, "endColumn": 5, "severity": 6, "message": 7 } } }, { "taskName": "clean", "showOutput": "always" }, { "taskName": "run", "showOutput": "always" }, { "taskName": "test", "showOutput": "always", "isTestCommand": true, "problemMatcher": [ { "owner": "rust", "fileLocation": [ "relative", "${workspaceRoot}" ], "pattern": { "regexp": "^(.*):(\\d+):(\\d+):\\s+(\\d+):(\\d+)\\s+(warning|error):\\s+(.*)$", "file": 1, "line": 2, "column": 3, "endLine": 4, "endColumn": 5, "severity": 6, "message": 7 } }, { "owner": "rust", "fileLocation": [ "relative", "${workspaceRoot}" ], "severity": "error", "pattern": { "regexp": "^.*panicked\\s+at\\s+'(.*)',\\s+(.*):(\\d+)$", "message": 1, "file": 2, "line": 3 } } ] } ] }
B. 給上述配置的任務添加快捷鍵,即「File」-->「Keybord Shortcuts」,在打開的keybinds.json添加以下快捷鍵:
// Place your key bindings in this file to overwrite the defaults [ { "key": "shift+alt+r", "command": "workbench.action.tasks.runTask" } ]
保存以上配置,重啓VS Code生效,我的也能夠選擇本身習慣的按鍵來使用,注意最好不要跟默認的快捷鍵發送衝突。
C. 測試,「File」-->「Open Folder」打開工程目錄,使用「shift+alt+r」打開運行命令行,選擇其中之一即可以成功運行!
至此,關於Rust開發工具介紹完畢。