-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.el
436 lines (383 loc) · 14.2 KB
/
init.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
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
;; PACKAGE INITIALIZATION
(require 'package)
(add-to-list 'package-archives '("melpa" . "http://melpa.milkbox.net/packages/") t)
(add-to-list 'package-archives '("melpa-stable" . "http://stable.melpa.org/packages/") t)
(add-to-list 'package-archives '("org" . "http://orgmode.org/elpa/") t)
(add-to-list 'load-path "~/.emacs.d/plugin/")
(add-to-list 'load-path "~/.emacs.d/lisp/")
(package-initialize)
(when (memq window-system '(mac ns))
(setenv "SHELL" "/bin/zsh")
(exec-path-from-shell-initialize)
(exec-path-from-shell-copy-envs '("PATH")))
(unless (package-installed-p 'use-package)
(package-refresh-contents)
(package-install 'use-package))
(defvar myPackages
'(better-defaults
elpy
flycheck
magit
neotree
evil
yasnippet-snippets
company
linum-relative
clean-aindent-mode
window-numbering
smart-mode-line
;; smex
cnfonts
pyenv-mode
smartparens
helm
sublime-themes
multiple-cursors
expand-region
helm-company
helm-swoop
ace-jump-mode
nyan-mode
material-theme))
(mapc #'(lambda (package)
(unless (package-installed-p package)
(package-install package)))
myPackages)
;; BASIC CUSTOMIZATION
(setq inhibit-splash-screen t)
;; (setq inhibit-startup-buffer-menu)
;; theme
(load-theme 'spolsky t)
(global-set-key (kbd "C-<f5>") 'redraw-display)
(setq visible-bell nil)
(setq ring-bell-function (lambda()
(invert-face 'mode-line)
(run-with-timer 0.1 nil 'invert-face 'mode-line)))
(tool-bar-mode -1)
(menu-bar-mode -1)
(scroll-bar-mode -1)
(set-face-attribute 'default nil :height 125)
(display-time-mode)
(global-linum-mode t) ;; Display line number
(define-key global-map (kbd "M-g") 'goto-line) ;; Modify goto line key
(global-hl-line-mode t) ;; Highlight current line
(column-number-mode 1) ;; Show column number
(setq-default tab-width 4) ;; Tap size
(set-keyboard-coding-system nil) ;; Meta key problem in Mac
(setq mac-option-key-is-meta nil
mac-command-key-is-meta t
mac-command-modifier 'meta
mac-option-modifier 'none)
(global-visual-line-mode 1)
(toggle-truncate-lines 1)
(setq c-default-style "k&r" c-basic-offset 4)
(global-set-key (kbd "M-S-<left>") 'shrink-window-horizontally)
(global-set-key (kbd "M-S-<right>") 'enlarge-window-horizontally)
(global-set-key (kbd "M-S-<down>") 'shrink-window)
(global-set-key (kbd "M-S-<up>") 'enlarge-window)
(setq temporary-file-directory "~/temp/")
(setq backup-directory-alist `((".*" . ,temporary-file-directory)))
(setq auto-save-file-name-transforms `((".*" ,temporary-file-directory t)))
(nyan-mode t)
(setq gdb-many-windows t
gdb-show-main t)
(global-set-key (kbd "M-`") 'other-frame)
(global-set-key (kbd "<f5>") (lambda()
(interactive)
(setq-local compilation-read-command nil)
(call-interactively 'compile)))
;; TERMINAL
(defun visit-term-buffer ()
"Create or visit a terminal buffer."
(interactive)
(if (not (get-buffer "*ansi-term*"))
(progn
(split-window-sensibly (selected-window))
(other-window 1)
(ansi-term (getenv "SHELL")))
(switch-to-buffer-other-window "*ansi-term*")))
(global-set-key (kbd "C-c t") 'visit-term-buffer)
;; ACE JUMP
(require 'ace-jump-mode)
(define-key global-map (kbd "C-c u") 'ace-jump-word-mode)
(define-key global-map (kbd "C-c C-u") 'ace-jump-char-mode)
(define-key global-map (kbd "C-c C-c C-u") 'ace-jump-line-mode)
;; CHINESE-FONTS-SETUP
;; (require 'chinese-fonts-setup)
;; (chinese-fonts-setup-enable)
;; CLEAN-AINDENT
(require 'clean-aindent-mode)
(clean-aindent-mode 1)
;; COMPANY
(add-hook 'after-init-hook 'global-company-mode)
;; ELPY
(require 'elpy)
(when (require 'flycheck nil t)
(setq elpy-modules (delq 'elpy-module-flymake elpy-modules))
(add-hook 'elpy-mode-hook 'flycheck-mode))
(elpy-enable)
;; (setq exec-path-from-shell-arguments '("-i"))
;; (exec-path-from-shell-copy-env "PATH")
;; (setq exec-path-from-shell-arguments '("-l"))
;; (elpy-use-ipython "ipython")
(setq python-shell-interpreter-args "")
(setq elpy-rpc-backend "jedi")
;; (pyenv-mode t)
;; EMMET
;; (require 'emmet-mode)
;; (add-hook 'html-mode-hook 'emmet-mode)
;; (add-hook 'css-mode-hook 'emmet-mode)
;; EXPAND-REGION
(require 'expand-region)
(global-set-key (kbd "C-=") 'er/expand-region)
;; EVIL
(require 'evil)
(defun toggle-evil-mode ()
(interactive)
(if (bound-and-true-p evil-local-mode)
(progn
(evil-local-mode (or -1 1))
(undo-tree-mode (or -1 1))
(set-variable 'cursor-type 'bar)
)
(progn
(evil-local-mode (or 1 1))
(set-variable 'cursor-type 'box)
)
)
)
(global-set-key (kbd "M-u") 'toggle-evil-mode)
(evil-mode t)
;; FUNCTION ARGS
; (require 'function-args)
; (fa-config-default)
;; HELM
(require 'helm)
(require 'helm-company)
(require 'helm-config)
(require 'helm-swoop)
(global-set-key (kbd "M-i") 'helm-swoop)
(global-set-key (kbd "M-I") 'helm-swoop-back-to-last-point)
(global-set-key (kbd "C-c M-i") 'helm-multi-swoop)
(global-set-key (kbd "C-c M-I") 'helm-multi-swoop-all)
(setq helm-multi-swoop-edit-save t)
(define-key helm-map (kbd "<tab>") 'helm-execute-persistent-action)
(global-set-key (kbd "C-x b") 'helm-buffers-list)
(global-set-key (kbd "C-x r b") 'helm-bookmarks)
(global-set-key (kbd "M-x") 'helm-M-x)
(global-set-key (kbd "M-y") 'helm-show-kill-ring)
(global-set-key (kbd "C-x C-f") 'helm-find-files)
(eval-after-load 'company
'(progn
(define-key company-mode-map (kbd "C-;") 'helm-company)
(define-key company-active-map (kbd "C-;") 'helm-company)))
;; LINENUM RELATIVE
(require 'linum-relative)
(linum-on)
;; JS2-MODE
;; (require 'js2-mode)
;; (add-to-list 'auto-mode-alist '("\\.js\\'" . js2-mode))
;; (add-to-list 'interpreter-mode-alist '("node" . js2-mode))
;; KEY-CHORD
;; (require 'key-chord)
;; (key-chord-mode 1)
;; (key-chord-define-global "" (kbd "<escape>"))
;; ORG
(add-to-list 'auto-mode-alist '("\\.\\(org\\|org_archive\\|txt\\)$" . org-mode))
(require 'org)
(org-babel-do-load-languages
'org-babel-load-languages
'(
(sh . t)
(python . t)
(R . t)
(ruby . t)
(perl . t)
(C . t))
)
(setq org-directory "~/Dropbox/Org")
(setq org-default-notes-file (concat org-directory "/notes.org"))
(setq org-log-done 'time)
(setq org-export-coding-system 'utf-8)
(setq org-latex-inputenc-alist '(("utf8" . "utf8x")))
;; Standard key bindings
(global-set-key "\C-cl" 'org-store-link)
(global-set-key "\C-ca" 'org-agenda)
(global-set-key "\C-cb" 'org-switchb)
(global-set-key "\C-cc" 'org-capture)
(global-set-key (kbd "C-c g")
(lambda () (interactive) (find-file "~/Dropbox/Org/gtd.org")))
(global-set-key (kbd "C-c j")
(lambda () (interactive) (find-file "~/Dropbox/Org/journals.org")))
(global-set-key (kbd "C-c n")
(lambda () (interactive) (find-file "~/Dropbox/Org/notes.org")))
(global-set-key (kbd "C-c r")
(lambda () (interactive) (find-file "~/Dropbox/Org/refiles.org")))
;; Org capture templates
(setq org-capture-templates
(quote (("t" "Tasks" entry
(file+headline "~/Dropbox/Org/refiles.org" "Inbox")
"* TODO %^{Task}\nSCHEDULED: %^t\n%?\n")
("T" "Quick Tasks" entry
(file+headline "~/Dropbox/Org/refiles.org" "Inbox")
"* TODO %^{Task}\n%t\n"
:immediate-finish t)
("n" "Notes" entry
(file+headline "~/Dropbox/Org/refiles.org" "Notes")
"* %^{Note} \n%U\n%?")
("N" "Quick Notes" item
(file+headline "~/Dropbox/Org/refiles.org" "Notes"))
("j" "Journals" plain
(file+datetree "~/Dropbox/Org/journals.org")
"**** %U %^{Title}\n%?"
:unnarrowed t)
)))
(setq org-todo-keywords
'((sequence "TODO" "DOING" "POSTPONED" "DONE")))
(setq org-todo-keyword-faces
'(("DOING" . "yellow") ("POSTPONED" . (:foreground "white" :background "red"))))
(require 'org-bullets)
(add-hook 'org-mode-hook (lambda () (org-bullets-mode 1)))
;; warn me of any dealines in next 7 days
(setq org-deadline-warning-days 7)
;; don't show tasks as scheduled if they are already shown as a dealine
(setq org-agenda-skip-scheduled-if-deadline-is-shown t)
(setq org-agenda-skip-scheduled-if-done t)
(setq org-agenda-skip-deadline-prewarning-if-scheduled (quote pre-scheduled))
;; CC-MODE
;; (require 'cc-mode)
;; (define-key c-mode-map [(tab)] 'company-complete)
;; (define-key c++-mode-map [(tab)] 'company-complete)
;; MARKDOWN MODE
;; (autoload 'markdown-mode "markdown-mode"
;; "Major mode for editing Markdown files" t)
;; (add-to-list 'auto-mode-alist '("\\.markdown\\'" . markdown-mode))
;; (add-to-list 'auto-mode-alist '("\\.md\\'" . markdown-mode))
;; MAGIT
(global-set-key (kbd "C-x g") 'magit-status)
;; MULTIPLE CURSORS
(require 'multiple-cursors)
(global-set-key (kbd "C-S-c C-S-c") 'mc/edit-lines)
(global-set-key (kbd "C-}") 'mc/mark-next-like-this)
(global-set-key (kbd "C-{") 'mc/mark-previous-like-this)
(global-set-key (kbd "C-c C-{") 'mc/mark-all-like-this)
;; NEOTREE
(require 'neotree)
(global-set-key (kbd "<f8>") 'neotree-toggle)
;; (require 'powerline)
;; (powerline-center-theme)
;; SMART MODE LINE
;; (require 'smart-mode-line)
;; (setq powerline-arrow-shape 'curve)
;; (setq powerline-default-separator-dir '(right . left))
;; (setq sml/theme 'powerline)
;; (setq sml/mode-width 0)
;; (setq sml/name-width 20)
;; (setq sml/no-confirm-load-theme t)
;; (sml/setup)
;; (require 'init-powerline)
;; SMARTPARENS
(require 'smartparens-config)
(add-hook 'html-mode-hook #'smartparens-mode)
(add-hook 'js-mode-hook #'smartparens-mode)
(add-hook 'python-mode-hook #'smartparens-mode)
(add-hook 'c-mode-hook #'smartparens-mode)
(add-hook 'markdown-mode-hook #'smartparens-mode)
(add-hook 'emacs-lisp-mode-hook #'smartparens-mode)
(sp-local-pair 'js2-mode "{" nil :post-handlers '((my-create-newline-and-enter-sexp "RET")))
(sp-with-modes '(c-mode c++-mode)
(sp-local-pair "{" nil :post-handlers '(("||\n[i]" "RET")))
(sp-local-pair "/*" "*/" :post-handlers '((" | " "SPC")
("* ||\n[i]" "RET"))))
(defun my-create-newline-and-enter-sexp (&rest_ignored)
(newline)
(indent-according-to-mode)
(forward-line -1)
(indent-according-to-mode))
;; SMEX
;; (global-set-key (kbd "C-x m") 'smex)
;; (global-set-key (kbd "M-X") 'smex-major-mode-commands)
;; (global-set-key (kbd "C-c C-c M-x") 'execute-extended-command) ;; This is the old M-x
;; UNDO-TREE
(global-set-key (kbd "M-/") 'undo-tree-visualize)
;; 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))
;; (setq web-mode-enable-current-column-highlight t)
;; (setq web-mode-enable-current-element-highlight t)
;; WINDOW NUMBERING
(window-numbering-mode 1)
;; WINNER
(winner-mode 1)
;; YASNIPPET
(setq yas-snippet-dirs
'("~/.emacs.d/snippets"
"~/.emacs.d/plugins/yasnippet"
))
(require 'yasnippet)
(yas-global-mode 1)
(add-hook 'term-mode-hook (lambda()
(setq yas-dont-activate t)))
(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.
'(ansi-color-faces-vector
[default bold shadow italic underline bold bold-italic bold])
'(ansi-color-names-vector
(vector "#4d4d4c" "#c82829" "#718c00" "#eab700" "#4271ae" "#8959a8" "#3e999f" "#d6d6d6"))
'(cfs--current-profile "profile1" t)
'(cfs--profiles-steps (quote (("profile1" . 6))) t)
'(custom-safe-themes
(quote
("0c29db826418061b40564e3351194a3d4a125d182c6ee5178c237a7364f0ff12" default)))
'(elpy-rpc-python-command "/usr/local/bin/python3")
'(fci-rule-color "#d6d6d6")
'(linum-relative-current-symbol "")
'(linum-relative-global-mode t)
'(markdown-enable-math t)
'(org-agenda-files (quote ("~/Dropbox/Org/gtd.org")))
'(org-hide-emphasis-markers t)
'(org-hide-leading-stars t)
'(org-modules
(quote
(org-bbdb org-bibtex org-docview org-gnus org-habit org-info org-irc org-mhe org-rmail org-w3m)))
'(org-refile-targets (quote ((org-agenda-files :maxlevel . 6))))
'(package-selected-packages
(quote
(yasnippet-snippets cnfonts window-numbering use-package sublime-themes smex smartparens smart-mode-line pyenv-mode org-bullets nyan-mode neotree multiple-cursors material-theme markdown-mode magit linum-relative helm-swoop helm-company function-args flycheck expand-region exec-path-from-shell evil emmet-mode elpy clean-aindent-mode better-defaults ace-jump-mode)))
'(pyvenv-virtualenvwrapper-python "/usr/local/bin/python3"))
;;; sRGB doesn't blend with Powerline's pixmap colors, but is only
;;; used in OS X. Disable sRGB before setting up Powerline.
(when (memq window-system '(mac ns))
(setq ns-use-srgb-colorspace nil))
(provide 'init)
;;; init.el ends here
(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.
'(linum-relative-current-face ((t (:inherit linum :background "#444444" :foreground "Orange" :weight bold))))
'(org-level-1 ((t (:inherit outline-1))))
'(org-level-2 ((t (:foreground "#6592e4"))))
'(org-level-3 ((t (:inherit outline-2))))
'(org-level-4 ((t (:inherit outline-4))))
'(org-level-5 ((t (:inherit outline-5))))
'(org-level-6 ((t (:foreground "brown"))))
'(org-level-7 ((t (:inherit outline-8))))
'(org-level-8 ((t (:foreground "grey"))))
'(powerline-evil-normal-face ((t (:inherit powerline-evil-base-face :background "chartreuse3"))))
'(term ((t (:foreground "ivory1"))))
'(term-color-black ((t (:foreground "gray80"))))
'(term-color-cyan ((t (:foreground "cyan2"))))
'(term-color-green ((t (:foreground "OliveDrab3"))))
'(term-color-yellow ((t (:foreground "gold1")))))