-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.el
375 lines (308 loc) · 9.45 KB
/
config.el
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
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
(defvar my-term-shell "/bin/bash")
(defadvice ansi-term (before force-bash)
(interactive (list my-term-shell)))
(ad-activate 'ansi-term)
(defun config-visit ()
(interactive)
(find-file "~/.emacs.d/config.org"))
(global-set-key (kbd "C-c e") 'config-visit)
(defun config-reload ()
(interactive)
(org-babel-load-file (expand-file-name "~/.emacs.d/config.org")))
(global-set-key (kbd "C-c r") 'config-reload)
(when (memq window-system '(mac ns x))
(exec-path-from-shell-initialize))
(use-package sudo-edit
:ensure t
:bind ("s-e" . 'sudo-edit))
;; The following lines are always needed.Choose your own keys.
(global-set-key "\C-cl" 'org-store-link)
(global-set-key "\C-ca" 'org-agenda)
(global-set-key "\C-cc" 'org-capture)
(global-set-key "\C-cb" 'org-switchb)
;; Switches code to current buffer when typing code
(setq org-src-window-setup 'current-window)
;; Snippets
;; Emacs-Lisp
(add-to-list 'org-structure-template-alist
'("el" . "src emacs-lisp"))
(add-hook 'org-mode-hook 'org-indent-mode)
(use-package org-bullets
:ensure t
:config
(add-hook 'org-mode-hook (lambda () (org-bullets-mode))))
(setq ido-enable-files-matching nil)
(setq ido-create-new-buffer 'always)
(setq ido-everywhere t)
(ido-mode 1)
(use-package ido-vertical-mode
:ensure t
:init
(ido-vertical-mode 1))
(setq ido-vertical-define-keys 'C-n-and-C-p-only)
(use-package smex
:ensure t
:init (smex-initialize)
:bind ( "M-x" . 'smex))
(global-set-key (kbd "C-x C-b") 'ido-switch-buffer)
;; Centaur Tabs
(use-package centaur-tabs
:ensure t
:init
(centaur-tabs-mode))
;; which-key
(use-package which-key
:ensure t
:init
(which-key-mode))
(use-package beacon
:ensure t
:init
(beacon-mode 1))
(use-package rainbow-mode
:ensure t
:init (add-hook 'prog-mode-hook 'rainbow-mode))
(use-package rainbow-delimiters
:ensure t
:init (add-hook 'prog-mode-hook 'rainbow-delimiters-mode))
(use-package switch-window
:ensure t
:config
(setq switch-window-input-style 'minibuffer)
(setq switch-window-increase 4)
(setq switch-window-threshold 2)
(setq switch-window-shortcut-style 'qwerty)
(setq switch-window-qwerty-shortcuts
'("a" "s" "d" "f" "h" "j" "k" "l"))
:bind
([remap other-window] . 'switch-window))
(use-package dashboard
:ensure t
:config
(dashboard-setup-startup-hook)
(setq dashboard-items '((recents . 10)))
(setq dashboard-banner-logo-title "Hello!"))
(use-package symon
:ensure t
:bind
("s-j" . 'symon-mode))
(use-package spaceline
:ensure t
:config
(require 'spaceline-config)
(setq powerline-default-separator (quote arrow))
(spaceline-spacemacs-theme))
(use-package dmenu
:ensure t
:bind
("s-f" . ' dmenu))
(setq display-time-24hr-format t)
(display-time-mode 1)
(line-number-mode 1)
(column-number-mode 1)
;; Annoying toolbars
(menu-bar-mode -1)
(tool-bar-mode -1)
(defun split-and-follow-horizontally ()
(interactive)
(split-window-below)
(balance-windows)
(other-window 1))
(global-set-key (kbd "C-x 2") 'split-and-follow-horizontally)
(defun split-and-follow-vertically ()
(interactive)
(split-window-right)
(balance-windows)
(other-window 1))
(global-set-key (kbd "C-x 3") 'split-and-follow-vertically)
;; Disable annoying startup
(setq inhibit-startup-message t)
;; Yes or No
(defalias 'yes-or-no-p 'y-or-n-p)
;; Scrolling
(setq scroll-conservatively 100)
;; Disable annoying bell
(setq ring-bell-function 'ignore)
;; Highlight Cursor
;; Set it to work on GUI Emacs only
(when window-system (global-hl-line-mode t))
;; Prettify symbol
(when window-system (global-prettify-symbols-mode t))
(global-set-key (kbd "C-x b") 'ibuffer)
(use-package avy
:ensure t
:init
:bind ( "M-s" . 'avy-goto-char))
(use-package hungry-delete
:ensure t
:config
(global-hungry-delete-mode))
(defun kill-whole-word ()
(interactive)
(backward-word)
(kill-word 1))
(global-set-key (kbd "C-c w w") 'kill-whole-word)
(defun copy-whole-line ()
(interactive)
(save-excursion
(kill-new
(buffer-substring
(point-at-bol)
(point-at-eol)))))
(global-set-key (kbd "C-c w l") 'copy-whole-line)
(global-subword-mode 1)
(setq electric-pair-pairs '(
(?\( . ?\))
(?\[ . ?\])
(?\{ . ?\})))
(electric-pair-mode t)
(use-package popup-kill-ring
:ensure t
:bind ("M-y" . 'popup-kill-ring))
(use-package multiple-cursors
:ensure t
:bind ("C-S-c C-S-c" . 'mc/edit-lines)
("C->" . 'mc/mark-next-like-this)
("C-<" . 'mc/mark-previous-like-this)
("C-c q" . 'mc/mark-all-like-this))
(use-package expand-region
:ensure t
:bind ("C-q" . 'er/expand-region))
(load
"~/.opam/4.08.1/share/emacs/site-lisp/tuareg-site-file.el")
(load
"~/.opam/4.08.1/share/emacs/site-lisp/ocp-indent.el")
(let ((opam-share (ignore-errors (car (process-lines "opam" "config" "var"
"share")))))
(when (and opam-share (file-directory-p opam-share))
;; Register Merlin
(add-to-list 'load-path (expand-file-name "emacs/site-lisp" opam-share))
(autoload 'merlin-mode "merlin" nil t nil)
;; Automatically start it in OCaml buffers
(add-hook 'tuareg-mode-hook 'merlin-mode t)
(add-hook 'caml-mode-hook 'merlin-mode t)
(push "/home/james/.opam/4.08.1/share/emacs/site-lisp" load-path)
;; Use opam switch to lookup ocamlmerlin binary
(setq merlin-command "/home/james/.opam/4.08.1/bin/ocamlmerlin")))
;; ## added by OPAM user-setup for emacs / base ## 56ab50dc8996d2bb95e7856a6eddb17b ## you can edit, but keep this line
(require 'opam-user-setup "~/.emacs.d/opam-user-setup.el")
;; ## end of OPAM user-setup addition for emacs / base ## keep this line
(load (expand-file-name "~/quicklisp/slime-helper.el"))
;; Default Common Lisp
(setq inferior-lisp-program "/usr/bin/sbcl")
(setq slime-contribs '(slime-fancy)) ; almost everything
(load-file (let ((coding-system-for-read 'utf-8))
(shell-command-to-string "agda-mode locate")))
;; Web Mode
(require 'web-mode)
(add-to-list 'auto-mode-alist '("\\.phtml\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.tpl\\.php\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.[agj]sp\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.as[cp]x\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.erb\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.mustache\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.djhtml\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.html?\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.css?\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.js?\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.ts\\'" . web-mode))
(setq org-latex-create-formula-image-program 'dvipng)
;; pdf-tools
(use-package pdf-tools
:ensure t
:init
(pdf-tools-install))
;; saveplace-pdf-tools
(require 'saveplace-pdf-view)
(save-place-mode 1)
;; Hook LaTex with pdf-tools
;; (server-start)
(setq TeX-view-program-selection '((output-pdf "PDF Tools")))
;; Syncs the pdf
(setq TeX-source-correlate-mode t)
;; to have the buffer refresh after compilation
(add-hook 'TeX-after-compilation-finished-functions
#'TeX-revert-document-buffer)
;; Enable elpy
(use-package elpy
:ensure t
:init
(elpy-enable))
;; For elpy
;;(setq elpy-rpc-python-command "python3")
;; For interactive shell
(setq python-shell-interpreter "python"
python-shell-interpreter-args "-i")
;; Company Mode
(use-package company
:ensure t
:config
(setq company-idle-delay nil)
;; (setq company-minimum-prefix-length 3)
(setq company-begin-commands '(self-insert-command))
(setq company-require-match nil)
(add-hook 'after-init-hook 'global-company-mode))
(global-set-key (kbd "<C-tab>") #'company-complete)
(with-eval-after-load 'company
(define-key company-active-map (kbd "M-n") nil)
(define-key company-active-map (kbd "M-p") nil)
(define-key company-active-map (kbd "SPC") nil)
(define-key company-active-map (kbd "C-n") #'company-select-next)
(define-key company-active-map (kbd "C-p") #'company-select-previous)
(define-key company-active-map (kbd "SPC") #'company-abort))
(use-package company-irony
:ensure t
:config
(require 'company)
(add-to-list 'company-backends 'company-irony))
(use-package company-c-headers
:ensure t
:config
(require 'company)
(add-to-list 'company-backends 'company-c-headers))
(use-package irony
:ensure t
:config
(add-hook 'c++-mode-hook 'irony-mode)
(add-hook 'c-mode-hook 'irony-mode)
(add-hook 'irony-mode-hook 'irony-cdb-autosetup-compile-options))
(with-eval-after-load 'company
(add-hook 'c++-mode-hook 'company-mode)
(add-hook 'c-mode-hook 'company-mode))
;; Open .v files with Proof-General's coq-mode
(require 'proof-site "~/.emacs.d/lisp/PG/generic/proof-site")
;; Load company-coq when opening Coq files
(add-hook 'coq-mode-hook #'company-coq-mode)
(use-package company-coq
:ensure t
:config
(require 'company)
(add-hook 'coq-mode-hook #'company-coq-mode))
(use-package company-math
:ensure t
:config
(require 'company)
;(add-to-list 'company-backends 'company-math-symbols-unicode)
(add-to-list 'company-backends
(append
'(company-math-symbols-latex
company-auctex-environments
company-auctex-labels
company-auctex-macros
company-auctex-bibs))))
;(use-package company-auctex
; :ensure t
; :config
; (company-auctex-init))
(eval-after-load 'flycheck
'(add-hook 'flycheck-mode-hook #'flycheck-irony-setup))
(use-package yasnippet
:ensure t
:config (use-package yasnippet-snippets
:ensure t)
(require 'yasnippet)
(yas-reload-all)
(yas-global-mode 1))
(use-package swiper
:ensure t
:bind ("C-s" . 'swiper))