-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.el
More file actions
817 lines (738 loc) · 27.3 KB
/
Copy pathinit.el
File metadata and controls
817 lines (738 loc) · 27.3 KB
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
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
;;; init.el --- Trev's Emacs Config -*- lexical-binding: t -*-
;;;
;;; Commentary:
;;; My living Emacs config.
;;;
;;; Code:
(use-package package
:custom
(package-install-upgrade-built-in t)
;; Don't forget to run `package-quickstart-refresh'!
(package-quickstart t)
:config
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
(add-to-list 'package-archives '("melpa-mirror" . "https://www.mirrorservice.org/sites/melpa.org/packages/") t))
(use-package use-package
:preface
(defun trev/use-package-ensure (name args state &optional no-refresh)
"Skip remote archives when NAME is already loadable from `load-path'."
(unless (or (package-built-in-p name) (locate-library (symbol-name name)))
(use-package-ensure-elpa name args state no-refresh)))
:custom
(use-package-always-defer t)
(use-package-always-ensure t)
(use-package-ensure-function #'trev/use-package-ensure)
(use-package-expand-minimally t))
(use-package auth-source :ensure nil :custom (auth-sources '("~/.authinfo.gpg")))
(use-package modus-themes
:demand t
:preface
(defvar trev/modus-theme 'modus-vivendi-deuteranopia
"Last selected Modus theme, persisted through `savehist'.")
(defun trev/modus-theme-save-current ()
"Remember the active Modus theme for the next session."
(when-let* ((theme (car custom-enabled-themes))
(_ (memq theme modus-themes-items)))
(setq trev/modus-theme theme)))
(defun trev/modus-theme-load-startup ()
"Load the remembered Modus theme."
(modus-themes-load-theme trev/modus-theme))
(defun trev/modus-theme-set-extra-faces (&rest _)
"Apply extra face tweaks after Modus theme changes."
(modus-themes-with-colors
(custom-set-faces
`(margin ((,c :background ,bg-main :foreground ,fg-main)))
`(diff-hl-insert ((,c :foreground ,bg-added-fringe :background ,bg-main)))
`(diff-hl-change ((,c :foreground ,bg-changed-fringe :background ,bg-main)))
`(diff-hl-delete ((,c :foreground ,bg-removed-fringe :background ,bg-main)))
`(modus-themes-ui-variable-pitch ((,c :height 0.9)))
`(erc-current-nick-face ((,c :foreground ,red-intense :background ,bg-main))))))
:hook
((modus-themes-after-load-theme . trev/modus-theme-save-current)
(modus-themes-after-load-theme . trev/modus-theme-set-extra-faces)
;; Loaded after init so `savehist' has already restored `trev/modus-theme'.
(after-init . trev/modus-theme-load-startup))
:bind
(("C-c T" . modus-themes-select)
("C-c t" . modus-themes-toggle)
:repeat-map trev/modus-themes-repeat-map
("t" . modus-themes-toggle))
:custom
(modus-themes-include-derivatives-mode t)
(modus-themes-to-toggle
'(modus-vivendi-deuteranopia modus-operandi-tinted))
(modus-themes-italic-constructs t)
(modus-themes-bold-constructs t)
(modus-themes-variable-pitch-ui nil)
(modus-themes-mixed-fonts t)
(modus-themes-common-palette-overrides
'((bg-search-current bg-yellow-intense)))
(modus-themes-headings
'((0 . (variable-pitch light 1.6))
(1 . (variable-pitch light 1.5))
(2 . (variable-pitch regular 1.4))
(3 . (variable-pitch regular 1.3))
(4 . (variable-pitch semibold 1.25))
(5 . (variable-pitch semibold 1.15))
(6 . (semibold 1.1))
(7 . (semibold 1.05))
(t . (semibold))))
:config
(with-eval-after-load 'diff-hl
(trev/modus-theme-set-extra-faces)))
(use-package spacious-padding
:demand t
:bind ("<f8>" . spacious-padding-mode)
:config
(setq spacious-padding-widths trev/spacious-padding-widths
spacious-padding-subtle-frame-lines nil)
(advice-add #'spacious-padding-set-faces :after #'trev/modus-theme-set-extra-faces)
(spacious-padding-mode))
(use-package emacs
:preface
(defun header-line-file-path ()
"Set `header-line-format' if symbol `buffer-file-name' is not nil."
(when buffer-file-name
(setq header-line-format '("%f"))))
(defun open-user-config ()
"Opens user's config file"
(interactive) (find-file user-init-file))
(define-advice message-make-date
(:around (orig-fun &rest args) messages-force-utc-tz)
"Force UTC timezone generation for the message date header."
(with-environment-variables
(("TZ" "Etc/UTC"))
(let ((res (apply orig-fun args)))
(set-time-zone-rule nil)
res)))
:hook
((find-file . header-line-file-path)
;; (prog-mode . display-line-numbers-mode)
)
:init
(save-place-mode)
;; `recentf-mode' loads and cleans the recentf file; defer it out of the
;; critical startup path while keeping `consult-recent-file' ready shortly
;; after the first frame appears.
(run-with-idle-timer 1 nil #'recentf-mode)
(column-number-mode) ; Column number mode
(delete-selection-mode)
(electric-pair-mode) ; Pair the pairs
(put 'suspend-frame 'disabled t) ; Disable suspend-frame
(setq auto-fill-function 'do-auto-fill
auto-save-file-name-transforms '((".*" "~/.cache/emacs/saves/" t))
browse-url-browser-function 'browse-url-generic
browse-url-generic-program "xdg-open"
backup-directory-alist '(("." . "~/.cache/emacs/backups"))
comment-auto-fill-only-comments t
confirm-kill-emacs nil
custom-file "/tmp/custom.el"
custom-safe-themes t
dictionary-server "dict.org"
display-buffer-alist
'(((category . xref-jump)
(display-buffer-reuse-window display-buffer-use-some-window)
(some-window . mru))
("\\*\\(Help\\|helpful\\|Customize\\|info\\|Ibuffer\\|.*eshell\\).*\\*"
(display-buffer-reuse-window display-buffer-in-side-window)
(side . right) (slot . 0) (window-width . .5))
("\\*\\(xref\\|Occur\\|.*diagnostics\\|.*vterm\\).*\\*"
(display-buffer-below-selected display-buffer-at-bottom)
(window-height . .2)))
display-line-numbers-grow-only t
display-line-numbers-width-start t
eldoc-echo-area-use-multiline-p nil
enable-recursive-minibuffers t
epg-pinentry-mode 'ask
eval-expression-print-length 30
fill-column 80
help-window-select t
indent-tabs-mode nil
inhibit-startup-message t
kill-buffer-quit-windows t
kill-do-not-save-duplicates t
mode-line-end-spaces nil
mode-line-front-space nil
mode-line-compact 'long
mode-line-collapse-minor-modes
'(auto-revert-mode ws-butler-mode editorconfig-mode apheleia-mode
eldoc-mode envrc-mode yas-minor-mode which-key-mode)
mouse-wheel-progressive-speed nil
quit-restore-window-no-switch 'skip-first
read-extended-command-predicate #'command-completion-default-include-p
ring-bell-function 'ignore
save-interprogram-paste-before-kill t
safe-local-variable-directories '("~/Workspace/")
scroll-preserve-screen-position 1
send-mail-function 'message-send-mail-with-sendmail
tab-always-indent 'complete
trusted-content '("~/Workspace/" "./lisp/")
undo-limit 67108864
undo-outer-limit 1006632960
undo-strong-limit 100663296
use-default-font-for-symbols nil
use-dialog-box nil
use-short-answers t
user-full-name "Trevor Arjeski"
user-mail-address "tmarjeski@gmail.com"
warning-minimum-level :error
window-combination-resize t
window-divider-default-right-width
(plist-get trev/spacious-padding-widths :right-divider-width))
(window-divider-mode) ; Gap between splits
;; Fonts
(set-face-attribute 'default nil :family "Iosevka" :height 166 :weight 'medium)
(set-face-attribute 'fixed-pitch nil :family "Iosevka Fixed" :height 166)
(set-face-attribute 'fixed-pitch-serif nil :family "Noto Serif" :height 166)
(set-face-attribute 'variable-pitch nil :family "Noto Sans" :weight 'normal)
;; https://github.com/ryanoasis/nerd-fonts/wiki/Glyph-Sets-and-Code-Points
(dolist (code-point
'((#xE6FA . #xE6B2) (#xE700 . #xE7C5) (#xF000 . #xF2E0) (#xE200 . #xE2A9)
(#xF500 . #xFD46) (#xE300 . #xE3EB) (#xF400 . #xF532) (#xE0B4 . #xE0C8)
(#xF0001 . #xF1AF0) (#xE0CC . #xE0D4) (#x23FB . #x23FE) (#xF300 . #xF372)
(#xE000 . #xE00A) (#xEA60 . #xEBEB) #x2665 #x26A1 #xF2A1 #xF27C #xE0A3 #xE0CA))
(set-fontset-font t code-point (font-spec :family "Symbols Nerd Font Mono")))
;; Generic keybindings
:bind
(("C-x K" . 'kill-current-buffer)
("C-c b" . 'ibuffer-other-window)
("C-'" . 'mode-line-other-buffer)
("C-c !" . 'open-user-config)
("M-o" . 'other-window)))
(use-package desktop
:custom
(desktop-load-locked-desktop 'check-pid)
:config
(add-to-list 'desktop-minor-mode-table '(envrc-mode nil))
(add-to-list 'desktop-minor-mode-table '(envrc-global-mode nil))
:init (desktop-save-mode))
(use-package fringe
:custom (fringes-outside-margins t)
:init
(define-fringe-bitmap 'right-curly-arrow
[0 0 0 0 28672 30720 15360 7680 3840 52992 65280 65024 64512 64512 65024 65024])
(define-fringe-bitmap 'left-curly-arrow
[0 0 0 0 14 30 60 120 240 243 255 127 63 63 127 127]))
;; Ligatures
(use-package ligature
:hook (prog-mode . ligature-mode)
:config
(ligature-set-ligatures
'prog-mode
'("-<<" "-<" "-<-" "<--" "<---" "<<-" "<-" "->" "->>" "-->" "--->" "->-" ">-" ">>-"
"=<<" "=<" "=<=" "<==" "<===" "<<=" "<=" "=>" "=>>" "==>" "===>" "=>=" ">=" ">>="
"<->" "<-->" "<--->" "<---->" "<=>" "<==>" "<===>" "<====>" "::" ":::" "__" "--"
"<~~" "~~>" "==" "!=" "/=" "~=" "<>" "===" "!==" "!===" "=/=" "=!="
"<:" ":=" "*=" "*+" "<*" "<*>" "*>" "<." "<.>" ".>" "+*" "=*" "=:" ":>"
"(*" "*)" "++" "+++" "|-" "-|" "<!--" "<!---")))
;; Project.el
(use-package project
:custom
(project-mode-line 'non-remote)
(project-switch-commands
'((consult-fd "Find file" ?f)
(consult-ripgrep "Find regexp" ?g)
(consult-project-buffer "Buffers" ?b)
(project-find-matching-buffer "Matching buffer" ?B)
(magit-project-status "Magit" ?m)
(project-eshell "Eshell" ?e)
(project-vterm "Vterm" ?t)
(project-any-command "Other" ?o)))
:config
(add-to-list 'project-kill-buffer-conditions '(major-mode . vterm-mode)))
(use-package dired
:custom
(dired-kill-when-opening-new-dired-buffer t)
(dired-auto-revert-buffer #'dired-directory-changed-p)
(dired-clean-up-buffers-too t)
(dired-clean-confirm-killing-deleted-buffers t)
(dired-recursive-copies 'always)
(dired-recursive-deletes 'always)
(dired-create-destination-dirs 'ask)
(dired-create-destination-dirs-on-trailing-dirsep t)
(wdired-create-parent-directories t))
(use-package autorevert
:hook (after-init . global-auto-revert-mode)
:custom
(auto-revert-verbose nil)
(global-auto-revert-non-file-buffers t))
(use-package xref
:defer t
:custom
(xref-auto-jump-to-first-definition 'show)
(xref-search-program 'ripgrep))
(use-package eldoc
:custom (eldoc-help-at-pt t))
(use-package elisp-mode
:ensure nil
:preface
(defun trev/elisp-enable-docstring-eldoc ()
"Show Emacs Lisp function docstrings in ElDoc."
(add-hook 'eldoc-documentation-functions
#'elisp-eldoc-funcall-with-docstring nil t))
:hook (emacs-lisp-mode . trev/elisp-enable-docstring-eldoc))
;; Keybinding
(use-package which-key
:init (which-key-mode)
:bind (("C-c K" . 'which-key-show-major-mode))
:custom
(which-key-max-description-length nil)
(which-key-popup-type 'side-window)
(which-key-sort-order 'which-key-description-order))
(use-package repeat
:hook (after-init . repeat-mode)
:bind ("M-RET" . repeat))
(use-package undo-fu
:init (global-unset-key (kbd "C-z"))
:bind
(("C-z" . 'undo-fu-only-undo)
("C-S-z" . 'undo-fu-only-redo)))
(use-package undo-fu-session
:demand
:config (undo-fu-session-global-mode))
;; Searching
(use-package isearch
:custom
(isearch-lazy-count t)
:bind
(:map isearch-mode-map
("C-n" . isearch-repeat-forward)
("C-p" . isearch-repeat-backward)))
(use-package grep
:defer t
:init
(setq grep-use-headings t
grep-command "rg -nHS0 --no-heading "))
;; Ibuffer
(use-package ibuffer
:preface
(defun ibuffer-mark-unimportant-for-delete ()
(interactive)
(ibuffer-mark-special-buffers)
(ibuffer-mark-read-only-buffers)
(ibuffer-change-marks ?> ?D))
:hook (ibuffer-mode . ibuffer-auto-mode)
:custom
(ibuffer-human-readable-size t)
:bind
(:map ibuffer-mode-map
("* D" . #'ibuffer-mark-unimportant-for-delete)))
(use-package autoinsert :init (auto-insert-mode))
;; Minibuffer
(use-package vertico
:custom
(vertico-count 6)
(vertico-cycle t)
(vertico-scroll-margin 5)
:init (vertico-mode))
(use-package orderless
:custom
(completion-category-defaults nil)
(completion-category-overrides '((file (styles basic partial-completion))))
(completion-styles '(orderless basic)))
;; Save minibuffer history between restarts
(use-package savehist
:demand t
:config
(add-to-list 'savehist-additional-variables 'trev/modus-theme)
(savehist-mode))
;; Minibuffer annotations
(use-package marginalia :init (marginalia-mode))
(use-package helpful
:bind
(("C-h f" . #'helpful-callable)
("C-h v" . #'helpful-variable)
("C-h k" . #'helpful-key)
("C-h x" . #'helpful-command)
("C-h o" . #'helpful-symbol)
("C-c C-d" . #'helpful-at-point)))
;; Completion
(use-package corfu
:init (global-corfu-mode)
:bind (:map corfu-map ("RET" . nil))
:custom
(corfu-left-margin-width 4)
(corfu-right-margin-width 4)
(corfu-popupinfo-delay 0)
(corfu-preview-current nil)
(corfu-quit-no-match 'separator)
(global-corfu-minibuffer t)
:config
(corfu-popupinfo-mode)
(add-to-list 'corfu--frame-parameters '(internal-border-width . 4)))
;; Completion-at-point helper
(use-package cape
:hook ((completion-at-point-functions . cape-file))
:bind ("C-c p" . cape-prefix-map)
:custom (text-mode-ispell-word-completion 'cape-dict))
;; Snippets
(use-package yasnippet
:hook (after-init . yas-global-mode)
:bind
(:map yas-minor-mode-map
("TAB" . nil)
("<tab>" . nil)
("C-c y" . 'yas-insert-snippet)))
(use-package yasnippet-snippets
:after yasnippet)
;; Consult functions
(use-package consult
:custom
(consult-fd-args '((if (executable-find "fdfind" 'remote) "fdfind" "fd")
"--full-path --color=never --hidden --no-ignore-vcs"))
:bind (("C-c /" . consult-ripgrep)
("C-c SPC" . consult-fd)
("C-c r" . consult-recent-file)
("C-<return>" . consult-line)
("C-c i" . consult-info)
([remap Info-search] . consult-info)
("C-x b" . consult-buffer)
("C-x 4 b" . consult-buffer-other-window)
("C-x r b" . consult-bookmark)
("C-x p b" . consult-project-buffer)
("M-y" . consult-yank-pop)
("M-g e" . consult-compile-error)
;; `C-u M-g f' widens to the whole project.
("M-g f" . consult-flymake)
("M-g M-g" . consult-goto-line))
:init
;; Use Consult to select xref locations with preview
(setq xref-show-xrefs-function #'consult-xref
xref-show-definitions-function #'consult-xref))
;; Embark for collecting completions / results
(use-package embark
:bind
(("C-c e" . embark-act)
("C-h B" . embark-bindings))
:config
;; Hide the mode line of the Embark live/completions buffers
(add-to-list 'display-buffer-alist
'("\\`\\*Embark Collect \\(Live\\|Completions\\)\\*"
nil
(window-parameters (mode-line-format . none)))))
(use-package embark-consult
:hook (embark-collect-mode . consult-preview-at-point-mode))
(use-package treesit
:ensure nil
:preface
(defun treesit-standard-langs (langs)
"Convert LANGS into `treesit-language-source-alist' entries."
(seq-map
(lambda (entry)
(pcase entry
((pred symbolp)
`(,entry ,(format "https://github.com/tree-sitter/tree-sitter-%s" entry)))
(`(,lang ,repo . ,rest)
`(,lang ,(format "https://github.com/%s" repo) ,@rest))
(_ (error "Invalid entry in treesit-standard-langs: %S" entry))))
langs))
:custom
(treesit-auto-install-grammar 'ask)
(treesit-font-lock-level 4)
(treesit-enabled-modes t)
(treesit-language-source-alist
(treesit-standard-langs
'(
bash c cpp css go html jsdoc json python rust toml
(nix "nix-community/tree-sitter-nix")
;; custom repo / branch / src-dir
(dockerfile "camdencheek/tree-sitter-dockerfile")
(gomod "camdencheek/tree-sitter-go-mod")
(javascript "tree-sitter/tree-sitter-javascript"
:revision "master" :source-dir "src")
(typescript "tree-sitter/tree-sitter-typescript"
:revision "master" :source-dir "typescript/src")
(tsx "tree-sitter/tree-sitter-typescript"
:revision "master" :source-dir "tsx/src")
(kdl "tree-sitter-grammars/tree-sitter-kdl")
(lua "tree-sitter-grammars/tree-sitter-lua")
(yaml "tree-sitter-grammars/tree-sitter-yaml")
(markdown "tree-sitter-grammars/tree-sitter-markdown"
:revision "split_parser" :source-dir "tree-sitter-markdown/src")
(markdown-inline "tree-sitter-grammars/tree-sitter-markdown"
:revision "split_parser" :source-dir "tree-sitter-markdown-inline/src")))))
;; Whitespace handling
(use-package ws-butler :demand 2 :config (ws-butler-global-mode))
;; Rainbow delimiters
(use-package rainbow-delimiters :hook (prog-mode . rainbow-delimiters-mode))
;; Editorconfig
(use-package editorconfig
:hook (after-init . editorconfig-mode))
;; Buffer specific direnv
(use-package envrc
:hook (after-init . envrc-global-mode))
;; Avy navigation
(use-package avy
:bind
(("C-c w" . #'avy-goto-word-0)
("C-c s" . #'avy-goto-char-timer)))
;; Formatting
(use-package apheleia
:demand t
:config
(apheleia-global-mode)
(dolist (formatter-cmd
'((shfmt . ("shfmt" "-i" "2" "-ci" "-kp" "-sr"))
(rustfmt . ("rustfmt" "--edition" "2024" "--quiet" "--emit" "stdout"))
(nixfmt . ("nixfmt"))))
(add-to-list 'apheleia-formatters formatter-cmd))
(add-to-list 'apheleia-mode-alist '(nix-ts-mode . nixfmt)))
;; Spelling
(use-package ispell
:custom
(ispell-local-dictionary "en")
(ispell-alternate-dictionary "en_US"))
(use-package flyspell
:hook
((message-mode . flyspell-mode)
(markdown-ts-mode . flyspell-mode)))
;; Git
(use-package magit
:custom
(magit-define-global-key-bindings 'recommended)
(magit-diff-refine-hunk t)
(magit-blame-echo-style 'headings)
(magit-diff-fontify-hunk t)
(magit-diff-use-indicator-faces t)
:hook (git-commit-setup . git-commit-turn-on-flyspell)
:config (add-to-list 'magit-git-environment "TZ=UTC"))
(use-package ghub
:init
(with-eval-after-load 'ghub
;; Guix Home links authinfo.gpg into /gnu/store without suffix; Ghub's
;; symlink cache workaround prevents Auth-Source from finding entries there.
(advice-remove #'auth-source-netrc-parse
#'auth-source-netrc-parse@handle-symlink)))
(use-package forge
:after magit)
;; Git modes
(use-package git-modes)
(use-package diff-hl
:preface
(define-fringe-bitmap 'vertical-bar-large (make-vector 60 #xf0))
(define-fringe-bitmap 'horizontal-bar-large (make-vector 4 #xff) nil nil 'top)
(defun diff-hl-bmp-fn-override (type _pos)
"Override diff-hl bitmaps."
(pcase type
('delete 'horizontal-bar-large)
(_ 'vertical-bar-large)))
:custom
(diff-hl-fringe-bmp-function #'diff-hl-bmp-fn-override)
:hook
(magit-post-refresh . diff-hl-magit-post-refresh)
:config
(global-diff-hl-mode)
(diff-hl-flydiff-mode))
;; Terminal
(use-package vterm
:ensure nil
:bind (:map project-prefix-map
("t" . project-vterm))
:preface
(defun project-vterm ()
(interactive)
(defvar vterm-buffer-name)
(let* ((default-directory (project-root (project-current t)))
(vterm-buffer-name (project-prefixed-buffer-name "vterm"))
(vterm-buffer (get-buffer vterm-buffer-name)))
(if (and vterm-buffer (not current-prefix-arg))
(pop-to-buffer vterm-buffer (bound-and-true-p display-comint-buffer-action))
(vterm))))
:config
(setq vterm-copy-exclude-prompt t)
(setq vterm-max-scrollback 100000)
(setq vterm-tramp-shells '(("ssh" "/bin/bash"))))
(use-package flymake
:custom
(flymake-fringe-indicator-position nil)
(flymake-show-diagnostics-at-end-of-line t)
:hook (prog-mode . flymake-mode))
;; Eglot LSP
(use-package eglot
:custom
(eglot-extend-to-xref t)
(eglot-code-action-indications '(eldoc-hint))
:hook
(c-ts-mode . eglot-ensure)
(c++-ts-mode . eglot-ensure)
(bash-ts-mode . eglot-ensure)
(sh-mode . eglot-ensure)
(rust-ts-mode . eglot-ensure)
(typescript-ts-mode . eglot-ensure)
(python-ts-mode . eglot-ensure)
(nix-ts-mode . eglot-ensure)
:bind
(:map eglot-mode-map
:prefix-map eglot-prefix-keymap
:prefix "C-c l"
("a" . eglot-code-actions)
("o" . eglot-code-actions-organize-imports)
("r" . eglot-rename)
("f" . eglot-format)
("d" . eglot-find-declaration)
("i" . eglot-find-implementation)
("t" . eglot-find-typeDefinition))
:config
(setf eglot-server-programs
'(((bash-ts-mode sh-mode) . ("bash-language-server" "start"))
(rust-ts-mode . ("rust-analyzer"
:initializationOptions
(:check
(:command "clippy")
:cargo
(:features "all"))))
((c-ts-mode c++-ts-mode) . ("clangd"))
((tsx-ts-mode typescript-ts-mode) . ("typescript-language-server" "--stdio"))
(python-ts-mode . ("pylsp"))
(nix-ts-mode . ("nil")))))
;; Paredit
(use-package paredit
:hook ((lisp-mode emacs-lisp-mode scheme-mode) . enable-paredit-mode)
:bind (:map paredit-mode-map (("M-?" . nil))))
;; Rust
(use-package rust-mode
:custom
(rust-mode-treesitter-derive (treesit-available-p))
(rust-format-on-save t))
;; Guile
(use-package geiser-guile
:custom (geiser-repl-per-project-p t))
;; Nix
(use-package nix-ts-mode
:mode "\\.nix\\'")
;; Common Lisp
(use-package sly :custom (inferior-lisp-program (executable-find "sbcl")))
;; Secrets
(use-package my-secrets :ensure nil)
(use-package elfeed
:preface
(defun trev/elfeed-load-secrets (&rest _)
"Load secrets before opening Elfeed."
(require 'my-secrets))
(defun elfeed-show-visit-eww ()
(interactive)
(let ((browse-url-browser-function #'eww-browse-url))
(elfeed-show-visit)))
:custom
(elfeed-use-libxml t)
:init
(advice-add 'elfeed :before #'trev/elfeed-load-secrets)
:bind
(("C-c @" . #'elfeed)
:map elfeed-show-mode-map
("e" . 'elfeed-show-visit-eww)))
;; GNU Bug tracker
(use-package debbugs)
(use-package org
:custom
(org-directory "~/.local/share/org/")
(org-default-notes-file "~/.local/share/org/notes.org")
(org-agenda-files '("~/.local/share/org/notes.org"))
(org-capture-templates
'(("n" "Note" entry (file+headline "~/.local/share/org/notes.org" "Notes")
"* %U %?\n")))
:bind
(("C-c a" . org-agenda)
("C-c c" . org-capture)
("C-c n" . (lambda ()
(interactive)
(find-file org-default-notes-file)))
("C-c N" . consult-org-heading))
:config
(make-directory org-directory t))
(use-package notmuch
:defer t
:preface
(defun trev/notmuch-mark-all-read ()
"Mark every message in the current notmuch view as read."
(interactive)
(let ((query (pcase major-mode
('notmuch-search-mode (notmuch-search-get-query))
('notmuch-tree-mode (notmuch-tree-get-query))
('notmuch-show-mode (notmuch-show-get-query))
(_ (user-error "Not in a notmuch search/tree/show buffer")))))
(when (yes-or-no-p (format "Mark [%s] read?" query))
(notmuch-tag query '("-unread"))
(notmuch-refresh-this-buffer))))
:bind
(("C-c m" . notmuch)
:map notmuch-search-mode-map
("M" . trev/notmuch-mark-all-read)
:map notmuch-tree-mode-map
("M" . trev/notmuch-mark-all-read)
:map notmuch-show-mode-map
("M" . trev/notmuch-mark-all-read))
:custom
(message-send-mail-function 'smtpmail-send-it)
(notmuch-archive-tags '("-unread"))
(notmuch-fcc-dirs nil)
(notmuch-identities '("tmarjeski@gmail.com" "tarjeski@gmail.com"))
(notmuch-saved-searches
;; Lieer syncs each account into one flat maildir and maps Gmail labels to
;; notmuch tags, so scope by `tag:account-*' (from the post-new hook) and
;; select folders with Gmail's own tags rather than by path.
'((:name "unread [u]" :query "tag:inbox and tag:account-main and tag:unread" :key "u")
(:name "inbox [i]" :query "tag:inbox and tag:account-main" :key "i")
(:name "lists [l]" :query "tag:inbox and tag:account-lists and tag:unread" :key "l" :search-type tree)
(:name "guix-devel [g]" :query "tag:guix-devel and tag:unread" :key "g" :search-type tree)
(:name "guix-help [h]" :query "tag:guix-help and tag:unread" :key "h" :search-type tree)
(:name "emacs-devel [e]" :query "tag:emacs-devel and tag:unread" :key "e" :search-type tree)
(:name "emacs-bugs [b]" :query "tag:emacs-bugs and tag:unread" :key "b" :search-type tree)
(:name "flagged [f]" :query "tag:flagged" :key "f")
(:name "sent [s]" :query "tag:sent and tag:account-main" :key "s")
(:name "trash [T]" :query "tag:trash or tag:spam" :key "T")
(:name "all-mail-6m [a]" :query "tag:account-main and date:6M.." :key "a")))
(notmuch-hello-sections
'(notmuch-hello-insert-header notmuch-hello-insert-saved-searches notmuch-hello-insert-alltags))
(notmuch-hello-auto-refresh t)
(notmuch-hello-indent 0)
(notmuch-column-control 1.0)
(notmuch-search-oldest-first nil)
(notmuch-show-logo nil)
(notmuch-show-relative-dates t)
(notmuch-show-indent-messages-width 0)
(notmuch-show-indent-multipart nil)
(notmuch-message-headers '("To" "Cc" "Subject" "Date"))
(notmuch-message-headers-visible t)
(notmuch-wash-wrap-lines-length 120)
(smtpmail-smtp-server "smtp.gmail.com")
(smtpmail-smtp-service 587)
(smtpmail-smtp-user "tmarjeski@gmail.com")
:hook ((notmuch-mua-send . notmuch-mua-attachment-check)))
;;; Local Packages
(use-package aoc
:ensure nil
:commands (aoc-fetch-input aoc-view-problem aoc-submit-answer)
:config
(setopt savehist-additional-variables
(append savehist-additional-variables '(aoc-year aoc-day-level))))
(use-package pastes
:vc (:url "git@github.com:trevarj/pastes.git"
:branch "main"
:lisp-dir "elisp"
:main-file "pastes.el"
:rev :newest)
:commands (pastes-setup
pastes-region
pastes-buffer
pastes-file
pastes-clipboard-image
pastes-delete-url))
(use-package trev-clatter :ensure nil :demand t)
(use-package nostr
:ensure nil
:load-path "/home/trev/Workspace/nostr.el"
:bind (("C-c $" . nostr-open))
:commands (nostr-open
nostr-open-profile
nostr-open-notifications
nostr-open-relays
nostr-open-id)
:custom
(nostr-backend-command
"/home/trev/Workspace/nostr.el/target/release/nostr-el-backend"))
(provide 'init)
;; Local Variables:
;; byte-compile-warnings: (not unresolved free-vars)
;; End:
;;; init.el ends here