From 9f37363764beedf81f58b763c4feac9ff9fb0493 Mon Sep 17 00:00:00 2001 From: chrunchyjesus Date: Thu, 4 Jul 2019 20:58:44 +0200 Subject: [PATCH 1/4] use keybindings from cargo mode --- modules/lang/rust/README.org | 21 +++++++++++++++------ modules/lang/rust/autoload.el | 6 ------ modules/lang/rust/config.el | 17 +++++++++++++---- modules/lang/rust/packages.el | 1 + 4 files changed, 29 insertions(+), 16 deletions(-) diff --git a/modules/lang/rust/README.org b/modules/lang/rust/README.org index 32f18b69d..43cd48e48 100644 --- a/modules/lang/rust/README.org +++ b/modules/lang/rust/README.org @@ -27,6 +27,7 @@ Add support to Rust language and cargo commands inside emacs. ** Plugins + [[https://github.com/rust-lang/rust-mode][Rust-mode]] + [[https://github.com/racer-rust/emacs-racer][Racer-mode]] ++ [[https://github.com/racer-rust/emacs-racer][Cargo-mode]] ** Hacks {A list of internal modifications to included packages} @@ -45,12 +46,20 @@ This module also supports LSP, it requires installation of Rust Language Server Keybindings -| Binding | Description | -|---------------------+---------------| -| ~ b b~ | ~cargo build~ | -| ~ b c~ | ~cargo check~ | -| ~ b r~ | ~cargo run~ | -| ~ b t~ | ~cargo test~ | +| Binding | Description | +|-----------------------+--------------------------| +| ~ b a~ | ~cargo add~ | +| ~ b b~ | ~cargo build~ | +| ~ b B~ | ~cargo bench~ | +| ~ b c~ | ~cargo check~ | +| ~ b C~ | ~cargo clippy~ | +| ~ b d~ | ~cargo doc~ | +| ~ b r~ | ~cargo run~ | +| ~ b s~ | ~cargo search~ | +| ~ b u~ | ~cargo update~ | +| ~ b t a~ | ~cargo test~ | +| ~ b t f~ | ~run tests current file~ | +| ~ b t t~ | ~run current test~ | * TODO Configuration How to configure this module, including common problems and how to address them. diff --git a/modules/lang/rust/autoload.el b/modules/lang/rust/autoload.el index 5d2333220..9f584cb44 100644 --- a/modules/lang/rust/autoload.el +++ b/modules/lang/rust/autoload.el @@ -7,12 +7,6 @@ "Return t if this is a cargo project." (locate-dominating-file buffer-file-name "Cargo.toml")) -;;;###autoload -(defun +rust-cargo-compile (command) - "TODO" - (let ((default-directory (+rust-cargo-project-p))) - (compile command))) - ;;;###autoload (defun +rust-racer-lookup-documentation (identifier) "A `+lookup/documentation' handler for Rust + Racer." diff --git a/modules/lang/rust/config.el b/modules/lang/rust/config.el index c199d2c4c..de13febeb 100644 --- a/modules/lang/rust/config.el +++ b/modules/lang/rust/config.el @@ -10,10 +10,19 @@ (map! :map rust-mode-map :localleader :prefix "b" - :desc "cargo build" "b" (λ! (+rust-cargo-compile "cargo build --color always")) - :desc "cargo check" "c" (λ! (+rust-cargo-compile "cargo check --color always")) - :desc "cargo run" "r" (λ! (+rust-cargo-compile "cargo run --color always")) - :desc "cargo test" "t" (λ! (+rust-cargo-compile "cargo test --color always")))) + :desc "cargo add" "a" #'cargo-process-add + :desc "cargo build" "b" #'cargo-process-build + :desc "cargo build" "B" #'cargo-process-bench + :desc "cargo check" "c" #'cargo-process-check + :desc "cargo clippy" "C" #'cargo-process-clippy + :desc "cargo doc" "d" #'cargo-process-doc + :desc "cargo run" "r" #'cargo-process-run + :desc "cargo search" "s" #'cargo-process-search + :desc "cargo update" "u" #'cargo-process-update + (:prefix-map ("t" . "cargo test") + :desc "all" "a" #'cargo-process-test + :desc "current file" "f" #'cargo-process-current-file-tests + :desc "current test" "t" #'cargo-process-current-test))) (def-package! racer diff --git a/modules/lang/rust/packages.el b/modules/lang/rust/packages.el index 3f5efb252..caec95715 100644 --- a/modules/lang/rust/packages.el +++ b/modules/lang/rust/packages.el @@ -2,6 +2,7 @@ ;;; lang/rust/packages.el (package! rust-mode) +(package! cargo) (when (featurep! :tools flycheck) (package! flycheck-rust)) From 883c390e2e7677df357683f44d770b079cbf3d61 Mon Sep 17 00:00:00 2001 From: chrunchyjesus Date: Thu, 4 Jul 2019 21:13:21 +0200 Subject: [PATCH 2/4] add documentation regarding some commands --- modules/lang/rust/README.org | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/modules/lang/rust/README.org b/modules/lang/rust/README.org index 43cd48e48..d175df1fe 100644 --- a/modules/lang/rust/README.org +++ b/modules/lang/rust/README.org @@ -40,6 +40,14 @@ To get started with Rust, you can either use =rustup= and install rust with: Package manager is not recommended to install Nightly version of Rust what is required for ~racer~ from [[https://github.com/racer-rust/racer#installation][version 2.1]] (more info in [[#Troubleshooting][Troubleshooting]]) +Some commands require additional crates to be installed to work, e.g. ~cargo +add~. +#+BEGIN_SRC sh +rustup component add rustfmt +rustup component add cargo-check +rustup component add cargo-edit +#+END_SRC + * Features This module also supports LSP, it requires installation of Rust Language Server [[https://github.com/rust-lang/rls][~RLS~]]. To enable this you need to enable ~lsp~ in ~:tools~ section in ~init.el~ file. From 301173f35fcbae5ee556996ea55d60006537a4b6 Mon Sep 17 00:00:00 2001 From: chrunchyjesus Date: Thu, 4 Jul 2019 21:33:13 +0200 Subject: [PATCH 3/4] remove b prefix, small refactor --- modules/lang/rust/README.org | 28 ++++++++++++++-------------- modules/lang/rust/config.el | 34 ++++++++++++++++++---------------- 2 files changed, 32 insertions(+), 30 deletions(-) diff --git a/modules/lang/rust/README.org b/modules/lang/rust/README.org index d175df1fe..505845146 100644 --- a/modules/lang/rust/README.org +++ b/modules/lang/rust/README.org @@ -54,20 +54,20 @@ This module also supports LSP, it requires installation of Rust Language Server Keybindings -| Binding | Description | -|-----------------------+--------------------------| -| ~ b a~ | ~cargo add~ | -| ~ b b~ | ~cargo build~ | -| ~ b B~ | ~cargo bench~ | -| ~ b c~ | ~cargo check~ | -| ~ b C~ | ~cargo clippy~ | -| ~ b d~ | ~cargo doc~ | -| ~ b r~ | ~cargo run~ | -| ~ b s~ | ~cargo search~ | -| ~ b u~ | ~cargo update~ | -| ~ b t a~ | ~cargo test~ | -| ~ b t f~ | ~run tests current file~ | -| ~ b t t~ | ~run current test~ | +| Binding | Description | +|---------------------+-----------------------------| +| ~ a~ | ~cargo add~ | +| ~ b~ | ~cargo build~ | +| ~ B~ | ~cargo bench~ | +| ~ c~ | ~cargo check~ | +| ~ C~ | ~cargo clippy~ | +| ~ d~ | ~cargo doc~ | +| ~ r~ | ~cargo run~ | +| ~ s~ | ~cargo search~ | +| ~ u~ | ~cargo update~ | +| ~ t a~ | ~cargo test~ | +| ~ t f~ | ~run tests in current file~ | +| ~ t t~ | ~run current test~ | * TODO Configuration How to configure this module, including common problems and how to address them. diff --git a/modules/lang/rust/config.el b/modules/lang/rust/config.el index de13febeb..5cb508ed4 100644 --- a/modules/lang/rust/config.el +++ b/modules/lang/rust/config.el @@ -7,22 +7,24 @@ (when (featurep! +lsp) (add-hook 'rust-mode-hook #'lsp!)) - (map! :map rust-mode-map - :localleader - :prefix "b" - :desc "cargo add" "a" #'cargo-process-add - :desc "cargo build" "b" #'cargo-process-build - :desc "cargo build" "B" #'cargo-process-bench - :desc "cargo check" "c" #'cargo-process-check - :desc "cargo clippy" "C" #'cargo-process-clippy - :desc "cargo doc" "d" #'cargo-process-doc - :desc "cargo run" "r" #'cargo-process-run - :desc "cargo search" "s" #'cargo-process-search - :desc "cargo update" "u" #'cargo-process-update - (:prefix-map ("t" . "cargo test") - :desc "all" "a" #'cargo-process-test - :desc "current file" "f" #'cargo-process-current-file-tests - :desc "current test" "t" #'cargo-process-current-test))) + (def-package! cargo + :defer t + :init + (map! :map rust-mode-map + :localleader + :desc "cargo add" "a" #'cargo-process-add + :desc "cargo build" "b" #'cargo-process-build + :desc "cargo bench" "B" #'cargo-process-bench + :desc "cargo check" "c" #'cargo-process-check + :desc "cargo clippy" "C" #'cargo-process-clippy + :desc "cargo doc" "d" #'cargo-process-doc + :desc "cargo run" "r" #'cargo-process-run + :desc "cargo search" "s" #'cargo-process-search + :desc "cargo update" "u" #'cargo-process-update + (:prefix ("t" . "cargo test") + :desc "all" "a" #'cargo-process-test + :desc "current file" "f" #'cargo-process-current-file-tests + :desc "current test" "t" #'cargo-process-current-test)))) (def-package! racer From e577ce01621c4380aeb7e6acb50b81712d4b1f25 Mon Sep 17 00:00:00 2001 From: chrunchyjesus Date: Fri, 5 Jul 2019 16:15:05 +0200 Subject: [PATCH 4/4] add b prefix back --- modules/lang/rust/README.org | 18 +++++++++--------- modules/lang/rust/config.el | 19 ++++++++++--------- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/modules/lang/rust/README.org b/modules/lang/rust/README.org index 505845146..4342cd1ed 100644 --- a/modules/lang/rust/README.org +++ b/modules/lang/rust/README.org @@ -56,15 +56,15 @@ Keybindings | Binding | Description | |---------------------+-----------------------------| -| ~ a~ | ~cargo add~ | -| ~ b~ | ~cargo build~ | -| ~ B~ | ~cargo bench~ | -| ~ c~ | ~cargo check~ | -| ~ C~ | ~cargo clippy~ | -| ~ d~ | ~cargo doc~ | -| ~ r~ | ~cargo run~ | -| ~ s~ | ~cargo search~ | -| ~ u~ | ~cargo update~ | +| ~ b a~ | ~cargo add~ | +| ~ b b~ | ~cargo build~ | +| ~ b B~ | ~cargo bench~ | +| ~ b c~ | ~cargo check~ | +| ~ b C~ | ~cargo clippy~ | +| ~ b d~ | ~cargo doc~ | +| ~ b r~ | ~cargo run~ | +| ~ b s~ | ~cargo search~ | +| ~ b u~ | ~cargo update~ | | ~ t a~ | ~cargo test~ | | ~ t f~ | ~run tests in current file~ | | ~ t t~ | ~run current test~ | diff --git a/modules/lang/rust/config.el b/modules/lang/rust/config.el index 5cb508ed4..4ab64e9dc 100644 --- a/modules/lang/rust/config.el +++ b/modules/lang/rust/config.el @@ -12,15 +12,16 @@ :init (map! :map rust-mode-map :localleader - :desc "cargo add" "a" #'cargo-process-add - :desc "cargo build" "b" #'cargo-process-build - :desc "cargo bench" "B" #'cargo-process-bench - :desc "cargo check" "c" #'cargo-process-check - :desc "cargo clippy" "C" #'cargo-process-clippy - :desc "cargo doc" "d" #'cargo-process-doc - :desc "cargo run" "r" #'cargo-process-run - :desc "cargo search" "s" #'cargo-process-search - :desc "cargo update" "u" #'cargo-process-update + (:prefix "b" + :desc "cargo add" "a" #'cargo-process-add + :desc "cargo build" "b" #'cargo-process-build + :desc "cargo bench" "B" #'cargo-process-bench + :desc "cargo check" "c" #'cargo-process-check + :desc "cargo clippy" "C" #'cargo-process-clippy + :desc "cargo doc" "d" #'cargo-process-doc + :desc "cargo run" "r" #'cargo-process-run + :desc "cargo search" "s" #'cargo-process-search + :desc "cargo update" "u" #'cargo-process-update) (:prefix ("t" . "cargo test") :desc "all" "a" #'cargo-process-test :desc "current file" "f" #'cargo-process-current-file-tests