aboutsummaryrefslogtreecommitdiffstats
path: root/init.el
blob: a1669b8daab04d2f3f74b44d6961376ffb89f22d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
;;; init.el --- emacs start up
;; Author: jason <jason@zzq.org>
;; Created: 15 Jun 2017
;; Version: 2
;; Keywords:
;; X-URL: https://beehive.io/jason/emacs.d/
;;; Commentary:
;;
;;; Code:
(defconst emacs-start-time (current-time))
(setq inhibit-startup-screen t ;; Hide the default startup screen
      savehist-file "~/.emacs.d/savehist"
      ;; Define where to store recovery files
      backup-directory-alist '(("." . "~/.emacs.d/backups"))
      ;; Use version numbers for backups.
      version-control t
      ;; Number of newest versions to keep.
      kept-new-versions 10
      ;; Number of oldest versions to keep.
      kept-old-versions 0
      ;; Don't ask to delete excess backup versions.
      delete-old-versions -1
      ;; Copy all files, don't rename them.
      backup-by-copying t
      ;; Make backups files under version control.
      vc-make-backup-files t
      ;; Don't confirm following when opening a symlink
      vc-follow-symlinks t)

(setq package-archives '(("elpa" . "http://elpa.gnu.org/packages/")
			 ;; For org-mode
			 ("org" . "http://orgmode.org/elpa/")
			 ;; melpa builds git repositories and can be unstable
			 ("melpa" . "http://melpa.org/packages/")
			 ;; marmalade has maintainers upload versions
			 ;; ("marmalade" . "https://marmalade-repo.org/packages/")
			 ;; melpa-stable builds from git tags but may be missing dependencies
			 ;; ("melpa-stable" . "https://stable.melpa.org/packages/")
			 ;; Elpy packages for the Python language
			 ;; ("elpy" . "https://jorgenschaefer.github.io/packages/")
			 ))

;; Initializes installed packages
(package-initialize)

;; Packages are managed by the use-package package, so we need to make sure it's installed
(unless (package-installed-p 'use-package)
  (package-refresh-contents)
  (package-install 'use-package))
(eval-when-compile
  (require 'use-package))
;; slight optimization for use-package's :bind directive
(require 'bind-key)

;; Add local library to the load path
(add-to-list 'load-path "~/.emacs.d/local-lib/")
;; Usernames and passwords are stored in a file that isn't sync'd to VC
(load "~/.emacs.d/secrets" t)

;; My misc functions
(require 'zzq-funcs)

(add-hook 'after-init-hook
	  (lambda ()
	    (progn
	      ;; Maximize the frame on startup
	      (toggle-frame-maximized)
	      ;; Always ensure packages are installed if they are defined with use-package
	      ;; (setq use-package-always-ensure t)

	      ;; Set default encoding to UTF-8
	      (set-language-environment "UTF-8")
	      (set-default-coding-systems 'utf-8)
	      (setq default-buffer-file-coding-system 'utf-8-unix)
	      ;; Hide the toolbar
	      (tool-bar-mode -1)
	      ;; Hide the scrollbar
	      (scroll-bar-mode -1)
	      ;; no beep and no blinking cursor
	      (setq ring-bell-function 'ignore
		    visible-bell nil
		    ;; display the full file path in the titlebar
		    frame-title-format
		    (list (format "%s %%S: %%j " (system-name))
			  '(buffer-file-name "%f" (dired-directory dired-directory "%b"))))

	      ;; Show matched parens
	      (show-paren-mode t)
	      ;; Allow undoing/redoing of window layouts with C-c left/right arrows
	      (winner-mode 1)
	      ;; Let y and n be good enough for yes and no questions
	      (fset 'yes-or-no-p 'y-or-n-p)
	      ;; Auto-refresh files changed on the file system
	      (global-auto-revert-mode 1)
	      ;; Save commands and their history
	      (savehist-mode +1)
	      (setq savehist-save-minibuffer-history +1)
	      (setq savehist-additional-variables
		    '(kill-ring
		      search-ring
		      regexp-search-ring))
	      ;; Allow mouse support in xterm
	      (xterm-mouse-mode 1)
	      ;; Automatically close parens when opening them
	      (electric-pair-mode 1)
	      ;; Ovewrite selected regions with what you're typing/pasting/etc
	      (delete-selection-mode 1)
	      ;; A region is only active when it is highlighted (mimics other editors)
	      (transient-mark-mode 1)
	      ;; Kill the current buffer by default
	      (global-set-key (kbd "C-x k") 'kill-this-buffer)
	      ;; Use ibuffer for the buffer list
	      (global-set-key (kbd "C-x C-b") 'ibuffer)
	      ;;;;;;;;;;;
	      ;; Hooks ;;
	      ;;;;;;;;;;;
	      (add-hook 'write-file-hooks
			'(lambda ()
			   ;; delete trailing whitespace from all files
			   (delete-trailing-whitespace)))
	      ;;;;;;;;;;;;
	      ;; Themes ;;
	      ;;;;;;;;;;;;
	      (use-package jbeans-theme
		:ensure t
		:config
		(load-theme 'jbeans))
	      ;;;;;;;;;;;;;;
	      ;; Packages ;;
	      ;;;;;;;;;;;;;;
	      ;; paradox - A better emacs package manager
	      (use-package paradox
		:ensure t
		:config
		;; Use paradox as the default package manager
		(paradox-enable))
	      ;; which-key - Displays a pop up with hints when pushing key bindings
	      (use-package which-key
		:ensure t
		:diminish which-key-mode
		:init
		(setq which-key-special-keys nil
		      which-key-use-C-h-commands t
		      which-key-echo-keystrokes 0.02
		      which-key-max-description-length 32
		      which-key-sort-order 'which-key-key-order-alpha)
		:config
		(which-key-mode))
	      ;; Ivy, swiper, and counsel for autocompleting emacs things
	      (use-package ivy
	     	:ensure t
		:pin elpa
		:diminish ivy-mode
		:bind (("C-s" . swiper)
		       ("M-x" . counsel-M-x)
		       ("C-x C-f" . counsel-find-file))
		:init
		;; Remove the ^ prefix
		(setq ivy-initial-inputs-alist nil
		      ;; Display recently opened files when switching buffers
		      ivy-use-virtual-buffers t
		      ;; Use ivy for magit
		      magit-completing-read-function 'ivy-completing-read
		      ;; Use ivy for projectile
		      projectile-completion-system 'ivy)
		:config
		(ivy-mode 1))
	      ;; avy - A quick way to jump around buffers
	      (use-package avy
		:ensure t
		:bind (("C-:" . avy-goto-line)))

	      ;; Other packages
	      ;; autocompletion - auto-completion for programming languages
	      (require 'autocompletion-conf)
	      ;; persp - virtual workspaces
	      (require 'persp-conf)
	      ;; powerline - prettier modeline
	      (require 'powerline-conf)
	      ;; projectile - utilities for working with projects
	      (require 'projectile-conf)
	      (require 'version-control-conf)

	      ;; Languages
	      (require 'python-conf)
	      (require 'rust-conf)

	      (message "Emacs loaded in %.3fs"
		       (/ (- (zzq/time-to-msec (current-time)) (zzq/time-to-msec emacs-start-time)) 1000.0))
	      ))) ;; End progn/lambda/add-hook after-init-hook

(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.
 '(custom-safe-themes
   (quote
    ("64f2981274fd8740b794bce9feee7949ed87b88fc0b4654bd98594e1aa81abcd" default)))
 '(package-selected-packages
   (quote
    (elpy magit racer cargo rust-mode company-quickhelp company projectile persp-mode avy ivy powerline which-key paradox use-package jbeans-theme)))
 '(paradox-github-token t)
 '(safe-local-variable-values
   (quote
    ((eval let
	   ((virtualenv "~/.virtualenvs/eb"))
	   (setq-local pythonic-environment virtualenv)
	   (my/advise-pythonic-activate virtualenv)))))
 '(show-paren-mode t)
 '(tool-bar-mode nil))

(custom-set-faces
 ;; custom-set-faces 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.
 '(default ((t (:family "Inconsolata" :foundry "PfEd" :slant normal :weight normal :height 98 :width normal)))))