blob: bec85a378dc1a53aebd942d1777916e896346178 (
plain)
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
;;; rust-conf.el --- Configurations of rust-mode -*- lexical-binding: t; -*-
;; Copyright (C) 2022 李俊緯
;; Author: 李俊緯 <mmemmew@gmail.com>
;; Keywords: convenience, c, data, emulations, faces, files, languages, local, tools
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
;;; Commentary:
;; This configures rust-mode.
;;; Code:
;;; Dependencies
(use-package "dash.el" 'dash)
(use-package "s.el" 's)
(use-package "f.el" 'f)
(require 'let-alist)
(use-package "markdown-mode" 'markdown-mode)
(require 'project)
(use-package "rust-mode" 'rust-mode)
(require 'seq)
(use-package "spinner.el" 'spinner)
(use-package "xterm-color" 'xterm-color)
(use-package "eglot" 'eglot)
(define-key eglot-mode-map (kbd "C-c r") #'eglot-rename)
(define-key eglot-mode-map (vector 3 ?\C-o)
#'eglot-code-action-organize-imports)
(define-key eglot-mode-map (kbd "C-c h") #'eldoc)
(setq eglot-autoshutdown t)
(setq eldoc-echo-area-use-multiline-p nil)
;; NOTE: I have manually commented out the line which requires
;; lsp-mode.
(use-package "rustic" 'rustic)
(setq rustic-lsp-client 'eglot)
(setq rustic-format-on-save t)
(setq rustic-lsp-setup-p nil)
(add-hook 'eglot-managed-mode-hook #'durand-rust-mode-hook)
(defun durand-rust-mode-hook ()
"Set up basic settings."
;; (remove-hook 'eldoc-documentation-functions
;; #'eglot-hover-eldoc-function)
)
;;; Fix a weird function
(defun durand-rustic-cargo-doc-a ()
"Open the documentation for the current project in a browser.
The documentation is built if necessary.
Modified by Durand -- 2022-02-09 21:43:19.966224"
(interactive)
(if (y-or-n-p "Open docs for dependencies as well?")
;; open docs only works with synchronous process
(shell-command (mapconcat #'identity
(list (rustic-cargo-bin) "doc --open")
" "))
(shell-command (mapconcat #'identity
(list (rustic-cargo-bin)
"doc --open --no-deps")
" "))))
(advice-add #'rustic-cargo-doc :override
#'durand-rustic-cargo-doc-a)
(provide 'rust-conf)
;;; rust-conf.el ends here
|