当前位置: 首页 > 工具软件 > Racer Rust > 使用案例 >

rust Linux环境下开发环境安装 和 IDE工具 EMACS配置

梁巴英
2023-12-01

官网:https://rustlang-cn.org/

安装教程:https://rustlang-cn.org/office/rust/book/getting-started/ch01-01-installation.html

emacs rust:https://manenko.com/2016/08/03/setup-emacs-for-rust-development.html

 

emacs 支持rust的配置

注:

1、export PATH="$HOME/.cargo/bin:$PATH"加到文件.bashrc,

(exec-path-from-shell-initialize)加到emacs配置文件以解决:auto-save-buffer cant locate executable rustfmt;

2、(setq racer-rust-src-path "/home/wang/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src")不能自动补全添加;

3、安装racer到此网站:https://github.com/racer-rust/emacs-racer

4、如果找不到racer添加:(setq racer-cmd "~/.cargo/bin/racer");

;; rust part

;;(require 'package)

;;(add-to-list 'package-archives

;; '("melpa" . "https://melpa.org/packages/") t)

(package-initialize)

(package-refresh-contents)

 

(add-hook 'racer-mode-hook #'company-mode)

(require 'rust-mode)

(add-hook 'rust-mode-hook

(lambda () (setq indent-tabs-mode nil)))

(setq rust-format-on-save t)

(define-key rust-mode-map (kbd "C-c C-c") 'rust-run)

(add-hook 'rust-mode-hook 'cargo-minor-mode)

(add-hook 'rust-mode-hook #'racer-mode)

(add-hook 'racer-mode-hook #'eldoc-mode)

(define-key rust-mode-map (kbd "TAB") #'company-indent-or-complete-common)

(setq company-tooltip-align-annotations t)

(exec-path-from-shell-initialize)

(setq racer-rust-src-path "/home/wang/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src")

 

 类似资料: