-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.el
278 lines (246 loc) · 8.39 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
;;; init.el --- Initialization file for Emacs
;;; Commentary:
;; Emacs Startup File
(require 'package)
;;; Code:
(add-to-list
'package-archives
'("melpa" . "http://melpa.org/packages/"))
(unless package--initialized (package-initialize))
;; inform byte compiler about free variables
(eval-when-compile
(defvar desktop-save)
(defvar desktop-path)
(defvar desktop-load-locked-desktop)
(defvar desktop-auto-save-timeout))
;; desktop-save settings
(desktop-save-mode 1)
(setq desktop-save t
desktop-path '("~/.emacs.d/")
desktop-load-locked-desktop t
desktop-auto-save-timeout 5)
;; miscellaneous settings
(add-to-list 'default-frame-alist '(fullscreen . maximized))
(add-hook 'before-save-hook 'delete-trailing-whitespace)
(global-auto-revert-mode t)
(setq column-number-mode t)
(setq-default indent-tabs-mode nil)
;; automatic package installation
(unless (package-installed-p 'use-package)
(package-refresh-contents)
(package-install 'use-package))
;; auto updates
(use-package auto-package-update
:ensure t
:config
(setq auto-package-update-delete-old-versions t
auto-package-update-interval 4)
(auto-package-update-maybe))
;; external package configurations
(use-package exec-path-from-shell
:ensure t
:config
(when (or (daemonp) (memq window-system '(mac ns x)))
(exec-path-from-shell-initialize)))
(use-package helm
:ensure t
:defines (helm-find-files-map helm-read-file-map)
:bind (("M-x" . helm-M-x)
("C-x C-f" . helm-find-files)
("C-x b" . helm-mini)
:map helm-map
("<tab>" . helm-execute-persistent-action)
("C-z" . helm-select-action)
:map helm-find-files-map
("<DEL>" . helm-ff-delete-char-backward)
("C-<backspace>" . helm-find-files-up-one-level)
:map helm-read-file-map
("<DEL>" . helm-ff-delete-char-backward)
("C-<backspace>" . helm-find-files-up-one-level))
:init (helm-mode 1))
(use-package magit
:ensure t
:bind (("C-x g" . magit-status)))
(use-package elpy
:ensure t
:bind (:map elpy-mode-map
("C-<up>" . nil)
("C-<down>" . nil))
:hook
(elpy-mode . (lambda ()
(add-hook 'before-save-hook
'elpy-format-code nil
'local)))
:init (elpy-enable)
:config (setq elpy-modules
(delq 'elpy-module-flymake
elpy-modules)))
(use-package flycheck
:ensure t
:hook
(flycheck-mode . (lambda()
;; Use ESLint from local node_modules
(let* ((current (or buffer-file-name
default-directory))
(nmodules (locate-dominating-file
current
"node_modules"))
(eslint (and nmodules
(expand-file-name
"node_modules/.bin/eslint"
nmodules))))
(when (and eslint (file-executable-p eslint))
(setq-local flycheck-javascript-eslint-executable
eslint)))))
:config
(global-flycheck-mode))
(use-package company
:ensure t
:init (global-company-mode))
(defun setup-tide-mode ()
"Set up tide mode and turn on related modes with tide specific configurations."
(tide-setup)
(tide-hl-identifier-mode 1)
(flycheck-mode 1)
(setq flycheck-check-syntax-automatically
'(save mode-enabled idle-change))
(company-mode 1)
(eldoc-mode 1))
(use-package tide
:ensure t
:after (typescript-mode flycheck company)
:bind (:map tide-mode-map
("C-x t s" . tide-restart-server)
("C-x t d" . tide-documentation-at-point)
("C-x t l" . tide-references)
("C-x t p" . tide-project-errors)
("C-x t e" . tide-error-at-point)
("C-x t n" . tide-rename-symbol)
("C-x t f" . tide-rename-file)
("C-x t o" . tide-format)
("C-x t x" . tide-fix)
("C-x t r" . tide-refactor)
("C-x t i" . tide-organize-imports)
("C-x t j" . tide-jsdoc-template)
("C-x t a" . tide-list-servers))
:hook
((typescript-mode . setup-tide-mode)
(before-save . tide-format-before-save))
:functions flycheck-add-next-checker
:config
(flycheck-add-next-checker 'javascript-tide 'javascript-eslint)
(flycheck-add-next-checker 'typescript-tide 'javascript-eslint)
(flycheck-add-next-checker 'jsx-tide 'javascript-eslint)
(flycheck-add-next-checker 'tsx-tide 'javascript-eslint))
(use-package web-mode
:ensure t
:after (tide flycheck)
:mode ("\\.jsx\\'" "\\.tsx\\'")
:functions flycheck-add-mode
:hook
(web-mode . (lambda ()
;; Set up tide only if file extension is jsx or tsx
(let ((ext (file-name-extension buffer-file-name)))
(when (or
(string-equal "jsx" ext)
(string-equal "tsx" ext))
(setup-tide-mode)))))
:config
(flycheck-add-mode 'jsx-tide 'web-mode)
(flycheck-add-mode 'tsx-tide 'web-mode))
(use-package js2-mode
:ensure t
:after (tide flycheck)
:mode "\\.js\\'"
:functions flycheck-add-mode
:hook
(js2-mode . setup-tide-mode)
:config
(flycheck-add-mode 'javascript-tide 'js2-mode))
(require 'term)
(use-package multi-term
:ensure t
:bind (("C-x M-m" . multi-term)
("C-x M-o" . multi-term-dedicated-open)
("C-x M-t" . multi-term-dedicated-toggle)
("C-x M-s" . multi-term-dedicated-select)
("C-x M-c" . multi-term-dedicated-close))
:config
;; Change default multi-term shell to zsh if available
(let ((zsh-bin (executable-find "zsh")))
(when zsh-bin
(setq multi-term-program zsh-bin)))
(defun term-send-C-x ()
(interactive)
(term-send-raw-string "\C-x"))
(setq term-bind-key-alist
(append term-bind-key-alist
'(("C-c C-j" . term-line-mode)
("C-c C-k" . term-char-mode)
("C-c C-x" . term-send-C-x)
("C-<" . multi-term-prev)
("C->" . multi-term-next)))))
(use-package json-mode
:ensure t)
(use-package yaml-mode
:ensure t)
(use-package dockerfile-mode
:ensure t)
(use-package docker-compose-mode
:ensure t)
(use-package which-key
:ensure t
:init (which-key-mode 1))
(use-package crux
:ensure t
:bind (("C-c t" . crux-transpose-windows)
("C-c d" . crux-delete-file-and-buffer)
("C-c r" . crux-rename-file-and-buffer)
("C-c o" . crux-kill-other-buffers)
("C-c i" . crux-find-user-init-file)
("C-c k" . crux-kill-whole-line)
("C-c DEL" . crux-kill-line-backwards)
("C-c e" . crux-sudo-edit)))
(use-package minimap
:ensure t
:bind (("C-c m" . minimap-mode))
:init
(setq minimap-window-location 'right)
(minimap-mode 1))
(use-package smartparens
:ensure t
:init
(require 'smartparens-config)
:bind (:map smartparens-mode-map
("M-p <right>" . sp-forward-sexp)
("M-p <left>" . sp-backward-sexp)
("M-p <down>" . sp-down-sexp)
("M-p <up>" . sp-backward-up-sexp)
("M-p s" . sp-splice-sexp)
("M-p x" . sp-kill-sexp))
:config
(smartparens-global-mode t))
(use-package hideshow
:bind (:map hs-minor-mode-map
("C-c +" . hs-show-block)
("C-c -" . hs-hide-block)
("C-c *" . hs-show-all)
("C-c /" . hs-hide-all))
:hook ((emacs-lisp-mode typescript-mode python-mode) . hs-minor-mode))
(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-enabled-themes '(tango-dark))
'(elpy-rpc-python-command "python3")
'(package-selected-packages '(flycheck elpy magit helm auto-package-update use-package))
'(python-shell-interpreter "python3"))
(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.
)
(provide 'init)
;;; init.el ends here