[ADD] Rust LSP to emacs config
This commit is contained in:
76
.emacs
76
.emacs
@@ -29,7 +29,6 @@
|
||||
(column-number-mode 1)
|
||||
(show-paren-mode 1)
|
||||
(electric-pair-mode 1)
|
||||
(global-font-lock-mode 0)
|
||||
(global-display-line-numbers-mode 1)
|
||||
(setq display-line-numbers-type 'relative)
|
||||
(set-face-attribute 'default nil :height 200)
|
||||
@@ -44,6 +43,77 @@
|
||||
(setq-default display-fill-column-indicator-column 79) ; 80 column indicator - Emacs columns are 0-based...
|
||||
(global-display-fill-column-indicator-mode 1)
|
||||
|
||||
(unless (package-installed-p 'lsp-mode)
|
||||
(package-install 'lsp-mode))
|
||||
|
||||
(use-package lsp-mode
|
||||
:init
|
||||
:config
|
||||
(add-hook 'lsp-mode-hook 'lsp-ui-mode)
|
||||
:custom
|
||||
;; what to use when checking on-save. "check" is default, I prefer clippy
|
||||
(lsp-rust-analyzer-cargo-watch-command "clippy")
|
||||
(lsp-eldoc-render-all t)
|
||||
(lsp-idle-delay 0.6)
|
||||
;; enable / disable the hints as you prefer:
|
||||
(lsp-inlay-hint-enable t)
|
||||
;; These are optional configurations. See https://emacs-lsp.github.io/lsp-mode/page/lsp-rust-analyzer/#lsp-rust-analyzer-display-chaining-hints for a full list
|
||||
(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-reborrow-hints nil)
|
||||
:hook (;; replace XXX-mode with concrete major-mode(e. g. python-mode)
|
||||
(c-mode . lsp)
|
||||
(python-mode . lsp))
|
||||
:commands lsp)
|
||||
|
||||
;;https://robert.kra.hn/posts/rust-emacs-setup/
|
||||
(use-package rustic
|
||||
:ensure
|
||||
: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
|
||||
;; uncomment for less flashiness
|
||||
;; (setq lsp-eldoc-hook nil)
|
||||
;; (setq lsp-enable-symbol-highlighting nil)
|
||||
;; (setq lsp-signature-auto-activate nil)
|
||||
|
||||
;; comment to disable rustfmt on save
|
||||
(setq rustic-format-on-save t)
|
||||
(add-hook 'rustic-mode-hook 'rk/rustic-mode-hook))
|
||||
|
||||
(defun rk/rustic-mode-hook ()
|
||||
;; so that run C-c C-c C-r works without having to confirm, but don't try to
|
||||
;; save rust buffers that are not file visiting. Once
|
||||
;; https://github.com/brotzeit/rustic/issues/253 has been resolved this should
|
||||
;; no longer be necessary.
|
||||
(when buffer-file-name
|
||||
(setq-local buffer-save-without-query t))
|
||||
(add-hook 'before-save-hook 'lsp-format-buffer nil t))
|
||||
|
||||
;; company
|
||||
(unless (package-installed-p 'company)
|
||||
(package-install 'company))
|
||||
|
||||
(use-package company
|
||||
:after lsp-mode
|
||||
:hook (prog-mode . company-mode)
|
||||
:bind (:map company-active-map
|
||||
("<tab>" . company-complete-selection))
|
||||
(:map lsp-mode-map
|
||||
("<tab>" . company-indent-or-complete-common))
|
||||
:custom
|
||||
(company-minimum-prefix-length 1)
|
||||
(company-idle-delay 0.0))
|
||||
|
||||
(setq neo-theme (if (display-graphic-p) 'icons))
|
||||
|
||||
;; Use keybindings
|
||||
@@ -80,6 +150,10 @@
|
||||
(unless (package-installed-p 'exwm)
|
||||
(package-install 'exwm))
|
||||
|
||||
(require 'exwm)
|
||||
(require 'exwm-config)
|
||||
;;(exwm-config-example)
|
||||
|
||||
(defun my-untabify-all-lines ()
|
||||
"Select all lines in the buffer and run 'untabify' on them."
|
||||
(interactive)
|
||||
|
||||
Reference in New Issue
Block a user