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.
 | 
					 ;; If there is more than one, they won't work right.
 | 
				
			||||||
 '(ffap-machine-p-known (quote reject))
 | 
					 '(ffap-machine-p-known (quote reject))
 | 
				
			||||||
 '(org-agenda-files (quote ("~/dev/personal.todo")))
 | 
					 '(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
 | 
				
			||||||
 ;; custom-set-faces was added by Custom.
 | 
					 ;; custom-set-faces was added by Custom.
 | 
				
			||||||
 ;; If you edit it by hand, you could mess it up, so be careful.
 | 
					 ;; 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.
 | 
					;; Configure emacs packages.
 | 
				
			||||||
(require 'package)
 | 
					(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-initialize)
 | 
				
			||||||
 | 
					;(package-refresh-contents)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
(when (not (package-installed-p 'use-package))
 | 
					;; Use-package for civilized configuration
 | 
				
			||||||
      (package-refresh-contents)
 | 
					(unless (package-installed-p 'use-package)
 | 
				
			||||||
      (package-install 'use-package))
 | 
					  (package-install 'use-package))
 | 
				
			||||||
(require 'use-package)
 | 
					(require 'use-package)
 | 
				
			||||||
 | 
					(setq use-package-always-ensure t)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
(setq dotfiles-dir
 | 
					(setq dotfiles-dir
 | 
				
			||||||
      (file-name-directory
 | 
					      (file-name-directory
 | 
				
			||||||
        (or (buffer-file-name) (file-chase-links load-file-name))))
 | 
					        (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
 | 
					;; Emacs customization / global plugin configuration
 | 
				
			||||||
(require 'jenga-init)
 | 
					(require 'jenga-init)
 | 
				
			||||||
| 
						 | 
					@ -20,11 +26,18 @@
 | 
				
			||||||
(require 'jenga-org)
 | 
					(require 'jenga-org)
 | 
				
			||||||
(require 'jenga-ui)
 | 
					(require 'jenga-ui)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
;; Custom languages and highlighting
 | 
					 | 
				
			||||||
(require 'jenga-elm)
 | 
					(require 'jenga-elm)
 | 
				
			||||||
 | 
					(require 'jenga-python)
 | 
				
			||||||
(require 'jenga-rust)
 | 
					(require 'jenga-rust)
 | 
				
			||||||
(require 'jenga-systemd)
 | 
					(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")
 | 
					(setq custom-file "~/.emacs.d/custom.el")
 | 
				
			||||||
(load custom-file)
 | 
					(load custom-file)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -20,6 +20,30 @@
 | 
				
			||||||
(global-set-key (kbd "S-C-j") 'shrink-window)
 | 
					(global-set-key (kbd "S-C-j") 'shrink-window)
 | 
				
			||||||
(global-set-key (kbd "S-C-k") 'enlarge-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.
 | 
					;;;; Company configuration.
 | 
				
			||||||
(use-package company
 | 
					(use-package company
 | 
				
			||||||
  :ensure t
 | 
					  :ensure t
 | 
				
			||||||
| 
						 | 
					@ -48,7 +72,7 @@
 | 
				
			||||||
    (evil-mode)
 | 
					    (evil-mode)
 | 
				
			||||||
    (setq evil-want-C-u-scroll t)
 | 
					    (setq evil-want-C-u-scroll t)
 | 
				
			||||||
    (eval-after-load "evil-maps"
 | 
					    (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)))
 | 
					      (define-key evil-normal-state-map "\M-." nil)))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
(use-package undo-tree
 | 
					(use-package undo-tree
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,14 +1,4 @@
 | 
				
			||||||
;;;; Python configuration.
 | 
					;;;; 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
 | 
					(use-package elpy
 | 
				
			||||||
    :ensure t
 | 
					    :ensure t
 | 
				
			||||||
    :init
 | 
					    :init
 | 
				
			||||||
| 
						 | 
					@ -21,6 +11,16 @@
 | 
				
			||||||
          python-indent-offset 4
 | 
					          python-indent-offset 4
 | 
				
			||||||
          python-shell-interpreter-args "console --simple-prompt"
 | 
					          python-shell-interpreter-args "console --simple-prompt"
 | 
				
			||||||
          python-shell-prompt-detect-failure-warning nil)
 | 
					          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
 | 
					    ;; Use IPython for REPL
 | 
				
			||||||
    (add-to-list 'python-shell-completion-native-disabled-interpreters
 | 
					    (add-to-list 'python-shell-completion-native-disabled-interpreters
 | 
				
			||||||
                 "jupyter")
 | 
					                 "jupyter")
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,43 +1,36 @@
 | 
				
			||||||
;;;; Rust mode configuration.
 | 
					;;;; Rust mode configuration.
 | 
				
			||||||
;; Add rust load hooks.
 | 
					;; Add rust load hooks.
 | 
				
			||||||
 | 
					(use-package rustic
 | 
				
			||||||
 | 
					  :config
 | 
				
			||||||
 | 
					  (setq rustic-flycheck-clippy-params "--message-format=json"))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
(use-package flycheck
 | 
					(use-package flycheck
 | 
				
			||||||
             :hook (prog-mode . flycheck-mode))
 | 
					  :hook (prog-mode . flycheck-mode))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
(use-package company
 | 
					(use-package company
 | 
				
			||||||
             :hook (prog-mode . company-mode)
 | 
					  :hook (prog-mode . company-mode)
 | 
				
			||||||
             :config (setq company-tooltip-align-annotations t)
 | 
					  :config (setq company-tooltip-align-annotations t)
 | 
				
			||||||
             (setq company-minimum-prefix-length 1))
 | 
					  (setq company-minimum-prefix-length 1))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
(use-package lsp-mode
 | 
					(use-package lsp-mode
 | 
				
			||||||
             :commands lsp
 | 
					  :commands lsp
 | 
				
			||||||
             :config (require 'lsp-clients))
 | 
					  :config (require 'lsp-clients))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
(use-package lsp-ui
 | 
					(use-package lsp-ui
 | 
				
			||||||
             :commands lsp-ui-mode
 | 
					  :commands lsp-ui-mode
 | 
				
			||||||
             :bind (:map lsp-ui-mode-map
 | 
					  :config (setq lsp-ui-peek-enable t)
 | 
				
			||||||
                         ("M-."     . lsp-ui-peek-find-definitions)
 | 
					  :bind (:map lsp-ui-mode-map
 | 
				
			||||||
                         ("M-,"     . lsp-ui-peek-jump-backward)
 | 
					          ("M-."     . lsp-ui-peek-find-definitions)
 | 
				
			||||||
                         ("M-?"     . lsp-ui-peek-find-references)
 | 
					          ("M-,"     . lsp-ui-peek-jump-backward)
 | 
				
			||||||
                         ("C-c u"   . lsp-ui-imenu)
 | 
					          ("M-?"     . lsp-ui-peek-find-references)
 | 
				
			||||||
                         ("C-c C-a" . lsp-ui-sideline-apply-code-actions))
 | 
					          ("C-c u"   . lsp-ui-imenu)
 | 
				
			||||||
             :config (setq lsp-ui-peek-enable t))
 | 
					          ("C-c C-a" . lsp-ui-sideline-apply-code-actions)))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
(use-package rust-mode
 | 
					(use-package helm-lsp
 | 
				
			||||||
             :config
 | 
					  :config
 | 
				
			||||||
             (setq rust-format-on-save t)
 | 
					  (define-key lsp-mode-map [remap xref-find-apropos] #'helm-lsp-workspace-symbol))
 | 
				
			||||||
             :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 flycheck-rust
 | 
					(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)
 | 
					(provide 'jenga-rust)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue