-
Notifications
You must be signed in to change notification settings - Fork 1
/
init-editing.el
252 lines (220 loc) · 6.42 KB
/
init-editing.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
;;; init-editing.el --- Editor related config
;;
;; Author: Kiran Shenoy
;; URL: https://github.com/kgs1992/.emacs.d/
;;
;;; Commentary:
;;
;; This package contains all of the editor related config.
;;
;;;
;;; Code:
;; General purpose config to make editing more peaceful
(setq inhibit-startup-screen t)
(setq debug-on-quit nil)
(setq message-log-max 2000)
(size-indication-mode t)
(delete-selection-mode 0)
(transient-mark-mode 0)
(setq-default wrap-lines t)
;; Auto refresh buffers
(global-auto-revert-mode 1)
(setq global-auto-revert-non-file-buffers t)
(setq auto-revert-verbose t)
;; Open files in the same frame
(setq ns-pop-up-frames nil)
;; Clenup whitespaces
(use-package whitespace-cleanup-mode
:ensure t
:defer t
:hook (after-init . global-whitespace-cleanup-mode))
;; Turn on spell check
(use-package flyspell
:defer t
:hook ((text-mode . flyspell-mode)
(prog-mode . flyspell-prog-mode)))
;;Set backup dir
(setq auto-save-directory-fallback "~/.saves")
(setq backup-directory-alist `(("." . "~/.saves")))
(setq backup-by-copying t)
(setq delete-old-versions t
kept-new-versions 6
kept-old-versions 2
version-control t)
;; Rainbow delimiters - Match parens
(use-package rainbow-delimiters
:ensure t
:defer t
:hook (prog-mode . rainbow-delimiters-mode)
:config
(setq show-paren-style 'expression))
;; Volatile highlights- visual feedback for operations (example: undo)
(use-package volatile-highlights
:ensure t
:defer t
:hook (after-init . volatile-highlights-mode))
;; Autocomplete - company
(use-package company
:ensure t
:defer t
:config
(setq company-tooltip-limit 20) ; Bigger popup window
(setq company-idle-delay .3) ; Decrease delay before autocompletion popup shows
(setq company-echo-delay 0) ; Remove annoying blinking
(setq company-begin-commands '(self-insert-command)) ; Start autocompletion only after typing
(setq company-tooltip-align-annotations t)
:hook (after-init . global-company-mode))
(use-package company-posframe
:ensure t
:defer t
:hook (after-init . company-posframe-mode))
(use-package company-prescient
:ensure t
:defer t
:hook (after-init . company-prescient-mode))
;; Autocomplete - ac
;; (use-package auto-complete
;; :ensure t
;; :defer t
;; :config
;; ;; (ac-config-default)
;; ;; (ac-flyspell-workaround)
;; ;; (setq
;; ;; ac-auto-show-menu 1
;; ;; ac-auto-start t
;; ;; ac-menu-height 20
;; ;; ac-delay 0.01
;; ;; )
;; (global-auto-complete-mode t))
;; Swiper (better C-s)
(use-package swiper
:ensure t
:defer t
:after ivy
:bind (("C-s" . swiper)))
;; (use-package swiper-helm
;; :ensure t
;; :defer t
;; :after (helm)
;; :bind (("C-s" . swiper-helm)))
;; Commenting
(global-set-key (kbd "M-;") 'comment-or-uncomment-region)
;; Show column number and line number
(use-package nlinum
:ensure t
:defer t
:config
(setq nlinum-format "%d\u2502"
nlinum-highlight-current-line t)
(dolist (mode '(column-number-mode line-number-mode))
(when (fboundp mode) (funcall mode t)))
:hook ((text-mode prog-mode) . nlinum-mode))
;; ;; Show current function/class
(use-package which-func
:defer t
:hook (prog-mode . which-function-mode))
;; Tab/spacing
(setq-default indent-tabs-mode nil)
(setq-default tab-width 4)
(setq indent-line-function 'insert-tab)
;; Undo-redo keybindings
(use-package undo-fu
:ensure t
:defer t
:bind (("C--" . undo-fu-only-undo)
("M--" . undo-fu-only-redo)))
(use-package undo-fu-session
:ensure t
:defer t
:hook (after-init . global-undo-fu-session-mode))
;; Symbol highlighting
(use-package symbol-overlay
:ensure t
:defer t
:hook (prog-mode . (lambda ()
(symbol-overlay-mode)
(setq symbol-overlay-scope t))))
;; Backward delete word instead of kill
(use-package evil
:ensure t
:defer t
:bind (("M-DEL" . evil-delete-backward-word)))
(use-package flycheck
:ensure t
:defer t
:config
(defun flycheck-list-errors-only-when-errors ()
"Show buffer with flycheck error."
(if flycheck-current-errors
(flycheck-list-errors)
(-when-let (buffer (get-buffer flycheck-error-list-buffer))
(dolist (window (get-buffer-window-list buffer))
(quit-window nil window)))))
:hook ((after-init . global-flycheck-mode)
(before-save . flycheck-list-errors-only-when-errors)))
(use-package lsp-mode
:ensure t
:config
;; use flycheck, not flymake
(setq lsp-prefer-flymake nil)
(setq lsp-auto-guess-root nil)
(setq lsp-print-performance nil)
(setq lsp-log-io nil)
(setq lsp-eldoc-hook nil)
(setq lsp-idle-delay 0.500))
;; optional - provides fancy overlay information
(use-package lsp-ui
:ensure t
:defer t
:config
(setq lsp-ui-doc-delay 2)
(setq lsp-ui-doc-position 'at-point))
(use-package flycheck-posframe
:ensure t
:defer t
:after flycheck
:hook (flycheck-mode . flycheck-posframe-mode))
;; (use-package format-all
;; :ensure t
;; :defer t
;; :hook (prog-mode . format-all-mode))
;; Text scaling
(use-package default-text-scale
:ensure t
:defer t
:bind (("s-=" . default-text-scale-increase)
("s--" . default-text-scale-decrease)
("s-0" . default-text-scale-reset))
)
;; Highlight indent guides
(use-package highlight-indent-guides
:ensure t
:defer t
:config
(setq highlight-indent-guides-method 'character
highlight-indent-guides-character ?\┊)
:hook (prog-mode . highlight-indent-guides-mode))
;; Dim unfocused windows
(use-package dimmer
:ensure t
:defer t
:config
(setq dimmer-adjustment-mode :foreground)
(setq dimmer-fraction 0.5)
(setq dimmer-watch-frame-focus-events nil)
(dimmer-configure-posframe)
(dimmer-configure-magit)
(dimmer-configure-company-box)
(defun dimmer-lsp-ui-doc-p ()
(string-prefix-p " *lsp-ui-doc-" (buffer-name)))
(add-to-list 'dimmer-prevent-dimming-predicates #'dimmer-lsp-ui-doc-p)
(defun advices/dimmer-config-change-handler ()
(dimmer--dbg-buffers 1 "dimmer-config-change-handler")
(let ((ignore (cl-some (lambda (f) (and (fboundp f) (funcall f)))
dimmer-prevent-dimming-predicates)))
(dimmer-process-all (not ignore))))
(advice-add 'dimmer-config-change-handler :override #'advices/dimmer-config-change-handler)
:hook (after-init . dimmer-mode))
(message "Loaded init-editing.el")
(provide 'init-editing)
;;; init-editing.el ends here