-
Notifications
You must be signed in to change notification settings - Fork 2
/
init.el
2537 lines (2271 loc) · 87.7 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
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
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
;; DEBUG
;; (setq debug-on-error t)
;; (setq debug-on-quit t)
;;; ELPA
(require 'package)
(require 'use-package)
(defvar os/emacs-tmp-dir (concat user-emacs-directory "tmp/")
"Scratch space for stuff...")
(setq package-user-dir (concat user-emacs-directory "elpa"))
(setq package-native-compile t)
(defvar os/private-config-file (concat user-emacs-directory "emacs-private.el")
"File with configuration info that can't be in public repository.")
(if (file-readable-p os/private-config-file)
(progn
(load-library os/private-config-file)
(message "Loaded private config")))
(use-package use-package
:no-require
:custom
(use-package-enable-imenu-support t))
(defvar bootstrap-version)
(let ((bootstrap-file
(expand-file-name
"straight/repos/straight.el/bootstrap.el"
(or (bound-and-true-p straight-base-dir)
user-emacs-directory)))
(bootstrap-version 7))
(unless (file-exists-p bootstrap-file)
(with-current-buffer
(url-retrieve-synchronously
"https://raw.githubusercontent.com/radian-software/straight.el/develop/install.el"
'silent 'inhibit-cookies)
(goto-char (point-max))
(eval-print-last-sexp)))
(load bootstrap-file nil 'nomessage))
(straight-use-package 'use-package)
(use-package early-init
:no-require
:unless (featurep 'early-init)
:config
(load-file (locate-user-emacs-file "early-init.el")))
(use-package delight
:ensure t)
(setq custom-file (concat user-emacs-directory "custom.el"))
(load custom-file)
;;; MAC STUFF
(when (eq system-type 'darwin)
(setq mac-command-modifier 'meta)
(setq mac-option-modifier nil)
(setq browse-url-browser-function 'browse-url-default-macosx-browser)
(add-to-list 'default-frame-alist '(ns-transparent-titlebar . t))
(add-to-list 'default-frame-alist '(ns-appearance . dark)))
(use-package local-config
:no-require
:preface
(defgroup local-config ()
"Customization group for local settings."
:prefix "local-config-"
:group 'emacs)
(defcustom local-config-dark-theme 'modus-vivendi
"Dark theme to use."
:tag "Dark theme"
:type 'symbol
:group 'local-config)
(defcustom local-config-light-theme 'modus-operandi
"Light theme to use."
:tag "Light theme"
:type 'symbol
:group 'local-config)
(defcustom no-hscroll-modes '(term-mode)
"Major modes to disable horizontal scrolling."
:tag "Modes to disable horizontal scrolling"
:type '(repeat symbol)
:group 'local-config)
(provide 'local-config))
(use-package functions
:no-require
:functions (dbus-color-theme-dark-p)
:init (require 'bind-key)
:bind (("M-Q" . split-pararagraph-into-lines))
:preface
(require 'subr-x)
(defun os-code-radio ()
(interactive)
(browse-url "https://coderadio.freecodecamp.org/"))
(defun open-line-below ()
"Open a line below the current line."
(interactive)
(end-of-line)
(newline)
(indent-for-tab-command))
(defun open-line-above ()
"Open a line above the current line."
(interactive)
(beginning-of-line)
(newline)
(forward-line -1)
(indent-for-tab-command))
(defun split-pararagraph-into-lines ()
"Split the current paragraph into lines with one sentence each."
(interactive)
(save-excursion
(let ((fill-column most-positive-fixnum))
(fill-paragraph))
(let ((auto-fill-p auto-fill-function)
(end (progn (end-of-line) (backward-sentence) (point))))
(back-to-indentation)
(unless (= (point) end)
(auto-fill-mode -1)
(while (< (point) end)
(forward-sentence)
(delete-horizontal-space)
(newline-and-indent))
(deactivate-mark)
(when auto-fill-p
(auto-fill-mode t))
(when (looking-at "^$")
(delete-char -1))))))
(defun in-termux-p ()
"Detect if Emacs is running in Termux."
(executable-find "termux-info"))
(defun dark-mode-enabled-p ()
"Check if dark mode is enabled."
(cond ((file-exists-p (expand-file-name "~/.dark-mode")) t)
((featurep 'dbus) (dbus-color-theme-dark-p))
(t nil)))
(defun memoize (fn)
"Create a storage for FN's args.
Checks if FN was called with set args before. If so, return the
value from the storage and don't call FN. Otherwise calls FN,
and saves its result in the storage. FN must be referentially
transparent."
(let ((memo (make-hash-table :test 'equal)))
(lambda (&rest args)
;; `memo' is used as a singleton to check for absense of value
(let ((value (gethash args memo memo)))
(if (eq value memo)
(puthash args (apply fn args) memo)
value)))))
(defmacro defmemo (name &rest funtail)
(declare (doc-string 3) (indent 2) (debug defun))
`(defalias ',name (memoize (lambda ,@funtail))))
(font-lock-add-keywords
'emacs-lisp-mode
'(("(\\(defmemo\\)\\_>\\s *\\(\\(?:\\sw\\|\\s_\\)+\\)?"
(1 font-lock-keyword-face nil t)
(2 font-lock-function-name-face nil t))))
(defvar-local ssh-tunnel-port nil)
(put 'ssh-tunnel-port 'safe-local-variable #'numberp)
(defun ssh-tunnel (host port &optional local-port)
"Start an SSH tunnel from localhost to HOST:PORT.
If LOCAL-PORT is nil, PORT is used as local port."
(interactive (list (read-string "host: " nil 'ssh-host-history)
(read-number "port: " ssh-tunnel-port 'ssh-port-history)
(when current-prefix-arg
(read-number "local port: " ssh-tunnel-port 'ssh-port-history))))
(let ((name (if (and local-port (not (= local-port port)))
(format "*ssh-tunnel:%s:%s:%s" local-port host port)
(format "*ssh-tunnel:%s:%s" host port))))
(async-shell-command
(format "ssh -4 -N -L %s:localhost:%s %s" (or local-port port) port host)
(concat " " name))))
(provide 'functions))
(use-package defaults
:no-require
:preface
(setq-default
indent-tabs-mode nil
load-prefer-newer t
truncate-lines t
bidi-paragraph-direction 'left-to-right
frame-title-format
'((:eval
(if (buffer-file-name)
(abbreviate-file-name (buffer-file-name))
(buffer-name))))
auto-window-vscroll nil
mouse-highlight t
hscroll-step 1
hscroll-margin 1
scroll-margin 0
scroll-preserve-screen-position nil
frame-resize-pixelwise window-system
window-resize-pixelwise window-system
fill-column 80)
(when (window-system)
(setq-default
x-gtk-use-system-tooltips nil
cursor-type 'box
blink-cursor-mode 0
cursor-in-non-selected-windows nil))
(setq
ring-bell-function 'ignore
mode-line-percent-position nil
enable-recursive-minibuffers t)
(when (version<= "27.1" emacs-version)
(setq bidi-inhibit-bpa t))
(global-visual-line-mode t)
(custom-set-variables
'(custom-safe-themes
'("ffafb0e9f63935183713b204c11d22225008559fa62133a69848835f4f4a758c" "7964b513f8a2bb14803e717e0ac0123f100fb92160dcf4a467f530868ebaae3e" "8d146df8bd640320d5ca94d2913392bc6f763d5bc2bb47bed8e14975017eea91" "99d1e29934b9e712651d29735dd8dcd431a651dfbe039df158aa973461af003e" "c5878086e65614424a84ad5c758b07e9edcf4c513e08a1c5b1533f313d1b17f1" "77fff78cc13a2ff41ad0a8ba2f09e8efd3c7e16be20725606c095f9a19c24d3d" "81f53ee9ddd3f8559f94c127c9327d578e264c574cda7c6d9daddaec226f87bb" "88f7ee5594021c60a4a6a1c275614103de8c1435d6d08cc58882f920e0cec65e" "9f297216c88ca3f47e5f10f8bd884ab24ac5bc9d884f0f23589b0a46a608fe14" "6b91ddbc12b0fc9f43fb9e31be8b76b16e387312232324c48e8c666418fe643c" "014cb63097fc7dbda3edf53eb09802237961cbb4c9e9abd705f23b86511b0a69" default)))
(provide 'defaults))
(use-package windmove
:config
(windmove-default-keybindings))
;;; Core packages
(use-package bind-key
:ensure t)
(require 'bind-key)
(use-package window
:config
(add-to-list
'display-buffer-alist
'("\\*Calendar*" (display-buffer-at-bottom))))
(use-package mouse
:bind (("<mode-line> <mouse-2>" . nil)
("<mode-line> <mouse-3>" . nil)))
(use-package mode-line
:no-require
:preface
(defvar mode-line-interactive-position
`(line-number-mode
(:propertize " %l:%C"
help-echo "mouse-1: Goto line"
mouse-face mode-line-highlight
local-map ,(let ((map (make-sparse-keymap)))
(define-key map [mode-line down-mouse-1] 'goto-line)
map)))
"Mode line position with goto line binding.")
(put 'mode-line-interactive-position 'risky-local-variable t)
(setq-default mode-line-format ; Sets the default mode-line format for all buffers
'( ; List of elements to display in the mode-line
"%e" ; Shows error message if there's not enough space
mode-line-front-space ; Space at beginning
mode-line-modified ; Shows if buffer is modified (*) or read-only (%)
mode-line-remote ; Shows @ if file is remote
mode-line-frame-identification ; Shows - if windowed, or terminal name if in terminal
; Custom project display section
(:propertize ; Adds face properties to the following expression
(:eval ; Evaluates the expression each time mode-line updates
(when-let ((project (project-current))) ; If in a project
(format "[%s] " (project-name project)))) ; Shows [project-name]
face warning) ; Displays in warning face color
; Buffer name section
(:propertize "%b" face mode-line-buffer-id) ; Current buffer name with special face
" " ; Space
mode-line-position ; Shows position in buffer (line number, %)
(vc-mode vc-mode) ; Version control information
" " ; Space
mode-line-modes ; Major and minor modes
mode-line-misc-info ; Misc information
mode-line-end-spaces)) ; Spaces at end
(provide 'mode-line))
(use-package font
:no-require
:hook (after-init . setup-fonts)
:preface
(defun font-installed-p (font-name)
"Check if a font with FONT-NAME is available."
(find-font (font-spec :name font-name)))
(defun setup-fonts ()
(cond ((font-installed-p "JetBrainsMono Nerd Font Mono")
(set-face-attribute 'default nil :font "JetBrainsMono Nerd Font Mono"))
((font-installed-p "Source Code Pro")
(set-face-attribute 'default nil :font "Source Code Pro")))
(when (font-installed-p "DejaVu Sans")
(set-face-attribute 'variable-pitch nil :font "DejaVu Sans")))
(provide 'font))
(use-package cus-edit
:custom
(custom-file (locate-user-emacs-file "custom.el"))
:init
(load custom-file :noerror))
(use-package novice
:preface
(defvar disabled-commands (locate-user-emacs-file "disabled.el")
"File to store disabled commands, that were enabled permanently.")
(define-advice enable-command (:around (fn command) use-disabled-file)
(let ((user-init-file disabled-commands))
(funcall fn command)))
:init
(load disabled-commands 'noerror))
(use-package files
:preface
(defvar backup-dir
(locate-user-emacs-file ".cache/backups")
"Directory to store backups.")
(defvar auto-save-dir
(locate-user-emacs-file ".cache/auto-save/")
"Directory to store auto-save files.")
:custom
(backup-by-copying t)
(create-lockfiles nil)
(backup-directory-alist
`(("." . ,backup-dir)))
(auto-save-file-name-transforms
`((".*" ,auto-save-dir t)))
(auto-save-no-message t)
(auto-save-interval 100)
(require-final-newline t)
:bind ("<f5>" . revert-buffer-quick)
:init
(unless (file-exists-p auto-save-dir)
(make-directory auto-save-dir t)))
(use-package subr
:no-require
:init
(if (boundp 'use-short-answers)
(setq-default use-short-answers t)
(fset 'yes-or-no-p 'y-or-n-p)))
(use-package savehist
:hook (after-init . savehist-mode))
(use-package simple
:bind (("M-z" . zap-up-to-char)
("M-S-z" . zap-to-char)
("C-x k" . kill-current-buffer)
("C-h C-f" . describe-face)
([remap undo] . undo-only))
:hook ((before-save . delete-trailing-whitespace)
(overwrite-mode . overwrite-mode-set-cursor-shape)
(after-init . column-number-mode)
(prog-mode . display-line-numbers-mode)
(after-init . line-number-mode))
:custom
(yank-excluded-properties t)
(blink-matching-delay 0)
(blink-matching-paren t)
(copy-region-blink-delay 0)
(shell-command-default-error-buffer "*Shell Command Errors*")
:config
(defun overwrite-mode-set-cursor-shape ()
(when (display-graphic-p)
(setq cursor-type (if overwrite-mode 'hollow 'box))))
:preface
(unless (fboundp 'minibuffer-keyboard-quit)
(autoload #'minibuffer-keyboard-quit "delsel" nil t))
(define-advice keyboard-quit
(:around (quit) quit-current-context)
"Quit the current context.
When there is an active minibuffer and we are not inside it close
it. When we are inside the minibuffer use the regular
`minibuffer-keyboard-quit' which quits any active region before
exiting. When there is no minibuffer `keyboard-quit' unless we
are defining or executing a macro."
(if (active-minibuffer-window)
(if (minibufferp)
(minibuffer-keyboard-quit)
(abort-recursive-edit))
(unless (or defining-kbd-macro
executing-kbd-macro)
(funcall-interactively quit)))))
(use-package common-lisp-modes
:straight '(common-lisp-modes :type git :host gitlab :repo "andreyorst/common-lisp-modes.el"))
(use-package minibuffer
:hook (eval-expression-minibuffer-setup . common-lisp-modes-mode)
:bind ( :map minibuffer-inactive-mode-map
("<mouse-1>" . ignore))
:custom
(completion-styles '(partial-completion basic))
(read-buffer-completion-ignore-case t)
(read-file-name-completion-ignore-case t)
:custom-face
(completions-first-difference ((t (:inherit unspecified)))))
(use-package orderless
:ensure t
:custom
(completion-styles '(orderless basic))
(completion-category-overrides '((file (styles basic partial-completion))))
(orderless-matching-styles
'(orderless-literal
orderless-prefixes
orderless-initialism
orderless-regexp
orderless-flex)))
(use-package diminish
:config
(diminish 'whole-line-or-region-local-mode)
(diminish 'visual-line-mode))
(use-package bindings
:bind ( :map ctl-x-map
("DEL" . nil)
("C-d" . dired-jump))
:init
(setq mode-line-end-spaces nil))
(use-package frame
:requires seq
:bind (("C-z" . ignore)
("C-x C-z" . ignore)))
(use-package startup
:no-require
:custom
(inhibit-splash-screen t))
(use-package menu-bar
:unless (display-graphic-p)
:config
(menu-bar-mode -1))
(use-package tooltip
:when (window-system)
:custom
(tooltip-x-offset 0)
(tooltip-y-offset (line-pixel-height))
(tooltip-frame-parameters
`((name . "tooltip")
(internal-border-width . 2)
(border-width . 1)
(no-special-glyphs . t))))
(use-package uniquify
:defer t
:custom
(uniquify-buffer-name-style 'forward))
(use-package display-line-numbers
:hook (display-line-numbers-mode . toggle-hl-line)
:custom
(display-line-numbers-width 4)
(display-line-numbers-grow-only t)
(display-line-numbers-width-start t)
:config
(defun toggle-hl-line ()
(hl-line-mode (if display-line-numbers-mode 1 -1))))
(use-package pixel-scroll
:when (fboundp #'pixel-scroll-precision-mode)
:hook (after-init . pixel-scroll-precision-mode)
:custom
(scroll-margin 0))
(use-package paren
:hook (prog-mode . show-paren-mode))
(use-package vc-hooks
:defer t
:custom
(vc-follow-symlinks t))
(use-package eldoc
:delight eldoc-mode
:defer t
:custom
(eldoc-echo-area-use-multiline-p nil))
(use-package dired
:preface
(defun dired-back-to-top ()
"Jump to the top file in a Dired buffer."
(interactive)
(goto-char (point-min))
;; because the number of header lines varies depending on whether
;; mode info is shown or hidden, find the double-dot directory entry
;; and go forward one line -- heuristic, but will always work.
(search-forward "..")
(dired-next-line 1))
(defun dired-jump-to-bottom ()
"Jump to the last file in a Dired buffer."
(interactive)
(goto-char (point-max))
(dired-next-line -1))
(defun dired-home-directory ()
(interactive)
(dired (expand-file-name "~/")))
:commands
dired
dired-jump
dired-next-line
dired-up-directory
:bind (:map dired-mode-map
("-" . dired-up-directory)
("~" . dired-home-directory)
("E" . wdired-change-to-wdired-mode)
([remap beginning-of-buffer] . dired-back-to-top)
([remap end-of-buffer] . dired-jump-to-bottom))
:config
(setq insert-directory-program "gls"
dired-use-ls-dired t
dired-listing-switches "-lAXGh --group-directories-first --sort=extension"))
;; Dired extra font locking
(use-package diredfl
:after (dired)
:hook (dired-mode .diredfl-mode))
(use-package json-hs-extra
:after json
:hook (json-ts-mode . json-hs-extra-setup)
:preface
(defun json-hs-extra-create-overlays (overlay)
"Creates overlays for block beginning, hiding whitespace.
Sets OVERLAY `json-hs-extra-overlays' property to the list of created
overlays."
(let ((end (point)))
(save-excursion
(forward-sexp -1)
(when-let ((overlays (ov-regexp "{[[:space:]\n]*" (point) end)))
(mapc (lambda (ov) (overlay-put ov 'display "{")) overlays)
(overlay-put overlay 'json-hs-extra-overlays overlays)))))
(defun json-hs-extra-delete-overlays (fn overlay)
"Deletes overlays for block beginning created earlier.
Deletes overlays in the `json-hs-extra-overlays' property of OVERLAY,
created with `json-hs-extra-create-overlays'."
(mapc #'delete-overlay (overlay-get overlay 'json-hs-extra-overlays))
(funcall fn overlay))
(defun json-hs-extra-setup ()
"Special settings for JSON buffers."
(setq-local hs-block-start-regexp "\\(?:{[[:space:]\n]*\\|\\[\\)"
hs-set-up-overlay #'json-hs-extra-create-overlays))
(provide 'json-hs-extra)
:config
(advice-add 'delete-overlay :around #'json-hs-extra-delete-overlays))
(use-package help
:custom
(help-window-select t))
(use-package flycheck
:ensure t
:init (global-flycheck-mode)
:bind (:map flycheck-mode-map
("M-n" . flycheck-next-error)
("M-p" . flycheck-previous-error)))
(use-package flyspell
:ensure t
:when (or (executable-find "ispell")
(executable-find "aspell")
(executable-find "hunspell"))
:hook ((org-mode git-commit-mode markdown-mode) . flyspell-mode))
(use-package autorevert
:hook (after-init . global-auto-revert-mode))
(use-package outline
:hook (common-lisp-modes-mode . lisp-outline-minor-mode)
:delight outline-minor-mode
:custom
(outline-minor-mode-cycle t)
:preface
(defun lisp-outline-minor-mode ()
(setq-local outline-regexp "^;;;;*[[:space:]]\\w")
(outline-minor-mode)))
(use-package browse-url
:when (fboundp 'xwidget-webkit-browse-url)
:custom (browse-url-browser-function #'xwidget-webkit-browse-url))
(use-package centered-window :ensure t)
(use-package repeat
:hook (after-init . repeat-mode))
;; TODO Document on this further, possibly disable LSP on very long files
(use-package so-long
:init (global-so-long-mode 1))
;;; Completion
(use-package vertico
:ensure t
:custom
(vertico-count 20) ; Number of candidates to display
(vertico-cycle t) ; Go from last to first candidate and first to last (cycle)?
(vertico-resize t)
:bind ( :map vertico-map
("M-RET" . vertico-exit-input))
:hook (after-init . vertico-mode))
(use-package vertico-directory
:after vertico
:bind ( :map vertico-map
("RET" . vertico-directory-enter)
("DEL" . vertico-directory-delete-char)
("M-DEL" . vertico-directory-delete-word))
:hook (rfn-eshadow-update-overlay . vertico-directory-tidy))
(use-package marginalia
:ensure t
:hook (after-init . marginalia-mode))
(use-package all-the-icons
:ensure all-the-icons)
(use-package all-the-icons-completion
:ensure all-the-icons-completion
:after (marginalia all-the-icons)
:functions
all-the-icons-completion-mode
:hook
(marginalia-mode . all-the-icons-completion-marginalia-setup)
:init
(all-the-icons-completion-mode))
(use-package all-the-icons-dired
:ensure all-the-icons-dired
:hook (dired-mode . all-the-icons-dired-mode))
(use-package all-the-icons-ibuffer
:ensure all-the-icons-ibuffer
:after (ibuffer)
:functions
all-the-icons-ibuffer-mode
:config
(all-the-icons-ibuffer-mode 1))
;;; APHELEIA
;; auto-format different source code files extremely intelligently
;; https://github.com/radian-software/apheleia
(use-package apheleia
:ensure apheleia
:diminish "" ; Don't show in modeline
:defines
apheleia-formatters
apheleia-mode-alist
:functions
apheleia-global-mode
:config
(setf (alist-get 'shfmt apheleia-formatters)
'("shfmt" "-i=4" "-sr" "-kp"))
(setq apheleia-log-debug-info nil)
;; https://git.genehack.net/os/emacs/issues/2
(setf (alist-get 'prettier-json apheleia-formatters)
'("prettier" "--stdin-filepath" filepath))
(setf (alist-get 'standard-clojure apheleia-formatters)
'("standard-clj" "fix" "-"))
(setf (alist-get 'python-mode apheleia-mode-alist) 'ruff)
(setf (alist-get 'clojure-mode apheleia-mode-alist) 'standard-clojure)
(setf (alist-get 'clojurec-mode apheleia-mode-alist) 'standard-clojure)
(setf (alist-get 'clojurescript-mode apheleia-mode-alist) 'standard-clojure)
(apheleia-global-mode +1))
(use-package corfu
:ensure t
;; Optional customizations
:custom
(corfu-cycle t) ; Allows cycling through candidates
(corfu-auto t) ; Enable auto completion
(corfu-auto-prefix 2) ; Minimum length of prefix for completion
(corfu-auto-delay 0) ; No delay for completion
(corfu-popupinfo-delay '(0.5 . 0.2)) ; Automatically update info popup after that numver of seconds
(corfu-preview-current 'insert) ; insert previewed candidate
(corfu-preselect 'prompt)
(corfu-on-exact-match nil) ; Don't auto expand tempel snippets
(tab-always-indent 'complete) ; First try to indent and then complete
;; Optionally use TAB for cycling, default is `corfu-complete'.
:bind (:map corfu-map
("TAB" . corfu-next)
([tab] . corfu-next)
("S-TAB" . corfu-previous)
([backtab] . corfu-previous)
([remap completion-at-point] . corfu-complete)
("RET" . corfu-complete-and-quit)
("<return>" . corfu-complete-and-quit))
:init
(global-corfu-mode)
(corfu-history-mode)
(corfu-popupinfo-mode) ; Popup completion info
:config
(defun corfu-complete-and-quit ()
(interactive)
(corfu-complete)
(corfu-quit))
(add-hook 'eshell-mode-hook
(lambda () (setq-local corfu-quit-at-boundary t
corfu-quit-no-match t
corfu-auto nil)
(corfu-mode))
nil
t))
(use-package corfu-popupinfo
:bind ( :map corfu-popupinfo-map
("M-p" . corfu-popupinfo-scroll-down)
("M-n" . corfu-popupinfo-scroll-up))
:hook (corfu-mode . corfu-popupinfo-mode)
:custom-face
(corfu-popupinfo ((t :height 1.0))))
(use-package kind-icon
:ensure kind-icon
:after (corfu)
:defines
corfu-margin-formatters ;; this is a lie
:functions
kind-icon-margin-formatter
:custom
(kind-icon-use-icons t)
(kind-icon-default-face 'corfu-default) ; Have background color be the same as `corfu' face background
(kind-icon-blend-background nil) ; Use midpoint color between foreground and background colors ("blended")?
(kind-icon-blend-frac 0.08)
:config
(add-to-list 'corfu-margin-formatters #'kind-icon-margin-formatter))
(use-package corfu-terminal
:ensure t
:unless (display-graphic-p)
:commands (corfu-terminal-mode)
:hook (after-init . corfu-terminal-mode))
(use-package cape
:ensure t
:after corfu
:config
(setq completion-at-point-functions '(cape-file)))
(use-package ov
:ensure t
:commands (ov-regexp))
(use-package consult
:ensure t
:defines
consult-customize
;; Replace bindings. Lazily loaded due by `use-package'.
:bind (;; C-c bindings in `mode-specific-map'
("C-c M-x" . consult-mode-command)
("C-c h" . consult-history)
("C-c k" . consult-kmacro)
("C-c m" . consult-man)
("C-c i" . consult-info)
([remap Info-search] . consult-info)
;; C-x bindings in `ctl-x-map'
("C-x M-:" . consult-complex-command) ;; orig. repeat-complex-command
("C-x b" . consult-buffer) ;; orig. switch-to-buffer
("C-x 4 b" . consult-buffer-other-window) ;; orig. switch-to-buffer-other-window
("C-x 5 b" . consult-buffer-other-frame) ;; orig. switch-to-buffer-other-frame
("C-x t b" . consult-buffer-other-tab) ;; orig. switch-to-buffer-other-tab
("C-x r b" . consult-bookmark) ;; orig. bookmark-jump
;; Custom M-# bindings for fast register access
("M-#" . consult-register-load)
("M-'" . consult-register-store) ;; orig. abbrev-prefix-mark (unrelated)
("C-M-#" . consult-register)
;; Other custom bindings
("M-y" . consult-yank-pop) ;; orig. yank-pop
;; M-g bindings in `goto-map'
("M-g e" . consult-compile-error)
("M-g f" . consult-flymake) ;; Alternative: consult-flycheck
("M-g g" . consult-goto-line) ;; orig. goto-line
("M-g M-g" . consult-goto-line) ;; orig. goto-line
("M-g o" . consult-outline) ;; Alternative: consult-org-heading
("M-g m" . consult-mark)
("M-g k" . consult-global-mark)
("M-g i" . consult-imenu)
("M-g I" . consult-imenu-multi)
;; M-s bindings in `search-map'
("M-s d" . consult-find) ;; Alternative: consult-fd
("M-s c" . consult-locate)
("M-s g" . consult-grep)
("M-s G" . consult-git-grep)
("M-s r" . consult-ripgrep)
("M-s l" . consult-line)
("M-s L" . consult-line-multi)
("M-s k" . consult-keep-lines)
("M-s u" . consult-focus-lines)
;; Isearch integration
("M-s e" . consult-isearch-history)
:map isearch-mode-map
("M-e" . consult-isearch-history) ;; orig. isearch-edit-string
("M-s e" . consult-isearch-history) ;; orig. isearch-edit-string
("M-s l" . consult-line) ;; needed by consult-line to detect isearch
("M-s L" . consult-line-multi) ;; needed by consult-line to detect isearch
;; Minibuffer history
:map minibuffer-local-map
("M-s" . consult-history) ;; orig. next-matching-history-element
("M-r" . consult-history)) ;; orig. previous-matching-history-element
;; Enable automatic preview at point in the *Completions* buffer. This is
;; relevant when you use the default completion UI.
:hook (completion-list-mode . consult-preview-at-point-mode)
;; The :init configuration is always executed (Not lazy)
:init
;; Optionally configure the register formatting. This improves the register
;; preview for `consult-register', `consult-register-load',
;; `consult-register-store' and the Emacs built-ins.
(setq register-preview-delay 0.5
register-preview-function #'consult-register-format)
;; Optionally tweak the register preview window.
;; This adds thin lines, sorting and hides the mode line of the window.
(advice-add #'register-preview :override #'consult-register-window)
;; Use Consult to select xref locations with preview
(setq xref-show-xrefs-function #'consult-xref
xref-show-definitions-function #'consult-xref)
;; Configure other variables and modes in the :config section,
;; after lazily loading the package.
:config
;; Optionally configure preview. The default value
;; is 'any, such that any key triggers the preview.
;; (setq consult-preview-key 'any)
;; (setq consult-preview-key "M-.")
;; (setq consult-preview-key '("S-<down>" "S-<up>"))
;; For some commands and buffer sources it is useful to configure the
;; :preview-key on a per-command basis using the `consult-customize' macro.
(consult-customize
consult-theme :preview-key '(:debounce 0.2 any)
consult-ripgrep consult-git-grep consult-grep
consult-bookmark consult-recent-file consult-xref
consult--source-bookmark consult--source-file-register
consult--source-recent-file consult--source-project-recent-file
;; :preview-key "M-."
:preview-key '(:debounce 0.4 any))
;; Optionally configure the narrowing key.
;; Both < and C-+ work reasonably well.
(setq consult-narrow-key "<") ;; "C-+"
;; Optionally make narrowing help available in the minibuffer.
;; You may want to use `embark-prefix-help-command' or which-key instead.
;; (define-key consult-narrow-map (vconcat consult-narrow-key "?") #'consult-narrow-help)
;; By default `consult-project-function' uses `project-root' from project.el.
;; Optionally configure a different project root function.
;;;; 1. project.el (the default)
;; (setq consult-project-function #'consult--default-project--function)
;;;; 2. vc.el (vc-root-dir)
;; (setq consult-project-function (lambda (_) (vc-root-dir)))
;;;; 3. locate-dominating-file
;; (setq consult-project-function (lambda (_) (locate-dominating-file "." ".git")))
;;;; 4. projectile.el (projectile-project-root)
;; (autoload 'projectile-project-root "projectile")
;; (setq consult-project-function (lambda (_) (projectile-project-root)))
;;;; 5. No project support
;; (setq consult-project-function nil)
)
(use-package which-key
:ensure which-key
:diminish
:functions
which-key-mode
:config
(which-key-mode))
;;; Org
(use-package org
:hook ((org-babel-after-execute . org-redisplay-inline-images))
:bind ( :map org-mode-map
("C-c l" . org-store-link))
:custom-face
(org-block ((t (:extend t))))
(org-block-begin-line
((t ( :slant unspecified
:weight normal
:background unspecified
:inherit (org-block shadow)
:extend t))))
(org-block-end-line
((t ( :slant unspecified
:weight normal
:background unspecified
:inherit org-block-begin-line
:extend t))))
(org-drawer ((t (:foreground unspecified :inherit shadow))))
:custom
(org-tags-column -120)
(org-startup-folded 'content)
(org-highlight-latex-and-related '(latex))
(org-preview-latex-default-process 'dvisvgm)
(org-src-fontify-natively t)
(org-preview-latex-image-directory ".ltximg/")
(org-confirm-babel-evaluate nil)
(org-log-done 'time)
(org-image-actual-width nil)
(org-edit-src-content-indentation 0)
(org-src-preserve-indentation t)
:config
(defun org-babel-edit-prep:emacs-lisp (_)
"Setup Emacs Lisp buffer for Org Babel."
(setq lexical-binding t))
(unless (version<= org-version "9.1.9")
(add-to-list 'org-modules 'org-tempo)))
(use-package ob-shell :after org)
(use-package org-capture
:bind ( :map mode-specific-map
("o c" . org-capture)))
(use-package ol
:after org-capture
:functions (org-link-set-parameters)
:preface
(defun blog-follow-html-link (path arg)
(funcall browse-url-browser-function path arg))
(defun blog-export-hmtl-link (path description _backend _properties)
"Export link directly to HTML."
(format "<a href=\"%s\">%s</a>" path (or description path)))
(defun blog-create-html-link (&optional _)
"Create a file link using completion."
(let ((link (read-string "Link: ")))
(concat "blog-html:" link)))
:config
(org-link-set-parameters
"org"
:export #'blog-export-static-org-link
:complete #'blog-create-static-org-link)
(org-link-set-parameters
"blog-html"
:follow #'blog-follow-html-link
:export #'blog-export-hmtl-link
:complete #'blog-create-html-link))
(use-package ox-hugo
:ensure t
:after ox
:preface
(declare-function org-export-data "ext:ox")
(declare-function org-export-get-node-property "ext:ox")
(define-advice org-hugo-heading (:around (fn heading contents info) patch)
(if (and (org-export-get-node-property :BLOG-COLLAPSABLE heading) (not (string-empty-p contents)))
(let ((title (org-export-data (org-element-property :title heading) info)))
(concat "<details class=\"foldlist\"><summary>" title
"</summary><div class=\"foldlistdata\">\n\n"
contents
"</div></details>"))
(funcall fn heading contents info))))
(use-package ox-latex
:after ox)
(use-package epresent
:ensure t
:custom
(epresent-text-scale 200)
(epresent-format-latex-scale 2)
:hook
(epresent-start-presentation . epresent-setup)
:preface
(defun epresent-setup ()
(interactive)
(visual-line-mode 1)
(flyspell-mode -1)