Menu Home

My Rust Emacs config

Reference

Robert Krahn’s excellent Configuring Emacs for Rust development.

Troubles or issues

  • LSP Language Server and Rustic mode unpredictably quitting.
    • This seems to have stabilized after I restarted Emacs a few times. Have yet to narrow down what the original cause was.

Config

;; Rust-specific setup
(use-package rustic
  :straight t
  :bind (:map rustic-mode-map
              ("M-j" . lsp-ui-imenu)
              ("M-?" . lsp-find-references)
              ("C-c C-c l" . flycheck-list-errors)
              ("C-c C-c a" . lsp-execute-code-action)
              ("C-c C-c r" . lsp-rename)
              ("C-c C-c q" . lsp-workspace-restart)
              ("C-c C-c Q" . lsp-workspace-shutdown)
              ("C-c C-c s" . lsp-rust-analyzer-status))


  :config
  (setq rustic-format-on-save t)
  (add-hook 'rustic-mode-hook 'kb/rustic-mode-hook) )

(defun kb/rustic-mode-hook()
  (when buffer-file-name
    (setq-local buffer-save-without-query t)))

;; Configuration to my lsp-mode use-package declaration
;; Rust
  (lsp-rust-analyzer-server-display-inlay-hints t)
  (lsp-rust-analyzer-display-lifetime-elision-hints-enable "skip_trivial")
  (lsp-rust-analyzer-display-chaining-hints t)
  (lsp-rust-analyzer-display-lifetime-elision-hints-use-parameter-names nil)
  (lsp-rust-analyzer-display-closure-return-type-hints t)
  (lsp-rust-analyzer-display-parameter-hints nil)
  (lsp-rust-analyzer-display-reborrow-hints nil)

Categories: development-environment Emacs

Tagged as:

Kent Bull

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: