Make Rust config the best ever
This commit is contained in:
		
							parent
							
								
									6214f60f72
								
							
						
					
					
						commit
						33e0010f7f
					
				
					 5 changed files with 80 additions and 48 deletions
				
			
		|  | @ -5,7 +5,9 @@ | |||
|  ;; If there is more than one, they won't work right. | ||||
|  '(ffap-machine-p-known (quote reject)) | ||||
|  '(org-agenda-files (quote ("~/dev/personal.todo"))) | ||||
|  '(package-selected-packages (quote (helm-lsp htmlize ein-mumamo use-package)))) | ||||
|  '(package-selected-packages (quote (helm-lsp htmlize ein-mumamo rustic use-package)))) | ||||
|  '(lsp-rust-analyzer-macro-expansion-method (quote rustic-analyzer-macro-expand)) | ||||
|  '(rustic-lsp-server (quote rust-analyzer)) | ||||
| (custom-set-faces | ||||
|  ;; custom-set-faces was added by Custom. | ||||
|  ;; If you edit it by hand, you could mess it up, so be careful. | ||||
|  |  | |||
							
								
								
									
										27
									
								
								init.el
									
										
									
									
									
								
							
							
						
						
									
										27
									
								
								init.el
									
										
									
									
									
								
							|  | @ -1,18 +1,24 @@ | |||
| ;; Configure emacs packages. | ||||
| (require 'package) | ||||
| (add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t) | ||||
| (setq package-archives | ||||
|       '(("org"     .       "https://orgmode.org/elpa/") | ||||
|         ("gnu"     .       "https://elpa.gnu.org/packages/") | ||||
|         ("melpa"   .       "https://melpa.org/packages/"))) | ||||
| (package-initialize) | ||||
| ;(package-refresh-contents) | ||||
| 
 | ||||
| (when (not (package-installed-p 'use-package)) | ||||
|       (package-refresh-contents) | ||||
|       (package-install 'use-package)) | ||||
| ;; Use-package for civilized configuration | ||||
| (unless (package-installed-p 'use-package) | ||||
|   (package-install 'use-package)) | ||||
| (require 'use-package) | ||||
| (setq use-package-always-ensure t) | ||||
| 
 | ||||
| (setq dotfiles-dir | ||||
|       (file-name-directory | ||||
|         (or (buffer-file-name) (file-chase-links load-file-name)))) | ||||
| (setq modules-path (concat dotfiles-dir "modules")) | ||||
| 
 | ||||
| (add-to-list 'load-path (concat dotfiles-dir "modules")) | ||||
| (add-to-list 'load-path modules-path) | ||||
| 
 | ||||
| ;; Emacs customization / global plugin configuration | ||||
| (require 'jenga-init) | ||||
|  | @ -20,11 +26,18 @@ | |||
| (require 'jenga-org) | ||||
| (require 'jenga-ui) | ||||
| 
 | ||||
| ;; Custom languages and highlighting | ||||
| (require 'jenga-elm) | ||||
| (require 'jenga-python) | ||||
| (require 'jenga-rust) | ||||
| (require 'jenga-systemd) | ||||
| (require 'jenga-python) | ||||
| 
 | ||||
| ;;(add-hook 'find-file-hook #'load-module) | ||||
| ;;(defun load-module () | ||||
| ;;  (when (stringp buffer-file-name) | ||||
| ;;        (cond ((string-match "\\.elm\\'" buffer-file-name) (require 'jenga-elm)) | ||||
| ;;              ((string-match "\\.py\\'" buffer-file-name) (require 'jenga-python)) | ||||
| ;;              ((string-match "\\.rs\\'" buffer-file-name) (require 'jenga-rust)) | ||||
| ;;              ((string-match "\\.service\\'" buffer-file-name) (require 'jenga-systemd))))) | ||||
| 
 | ||||
| (setq custom-file "~/.emacs.d/custom.el") | ||||
| (load custom-file) | ||||
|  |  | |||
|  | @ -20,6 +20,30 @@ | |||
| (global-set-key (kbd "S-C-j") 'shrink-window) | ||||
| (global-set-key (kbd "S-C-k") 'enlarge-window) | ||||
| 
 | ||||
| (use-package which-key | ||||
|   :diminish | ||||
|   :config | ||||
|   (which-key-mode) | ||||
|   (which-key-setup-side-window-bottom) | ||||
|   (setq which-key-idle-delay 0.1)) | ||||
| 
 | ||||
| (use-package diminish | ||||
|   :defer 5 | ||||
|   :config | ||||
|   (diminish 'org-indent-mode)) | ||||
| 
 | ||||
| ;; Note that ‘uniquify’ is builtin. | ||||
| (require 'uniquify) | ||||
| (setq uniquify-separator "/"               ;; The separator in buffer names. | ||||
|       uniquify-buffer-name-style 'forward) ;; names/in/this/style | ||||
| 
 | ||||
| (use-package rg | ||||
|   :config | ||||
|   (global-set-key (kbd "M-s g") 'rg) | ||||
|   (global-set-key (kbd "M-s d") 'rg-dwim)) | ||||
| 
 | ||||
| (use-package helm-rg) | ||||
| 
 | ||||
| ;;;; Company configuration. | ||||
| (use-package company | ||||
|   :ensure t | ||||
|  | @ -48,7 +72,7 @@ | |||
|     (evil-mode) | ||||
|     (setq evil-want-C-u-scroll t) | ||||
|     (eval-after-load "evil-maps" | ||||
|       ;; Unset Evil's "M-." keymap so that TAGS definitions can be followed. | ||||
|       ;; Unset Evil's "M-." keymap to enable symbol definition following. | ||||
|       (define-key evil-normal-state-map "\M-." nil))) | ||||
| 
 | ||||
| (use-package undo-tree | ||||
|  |  | |||
|  | @ -1,14 +1,4 @@ | |||
| ;;;; Python configuration. | ||||
| (use-package jupyter | ||||
|     :ensure t) | ||||
| (use-package ein | ||||
|     :ensure t) | ||||
| (use-package py-autopep8 | ||||
|     :ensure t) | ||||
| (use-package yasnippet | ||||
|     :ensure t) | ||||
| (use-package jedi | ||||
|     :ensure t) | ||||
| (use-package elpy | ||||
|     :ensure t | ||||
|     :init | ||||
|  | @ -21,6 +11,16 @@ | |||
|           python-indent-offset 4 | ||||
|           python-shell-interpreter-args "console --simple-prompt" | ||||
|           python-shell-prompt-detect-failure-warning nil) | ||||
|     (use-package jupyter | ||||
|         :ensure t) | ||||
|     (use-package ein | ||||
|         :ensure t) | ||||
|     (use-package py-autopep8 | ||||
|         :ensure t) | ||||
|     (use-package yasnippet | ||||
|         :ensure t) | ||||
|     (use-package jedi | ||||
|         :ensure t) | ||||
|     ;; Use IPython for REPL | ||||
|     (add-to-list 'python-shell-completion-native-disabled-interpreters | ||||
|                  "jupyter") | ||||
|  |  | |||
|  | @ -1,43 +1,36 @@ | |||
| ;;;; Rust mode configuration. | ||||
| ;; Add rust load hooks. | ||||
| (use-package rustic | ||||
|   :config | ||||
|   (setq rustic-flycheck-clippy-params "--message-format=json")) | ||||
| 
 | ||||
| (use-package flycheck | ||||
|              :hook (prog-mode . flycheck-mode)) | ||||
|   :hook (prog-mode . flycheck-mode)) | ||||
| 
 | ||||
| (use-package company | ||||
|              :hook (prog-mode . company-mode) | ||||
|              :config (setq company-tooltip-align-annotations t) | ||||
|              (setq company-minimum-prefix-length 1)) | ||||
|   :hook (prog-mode . company-mode) | ||||
|   :config (setq company-tooltip-align-annotations t) | ||||
|   (setq company-minimum-prefix-length 1)) | ||||
| 
 | ||||
| (use-package lsp-mode | ||||
|              :commands lsp | ||||
|              :config (require 'lsp-clients)) | ||||
|   :commands lsp | ||||
|   :config (require 'lsp-clients)) | ||||
| 
 | ||||
| (use-package lsp-ui | ||||
|              :commands lsp-ui-mode | ||||
|              :bind (:map lsp-ui-mode-map | ||||
|                          ("M-."     . lsp-ui-peek-find-definitions) | ||||
|                          ("M-,"     . lsp-ui-peek-jump-backward) | ||||
|                          ("M-?"     . lsp-ui-peek-find-references) | ||||
|                          ("C-c u"   . lsp-ui-imenu) | ||||
|                          ("C-c C-a" . lsp-ui-sideline-apply-code-actions)) | ||||
|              :config (setq lsp-ui-peek-enable t)) | ||||
|   :commands lsp-ui-mode | ||||
|   :config (setq lsp-ui-peek-enable t) | ||||
|   :bind (:map lsp-ui-mode-map | ||||
|           ("M-."     . lsp-ui-peek-find-definitions) | ||||
|           ("M-,"     . lsp-ui-peek-jump-backward) | ||||
|           ("M-?"     . lsp-ui-peek-find-references) | ||||
|           ("C-c u"   . lsp-ui-imenu) | ||||
|           ("C-c C-a" . lsp-ui-sideline-apply-code-actions))) | ||||
| 
 | ||||
| (use-package rust-mode | ||||
|              :config | ||||
|              (setq rust-format-on-save t) | ||||
|              :hook (rust-mode . lsp)) | ||||
| 
 | ||||
| (use-package lsp-rust | ||||
|              :after lsp-mode | ||||
|              :config | ||||
|              (setq lsp-rust-server 'rust-analyzer)) | ||||
| 
 | ||||
| 
 | ||||
| ;; Add keybindings for interacting with Cargo | ||||
| (use-package cargo | ||||
|              :hook (rust-mode . cargo-minor-mode)) | ||||
| (use-package helm-lsp | ||||
|   :config | ||||
|   (define-key lsp-mode-map [remap xref-find-apropos] #'helm-lsp-workspace-symbol)) | ||||
| 
 | ||||
| (use-package flycheck-rust | ||||
|              :config (add-hook 'flycheck-mode-hook #'flycheck-rust-setup)) | ||||
|   :config (add-hook 'flycheck-mode-hook #'flycheck-rust-setup)) | ||||
| 
 | ||||
| (provide 'jenga-rust) | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue