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
|
(setq gc-cons-threshold 200000000)
;; package setup
(defvar elpaca-installer-version 0.7)
(defvar elpaca-directory (expand-file-name "elpaca/" user-emacs-directory))
(defvar elpaca-builds-directory (expand-file-name "builds/" elpaca-directory))
(defvar elpaca-repos-directory (expand-file-name "repos/" elpaca-directory))
(defvar elpaca-order '(elpaca :repo "https://github.com/progfolio/elpaca.git"
:ref nil :depth 1
:files (:defaults "elpaca-test.el" (:exclude "extensions"))
:build (:not elpaca--activate-package)))
(let* ((repo (expand-file-name "elpaca/" elpaca-repos-directory))
(build (expand-file-name "elpaca/" elpaca-builds-directory))
(order (cdr elpaca-order))
(default-directory repo))
(add-to-list 'load-path (if (file-exists-p build) build repo))
(unless (file-exists-p repo)
(make-directory repo t)
(when (< emacs-major-version 28) (require 'subr-x))
(condition-case-unless-debug err
(if-let ((buffer (pop-to-buffer-same-window "*elpaca-bootstrap*"))
((zerop (apply #'call-process `("git" nil ,buffer t "clone"
,@(when-let ((depth (plist-get order :depth)))
(list (format "--depth=%d" depth) "--no-single-branch"))
,(plist-get order :repo) ,repo))))
((zerop (call-process "git" nil buffer t "checkout"
(or (plist-get order :ref) "--"))))
(emacs (concat invocation-directory invocation-name))
((zerop (call-process emacs nil buffer nil "-Q" "-L" "." "--batch"
"--eval" "(byte-recompile-directory \".\" 0 'force)")))
((require 'elpaca))
((elpaca-generate-autoloads "elpaca" repo)))
(progn (message "%s" (buffer-string)) (kill-buffer buffer))
(error "%s" (with-current-buffer buffer (buffer-string))))
((error) (warn "%s" err) (delete-directory repo 'recursive))))
(unless (require 'elpaca-autoloads nil t)
(require 'elpaca)
(elpaca-generate-autoloads "elpaca" repo)
(load "./elpaca-autoloads")))
(add-hook 'after-init-hook #'elpaca-process-queues)
(elpaca `(,@elpaca-order))
(elpaca elpaca-use-package
;; Enable use-package :ensure support for Elpaca.
(elpaca-use-package-mode)
(setq elpaca-use-package-by-default t))
(unless (package-installed-p 'vc-use-package)
(package-vc-install "https://github.com/slotThe/vc-use-package"))
(require 'vc-use-package)
(elpaca-wait)
;; basic interface
(setq make-backup-files nil
create-lockfiles nil
erc-join-buffer 'window
confirm-kill-processes nil)
(setq inhibit-startup-message t
backup-inhibited t)
(scroll-bar-mode -1)
(tool-bar-mode -1)
(tooltip-mode -1)
(menu-bar-mode -1)
(setq scroll-up-aggressively nil
scroll-down-aggressively nil
scroll-conservatively 101
display-line-numbers-type t)
(setq scroll-step 1)
(setq scroll-margin 8)
(column-number-mode +1)
(global-display-line-numbers-mode t)
(setq-default fill-column 80)
(electric-pair-mode +1)
(dolist (mode '(org-mode-hook
term-mode-hook
vterm-mode-hook
shell-mode-hook
eshell-mode-hook
mu4e-main-mode-hook
mu4e-headers-mode-hook))
(add-hook mode (lambda () (display-line-numbers-mode 0))))
(set-frame-parameter (selected-frame) 'alpha '(90 . 90))
(add-to-list 'default-frame-alist '(alpha . (90 . 90)))
(set-face-attribute 'default nil
:font "DejaVu Sans Mono"
:family "Monospace"
:height 97)
(set-face-attribute 'variable-pitch nil
:font "DejaVu Sans"
:height 97)
(set-face-attribute 'fixed-pitch nil
:font "DejaVu Sans Mono"
:family "Monospace"
:height 97)
(use-package doom-modeline
:ensure t
:init (doom-modeline-mode 1)
:custom ((doom-modeline-height 15)))
(use-package doom-themes
:config
(setq doom-themes-enable-bold t
doom-themes-enable-italic t)
;(load-theme 'doom-snazzy t)
(doom-themes-org-config))
(use-package miasma-theme
:vc (:fetcher github :repo daut/miasma-theme.el)
:config
(load-theme 'miasma t))
;; misc changes
(use-package diminish)
(auto-revert-mode 1)
(use-package helpful
:bind
([remap describe-command] . helpful-command)
([remap describe-function] . helpful-callable)
([remap describe-variable] . helpful-variable)
([remap describe-key] . helpful-key))
;; interface packages
;; - vertico and completion
(use-package vertico
:ensure (vertico :files (:defaults "extensions/*"))
:diminish vertico-mode
:bind (:map vertico-map
("C-n" . vertico-next)
("C-p" . vertico-previous))
:init
(vertico-mode 1)
;; (vertico-flat-mode 1)
(setq vertico-count 15))
(use-package vertico-directory
:after vertico
:ensure nil
;; More convenient directory navigation commands
:bind (:map vertico-map
("RET" . vertico-directory-enter)
("DEL" . vertico-directory-delete-char)
("M-DEL" . vertico-directory-delete-word))
;; Tidy shadowed file names
:hook (rfn-eshadow-update-overlay . vertico-directory-tidy))
(use-package which-key
:init (which-key-mode)
:diminish which-key-mode
:config
(setq which-key-idle-delay 0.5))
(use-package marginalia
:diminish marginalia-mode
:after vertico
:custom
(marginalia-annotators '(marginalia-annotators-heavy marginalia-annotators-light nil))
:config
(marginalia-mode))
(use-package consult
:config
(setq completion-in-region-function
(lambda (&rest args)
(apply (if vertico-mode
#'consult-completion-in-region
#'completion--in-region)
args)))
(consult-customize consult-buffer :preview-key "M-."))
(use-package orderless
:config
(setq completion-styles '(orderless)
completion-category-defaults nil
completion-category-overrides '((file (styles . (partial-completion))))))
;; - icons
(use-package nerd-icons)
(use-package all-the-icons)
(use-package all-the-icons-dired
:hook (dired-mode . all-the-icons-dired-mode))
(use-package emojify
:hook (after-init . global-emojify-mode)
:config
(add-hook 'prog-mode-hook #'(lambda () (emojify-mode -1))))
;; text editing packages
(use-package rainbow-delimiters
:diminish rainbow-delimiters-mode
:hook (prog-mode . rainbow-delimiters-mode))
(use-package highlight-quoted
:diminish highlight-quoted-mode
:hook (emacs-lisp-mode . highlight-quoted-mode))
;; - flyspell ( still working on perfect config )
;; (use-package flyspell
;; :ensure nil
;; ;; :diminish flyspell-mode
;; )
;; (setq flyspell-prog-text-faces '(font-lock-doc-face))
;; (use-package flyspell-correct
;; :after flyspell)
;; (use-package consult-flyspell
;; :ensure (consult-flyspell :host gitlab :repo "OlMon/consult-flyspell" :branch "master")
;; :config
;; ;; default settings
;; (setq consult-flyspell-select-function (lambda () (flyspell-correct-at-point) (consult-flyspell))
;; consult-flyspell-set-point-after-word t
;; consult-flyspell-always-check-buffer nil))
;; (add-hook 'text-mode-hook 'flyspell-mode)
;; (add-hook 'prog-mode-hook 'flyspell-prog-mode)
;; directory changes and packages
(recentf-mode 1)
(use-package no-littering
:config
(add-to-list 'recentf-exclude
(recentf-expand-file-name no-littering-var-directory))
(add-to-list 'recentf-exclude
(recentf-expand-file-name no-littering-etc-directory))
(setq custom-file (no-littering-expand-etc-file-name "custom.el")))
(use-package savehist
:ensure nil
:diminish savehist-mode
:init
(savehist-mode 1))
;; - dired
(setf dired-kill-when-opening-new-dired-buffer t)
(setq dired-dwim-target t)
;; -- undo tree
(use-package undo-tree
:diminish undo-tree-mode
:config
(global-undo-tree-mode)
(add-hook 'authinfo-mode-hook #'(lambda () (setq-local undo-tree-auto-save-history nil)))
(defvar --undo-history-directory (concat user-emacs-directory "undotreefiles/")
"Directory to save undo history files.")
(unless (file-exists-p --undo-history-directory)
(make-directory --undo-history-directory t))
;; stop littering with *.~undo-tree~ files everywhere
(setq undo-tree-history-directory-alist `(("." . ,--undo-history-directory))))
(global-set-key (kbd "C-/") #'undo-tree-undo)
(global-set-key (kbd "M-/") #'undo-tree-redo)
;; - embark
(use-package embark
:bind
(("C-." . embark-act)
("C-;" . embark-dwim))
:init
(setq prefix-help-command #'embark-prefix-help-command)
:config
(setq embark--minimal-indicator-overlay nil)
(setq embark-indicators (delq 'embark-mixed-indicator embark-indicators))
(add-to-list 'embark-indicators #'embark-minimal-indicator))
(use-package embark-consult
:config
(define-key embark-file-map (kbd "S") 'sudo-find-file))
;; development
;; - magit
(use-package transient)
(use-package magit
:bind (("C-x g" . magit-status))
:custom
(magit-display-buffer-function #'magit-display-buffer-same-window-except-diff-v1))
;; - projectile
;; - tree sitter
(use-package tree-sitter
:diminish tree-sitter-mode
:config
(global-tree-sitter-mode 1))
(use-package tree-sitter-langs)
;; - snippet
(use-package yasnippet
:config
(yas-global-mode 1))
;; - LSP mode
(use-package lsp-mode
:commands (lsp lsp-deferred)
:init
(setq lsp-keymap-prefix "C-c l"
lsp-headerline-breadcrumb-enable t
lsp-headerline-breadcrumb-segments '(path-up-to-project file symbols)
lsp-lens-enable nil)
(lsp-headerline-breadcrumb-mode)
:config
(lsp-enable-which-key-integration t)
:hook (
(c-mode . lsp)
(c++-mode . lsp-deferred)
(python-mode . lsp-deferred)
(csharp-mode . lsp)
)
:custom
(lsp-completion-provider :none) ; corfu
)
(use-package lsp-ui
:hook (lsp-mode . lsp-ui-mode))
(setq lsp-ui-doc-position 'bottom)
;; - - lsp booster
(defun lsp-booster--advice-json-parse (old-fn &rest args)
"Try to parse bytecode instead of json."
(or
(when (equal (following-char) ?#)
(let ((bytecode (read (current-buffer))))
(when (byte-code-function-p bytecode)
(funcall bytecode))))
(apply old-fn args)))
(advice-add (if (progn (require 'json)
(fboundp 'json-parse-buffer))
'json-parse-buffer
'json-read)
:around
#'lsp-booster--advice-json-parse)
(defun lsp-booster--advice-final-command (old-fn cmd &optional test?)
"Prepend emacs-lsp-booster command to lsp CMD."
(let ((orig-result (funcall old-fn cmd test?)))
(if (and (not test?) ;; for check lsp-server-present?
(not (file-remote-p default-directory)) ;; see lsp-resolve-final-command, it would add extra shell wrapper
lsp-use-plists
(not (functionp 'json-rpc-connection)) ;; native json-rpc
(executable-find "emacs-lsp-booster"))
(progn
(when-let ((command-from-exec-path (executable-find (car orig-result)))) ;; resolve command from exec-path (in case not found in $PATH)
(setcar orig-result command-from-exec-path))
(message "Using emacs-lsp-booster for %s!" orig-result)
(cons "emacs-lsp-booster" orig-result))
orig-result)))
(advice-add 'lsp-resolve-final-command :around #'lsp-booster--advice-final-command)
;; flycheck
(use-package flycheck
:diminish flycheck-mode
:config
(setq flycheck-error-message-buffer " *Flycheck error messages*")
(setq-default flycheck-emacs-lisp-load-path 'inherit)
(global-flycheck-mode 1))
(use-package flycheck-pos-tip
:ensure t
:after flycheck
:config
(flycheck-pos-tip-mode))
;; - - hooks
(defun my-c-mode-common-hook ()
;; my customizations for all of c-mode, c++-mode, objc-mode, java-mode
(c-set-offset 'substatement-open 0)
;; other customizations can go here
(setq c++-tab-always-indent t)
(setq c-basic-offset 4) ;; Default is 2
(setq c-indent-level 4) ;; Default is 2
(setq tab-stop-list '(4 8 12 16 20 24 28 32 36 40 44 48 52 56 60))
(setq tab-width 4)
(setq indent-tabs-mode t))
(add-hook 'c-mode-common-hook 'my-c-mode-common-hook)
;; - - additional packages
(use-package consult-lsp
:after lsp)
(use-package lsp-treemacs
:after lsp)
;; - completion
(use-package corfu
:ensure t
:custom
(corfu-cycle t)
(corfu-auto t)
(corfu-auto-prefix 2)
(corfu-auto-delay 0.2)
(corfu-popupinfo-delay '(0.3 . 0.2))
(corfu-preview-current 'insert)
(corfu-preselect 'first)
(corfu-on-exact-match nil)
:bind (:map corfu-map
("C-g" . corfu-quit))
:init
(global-corfu-mode)
(corfu-history-mode)
(corfu-popupinfo-mode))
(use-package cape
;; Bind prefix keymap providing all Cape commands under a mnemonic key.
;; Press C-c p ? to for help.
:bind ("C-c p" . cape-prefix-map) ;; Alternative keys: M-p, M-+, ...
;; Alternatively bind Cape commands individually.
;; :bind (("C-c p d" . cape-dabbrev)
;; ("C-c p h" . cape-history)
;; ("C-c p f" . cape-file)
;; ...)
:init
;; Add to the global default value of `completion-at-point-functions' which is
;; used by `completion-at-point'. The order of the functions matters, the
;; first function returning a result wins. Note that the list of buffer-local
;; completion functions takes precedence over the global list.
(add-hook 'completion-at-point-functions #'cape-dabbrev)
(add-hook 'completion-at-point-functions #'cape-file)
(add-hook 'completion-at-point-functions #'cape-elisp-block)
;; (add-hook 'completion-at-point-functions #'cape-history)
;; ...
)
;; - misc
(use-package evil-nerd-commenter
:bind ("M-;" . evilnc-comment-or-uncomment-lines))
;; keybinds
(global-unset-key (kbd "C-z"))
(global-set-key (kbd "<escape>") #'keyboard-escape-quit)
(global-set-key (kbd "C-c f") #'consult-line)
(use-package move-text)
(global-set-key (kbd "M-p") #'move-text-up)
(global-set-key (kbd "M-n") #'move-text-down)
(use-package expand-region)
(global-set-key (kbd "C-=") 'er/expand-region)
(use-package multiple-cursors
:bind (:map global-map
("C->" . 'mc/mark-next-like-this)
("C-<" . 'mc/mark-previous-like-this)
("C-c C->" . 'mc/mark-all-like-this)
:map mc/keymap
("<return>" . nil)))
|