aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjason2017-06-19 10:50:04 -0600
committerjason2017-06-19 10:50:04 -0600
commit6ad2e2503947fc8fb17ca18e3806fe0d06b437e8 (patch)
tree3ec8be87f5c9ea85947d2873c76ba95dcdbdf919
parent9de78f34f36851e6471cb8e20b80bee907d0711a (diff)
downloaddotemacs-6ad2e2503947fc8fb17ca18e3806fe0d06b437e8.tar.gz
dotemacs-6ad2e2503947fc8fb17ca18e3806fe0d06b437e8.zip
Add autocompletion and rust support
-rw-r--r--init.el400
-rw-r--r--local-lib/autocompletion-conf.el30
-rw-r--r--local-lib/rust-conf.el32
3 files changed, 265 insertions, 197 deletions
diff --git a/init.el b/init.el
index 2849e94..a7db81f 100644
--- a/init.el
+++ b/init.el
@@ -1,197 +1,203 @@
1;;; init.el --- emacs start up 1;;; init.el --- emacs start up
2;; Author: jason <jason@zzq.org> 2;; Author: jason <jason@zzq.org>
3;; Created: 03 Dec 2015 3;; Created: 15 Jun 2017
4;; Version: 0.2 4;; Version: 2
5;; Keywords: 5;; Keywords:
6;; X-URL: https://beehive.io/jason/emacs.d/ 6;; X-URL: https://beehive.io/jason/emacs.d/
7;;; Commentary: 7;;; Commentary:
8;; 8;;
9;;; Code: 9;;; Code:
10(defconst emacs-start-time (current-time)) 10(defconst emacs-start-time (current-time))
11(setq inhibit-startup-screen t ;; Hide the default startup screen 11(setq inhibit-startup-screen t ;; Hide the default startup screen
12 savehist-file "~/.emacs.d/savehist" 12 savehist-file "~/.emacs.d/savehist"
13 ;; Define where to store recovery files 13 ;; Define where to store recovery files
14 backup-directory-alist '(("." . "~/.emacs.d/backups")) 14 backup-directory-alist '(("." . "~/.emacs.d/backups"))
15 ;; Use version numbers for backups. 15 ;; Use version numbers for backups.
16 version-control t 16 version-control t
17 ;; Number of newest versions to keep. 17 ;; Number of newest versions to keep.
18 kept-new-versions 10 18 kept-new-versions 10
19 ;; Number of oldest versions to keep. 19 ;; Number of oldest versions to keep.
20 kept-old-versions 0 20 kept-old-versions 0
21 ;; Don't ask to delete excess backup versions. 21 ;; Don't ask to delete excess backup versions.
22 delete-old-versions -1 22 delete-old-versions -1
23 ;; Copy all files, don't rename them. 23 ;; Copy all files, don't rename them.
24 backup-by-copying t 24 backup-by-copying t
25 ;; Make backups files under version control. 25 ;; Make backups files under version control.
26 vc-make-backup-files t 26 vc-make-backup-files t
27 ;; Don't confirm following when opening a symlink 27 ;; Don't confirm following when opening a symlink
28 vc-follow-symlinks t) 28 vc-follow-symlinks t)
29 29
30(setq package-archives '(("elpa" . "http://elpa.gnu.org/packages/") 30(setq package-archives '(("elpa" . "http://elpa.gnu.org/packages/")
31 ;; For org-mode 31 ;; For org-mode
32 ("org" . "http://orgmode.org/elpa/") 32 ("org" . "http://orgmode.org/elpa/")
33 ;; melpa builds git repositories and can be unstable 33 ;; melpa builds git repositories and can be unstable
34 ("melpa" . "http://melpa.org/packages/") 34 ("melpa" . "http://melpa.org/packages/")
35 ;; marmalade has maintainers upload versions 35 ;; marmalade has maintainers upload versions
36 ;; ("marmalade" . "https://marmalade-repo.org/packages/") 36 ;; ("marmalade" . "https://marmalade-repo.org/packages/")
37 ;; melpa-stable builds from git tags but may be missing dependencies 37 ;; melpa-stable builds from git tags but may be missing dependencies
38 ;; ("melpa-stable" . "https://stable.melpa.org/packages/") 38 ;; ("melpa-stable" . "https://stable.melpa.org/packages/")
39 ;; Elpy packages for the Python language 39 ;; Elpy packages for the Python language
40 ;; ("elpy" . "https://jorgenschaefer.github.io/packages/") 40 ;; ("elpy" . "https://jorgenschaefer.github.io/packages/")
41 )) 41 ))
42 42
43;; Initializes installed packages 43;; Initializes installed packages
44(package-initialize) 44(package-initialize)
45 45
46;; Packages are managed by the use-package package, so we need to make sure it's installed 46;; Packages are managed by the use-package package, so we need to make sure it's installed
47(unless (package-installed-p 'use-package) 47(unless (package-installed-p 'use-package)
48 (package-refresh-contents) 48 (package-refresh-contents)
49 (package-install 'use-package)) 49 (package-install 'use-package))
50(eval-when-compile 50(eval-when-compile
51 (require 'use-package)) 51 (require 'use-package))
52;; slight optimization for use-package's :bind directive 52;; slight optimization for use-package's :bind directive
53(require 'bind-key) 53(require 'bind-key)
54 54
55;; Add local library to the load path 55;; Add local library to the load path
56(add-to-list 'load-path "~/.emacs.d/local-lib/") 56(add-to-list 'load-path "~/.emacs.d/local-lib/")
57;; Usernames and passwords are stored in a file that isn't sync'd to VC 57;; Usernames and passwords are stored in a file that isn't sync'd to VC
58(load "~/.emacs.d/secrets" t) 58(load "~/.emacs.d/secrets" t)
59 59
60;; My misc functions 60;; My misc functions
61(require 'zzq-funcs) 61(require 'zzq-funcs)
62 62
63(add-hook 'after-init-hook 63(add-hook 'after-init-hook
64 (lambda () 64 (lambda ()
65 (progn 65 (progn
66 ;; Maximize the frame on startup 66 ;; Maximize the frame on startup
67 (toggle-frame-maximized) 67 (toggle-frame-maximized)
68 ;; Always ensure packages are installed if they are defined with use-package 68 ;; Always ensure packages are installed if they are defined with use-package
69 ;; (setq use-package-always-ensure t) 69 ;; (setq use-package-always-ensure t)
70 70
71 ;; Set default encoding to UTF-8 71 ;; Set default encoding to UTF-8
72 (set-language-environment "UTF-8") 72 (set-language-environment "UTF-8")
73 (set-default-coding-systems 'utf-8) 73 (set-default-coding-systems 'utf-8)
74 ;; Hide the toolbar 74 ;; Hide the toolbar
75 (tool-bar-mode -1) 75 (tool-bar-mode -1)
76 ;; Hide the scrollbar 76 ;; Hide the scrollbar
77 (scroll-bar-mode -1) 77 (scroll-bar-mode -1)
78 ;; no beep and no blinking cursor 78 ;; no beep and no blinking cursor
79 (setq ring-bell-function 'ignore 79 (setq ring-bell-function 'ignore
80 visible-bell nil 80 visible-bell nil
81 ;; display the full file path in the titlebar 81 ;; display the full file path in the titlebar
82 frame-title-format 82 frame-title-format
83 (list (format "%s %%S: %%j " (system-name)) 83 (list (format "%s %%S: %%j " (system-name))
84 '(buffer-file-name "%f" (dired-directory dired-directory "%b")))) 84 '(buffer-file-name "%f" (dired-directory dired-directory "%b"))))
85 85
86 ;; Show matched parens 86 ;; Show matched parens
87 (show-paren-mode t) 87 (show-paren-mode t)
88 ;; Allow undoing/redoing of window layouts with C-c left/right arrows 88 ;; Allow undoing/redoing of window layouts with C-c left/right arrows
89 (winner-mode 1) 89 (winner-mode 1)
90 ;; Let y and n be good enough for yes and no questions 90 ;; Let y and n be good enough for yes and no questions
91 (fset 'yes-or-no-p 'y-or-n-p) 91 (fset 'yes-or-no-p 'y-or-n-p)
92 ;; Auto-refresh files changed on the file system 92 ;; Auto-refresh files changed on the file system
93 (global-auto-revert-mode 1) 93 (global-auto-revert-mode 1)
94 ;; Save commands and their history 94 ;; Save commands and their history
95 (savehist-mode +1) 95 (savehist-mode +1)
96 (setq savehist-save-minibuffer-history +1) 96 (setq savehist-save-minibuffer-history +1)
97 (setq savehist-additional-variables 97 (setq savehist-additional-variables
98 '(kill-ring 98 '(kill-ring
99 search-ring 99 search-ring
100 regexp-search-ring)) 100 regexp-search-ring))
101 ;; Allow mouse support in xterm 101 ;; Allow mouse support in xterm
102 (xterm-mouse-mode 1) 102 (xterm-mouse-mode 1)
103 ;; Automatically close parens when opening them 103 ;; Automatically close parens when opening them
104 (electric-pair-mode 1) 104 (electric-pair-mode 1)
105 ;; Ovewrite selected regions with what you're typing/pasting/etc 105 ;; Ovewrite selected regions with what you're typing/pasting/etc
106 (delete-selection-mode 1) 106 (delete-selection-mode 1)
107 ;; A region is only active when it is highlighted (mimics other editors) 107 ;; A region is only active when it is highlighted (mimics other editors)
108 (transient-mark-mode 1) 108 (transient-mark-mode 1)
109 ;;;;;;;;;;; 109 ;;;;;;;;;;;
110 ;; Hooks ;; 110 ;; Hooks ;;
111 ;;;;;;;;;;; 111 ;;;;;;;;;;;
112 (add-hook 'write-file-hooks 112 (add-hook 'write-file-hooks
113 '(lambda () 113 '(lambda ()
114 ;; delete trailing whitespace from all files 114 ;; delete trailing whitespace from all files
115 (delete-trailing-whitespace))) 115 (delete-trailing-whitespace)))
116 ;;;;;;;;;;;; 116 ;;;;;;;;;;;;
117 ;; Themes ;; 117 ;; Themes ;;
118 ;;;;;;;;;;;; 118 ;;;;;;;;;;;;
119 (use-package jbeans-theme 119 (use-package jbeans-theme
120 :ensure t 120 :ensure t
121 :config 121 :config
122 (load-theme 'jbeans)) 122 (load-theme 'jbeans))
123 ;;;;;;;;;;;;;; 123 ;;;;;;;;;;;;;;
124 ;; Packages ;; 124 ;; Packages ;;
125 ;;;;;;;;;;;;;; 125 ;;;;;;;;;;;;;;
126 ;; paradox - A better emacs package manager 126 ;; paradox - A better emacs package manager
127 (use-package paradox 127 (use-package paradox
128 :ensure t 128 :ensure t
129 :config 129 :config
130 ;; Use paradox as the default package manager 130 ;; Use paradox as the default package manager
131 (paradox-enable)) 131 (paradox-enable))
132 ;; which-key - Displays a pop up with hints when pushing key bindings 132 ;; which-key - Displays a pop up with hints when pushing key bindings
133 (use-package which-key 133 (use-package which-key
134 :ensure t 134 :ensure t
135 :diminish which-key-mode 135 :diminish which-key-mode
136 :init 136 :init
137 (setq which-key-special-keys nil 137 (setq which-key-special-keys nil
138 which-key-use-C-h-commands t 138 which-key-use-C-h-commands t
139 which-key-echo-keystrokes 0.02 139 which-key-echo-keystrokes 0.02
140 which-key-max-description-length 32 140 which-key-max-description-length 32
141 which-key-sort-order 'which-key-key-order-alpha) 141 which-key-sort-order 'which-key-key-order-alpha)
142 :config 142 :config
143 (which-key-mode)) 143 (which-key-mode))
144 ;; Ivy, swiper, and counsel for autocompleting emacs things 144 ;; Ivy, swiper, and counsel for autocompleting emacs things
145 (use-package ivy 145 (use-package ivy
146 :ensure t 146 :ensure t
147 :pin elpa 147 :pin elpa
148 :diminish ivy-mode 148 :diminish ivy-mode
149 :bind (("C-s" . swiper) 149 :bind (("C-s" . swiper)
150 ("M-x" . counsel-M-x) 150 ("M-x" . counsel-M-x)
151 ("C-x C-f" . counsel-find-file)) 151 ("C-x C-f" . counsel-find-file))
152 :init 152 :init
153 ;; Remove the ^ prefix 153 ;; Remove the ^ prefix
154 (setq ivy-initial-inputs-alist nil 154 (setq ivy-initial-inputs-alist nil
155 ;; Display recently opened files when switching buffers 155 ;; Display recently opened files when switching buffers
156 ivy-use-virtual-buffers t 156 ivy-use-virtual-buffers t
157 ;; Use ivy for magit 157 ;; Use ivy for magit
158 magit-completing-read-function 'ivy-completing-read 158 magit-completing-read-function 'ivy-completing-read
159 ;; Use ivy for projectile 159 ;; Use ivy for projectile
160 projectile-completion-system 'ivy) 160 projectile-completion-system 'ivy)
161 :config 161 :config
162 (ivy-mode 1)) 162 (ivy-mode 1))
163 ;; avy - A quick way to jump around buffers 163 ;; avy - A quick way to jump around buffers
164 (use-package avy 164 (use-package avy
165 :ensure t 165 :ensure t
166 :bind (("C-:" . avy-goto-line))) 166 :bind (("C-:" . avy-goto-line)))
167 ;; Other packages 167
168 ;; persp - virtual workspaces 168 ;; Other packages
169 (require 'persp-conf) 169 ;; autocompletion - auto-completion for programming languages
170 ;; powerline - prettier modeline 170 (require 'autocompletion-conf)
171 (require 'powerline-conf) 171 ;; persp - virtual workspaces
172 ;; projectile - utilities for working with projects 172 (require 'persp-conf)
173 (require 'projectile-conf) 173 ;; powerline - prettier modeline
174 174 (require 'powerline-conf)
175 (message "Emacs loaded in %.3fs" 175 ;; projectile - utilities for working with projects
176 (/ (- (zzq/time-to-msec (current-time)) (zzq/time-to-msec emacs-start-time)) 1000.0)) 176 (require 'projectile-conf)
177 ))) ;; End progn/lambda/add-hook after-init-hook 177
178 178 ;; Languages
179(custom-set-variables 179 (require 'rust-conf)
180 ;; custom-set-variables was added by Custom. 180
181 ;; If you edit it by hand, you could mess it up, so be careful. 181 (message "Emacs loaded in %.3fs"
182 ;; Your init file should contain only one such instance. 182 (/ (- (zzq/time-to-msec (current-time)) (zzq/time-to-msec emacs-start-time)) 1000.0))
183 ;; If there is more than one, they won't work right. 183 ))) ;; End progn/lambda/add-hook after-init-hook
184 '(custom-safe-themes 184
185 (quote 185(custom-set-variables
186 ("64f2981274fd8740b794bce9feee7949ed87b88fc0b4654bd98594e1aa81abcd" default))) 186 ;; custom-set-variables was added by Custom.
187 '(package-selected-packages 187 ;; If you edit it by hand, you could mess it up, so be careful.
188 (quote 188 ;; Your init file should contain only one such instance.
189 (projectile persp-mode avy ivy powerline which-key paradox use-package jbeans-theme))) 189 ;; If there is more than one, they won't work right.
190 '(paradox-github-token t)) 190 '(custom-safe-themes
191 191 (quote
192(custom-set-faces 192 ("64f2981274fd8740b794bce9feee7949ed87b88fc0b4654bd98594e1aa81abcd" default)))
193 ;; custom-set-faces was added by Custom. 193 '(package-selected-packages
194 ;; If you edit it by hand, you could mess it up, so be careful. 194 (quote
195 ;; Your init file should contain only one such instance. 195 (racer cargo rust-mode company-quickhelp company projectile persp-mode avy ivy powerline which-key paradox use-package jbeans-theme)))
196 ;; If there is more than one, they won't work right. 196 '(paradox-github-token t))
197 '(default ((t (:family "Inconsolata" :foundry "outline" :slant normal :weight normal :height 79 :width normal))))) 197
198(custom-set-faces
199 ;; custom-set-faces was added by Custom.
200 ;; If you edit it by hand, you could mess it up, so be careful.
201 ;; Your init file should contain only one such instance.
202 ;; If there is more than one, they won't work right.
203 '(default ((t (:family "Inconsolata" :foundry "outline" :slant normal :weight normal :height 79 :width normal)))))
diff --git a/local-lib/autocompletion-conf.el b/local-lib/autocompletion-conf.el
new file mode 100644
index 0000000..0b5d200
--- /dev/null
+++ b/local-lib/autocompletion-conf.el
@@ -0,0 +1,30 @@
1;;; autocompletion-conf.el --- configuration for language auto-complete
2;; Author: jason <jason@zzq.org>
3;; Created: 16 Jun 2017
4;;; Commentary:
5;;
6;; Configures the auto-completion framework (company-mode)
7;;
8;;; Code:
9(use-package company
10 :ensure t
11 :init
12 (setq
13 ;; Display the suggestion popup quickly
14 company-idle-delay 0.4
15 ;; Display the suggestion popup after 1 character
16 company-minimum-prefix-length 1)
17 :config
18 (add-hook 'company-mode-hook '(lambda ()
19 (progn
20 ;; I prefer to use TAB instead of RETURN to finish completion
21 (define-key company-active-map [return] nil)
22 (define-key company-active-map [tab] 'company-complete-selection)))))
23;; Display documentation in a popup
24(use-package company-quickhelp
25 :ensure t
26 :config
27 (add-hook 'company-mode-hook '(lambda ()
28 (progn
29 (company-quickhelp-mode)))))
30(provide 'autocompletion-conf)
diff --git a/local-lib/rust-conf.el b/local-lib/rust-conf.el
new file mode 100644
index 0000000..a0c7b7d
--- /dev/null
+++ b/local-lib/rust-conf.el
@@ -0,0 +1,32 @@
1;;; rust-conf.el --- configuration for the rust language
2;; Author: jason <jason@zzq.org>
3;; Created: 16 Jun 2017
4;;; Commentary:
5;;
6;; Installation:
7;; * Install Rust: https://www.rust-lang.org/en-US/install.html
8;; * Install Racer: https://github.com/racer-rust/racer
9;; * Install the Rust source: rustup component add rust-src - This goes to:
10;; ~/.multirust/toolchains/[toolchain]/lib/rustlib/src/rust/src
11;; * Define the RUST_SRC_PATH environment var to the source directory
12;;
13;;; Code:
14(use-package rust-mode
15 :ensure t
16 :commands (rust-mode))
17
18(use-package cargo
19 :ensure t
20 :commands (cargo-minor-mode))
21
22(use-package racer
23 :ensure t
24 :commands (racer-mode))
25
26(add-hook 'rust-mode-hook (lambda ()
27 (progn
28 (racer-mode)
29 (cargo-minor-mode))))
30(add-hook 'racer-mode-hook #'company-mode)
31
32(provide 'rust-conf)