lang/rust: use rustic-mode instead on Emacs 26+
This commit is contained in:
parent
683683736d
commit
236c9ceeab
2 changed files with 60 additions and 29 deletions
|
@ -1,44 +1,73 @@
|
||||||
;;; lang/rust/config.el -*- lexical-binding: t; -*-
|
;;; lang/rust/config.el -*- lexical-binding: t; -*-
|
||||||
|
|
||||||
(after! rust-mode
|
(def-package! rust-mode
|
||||||
(set-docsets! 'rust-mode "Rust")
|
:mode ("\\.rs$" . +rust|init)
|
||||||
|
:config
|
||||||
(setq rust-indent-method-chain t)
|
(setq rust-indent-method-chain t)
|
||||||
|
|
||||||
|
(defun +rust|init ()
|
||||||
|
"Use `rustic-mode' if possible, otherwise fall back to `rust-mode'."
|
||||||
|
(if (and EMACS26+ (require 'rustic nil t))
|
||||||
|
(rustic-mode)
|
||||||
|
(rust-mode)))
|
||||||
|
|
||||||
|
(set-docsets! '(rust-mode rustic-mode) "Rust")
|
||||||
(when (featurep! +lsp)
|
(when (featurep! +lsp)
|
||||||
(add-hook 'rust-mode-local-vars-hook #'lsp!))
|
(add-hook 'rust-mode-local-vars-hook #'lsp!))
|
||||||
|
|
||||||
(def-package! cargo
|
;; TODO PR these upstream
|
||||||
:defer t
|
(after! dtrt-indent
|
||||||
:init
|
(pushnew! dtrt-indent-hook-mapping-list
|
||||||
(map! :map rust-mode-map
|
'(rust-mode default rust-indent-offset)
|
||||||
:localleader
|
'(rustic-mode default rustic-indent-offset)))
|
||||||
(:prefix "b"
|
(when (featurep! :tools editorconfig)
|
||||||
:desc "cargo add" "a" #'cargo-process-add
|
(after! editorconfig
|
||||||
:desc "cargo build" "b" #'cargo-process-build
|
(pushnew! editorconfig-indentation-alist
|
||||||
:desc "cargo bench" "B" #'cargo-process-bench
|
'(rust-mode rust-indent-offset)
|
||||||
:desc "cargo check" "c" #'cargo-process-check
|
'(rustic-mode rustic-indent-offset)))))
|
||||||
: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
|
(def-package! racer
|
||||||
:unless (featurep! +lsp)
|
:unless (featurep! +lsp)
|
||||||
:after rust-mode
|
:hook ((rust-mode rustic-mode) . racer-mode)
|
||||||
:config
|
:config
|
||||||
(add-hook 'rust-mode-hook #'racer-mode)
|
|
||||||
(set-lookup-handlers! 'rust-mode
|
(set-lookup-handlers! 'rust-mode
|
||||||
:definition '(racer-find-definition :async t)
|
:definition '(racer-find-definition :async t)
|
||||||
:documentation '+rust-racer-lookup-documentation))
|
:documentation '+rust-racer-lookup-documentation))
|
||||||
|
|
||||||
|
|
||||||
(def-package! flycheck-rust
|
(def-package! rustic
|
||||||
:when (featurep! :tools flycheck)
|
:when EMACS26+
|
||||||
:after rust-mode
|
:after rust-mode
|
||||||
:config (add-hook 'rust-mode-hook #'flycheck-rust-setup))
|
:config
|
||||||
|
(setq rustic-indent-method-chain rust-indent-method-chain
|
||||||
|
rustic-flycheck-setup-mode-line-p nil
|
||||||
|
rustic-rls-pkg (featurep! +lsp)))
|
||||||
|
|
||||||
|
|
||||||
|
;;
|
||||||
|
;;; Tools
|
||||||
|
|
||||||
|
(def-package! cargo
|
||||||
|
:after rust-mode
|
||||||
|
:config
|
||||||
|
(defvar +rust-keymap
|
||||||
|
(if (boundp 'rustic-mode-map)
|
||||||
|
rustic-mode-map
|
||||||
|
rust-mode-map))
|
||||||
|
(map! :map +rust-keymap
|
||||||
|
:localleader
|
||||||
|
(: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
|
||||||
|
:desc "current test" "t" #'cargo-process-current-test)))
|
||||||
|
|
|
@ -1,11 +1,13 @@
|
||||||
;; -*- no-byte-compile: t; -*-
|
;; -*- no-byte-compile: t; -*-
|
||||||
;;; lang/rust/packages.el
|
;;; lang/rust/packages.el
|
||||||
|
|
||||||
|
(when EMACS26+
|
||||||
|
(package! rustic))
|
||||||
(package! rust-mode)
|
(package! rust-mode)
|
||||||
(package! cargo)
|
|
||||||
|
|
||||||
(when (featurep! :tools flycheck)
|
(when (featurep! :tools flycheck)
|
||||||
(package! flycheck-rust))
|
(package! flycheck-rust))
|
||||||
|
|
||||||
(unless (featurep! +lsp)
|
(unless (featurep! +lsp)
|
||||||
(package! racer))
|
(package! racer))
|
||||||
|
|
||||||
|
;;
|
||||||
|
(package! cargo)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue