summaryrefslogtreecommitdiff
path: root/emacs.d/init.el
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2021-07-18 12:25:07 +0300
committerLars Wirzenius <liw@liw.fi>2021-07-18 12:25:07 +0300
commitba6730976e5ec75116cfb8eab85209f03e288336 (patch)
tree72ad4396f9d13d92dfd28b2aaed3f7a2373f1102 /emacs.d/init.el
parent7b1ff00fca396e9999bb3706e413ebd7d5ae51c4 (diff)
downloadliw-dot-files-ba6730976e5ec75116cfb8eab85209f03e288336.tar.gz
emacs: change to rustic from racer
https://robert.kra.hn/posts/2021-02-07_rust-with-emacs/ Sponsored-by: author
Diffstat (limited to 'emacs.d/init.el')
-rw-r--r--emacs.d/init.el93
1 files changed, 67 insertions, 26 deletions
diff --git a/emacs.d/init.el b/emacs.d/init.el
index 3fa4739..bfc500c 100644
--- a/emacs.d/init.el
+++ b/emacs.d/init.el
@@ -18,7 +18,7 @@
;; Run this manually from time to time to update package lists.
;(package-refresh-contents)
-;; Use-package for civilized configuration
+;; use-package for easier configuration
(unless (package-installed-p 'use-package)
(package-install 'use-package))
@@ -33,21 +33,30 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Packages I like.
+;; Major mode for editing Apache configuration files.
(use-package apache-mode)
-(use-package blacken)
+
+;; Hide some mode line displays that are just noise.
(use-package diminish)
-(use-package go-mode)
+
+;; Major mode for GraphViz dot files.
(use-package graphviz-dot-mode)
+;; Use git from Emacs.
(use-package magit
:config
(global-set-key (kbd "C-x g") 'magit-status))
+;; Use the black Python source formatter to format Emacs buffers.
+(use-package blacken)
+
+;; Major mode for Python source code.
(use-package python-mode
:config
(py-underscore-word-syntax-p-off)
(add-hook 'python-mode-hook 'blacken-mode))
+;; Major mode for YAML files.
(use-package yaml-mode
:config
(add-to-list 'auto-mode-alist '("\\.ick\\'" . yaml-mode))
@@ -55,51 +64,85 @@
(add-to-list 'auto-mode-alist '("\\.yaml\\'" . yaml-mode))
(add-to-list 'auto-mode-alist '("\\.yml\\'" . yaml-mode)))
+;; Major mode for Markdown text files.
(use-package markdown-mode
:config
(add-to-list 'auto-mode-alist '("NEWS" . markdown-mode))
(add-to-list 'auto-mode-alist '("README" . markdown-mode))
(add-to-list 'auto-mode-alist '("\\.mdwn\\'" . markdown-mode)))
-(use-package modus-operandi-theme
- :config
- (setq modus-operandi-theme-slanted-constructs t)
- (setq modus-operandi-theme-bold-constructs t)
- (load-theme 'modus-operandi t))
-
-(use-package rust-mode
+;; Major mode for edit source code in the Rust language.
+(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
- (setq-default rust-format-on-save t)
- (setq-default rust-rustfmt-bin "~/liw-dot-files/bin/rustfmt-2018"))
-
-(use-package racer
+ ;; 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))
+
+;; Mode for using the Rust Language Server Protocol for nicer Rust
+;; editing.
+(use-package lsp-mode
+ :ensure
+ :commands lsp
+ :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)
+ (lsp-rust-analyzer-server-display-inlay-hints t)
:config
- ;; https://github.com/racer-rust/emacs-racer/issues/140
- (setq racer-rust-src-path
- "/home/liw/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library")
- (add-hook 'rust-mode-hook #'racer-mode)
- (add-hook 'racer-mode-hook #'eldoc-mode))
-
+ (add-hook 'lsp-mode-hook 'lsp-ui-mode))
+
+;; UI for lsp-mode.
+(use-package lsp-ui
+ :ensure
+ :commands lsp-ui-mode
+ :custom
+ (lsp-ui-peek-always-show t)
+ (lsp-ui-sideline-show-hover t)
+ (lsp-ui-doc-enable nil))
+
+;; Text completion framework for Emacs.
(use-package company
:config
(setq company-tooltip-align-annotations t)
; (define-key rust-mode-map (kbd "TAB") #'company-indent-or-complete-common)
(add-hook 'racer-mode-hook #'company-mode))
-
+;; Minor mode for on-the-fly checks for various types of files.
(use-package flycheck
:config
(setq-default flycheck-disabled-checkers '(python-pylint)))
-
+;; Flycheck for the Rust language.
(use-package flycheck-rust)
;;(with-eval-after-load 'rust-mode
;; (add-hook 'flycheck-mode-hook #'flycheck-rust-setup))
+;; Minor mode to color mode line based on how happy flycheck is.
(use-package flycheck-color-mode-line)
(eval-after-load 'flycheck
'(add-hook 'flycheck-mode-hook 'flycheck-color-mode-line-mode))
+;; UI theme for Emacs.
+(use-package modus-operandi-theme
+ :config
+ (setq modus-operandi-theme-slanted-constructs t)
+ (setq modus-operandi-theme-bold-constructs t)
+ (load-theme 'modus-operandi t))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; UI tweaks.
@@ -117,9 +160,9 @@
;; Show line number before line.
(global-display-line-numbers-mode)
(set-face-attribute 'line-number nil
- :height 0.7)
+ :height 0.8)
(set-face-attribute 'line-number-current-line nil
- :foreground "#ff0000" :height 0.7)
+ :foreground "#ff0000" :height 0.8)
;; Enable X CLIPBOARD selection, instead of PRIMARY.
(setq select-enable-clipboard t)
@@ -137,9 +180,7 @@
(add-hook 'text-mode-hook 'hl-line-mode)
(add-hook 'prog-mode-hook 'hl-line-mode)
-
;; Key bindings
-
(global-set-key (kbd "<f5>") 'compile)
(global-set-key (kbd "C-<f5>") 'recompile)
(global-unset-key "\C-x\C-b")