401-rust: reorganize use-package configurations

Signed-off-by: Ralf Zerres <ralf.zerres@networkx.de>
This commit is contained in:
2020-06-24 01:35:16 +02:00
parent 35ef870b21
commit 2aef9f9983

View File

@@ -1,74 +1,57 @@
;;; 401-rust.el --- handle rust code
;;; Commentary:
;; using rust-mode with rust-analyzer via lsp
;;; Code:
;; load rustic -> IDE like for rust
;; it superseeds rust-mode
(use-package rustic
:ensure t
:init
(setq rustic-lsp-server 'rust-analyzer)
(setq rustic-format-on-save t))
:config
;; recommended: use spaces instead of tabs
(add-hook 'rust-mode-hook
(lambda () (setq indent-tabs-mode nil)))
(add-hook 'rustic-mode-hook
(lambda () (setq indent-tabs-mode nil)))
;; enable code folding und line numbering rust buffers
(add-hook 'prog-mode-hook
;;'lsp-origami-mode
'hs-minor-mode
'linum-relative-mode)
;;(remove-hook 'rustic-mode-hook 'flycheck-mode)
;; use the lsp UI package
(use-package lsp-ui)
;; use the lsp UI package
;; https://emacs-lsp.github.io/lsp-mode
(use-package lsp-ivy)
(use-package lsp-ui)
;; use rust-analyzer via lsp
;; (setq lsp-rust-analyzer-server-command '("~/.cargo/bin/rust-analyzer"))
;; (add-hook 'before-save-hook (lambda () (when (eq 'rust-mode major-mode)
;; (lsp-format-buffer))))
;; use the yasnippet
(use-package yasnippet
;; YASnippet is a template system for Emacs.
;; It allows you to type an abbreviation and automatically expand it into function templates
;; use YASnippet as a non-global minor mode
:config
(yas-reload-all))
;; load the language-server-protocol (lsp)
;; (use-package lsp-mode
;; :init
;; (add-hook 'prog-mode-hook 'lsp-mode)
;; :after rustic)
;; company-capf.el from load-path
(use-package linum-relative
:config
(setq linum-relative-backend 'display-line-numbers-mode))
;; ;; :config
;; ;; (use-package lsp-flycheck
;; ;; :ensure f ; comes with lsp-mode
;; ;; :after rustic))
;; (push 'rustic-clippy flycheck-checkers)
;; Turn off flycheck.
;; (remove-hook 'rustic-mode-hook 'flycheck-mode)
;; ;; load rust-mode
;; (use-package rust-mode
;; :mode "\\.rs\\'"
;; :init
;; (setq rust-format-on-save t))
;; ;; bind the lsp-rust mode
;; (use-package lsp-rust
;; :after lsp-mode)
;; option: bind commands to keys:
;; - lsp-rust-analyzer-join-lines
;; - lsp-extend-selection
;; - lsp-rust-analyzer-expand-macro
;; (autoload 'rust-mode "rust-mode"
;; "Major mode for the rust programming language" t)
;; (add-hook 'rust-mode-hook #'racer-mode)
;; (add-hook 'racer-mode-hook #'eldoc-mode)
;; (add-hook 'racer-mode-hook #'company-mode)
;; (add-hook 'rust-mode-hook 'cargo-minor-mode)
;; (add-hook 'flycheck-mode #'flycheck-rust)
;; (add-hook 'flycheck-mode-hook #'flycheck-rust-setup)
;; ;; reccommended: use spaces instead of tabs
;; (add-hook 'rust-mode-hook
;; (lambda () (setq indent-tabs-mode nil)))
;; ;; on save, run rustfmt if installed (C-c C-f)
;; (setq rust-format-on-save t)
:custom
;;(linum-on)
;;(linum-relative-toggle)
;;(hs-minor-mode t)
;;(lsp-origami-try-enable)
;;(linum-relative-mode 1))
(rustic-lsp-server 'rust-analyzer)
(rustic-lsp-format t))
(provide '401-rust)
;; Local Variables:
;; no-byte-compile: t
;; End
;;; 401-rust.el ends here