diff options
author | JSDurand <mmemmew@gmail.com> | 2022-02-09 22:35:31 +0800 |
---|---|---|
committer | JSDurand <mmemmew@gmail.com> | 2022-02-09 22:35:31 +0800 |
commit | 435c95393459d0c7825a4431f0ebcec6898ba16b (patch) | |
tree | af55520cd89ca7a98df7861e036bb9d98f85b48d /rust-conf.el | |
parent | 76747a2aadd216596ee386e0025ab651a32f16fa (diff) |
add configurations for rust
* common.el (common):
* init.el (rustic-mode):
(assoc):
* rust-conf.el ("dash.el"):
("s.el"):
("f.el"):
(let-alist):
("markdown-mode"):
(project):
("rust-mode"):
(seq):
("spinner.el"):
("xterm-color"):
("eglot"):
(eglot-mode-map):
(eglot-autoshutdown):
("rustic"):
(rustic-lsp-client):
(rustic-format-on-save):
(eglot-managed-mode-hook):
(durand-rust-mode-hook):
(durand-rustic-cargo-doc-a):
(#'rustic-cargo-doc):
(rust-conf):
Diffstat (limited to 'rust-conf.el')
-rw-r--r-- | rust-conf.el | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/rust-conf.el b/rust-conf.el new file mode 100644 index 0000000..10adb5c --- /dev/null +++ b/rust-conf.el @@ -0,0 +1,83 @@ +;;; 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 (kbd "C-c o") + #'eglot-code-action-organize-imports) +(define-key eglot-mode-map (kbd "C-c h") #'eldoc) + +(setq eglot-autoshutdown t) + +;; 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) + +(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 |