-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.emacs
493 lines (433 loc) · 15 KB
/
.emacs
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
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
;; Code:
;; User info
(setq user-full-name "Greg Perrin")
(setq user-mail-address "gregoryperrin.ucb@gmail.com")
;; UI setup
;; (scroll-bar-mode -1)
(tool-bar-mode -1)
(menu-bar-mode -1)
;; always follow symlinks
(setq vc-follow-symlinks nil)
;; Backup and Autosave Directories
(setq temporary-file-directory "~/.tmp/")
(setq backup-directory-alist
`((".*" . ,temporary-file-directory)))
(setq auto-save-file-name-transforms
`((".*" ,temporary-file-directory t)))
(setq auto-save-default nil)
(setq make-backup-files nil)
(setq create-lockfiles nil)
;; linum setup
;; (global-linum-mode)
(global-display-line-numbers-mode)
(global-hl-line-mode +1)
(set-face-attribute 'hl-line nil :inherit nil :background "gray6")
;; (set-face-foreground 'linum "color-242")
(setq linum-format "%4d \u2502 ")
(setq mac-command-modifier 'meta
mac-option-modifier 'none)
;;; sys clipboard
(setq x-select-enable-clipboard t)
;; (defun copy-from-osx ()
;; (shell-command-to-string "pbpaste"))
;; (defun paste-to-osx (text &optional push)
;; (let ((process-connection-type nil))
;; (let ((proc (start-process "pbcopy" "*Messages*" "pbcopy")))
;; (process-send-string proc text)
;; (process-send-eof proc))))
;; (setq interprogram-cut-function 'paste-to-osx)
;; (setq interprogram-paste-function 'copy-from-osx)
(setq vc-follow-symlinks nil)
(setq create-lockfiles nil)
;; (exec-path-from-shell-initialize)
(defun rem ()
"reload your .emacs file without restarting Emacs"
(interactive)
(load-file "~/.emacs"))
(defun use-eslint-from-node-modules ()
(let* ((root (locate-dominating-file
(or (buffer-file-name) default-directory)
"node_modules"))
(eslint (and root
(expand-file-name "node_modules/eslint/bin/eslint.js"
root))))
(when (and eslint (file-executable-p eslint))
(setq-local flycheck-javascript-eslint-executable eslint))))
;; Misc native issues
(setq backup-inhibited t) ; disable backup
(setq auto-save-default nil) ; disable autosave
(setq gc-cons-threshold 100000000)
(setq read-process-output-max (* 4096 4096)) ;; 1mb
(defun show-file-name ()
"Show the full path file name in the minibuffer."
(interactive)
(message (buffer-file-name)))
;; Tabs
(setq-default indent-tabs-mode nil)
(setq-default tab-width 2)
(setq standard-indent 2)
;; Matching delimiter mode
(show-paren-mode 1)
(setq show-paren-delay 0)
;; Face recognition
(defun what-face (pos)
(interactive "d")
(let ((face (or (get-char-property (point) 'read-face-name)
(get-char-property (point) 'face))))
(if face (message "Face: %s" face) (message "No face at %d" pos))))
;; Evil nav extension
(global-set-key (kbd "C-j")
(lambda () (interactive) (next-line 5)))
(global-set-key (kbd "C-k")
(lambda () (interactive) (previous-line 5)))
;; Install use-package if necessary
(require 'package)
(setq package-enable-at-startup nil)
(setq package-archives (append package-archives
'(("melpa" . "http://melpa.org/packages/")
("marmalade" . "http://marmalade-repo.org/packages/")
("gnu" . "http://elpa.gnu.org/packages/")
("org" . "http://orgmode.org/elpa/")
("elpy" . "http://jorgenschaefer.github.io/packages/"))))
(package-initialize)
;; Bootstrap use-package
(unless (package-installed-p 'use-package)
(package-refresh-contents)
(package-install 'use-package))
(use-package evil
:ensure t ;; install the evil package if not installed
:init ;; tweak evil's configuration before loading it
(setq evil-want-keybinding nil)
(setq evil-search-module 'evil-search)
(setq evil-ex-complete-emacs-commands nil)
(setq evil-vsplit-window-right t)
(setq evil-split-window-below t)
(setq evil-shift-round nil)
(setq evil-want-C-u-scroll t)
(with-eval-after-load 'evil-maps
(define-key evil-motion-state-map (kbd "TAB") nil))
:config ;; tweak evil after loading it
(evil-mode))
(use-package evil-collection
:after evil
:ensure t
:config
(setq evil-collection-setup-minibuffer t)
(evil-collection-init))
(use-package evil-leader
:ensure t
:after evil
:init
(global-evil-leader-mode)
(evil-leader/set-leader "<SPC>")
(evil-leader/set-key
"s" 'save-buffer
"q" 'kill-buffer
"a" 'show-file-name
"\\" 'split-window-horizontally
"<right>" 'shrink-window-horizontally
"<left>" 'enlarge-window-horizontally
"w" 'ace-window
"b" 'counsel-switch-buffer
"r" 'counsel-rg
"g" 'counsel-git-grep
"t" 'neotree-toggle
"i" 'lsp-ui-imenu
"f" 'swiper
"l" 'linum-mode
"q" 'query-replace-regexp
"y" 'yas-expand
"n" 'next-buffer
"p" 'projectile-command-map
"q" 'query-replace-regexp
"l" 'linum-mode
"e" 'counsel-M-x)
:config
(global-evil-leader-mode))
(use-package evil-commentary
:ensure t
:after evil
:init
(evil-commentary-mode))
(use-package key-chord
:ensure t
:after evil
:config
(key-chord-mode 1)
:init
(key-chord-define evil-insert-state-map "fd" 'evil-normal-state)
(key-chord-define evil-visual-state-map "fd" 'evil-normal-state)
(key-chord-define evil-insert-state-map "jk" 'evil-normal-state)
(key-chord-define evil-visual-state-map "jk" 'evil-normal-state))
(use-package color-theme-modern
:ensure t
:init
(add-to-list 'custom-theme-load-path
(file-name-as-directory "~/.emacs.d/themes/"))
:config
(load-theme 'kingsajz t t)
(enable-theme 'kingsajz))
(use-package spaceline
:ensure t
:after color-theme-modern
:init
(spaceline-emacs-theme))
(use-package neotree
:ensure t
:config
(add-hook 'neotree-mode-hook
(lambda ()
(define-key evil-normal-state-local-map (kbd "TAB") 'neotree-enter)
(define-key evil-normal-state-local-map (kbd "SPC") 'neotree-quick-look)
(define-key evil-normal-state-local-map (kbd "q") 'neotree-hide)
;; dumb hack to fix line jumps in tree
(define-key evil-normal-state-local-map (kbd "C-j") (lambda () (interactive) (next-line 5)))
(define-key evil-normal-state-local-map (kbd "C-k") (lambda () (interactive) (previous-line 5)))
(define-key evil-normal-state-local-map (kbd "TAB") 'neotree-change-root)))
(setq neo-window-width 35)
(setq-default neo-show-hidden-files t))
(use-package projectile
:ensure t
:after evil
:config
(setq projectile-completion-system 'ivy)
(projectile-mode +1))
(use-package ace-window
:ensure t
:config
(setq aw-keys '(?j ?k ?l)
aw-dispatch-always t))
(use-package ivy
:ensure t
:after key-chord
:init
(setq ivy-initial-inputs-alist nil)
(setq ivy-display-style 'fancy)
(setq ivy-dynamic-exhibit-delay-ms 250)
:bind (
:map ivy-minibuffer-map
("C-j" . 'ivy-next-line)
("C-k" . 'ivy-previous-line))
:config
(ivy-mode t))
(use-package counsel
:ensure t
:config
(setq counsel-rg-base-command "rg -i -M 120 --no-heading --line-number --color never %s . --no-ignore-vcs")
:bind (("M-x" . counsel-M-x)))
(use-package swiper
:ensure t
)
(use-package dumb-jump
:ensure t
:after evil evil-collection
:config
(setq dumb-jump-prefer-searcher 'rg)
)
(use-package smartparens
:ensure t
:config
(require 'smartparens-config)
(smartparens-global-mode))
(use-package wgrep
:ensure t
:after ivy counsel)
(use-package wgrep-ag
:ensure t
:after wgrep ivy counsel)
(use-package imenu-list
:ensure t
:config
(setq imenu-list-focus-after-activation t))
;; Company
(use-package company
:ensure t
:after color-theme-modern evil
:bind (:map company-active-map
("C-j" . company-select-next)
("C-k" . company-select-previous))
:config
(setq company-idle-delay 0.1)
:init
(set (make-local-variable 'company-backends)
'((company-files company-keywords company-capf company-dabbrev-code company-yasnippet company-etags company-dabbrev)))
(global-company-mode))
;; (with-eval-after-load 'company
;; (define-key company-active-map (kbd "TAB") nil)))
(use-package company-go
:ensure t
:defer t
:init
(with-eval-after-load 'company
(add-to-list 'company-backends 'company-go)))
(use-package go-mode
:ensure t
:init
(progn
(setq gofmt-command "goimports")
(add-hook 'before-save-hook 'gofmt-before-save)
(bind-key [remap find-tag] #'godef-jump))
:config
(add-hook 'go-mode-hook 'electric-pair-mode))
(use-package flycheck
:ensure t
:after web-mode
:init
(global-flycheck-mode)
:config
(flycheck-add-mode 'javascript-eslint 'web-mode)
(setq-default flycheck-temp-prefix ".flycheck")
;; (setq flycheck-idle-change-delay 4)
(setq flycheck-check-syntax-automatically '(idle-change idle-buffer-switch))
(setq-default flycheck-disabled-checkers
(append flycheck-disabled-checkers
'(json-jsonlist)))
(set-face-attribute 'flycheck-error nil :foreground "red")
:hook ((web-mode . use-eslint-from-node-modules)))
(use-package lsp-mode
:ensure t
:after company web-mode flycheck
:hook ((web-mode . lsp))
:config
;; (setq lsp-log-io t)
;; (setq lsp-print-performance t)
(setq lsp-enable-folding nil)
(setq lsp-restart 'auto-restart)
(setq lsp-enable-snippet nil)
(setq lsp-eldoc-hook nil)
(setq lsp-enable-symbol-highlighting nil)
(setq lsp-diagnostic-package :none)
(setq lsp-enable-on-type-formatting nil)
(setq lsp-signature-auto-activate nil)
;; (setq-default flycheck-disabled-checkers
;; (append flycheck-disabled-checkers
;; '(json-jsonlist)))
(set-face-attribute 'flycheck-error nil :foreground "red")
;; don't scan 3rd party javascript libraries
;; (push "[/\\\\][^/\\\\]*\\.\\(json\\|html\\|jade\\)$" lsp-file-watch-ignored) ; json
(use-package lsp-ui
:ensure t
:after lsp-mode
:config
(lsp-ui-doc-mode -1)
(setq lsp-ui-doc-enable nil)
(eldoc-mode -1)
(setq lsp-ui-sideline-enable nil)
(add-hook 'lsp-ui-imenu-mode
(lambda () (interactive) (linum-mode -1))))
)
(use-package lsp-python-ms
:ensure t
:init (setq lsp-python-ms-auto-install-server t)
:hook (python-mode . (lambda ()
(require 'lsp-python-ms)
(lsp)))) ; or lsp-deferred
;; (use-package yasnippet
;; :ensure t
;; :after company
;; :config
;; (use-package yasnippet-snippets
;; :ensure t)
;; (yas-global-mode t)
;; (define-key yas-minor-mode-map (kbd "<tab>") nil)
;; (define-key yas-minor-mode-map (kbd "C-'") #'yas-expand))
(use-package web-mode
:ensure t
:init
(setq web-mode-enable-auto-pairing t
web-mode-enable-auto-closing t
web-mode-enable-auto-opening t
web-mode-enable-auto-indentation t
web-mode-enable-block-face t
web-mode-enable-part-face t
web-mode-enable-comment-keywords t
web-mode-enable-css-colorization t
web-mode-enable-current-element-highlight t
;; web-mode-enable-heredoc-fontification t
web-mode-enable-engine-detection t
web-mode-markup-indent-offset 2
web-mode-attr-indent-offset 2
web-mode-css-indent-offset 2
web-mode-code-indent-offset 2
web-mode-style-padding 2
web-mode-script-padding 2
web-mode-block-padding 0
web-mode-comment-style 2)
(lambda ()
(web-mode-set-content-type "jsx")
(message "now set to: %s" web-mode-content-type))
:config
(set-face-attribute 'web-mode-html-tag-face nil :foreground "color-79" :bold t)
(set-face-attribute 'web-mode-html-tag-bracket-face nil :foreground "White")
(set-face-attribute 'web-mode-html-attr-name-face nil :foreground "color-69" :bold t)
(set-face-attribute 'web-mode-function-call-face nil :foreground "color-105" :bold t)
(add-to-list 'web-mode-indentation-params '("lineup-quotes" . t))
(add-to-list 'auto-mode-alist '("\\.js\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.jsx$" . web-mode))
;; (add-to-list 'auto-mode-alist '("\\.html\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.tsx\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.ts\\'" . web-mode))
(defadvice web-mode-highlight-part (around tweak-jsx activate)
(if (equal web-mode-content-type "jsx")
(let ((web-mode-enable-part-face nil))
ad-do-it)
ad-do-it))
(defadvice web-mode-highlight-part (around tweak-jsx activate)
(if (equal web-mode-content-type "tsx")
(let ((web-mode-enable-part-face nil))
ad-do-it)
ad-do-it))
(defadvice web-mode-highlight-part (around tweak-jsx activate)
(if (equal web-mode-content-type "jsx")
(let ((web-mode-enable-part-face nil))
ad-do-it)
ad-do-it))
(defadvice web-mode-highlight-part (around tweak-jsx activate)
(if (equal web-mode-content-type "tsx")
(let ((web-mode-enable-part-face nil))
ad-do-it)
ad-do-it))
)
(use-package protobuf-mode
:ensure t)
(use-package dockerfile-mode
:ensure t)
(use-package yaml-mode
:ensure t)
(use-package json-mode
:ensure t
:config
(setq json-reformat:indent-width 2))
(use-package markdown-mode
:ensure t
:commands (markdown-mode gfm-mode)
:mode (("README\\.md\\'" . gfm-mode)
("\\.md\\'" . markdown-mode)
("\\.markdown\\'" . markdown-mode))
:init (setq markdown-command "multimarkdown"))
(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.
'(package-selected-packages
'(docker cmake-mode rust-mode yaml-mode wgrep-ag web-mode use-package spaceline smartparens protobuf-mode projectile neotree lsp-ui lsp-python-ms key-chord json-mode imenu-list flycheck evil-leader evil-commentary evil-collection dumb-jump dockerfile-mode counsel company-go color-theme-modern ace-window)))
(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 (:background "312c2c"))))
'(company-preview ((t (:foreground "darkgray" :underline t))))
'(company-preview-common ((t (:inherit company-preview))))
'(company-tooltip ((t (:background "lightgray" :foreground "black"))))
'(company-tooltip-common ((((type x)) (:inherit company-tooltip :weight bold)) (t (:inherit company-tooltip))))
'(company-tooltip-common-selection ((((type x)) (:inherit company-tooltip-selection :weight bold)) (t (:inherit company-tooltip-selection))))
'(company-tooltip-scrollbar-thumb ((t (:background "#121212"))))
'(company-tooltip-scrollbar-track ((t (:background "#121212"))))
'(company-tooltip-selection ((t (:background "steelblue" :foreground "white"))))
'(neo-dir-link-face ((t (:foreground "brightcyan" :bold t))))
'(neo-expand-btn-face ((t (:foreground "brightwhite" :bold t))))
'(neo-file-link-face ((t (:foreground "color-63" :bold t))))
'(neo-header-face ((t (:foreground "color-130"))))
'(neo-root-dir-face ((t (:foreground "color-171")))))