diff --git a/emacs.d/init.el b/emacs.d/init.el index 4e51f50..2793a9a 100755 --- a/emacs.d/init.el +++ b/emacs.d/init.el @@ -1,7 +1,7 @@ ;;; ===================== ;;; ;;; Author: Muha Aliss ;;; ;;; Mail: muhaaliss@pm.me ;;; -;;; Edit: 15/11/2023 ;;; +;;; Edit: 14/04/2024 ;;; ;;; ===================== ;;; @@ -29,6 +29,9 @@ counsel all-the-icons all-the-icons-dired + dap-mode + exec-path-from-shell + perspective )) ;; Search packages in installed packages, @@ -250,20 +253,22 @@ (global-set-key (kbd " v") 'counsel-describe-variable) (global-set-key (kbd " o") 'counsel-describe-symbol) (global-set-key (kbd " l") 'counsel-find-library) -(global-set-key (kbd "") 'ivy-resume) +(global-set-key (kbd "") 'ivy-resume) ;;; ===================== ;;; ;;; Load other .el files ;;; ;;; ===================== ;;; + (load "~/.emacs.d/xah") +(load "~/.emacs.d/rust") (custom-set-variables ;; custom-set-variables was added by Custom. ;; If you edit it by hand, you could mess it up, so be careful. ;; Your init file should contain only one such instance. ;; If there is more than one, they won't work right. '(package-selected-packages - '(doom-themes all-the-icons-ivy-rich gnu-elpa gnu-elpa-keyring-update use-package which-key counsel all-the-icons all-the-icons-dired))) + '(rustic flycheck company doom-themes all-the-icons-ivy-rich gnu-elpa gnu-elpa-keyring-update use-package which-key counsel all-the-icons all-the-icons-dired dap-mode))) (custom-set-faces ;; custom-set-faces was added by Custom. ;; If you edit it by hand, you could mess it up, so be careful. diff --git a/emacs.d/rust.el b/emacs.d/rust.el new file mode 100644 index 0000000..a2f3034 --- /dev/null +++ b/emacs.d/rust.el @@ -0,0 +1,121 @@ +(use-package exec-path-from-shell + :ensure + :init (exec-path-from-shell-initialize)) + +;; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- +;; 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) + ("C-c C-c f" . rustic-format-buffer))) + +;; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- +;; for rust-analyzer integration + +(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) + ;; This controls the overlays that display type and other hints inline. Enable + ;; / disable as you prefer. Well require a `lsp-workspace-restart' to have an + ;; effect on open projects. + (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)) + +;; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- +;; inline errors + +(use-package flycheck :ensure) + + +;; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- +;; auto-completion and code snippets + +(use-package yasnippet + :ensure + :config + (yas-reload-all) + (add-hook 'prog-mode-hook 'yas-minor-mode) + (add-hook 'text-mode-hook 'yas-minor-mode)) + +(use-package company + :ensure + :bind + (:map company-active-map + ("C-n". company-select-next) + ("C-p". company-select-previous) + ("M-<". company-select-first) + ("M->". company-select-last)) + (:map company-mode-map + ("". tab-indent-or-complete) + ("TAB". tab-indent-or-complete))) + +(defun company-yasnippet-or-completion () + (interactive) + (or (do-yas-expand) + (company-complete-common))) + +(defun check-expansion () + (save-excursion + (if (looking-at "\\_>") t + (backward-char 1) + (if (looking-at "\\.") t + (backward-char 1) + (if (looking-at "::") t nil))))) + +(defun do-yas-expand () + (let ((yas/fallback-behavior 'return-nil)) + (yas/expand))) + +(defun tab-indent-or-complete () + (interactive) + (if (minibufferp) + (minibuffer-complete) + (if (or (not yas/minor-mode) + (null (do-yas-expand))) + (if (check-expansion) + (company-complete-common) + (indent-for-tab-command))))) + + +;; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- +;; Create / cleanup rust scratch projects quickly + +(use-package rust-playground :ensure) + + +;; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- +;; for Cargo.toml and other config files + +(use-package toml-mode :ensure)