-
Notifications
You must be signed in to change notification settings - Fork 1
/
init.el
454 lines (343 loc) · 11.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
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
(use-package better-defaults)
;; default mode for the *scratch* buffer
(setq initial-major-mode 'fundamental-mode)
;;------------------------------------------------------------------------------
;; which-key: shows a popup of available keybindings when typing a long key
;; sequence (e.g. C-x ...)
(use-package which-key
:diminish
:config
(which-key-mode))
;; Show the help buffer after startup
(add-hook 'after-init-hook 'help-quick)
;; (use-package base16-theme
;; :config
;; (load-theme 'base16-eighties t))
(use-package emacs
:config
(load-theme 'modus-vivendi))
;;------------------------------------------------------------------------------
;; Automatically reread from disk if the underlying file changes
(setq auto-revert-avoid-polling t)
(setq auto-revert-interval 5)
(setq auto-revert-check-vc-info t)
(global-auto-revert-mode)
;;------------------------------------------------------------------------------
(setq-default tab-width 3)
(set-frame-font "Source Code Pro Medium-11")
(defalias 'yes-or-no-p 'y-or-n-p)
(add-hook 'dired-mode-hook 'dired-hide-details-mode)
(electric-pair-mode 1)
(setq python-shell-interpreter "python3.8")
(defvaralias 'flycheck-python-pylint-executable 'python-shell-interpreter)
(setq js-indent-level 2)
;;------------------------------------------------------------------------------
;; automatically save buffers associated with files on buffer switch
;; and on windows switch
(defadvice switch-to-buffer (before save-buffer-now activate)
(when buffer-file-name (save-buffer)))
(defadvice other-window (before other-window-now activate)
(when buffer-file-name (save-buffer)))
(defadvice windmove-up (before other-window-now activate)
(when buffer-file-name (save-buffer)))
(defadvice windmove-down (before other-window-now activate)
(when buffer-file-name (save-buffer)))
(defadvice windmove-left (before other-window-now activate)
(when buffer-file-name (save-buffer)))
(defadvice windmove-right (before other-window-now activate)
(when buffer-file-name (save-buffer)))
;;------------------------------------------------------------------------------
(defun my-delete-trailing-whitespace ()
(when (not (string= (file-name-extension buffer-file-name) "http"))
(delete-trailing-whitespace)))
(setq-default whitespace-style '(face trailing lines empty))
(setq-default whitespace-line-column 100)
(add-hook 'before-save-hook 'my-delete-trailing-whitespace)
(global-whitespace-mode t)
;;------------------------------------------------------------------------------
(require 'package)
(setq package-enable-at-startup nil)
(add-to-list 'package-archives
'("melpa" . "https://melpa.org/packages/"))
(package-initialize)
(unless (package-installed-p 'use-package)
(package-refresh-contents)
(package-install 'use-package))
(unless (package-installed-p 'diminish)
(package-refresh-contents)
(package-install 'diminish))
(eval-when-compile
(require 'use-package))
(require 'diminish)
(require 'bind-key)
(require 'use-package-ensure)
(setq use-package-always-ensure t)
;-------------------------------------------------------------------------------
(use-package flyspell
:defer t
:init
(progn
(add-hook 'prog-mode-hook 'flyspell-prog-mode)
(add-hook 'text-mode-hook 'flyspell-mode)
)
:config
(setq-default ispell-program-name "hunspell")
(setq ispell-really-hunspell t)
(setq ispell-local-dictionary-alist
`((nil "[[:alpha:]]" "[^[:alpha:]]" "[']" t ("-d" "en_US") nil utf-8)))
)
(use-package flyspell-correct
:after flyspell
:bind (:map flyspell-mode-map ("C-;" . flyspell-correct-wrapper)))
;-------------------------------------------------------------------------------
;; (use-package smex
;; :config
;; (global-set-key (kbd "M-x") 'smex))
;; (use-package flx-ido
;; :init
;; (flx-ido-mode 1)
;; (setq ido-enable-flex-matching t)
;; (setq ido-use-faces nil))
;; (use-package ido-completing-read+
;; :config
;; (ido-ubiquitous-mode 1))
(use-package helm
:diminish
:init
(setq helm-mode-fuzzy-match t
helm-completion-in-region-fuzzy-match t)
:config
(helm-mode 1)
:bind (("M-x" . helm-M-x)
("C-x C-f" . helm-find-files)
("C-x b" . helm-buffers-list)
("C-x c o" . helm-occur)
("M-y" . helm-show-kill-ring)
("C-x r b" . helm-filtered-bookmarks)))
;-------------------------------------------------------------------------------
(use-package editorconfig
:diminish
:config
(editorconfig-mode 1))
(use-package highlight-symbol
:config
(setq highlight-symbol-idle-delay 0.5)
(add-hook 'prog-mode-hook 'highlight-symbol-mode))
(use-package ag
:defer t
:commands (ag ag-regexp ag-project))
(use-package projectile
:diminish
:config
(projectile-mode +1)
(define-key projectile-mode-map (kbd "C-c p") 'projectile-command-map))
(use-package magit
:defer 3
:config
; (setq magit-completing-read-function 'magit-ido-completing-read)
:bind
("C-x g" . magit-status))
(use-package flycheck
:defer 3
:config
(global-flycheck-mode 1))
(use-package markdown-mode
:commands
(markdown-mode gfm-mode)
:mode
("README\\.md\\'" . gfm-mode)
("\\.md\\'" . markdown-mode)
("\\.markdown\\'" . markdown-mode)
:init
(setq markdown-command "multimarkdown"))
(use-package yaml-mode
:mode ("\\.ya?ml\\'" . yaml-mode))
(use-package terraform-mode
:mode ("\\.tf\\'" . terraform-mode)
:custom
(terraform-format-on-save t)
:config
(add-hook 'terraform-mode-hook #'outline-minor-mode))
(use-package kotlin-mode
:mode ("\\.kts\\'" . kotlin-mode))
(use-package rust-mode
:mode ("\\.rs\\'" . rust-mode)
:init
(setq indent-tabs-mode nil)
(setq rust-format-on-save t))
(use-package expand-region
:defer t
:bind ("C-=" . er/expand-region))
(use-package go-mode
:mode ("\\.go\\'" . go-mode)
:init
(setq gofmt-command "goimports")
:config
(add-hook 'before-save-hook 'gofmt-before-save))
;; (use-package flycheck-golangci-lint
;; :hook (go-mode . flycheck-golangci-lint-setup)
;; :init)
(use-package coffee-mode
:mode
("\\.coffee\\'" . coffee-mode)
:init
(setq coffee-tab-width 2))
(use-package typescript-mode
:mode
("\\.ts\\'" . typescript-mode)
:init
(setq typescript-indent-level 2))
(use-package web-mode
:mode
("\\.erb\\'" . web-mode)
("\\.mustache\\'" . web-mode)
("\\.html\\'" . web-mode)
("\\.vue\\'" . web-mode)
("\\.mjml\\'" . web-mode)
:custom
(web-mode-script-padding 0)
(web-mode-style-padding 0)
(web-mode-block-padding 0)
(web-mode-markup-indent-offset 2)
(web-mode-css-indent-offset 2)
(web-mode-code-indent-offset 2))
(use-package lua-mode
:mode
("\\.lua\\'" . lua-mode))
(use-package php-mode
:mode
("\\.php\\'" . php-mode))
(use-package css-mode
:init
(setq css-indent-offset 2))
(use-package rubocopfmt
:hook
(ruby-mode . rubocopfmt-mode)
:custom
(rubocopfmt-use-bundler-when-possible nil))
(use-package edit-indirect)
(use-package yaml-mode
:mode ("\\.ya?ml\\'" . yaml-mode))
(use-package csharp-mode
:mode ("\\.cs\\'" . csharp-mode))
;; (use-package vue-mode
;; :ensure t
;; :mode
;; ("\\.vue\\'" . vue-mode))
;; (use-package mmm-mode
;; :ensure t
;; :init
;; (setq mmm-js-mode-enter-hook (lambda () (setq syntax-ppss-table nil)))
;; (setq mmm-typescript-mode-enter-hook (lambda () (setq syntax-ppss-table nil))))
(use-package pug-mode
:mode
("\\.pug\\'" . pug-mode)
:init
(setq pug-tab-width 2))
(use-package scss-mode
:mode
("\\.scss\\'" . scss-mode))
(use-package prettier-js
:config
(add-hook 'xml-hook 'prettier-js-mode)
(add-hook 'web-mode-hook 'prettier-js-mode)
(add-hook 'js-mode-hook 'prettier-js-mode)
(add-hook 'java-mode-hook 'prettier-js-mode)
(add-hook 'vue-mode-hook 'prettier-js-mode)
(add-hook 'typescript-mode-hook 'prettier-js-mode)
(add-hook 'scss-mode-hook 'prettier-js-mode)
(add-hook 'markdown-mode-hook 'prettier-js-mode)
(add-hook 'yaml-mode-hook 'prettier-js-mode))
(use-package blacken
:config
(add-hook 'python-mode-hook 'blacken-mode))
(use-package protobuf-mode
:mode ("\\.proto\\'" . protobuf-mode))
(use-package langtool
:init
(setq langtool-language-tool-jar "/home/vmihailenco/Downloads/LanguageTool-5.1/languagetool-commandline.jar"))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; (use-package lsp-mode
;; :ensure t
;; :config
;; (setq lsp-enable-completion-at-point nil)
;; :commands
;; (lsp lsp-deferred)
;; :hook
;; (go-mode . lsp-deferred))
;; Set up before-save hooks to format buffer and add/delete imports.
;; Make sure you don't have other gofmt/goimports hooks enabled.
;(defun lsp-go-install-save-hooks ()
; (add-hook 'before-save-hook #'lsp-format-buffer t t)
; (add-hook 'before-save-hook #'lsp-organize-imports t t))
;(add-hook 'go-mode-hook #'lsp-go-install-save-hooks)
;; ;; Optional - provides fancier overlays.
;; (use-package lsp-ui
;; :ensure t
;; :commands lsp-ui-mode)
;; ;; Company mode is a standard completion package that works well with lsp-mode.
;; (use-package company
;; :ensure t
;; :config
;; ;; Optionally enable completion-as-you-type behavior.
;; (setq company-idle-delay 0)
;; (setq company-minimum-prefix-length 1))
;; ;; company-lsp integrates company mode completion with lsp-mode.
;; ;; completion-at-point also works out of the box but doesn't support snippets.
;; (use-package company-lsp
;; :ensure t
;; :commands company-lsp)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(use-package hydra)
(defhydra hydra-lsp (:exit t :hint nil)
"
Buffer^^ Server^^ Symbol
-------------------------------------------------------------------------------------
[_f_] format [_M-r_] restart [_d_] declaration [_i_] implementation [_o_] documentation
[_m_] imenu [_S_] shutdown [_D_] definition [_t_] type [_r_] rename
[_x_] execute action [_M-s_] describe session [_R_] references [_s_] signature"
("d" lsp-find-declaration)
("D" lsp-ui-peek-find-definitions)
("R" lsp-ui-peek-find-references)
("i" lsp-ui-peek-find-implementation)
("t" lsp-find-type-definition)
("s" lsp-signature-help)
("o" lsp-describe-thing-at-point)
("r" lsp-rename)
("f" lsp-format-buffer)
("m" lsp-ui-imenu)
("x" lsp-execute-code-action)
("M-s" lsp-describe-session)
("M-r" lsp-workspace-restart)
("S" lsp-workspace-shutdown))
(global-unset-key (kbd "C-z"))
(global-set-key (kbd "C-z l") 'hydra-lsp/body)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(use-package autodisass-java-bytecode
:ensure t
:defer t)
(use-package google-c-style
:defer t
:ensure t
:commands
(google-set-c-style))
(use-package meghanada
:defer t
:ensure t
:init
(add-hook 'java-mode-hook
(lambda ()
(google-set-c-style)
(google-make-newline-indent)
(meghanada-mode t)
(add-hook 'before-save-hook 'meghanada-code-beautify-before-save)))
:config
(use-package realgud
:ensure t)
(setq indent-tabs-mode nil)
(setq tab-width 2)
(setq c-basic-offset 2)
(setq meghanada-server-remote-debug t)
(setq meghanada-javac-xlint "-Xlint:all,-processing")
:commands
(meghanada-mode))