;;; rust-conf.el --- Configurations of rust-mode -*- lexical-binding: t; -*- ;; Copyright (C) 2022 李俊緯 ;; Author: 李俊緯 ;; 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 . ;;; 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) ;; Now this is built-in since Emacs-29. (require '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