-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit-rust.el
41 lines (35 loc) · 1.08 KB
/
init-rust.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
(use-package rust-mode
;; :custom (rust-indent-offset 2)
:init
(add-hook! 'rust-mode-hook
(setq compile-command "cargo build")
(setq jester-run-command "cargo run")
(setq jester-test-command "cargo test"))
:mode "\\.rs\\'")
(use-package flycheck-rust
:init
(add-hook! 'flycheck-mode-hook #'flycheck-rust-setup))
(jester/def-make-assignment-function
jester/make-rust-assignment
";"
;; [empty] <=> let <=> let mut
(cond
((looking-at "let mut ") (replace-match ""))
((looking-at "let ") (replace-match "let mut "))
(t (insert "let "))))
(defun jester/rust-insert-fat-or-slim-arrow ()
"Insert a fat or slim arrow, depending on whether in a match body."
(interactive)
(save-match-data
(insert (if (save-excursion
(search-backward "{")
(beginning-of-line-text)
(looking-at "match"))
" => "
" -> "))))
(general-define-key
:states '(insert emacs)
:keymaps 'rust-mode-map
"C-j" 'jester/make-rust-assignment
"C-l" 'jester/rust-insert-fat-or-slim-arrow)
(provide 'init-rust)