diff --git a/init.el b/init.el index 767e759..560e9d0 100644 --- a/init.el +++ b/init.el @@ -29,7 +29,7 @@ There are two things you can do about this warning: '(global-display-line-numbers-mode t) '(inhibit-startup-screen t) '(package-selected-packages - '(flycheck-gometalinter go-mode doom-themes lsp-mode hydra gitlab-ci-mode gitlab-ci-mode-flycheck web-mode impatient-mode exec-path-from-shell rust-playground all-the-icons neotree base16-theme afternoon-theme ample-theme nord-theme company-racer racer markdown-mode+ dumb-jump magit company flycheck-rust flycheck json-mode flymake-json tss tide material-theme zenburn-theme ac-js2 auto-complete projectile helm js2-mode cargo rust-mode iedit gitlab-ci-mode gitlab-ci-mode-flycheck dap-mode typescript-mode tree-sitter tree-sitter-langs)) + '(rustic toml-mode lsp-ui flycheck-gometalinter go-mode doom-themes lsp-mode hydra gitlab-ci-mode gitlab-ci-mode-flycheck web-mode impatient-mode exec-path-from-shell rust-playground all-the-icons neotree base16-theme afternoon-theme ample-theme nord-theme company-racer racer markdown-mode+ dumb-jump magit company flycheck-rust flycheck json-mode flymake-json tss tide material-theme zenburn-theme ac-js2 auto-complete projectile helm js2-mode cargo rust-mode iedit gitlab-ci-mode gitlab-ci-mode-flycheck dap-mode typescript-mode tree-sitter tree-sitter-langs)) '(tool-bar-mode nil)) (custom-set-faces ;; custom-set-faces was added by Custom. @@ -38,6 +38,8 @@ There are two things you can do about this warning: ;; If there is more than one, they won't work right. '(default ((t (:family "Menlo" :foundry "CTDB" :slant normal :weight normal :height 160 :width normal))))) +(require 'use-package) + (add-to-list 'load-path "~/.emacs.d/lib") (require 'init-editor) (require 'init-web) diff --git a/lib/init-rust.el b/lib/init-rust.el index f01a588..36b4527 100644 --- a/lib/init-rust.el +++ b/lib/init-rust.el @@ -2,13 +2,72 @@ (require 'rust-mode) (add-to-list 'auto-mode-alist '("\\.rs\\'" . rust-mode)) (setq rust-format-on-save t) + (add-hook 'rust-mode-hook 'cargo-minor-mode) -(with-eval-after-load 'rust-mode - (add-hook 'flycheck-mode-hook #'flycheck-rust-setup)) -(add-hook 'rust-mode-hook #'racer-mode) -(add-hook 'racer-mode-hook #'eldoc-mode) -(add-hook 'racer-mode-hook #'company-mode) -(define-key rust-mode-map (kbd "TAB") #'company-indent-or-complete-common) + +;; (with-eval-after-load 'rust-mode +;; (add-hook 'flycheck-mode-hook #'flycheck-rust-setup)) +;; (add-hook 'rust-mode-hook #'racer-mode) +;; (add-hook 'racer-mode-hook #'eldoc-mode) +;; (add-hook 'racer-mode-hook #'company-mode) +;; (define-key rust-mode-map (kbd "TAB") #'company-indent-or-complete-common) + +;; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- +;; rustic = basic rust-mode + additions + +(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) + ("C-c C-c e" . lsp-rust-analyzer-expand-macro) + ("C-c C-c d" . dap-hydra) + ("C-c C-c h" . lsp-ui-doc-glance)) + :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 + (add-hook 'rustic-mode-hook 'rk/rustic-mode-hook)) + +(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) + ;; enable / disable the hints as you prefer: + (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) + :config + (add-hook 'lsp-mode-hook 'lsp-ui-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)) + +(use-package toml-mode :ensure) + +(use-package flycheck :ensure) ;; Rust playground https://github.com/grafov/rust-playground ;; M-x rust-playground -> Type -> Ctrl-RET -> See results -> M-x rust-playground-rm