-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.el
971 lines (848 loc) · 38.4 KB
/
config.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
;;; $DOOMDIR/config.el -*- lexical-binding: t; -*-
;; ____________________________________________________________________________
;;; FRAMES
;; Initial frame placement
(pushnew! initial-frame-alist
'(fullscreen . maximized))
;; Default frame placement
(pushnew! default-frame-alist
'(width . 90)
'(height . 50)
'(left . 940)
'(top . 0))
;; Bring frame to the front
(select-frame-set-input-focus (selected-frame))
;; ____________________________________________________________________________
;;; FONTS
(setq! doom-font
(font-spec :family "Iosevka Dee" :size 16 :weight 'normal)
doom-serif-font
(font-spec :family "Iosevka Dee Slab" :size 16 :weight 'normal)
doom-variable-pitch-font
(font-spec :family "ETBembo" :size 18 :weight 'normal))
;; ____________________________________________________________________________
;;; THEMES
;; Modus theme settings
(use-package! modus-themes
:config
(setq modus-themes-bold-constructs t
modus-themes-italic-constructs nil
modus-themes-mixed-fonts t)
(setq modus-themes-common-palette-overrides
'((border-mode-line-active unspecified)
(border-mode-line-inactive unspecified)))
(setq modus-operandi-tinted-palette-overrides
modus-themes-preset-overrides-warmer)
(setq modus-vivendi-tinted-palette-overrides
modus-themes-preset-overrides-warmer))
;; Do not extend `region' background past the end of the line
(custom-set-faces
'(region ((t :extend nil))))
;;; - Set light/dark theme:
(setq my-theme-light 'modus-operandi-tinted)
(setq my-theme-dark 'modus-vivendi-tinted)
;; Switch between dark/light theme based on the system appearance
;; <https://github.com/d12frosted/homebrew-emacs-plus?tab=readme-ov-file#system-appearance-change>
(defun my-apply-theme (appearance)
"Load theme, taking current system APPEARANCE into consideration."
(mapc #'disable-theme custom-enabled-themes)
(setq! doom-theme
(pcase appearance
('light (load-theme my-theme-light t)
;; Global variable will be used as an argument to launch emacsclient frames
(doom/set-frame-opacity (setq my-frame-opacity 100))
;; Eventually return theme name to set `doom-theme'
my-theme-light)
('dark (load-theme my-theme-dark t)
;; Global variable will be used as an argument to launch emacsclient frames
(doom/set-frame-opacity (setq my-frame-opacity 80))
;; Eventually return theme name to set `doom-theme'
my-theme-dark))))
(add-hook! 'ns-system-appearance-change-functions #'my-apply-theme)
;; BUG Fix for https://github.com/doomemacs/doomemacs/issues/6720
(after! diff-hl
(add-hook! 'doom-load-theme-hook
(defun +vc-gutter-make-diff-hl-faces-transparent-h ()
(mapc (doom-rpartial #'set-face-background (face-background 'default))
'(diff-hl-insert
diff-hl-delete
diff-hl-change)))))
;; ____________________________________________________________________________
;;; KEYBINDINGS
(setq! doom-leader-key "SPC"
doom-leader-alt-key "M-SPC"
doom-localleader-key ","
doom-localleader-alt-key "M-SPC ,")
(map! :leader
;; doom-leader-map
:desc nil ":" nil ; M-x
:desc nil "<" nil ; Switch buffer
:desc nil "X" nil ; Org capture
:desc nil "`" nil ; Switch to last buffer
:desc nil "~" nil ; Toggle last popup
:desc "Toggle popups" "`" #'+popup/toggle
:desc "Directories" "d" #'consult-dir
:desc "Command" "m" #'execute-extended-command
:desc "Complex command" "M" #'consult-complex-command
:desc "Switch buffer" "," #'switch-to-buffer
:desc "Previous window" "j" #'evil-window-mru
:desc "Lisp" "l" #'sly
:desc "Eshell" "e" #'+eshell/toggle
:desc "IEx" "r" #'inf-elixir-run
:desc "Vertical split" "V" #'+evil/window-vsplit-and-follow
:desc "Horizontal split" "S" #'+evil/window-split-and-follow
;; doom-leader-buffer-map
:desc "Kill buffer and window" "b D" #'kill-buffer-and-window
;; doom-leader-file-map
:desc nil "f l" nil ; Locate file
;; doom-leader-open-map
:desc "Browse URL" "o w" #'browse-url
:desc "Browse URL external" "o W" #'browse-url-default-macosx-browser
:desc "Browse URL in Webkit" "o C-w" #'xwidget-webkit-browse-url
;; doom-leader-search-map
:desc "Find file at point" "s f" #'ffap
;; evil-window-map
:desc nil "w `" #'+popup/raise
:desc nil "w ~" #'+popup/buffer
)
;; . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
;;; - MacOS
;; Make the <Command> key on MacOS act as <Ctrl> key: "C- ..."
(setq! mac-command-modifier 'control)
;; Make the <Option> key on MacOS act as <Meta> key for "M- ..."
;; (setq! mac-option-modifier 'meta)
;; . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
;;; - Swap keys
;; <https://github.com/wbolster/evil-swap-keys>
(use-package! evil-swap-keys
:config
(global-evil-swap-keys-mode 1)
;; Shift number keys in all Evil states for any buffer type
(setq-hook! 'evil-local-mode-hook
evil-swap-keys-text-input-states
'(emacs insert replace visual normal motion operator operator-pending hyvbrid global surround next previous nil))
(add-hook! 'evil-local-mode-hook
#'evil-swap-keys-swap-number-row))
;; . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
;;; - Which-key
(after! which-key
(setq! which-key-idle-delay 0.4
which-key-idle-secondary-delay 0.01))
;; ____________________________________________________________________________
;;; SHELLS
(defvar my-shell (executable-find "fish"))
(setq! explicit-shell-file-name my-shell)
;; Use a Posix shell under the hood to avoid problems wherever Emacs (or Emacs
;; packages) spawn child processes via shell commands and rely on their output
(setq! shell-file-name (or (executable-find "bash")
(executable-find "dash")
(executable-find "zsh")
(executable-find "sh")))
;; . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
;;; - Eshell
(after! eshell
(setq! eshell-scroll-to-bottom-on-output nil)
(setq eshell-list-files-after-cd t)
(setq! eshell-term-name "xterm-256color")
(set-eshell-alias!
"q" "exit"
"l" "ls $*"
"la" "ls -A $*"
"ll" "ls -lh $*"
"lla" "ls -lhA $*"
"lt" "eza -T --icons $*"
"lat" "eza -AT --icons $*"
"llt" "eza -lT --icons $*"
"llat" "eza -lAT --icons $*"
"up" "eshell-up $1"
"cdp" "cd-to-project"
"mkdir" "mkdir -p $*"
"tr" "trash $*"
;; Emacs commands
"f" "find-file $1"
"fo" "find-file-other-window $1"
"d" "dired $1"
"do" "dired-other-window $1"
"g" "magit-status"
"doomS" "doom sync --gc --aot"
"doomU" "doom upgrade --aot"
"doomR" "doom/restart"
;; Adblocker
"hblock-off" "hblock -S none -D none"
;; Git
"git" "git --no-pager $*"
;; Tar archives
"targ" "tar cfvz $*"
"targx" "tar xfvz $*"
"tarb" "tar cfvj $*"
"tarbx" "tar xfvj $*"
;; Lisp
"lisp" "rlwrap ros -Q run $*"
"lisp-swank" "rlwrap ros -Q run --eval \"(ql:quickload :swank)\" --eval \"(swank:create-server :dont-close t)\""
;; macOS
"app-unblock" "sudo xattr -d com.apple.quarantine $*"
"app-clear" "sudo xattr -crv $*"
"app-sign" "sudo codesign --force --deep --sign - $*"
;; Homebrew
"brewup" "brew update && brew upgrade"
"brewu" "brew update"
;; Apt-get
"pacu" "sudo apt-get update"
"pacup" "sudo apt-get update && sudo apt-get upgrade"
"pacupd" "sudo apt-get dist-upgrade"
"pacs" "apt-cache search $*"
"pacinfo" "apt-cache show $*"
"paci" "sudo apt-get install --no-install-recommends $*"
"pacli" "apt list --installed"
"paclig" "apt list --installed | grep $*"
"pacmark" "sudo apt-mark $*"
"pacr" "sudo apt-get remove --purge $*"
"pacar" "sudo apt-get autoremove --purge $*"
;; Guix
"guixup" "guix pull && guix package -u"
;; Nix
"nixup" "nix-channel --update nixpkgs && nix-env -u '*'"
;; Too small /tmp directory
"resizetmp" "sudo mount -o remount,size=8G,noatime /tmp"))
;; . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
;;; - Vterm
(after! vterm
(setq! vterm-shell my-shell))
;; ____________________________________________________________________________
;;; WINDOW MANAGEMENT
;; <https://github.com/dimitri/switch-window>
(after! switch-window
(setq! switch-window-background nil)
(setq! switch-window-multiple-frames t)
(setq! switch-window-threshold 1)
(setq! switch-window-mvborder-increment 1)
;; Vim-like keybindings for window resizing
(setq! switch-window-extra-map
(let ((map (make-sparse-keymap)))
(define-key map (kbd "k") #'switch-window-mvborder-up)
(define-key map (kbd "j") #'switch-window-mvborder-down)
(define-key map (kbd "h") #'switch-window-mvborder-left)
(define-key map (kbd "l") #'switch-window-mvborder-right)
(define-key map (kbd "=") #'balance-windows)
(define-key map (kbd "SPC") #'switch-window-resume-auto-resize-window)
map))
(setq! switch-window-minibuffer-shortcut 109) ; "m"
(setq! switch-window-qwerty-shortcuts
'("a" "s" "d" "f" "g"
"q" "w" "e" "r" "t" "y"
"u" "i" "o" "p"
"z" "x" "c" "v"
"b" "n"))
(set-face-attribute 'switch-window-background nil
:inherit 'shadow)
;; Bind `switch-window' commands to regular Emacs keybindings
;; TODO Set up Evil equivalents and replace some default Doom bindings
(map! :map switch-window-mode-map
:e "C-x o" #'switch-window
:e "C-x 1" #'switch-window-then-maximize
:e "C-x 2" #'switch-window-then-split-below
:e "C-x 3" #'switch-window-then-split-right
:e "C-x 0" #'switch-window-then-delete
:e "C-x 4 0" #'switch-window-then-kill-buffer
:e "C-x 4 d" #'switch-window-then-dired
:e "C-x 4 f" #'switch-window-then-find-file
:e "C-x 4 b" #'switch-window-then-display-buffer
:e "C-x 4 s" #'switch-window-then-swap-buffer))
(after! ace-window
(setq! aw-keys '(?a ?s ?d ?f ?g
?q ?w ?r ?t ?y
?i ?p))
(setq! aw-scope 'global)
(setq! ace-window-display-mode 1
aw-display-mode-overlay nil)
(set-face-attribute 'aw-background-face nil
:inherit 'shadow))
;; . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
;;; - Popup windows
;; Adjust defaults
;; (plist-put +popup-defaults :height 0.3)
;; Make `other-window' work on popup-windows too
(setq! +popup-default-parameters
(remove '(no-other-window . t) +popup-default-parameters))
;; Make Eglot help windows higher
(after! eglot
(set-popup-rule! "^\\*eglot-help" :size 0.42 :quit t :select t))
;; Further popup adjustments
(set-popup-rules!
'(("^\\*Customize" :slot 2 :side bottom :size 0.5 :select t :quit nil)
("^\\*\\([Hh]elp\\|Apropos\\)" :slot 2 :vslot -8 :size 0.42 :select t)
("^\\*eww\\*" :vslot -11 :size 0.35 :select t)
("^\\*info\\*$" :slot 2 :vslot 2 :size 0.45 :select t)))
;; ____________________________________________________________________________
;;; MINIBUFFER
;; <https://www.gnu.org/software/emacs/manual/html_mono/emacs.html#Minibuffer>
;; Show the depth of recursive minibuffers?
(minibuffer-depth-indicate-mode 1)
;; Delete duplicates from the command history
(setq! history-delete-duplicates t)
;; Modal editing in the minibuffer
(setq! evil-collection-setup-minibuffer t)
;; ____________________________________________________________________________
;;; MISC UI
(after! vertico
(setq! vertico-cycle nil))
(after! hl-line
(setq! hl-line-sticky-flag nil)
(setq! global-hl-line-modes '(text-mode
special-mode
org-agenda-mode
dired-mode)))
;; Don't hide mode-line
(after! hide-mode-line
(advice-add #'hide-mode-line-mode :around
(lambda (orig &optional args) nil)))
;; ____________________________________________________________________________
;;; BUFFER MANAGEMENT
(setq! initial-major-mode #'lisp-interaction-mode)
(after! ibuffer
(add-hook! 'ibuffer-mode-hook #'ibuffer-auto-mode))
;; Kill all buffers at once
(defun my-kill-all-buffers ()
"Really kill all buffers at once."
(interactive)
(save-some-buffers)
(let ((kill-buffer-query-functions '()))
(mapc #'kill-buffer (buffer-list))))
;; ____________________________________________________________________________
;;; ELDOC
;; <https://www.gnu.org/software/emacs/manual/html_mono/emacs.html#Lisp-Doc>
;; <https://www.masteringemacs.org/article/seamlessly-merge-multiple-documentation-sources-eldoc>
(setq! eldoc-minor-mode-string nil
eldoc-documentation-strategy 'eldoc-documentation-compose-eagerly
eldoc-echo-area-display-truncation-message nil
eldoc-echo-area-prefer-doc-buffer nil
eldoc-echo-area-use-multiline-p 'truncate-sym-name-if-fit)
;; ____________________________________________________________________________
;;; RECENT FILES
(after! recentf
;; Exclude certain files
(add-to-list 'recentf-exclude
(expand-file-name
(concat doom-emacs-dir ".local/etc/workspaces/autosave"))))
;; ____________________________________________________________________________
;;; BACKUP
;; <https://www.gnu.org/software/emacs/manual/html_mono/emacs.html#Backup>
;; Make backup before saving files
(setq! make-backup-files t)
;; Specify file name/path patterns and directories ("REGEXP" . "DIRECTORY")
(setq! backup-directory-alist
`(("." . ,(concat (getenv "HOME") "/Documents/backup/emacs/"))))
;; ____________________________________________________________________________
;;; COMINT
(after! comint
(setq! comint-input-ignoredups t
comint-scroll-to-bottom-on-input 'this))
;; ____________________________________________________________________________
;;; DIRED
;; <https://www.gnu.org/software/emacs/manual/html_mono/emacs.html#Dired>
(after! dired
;; Listing columns; Switch arguments with "C-u s" e.g. hide backups with -B
(setq! dired-listing-switches "-lhFA -v --group-directories-first")
;; (setq! dired-kill-when-opening-new-dired-buffer t)
(add-hook! 'dired-mode-hook
#'dired-hide-details-mode
#'dired-omit-mode
(setq! dired-omit-files "\\`[.]?#\\|\\`[.][.]?\\'\\|^\\."))
(map! :localleader :mode dired-mode
:n "d" #'dired-hide-details-mode)
;; BUG <https://github.com/doomemacs/doomemacs/issues/8170>
(defun reset-cursor-after-wdired-exit ()
"Restore the evil-normal-state-cursor to 'box' after exiting Editable Dired."
(kill-local-variable 'evil-normal-state-cursor)
(kill-local-variable 'cursor-type)
(setq evil-normal-state-cursor 'box)
(setq cursor-type 'box))
(advice-add 'wdired-finish-edit :after #'reset-cursor-after-wdired-exit) ;; ZZ
(advice-add 'wdired-abort-changes :after #'reset-cursor-after-wdired-exit) ;; ZQ
(advice-add 'evil-force-normal-state :after #'reset-cursor-after-wdired-exit)) ;; ESC
;; ____________________________________________________________________________
;;; CALENDAR
;; <https://www.gnu.org/software/emacs/manual/html_mono/emacs.html#Calendar_002fDiary>
(setq! calendar-date-style 'iso
calendar-week-start-day 1
calendar-weekend-days '(6 0))
;; ____________________________________________________________________________
;;; UTILITIES
;; Show and manage OS processes
(setq! proced-auto-update-interval 1
proced-auto-update-flag t
proced-enable-color-flag t
proced-descend t)
;; ____________________________________________________________________________
;;; WEB BROWSERS
;; <https://www.gnu.org/software/emacs/manual/html_mono/eww.html#Top>
(setq! url-privacy-level '(email lastloc cookies))
(url-setup-privacy-info)
(defun my-user-agent (browser-name)
;; TODO: make user-agent selection interactive
(cond
((equal browser-name 'safari-macos)
(setq! url-user-agent
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/603.3.8 (KHTML, like Gecko) Version/11.0.1 Safari/603.3.8"))
((equal browser-name 'safari-iphone)
(setq! url-user-agent
"Mozilla/5.0 (iPhone; CPU iPhone OS 18_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.2 Mobile/15E148 Safari/604.1"))
((equal browser-name 'w3m)
(setq! url-user-agent
"w3m/0.5.3+git2020050"))
(t
(setq! url-user-agent
'default))))
;; Set the user agent for the internal web browser
(my-user-agent 'safari-iphone)
;; Default system browser
(setq! browse-url-browser-function #'eww-browse-url)
;; Secondary web browser
(setq! browse-url-secondary-browser-function #'browse-url-default-browser)
;; ____________________________________________________________________________
;;; PDF-TOOLS
(after! pdf-tools
;; Compile without asking
(pdf-tools-install :no-query))
;; ____________________________________________________________________________
;;; ORG
(after! org
(setq! org-directory "~/Documents/org/")
(setq! org-hide-leading-stars nil))
;; <https://github.com/alphapapa/org-sticky-header>
(use-package! org-sticky-header
:after org
:config
(add-hook! 'org-mode-hook #'org-sticky-header-mode))
;; ____________________________________________________________________________
;;; EDITING / PROGRAMMING
;; . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
;;; - Tree-Sitter text objects
(map! (:map +tree-sitter-outer-text-objects-map
;; Use 'm' like "module" instead
"m" (evil-textobj-tree-sitter-get-textobj "class.outer"))
(:map +tree-sitter-inner-text-objects-map
;; Use 'm' like "module" instead
"m" (evil-textobj-tree-sitter-get-textobj "class.inner")))
;; . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
;;; - Kill-ring, yanking, copy & paste
;; <https://github.com/NicholasBHubbard/clean-kill-ring.el>
(use-package! clean-kill-ring
:config
(clean-kill-ring-mode 1))
;; . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
;;; - Parenthesis
;; Highlight enclosing parens, or whole expressions?
(setq! show-paren-style 'parenthesis)
;; Color-code nested parens
;; <https://github.com/Fanael/rainbow-delimiters>
(add-hook! '(prog-mode-hook conf-mode-hook)
#'rainbow-delimiters-mode)
;; Structural editing: Lispyville
;; <https://oremacs.com/lispy>
;; <https://github.com/abo-abo/lispy>
(after! (lispy lispyville)
(map! :map lispy-mode-map-lispy
;; Unbind individual bracket keys
"[" nil
"]" nil
;; Re-bind commands bound to bracket keys by default
"M-[" #'lispyville-previous-opening
"M-]" #'lispyville-next-opening))
;; Structural editing: Smartparens
;; <https://github.com/Fuco1/smartparens>
;; <https://smartparens.readthedocs.io/en/latest/>
(after! smartparens
(setq! show-smartparens-global-mode t)
;; Custom keybinding set, a blend of standard Emacs sexp keybindings
;; and Paredit keybindings
;; (map! :map smartparens-mode-map
;; ;; Navigation
;; "C-M-f" #'sp-forward-sexp
;; "C-M-b" #'sp-backward-sexp
;; "C-M-u" #'sp-backward-up-sexp
;; "C-M-d" #'sp-down-sexp
;; "C-M-p" #'sp-backward-down-sexp
;; "C-M-n" #'sp-up-sexp
;; "C-M-a" #'sp-beginning-of-sexp
;; "C-M-e" #'sp-end-of-sexp
;; ;; Depth-changing commands
;; "C-M-g" #'sp-unwrap-sexp
;; "C-M-s" #'sp-splice-sexp
;; ;; Forward slurp/barf
;; "C-)" #'sp-forward-slurp-sexp
;; "C-}" #'sp-forward-barf-sexp
;; ;; Backward slurp/barf
;; "C-(" #'sp-backward-slurp-sexp
;; "C-{" #'sp-backward-barf-sexp
;; ;; Misc
;; "C-M-k" #'sp-kill-sexp
;; "C-M-<backspace>" #'sp-backward-kill-sexp
;; "C-M-SPC" #'sp-mark-sexp
;; "C-M-w" #'sp-copy-sexp
;; "C-M-t" #'sp-transpose-sexp
;; "M-(" #'sp-wrap-round)
)
;; . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
;;; - Line numbers
(setq! display-line-numbers-type 'relative)
(remove-hook! '(prog-mode-hook text-mode-hook conf-mode-hook)
#'display-line-numbers-mode)
;; . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
;;; - Indentation
;; Delete the whole indentation instead spaces one-by-one via <backspace>?
;; (Possibly shadowed by 3rd-party packages like 'smartparens-mode'
(setq! backward-delete-char-untabify-method 'all)
;; <https://github.com/Malabarba/aggressive-indent-mode>
(use-package! aggressive-indent
:config
(global-aggressive-indent-mode 1))
;; Indentation guides
(after! indent-bars
(setq! indent-bars-no-descend-lists nil
indent-bars-highlight-current-depth '(:face fringe)
indent-bars-display-on-blank-lines t)
(remove-hook! 'text-mode-hook
#'indent-bars-mode))
;; . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
;;; - Searching
;; TODO: Add keybindings for search and replace
;; The 'query-' variant asks with each string. Confirm with "SPC",
;; or omit the current selection via "n"
;; . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
;;; - Comments
(after! newcomment
(setq! comment-empty-lines t))
;; ____________________________________________________________________________
;;; LISP
(defun my-lisp-src-modes ()
"Generates a non-exhaustive list of loaded Lisp-related modes.
Entries are derived from the smartparens package"
(seq-filter #'fboundp '(clojure-mode
clojurec-mode
clojurescript-mode
clojurex-mode
clojure-ts-mode
clojurescript-ts-mode
clojurec-ts-mode
common-lisp-mode
emacs-lisp-mode
fennel-mode
gerbil-mode
lfe-mode ; addition
lisp-mode
lisp-data-mode ; addition
racket-mode
scheme-mode
stumpwm-mode
)))
(defun my-lisp-repl-modes ()
"Generates a non-exhaustive list of loaded Lisp-related REPLs.
Entries are derived from the smartparens package."
(seq-filter #'fboundp '(cider-repl-mode
eshell-mode
fennel-repl-mode
geiser-repl-mode
inf-clojure-mode
inferior-emacs-lisp-mode
inferior-lfe-mode ; addition
inferior-lisp-mode
inferior-scheme-mode
lisp-interaction-mode
monroe-mode
racket-repl-mode
scheme-interaction-mode
slime-repl-mode
sly-mrepl-mode
)))
;; . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
;;; - Elisp
(when (modulep! indent-guides)
(add-hook! 'emacs-lisp-mode-hook
(indent-bars-mode -1)))
(after! (lispy lispyville)
;; Making sure that the comment with the result is placed after the evaluated
;; expression, not inside it
(advice-add #'lispy-eval-and-comment
:around #'evil-collection-elisp-mode-last-sexp)
(map! :localleader
:map (emacs-lisp-mode-map lisp-interaction-mode-map)
:prefix "e"
:n "c" #'lispy-eval-and-comment))
;; . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
;;; - Common Lisp
;; <https://www.gnu.org/software/emacs/manual/html_mono/emacs.html#Executing-Lisp>
;; <http://joaotavora.github.io/sly/>
;; <https://github.com/joaotavora/sly>
;; Default Lisp implementation
(setq! inferior-lisp-program "ros -Q run")
(add-to-list '+lisp-quicklisp-paths "~/.roswell/lisp/quicklisp" 'append)
(when (modulep! indent-guides)
(add-hook! '(lisp-mode-hook lisp-data-mode-hook)
(indent-bars-mode -1)))
(after! sly
;; Set Sly Lisp implementations
(setq! sly-lisp-implementations
'((roswell ("ros" "-Q" "run"))
(sbcl ("ros" "-L" "sbcl" "-Q" "run") :coding-system utf-8-unix)
(ccl ("ros" "-L" "ccl-bin" "-Q" "run"))))
(setq! sly-default-lisp 'roswell
sly-command-switch-to-existing-lisp 'always
sly-complete-symbol-function #'sly-flex-completions)
(add-hook! 'sly-mrepl-mode-hook
#'rainbow-delimiters-mode)
(add-hook! 'sly-net-process-close-hooks
;; Switch to normal state when connection is closed
(when (string-match-p "^\\*sly-mrepl.*\\*" (buffer-name))
(evil-normal-state)))
;; Change some of Doom's default Common Lisp keybindings
(map! (:map sly-db-mode-map
:n "gr" #'sly-db-restart-frame)
(:map sly-inspector-mode-map
:n "gb" #'sly-inspector-pop
:n "gr" #'sly-inspector-reinspect
:n "gR" #'sly-inspector-fetch-all
:n "K" #'sly-inspector-describe-inspectee)
(:map sly-xref-mode-map
:n "gr" #'sly-recompile-xref
:n "gR" #'sly-recompile-all-xrefs)
(:map lisp-mode-map
:n "gb" #'sly-pop-find-definition-stack)
(:localleader
:map lisp-mode-map
:desc "Sly" "'" #'sly
:desc "Sly (ask)" ";" (cmd!! #'sly '-)
:desc "Expand macro" "m" #'macrostep-expand
:desc "Find file in Quicklisp" "f" #'+lisp/find-file-in-quicklisp
:desc "Quickload System" "q" #'sly-quickload
(:prefix "c" ; ("c" . "compile")
:desc "Compile toplevel form" "c" #'sly-compile-defun
:desc "Compile file" "C" nil ; #'sly-compile-file
:desc "Compile file" "f" #'sly-compile-file
:desc "Compile/load file" "F" nil ; #'sly-compile-and-load-file
:desc "Load file" "l" #'sly-load-file
:desc "Compile/load file" "L" #'sly-compile-and-load-file
:desc "Remove notes" "n" #'sly-remove-notes
:desc "Compile region" "r" #'sly-compile-region)
(:prefix "e" ; ("e" . "evaluate")
:desc "Evaluate buffer" "b" #'sly-eval-buffer
:desc "Evaluate defun" "d" #'sly-overlay-eval-defun
:desc "Evaluate last" "e" #'sly-eval-last-expression
:desc "Evaluate/print last" "E" #'sly-eval-print-last-expression
:desc "Evaluate defun (async)" "f" #'sly-eval-defun
:desc "Undefine function" "F" nil ; #'sly-undefine-function
:desc "Evaluate region" "r" #'sly-eval-region)
(:prefix ("u" . "undefine")
:desc "Undefine function" "f" #'sly-undefine-function
:desc "Unintern symbol" "s" #'sly-unintern-symbol)
(:prefix "g" ; ("g" . "goto")
:desc "Go back" "b" #'sly-pop-find-definition-stack
:desc "Go to" "d" #'sly-edit-definition
:desc "Go to (other window)" "D" #'sly-edit-definition-other-window
:desc "Next note" "n" #'sly-next-note
:desc "Previous note" "N" #'sly-previous-note
:desc "Next sticker" "s" #'sly-stickers-next-sticker
:desc "Previous sticker" "S" #'sly-stickers-prev-sticker)
(:prefix "h" ; ("h" . "help")
:desc "Who calls" "<" #'sly-who-calls
:desc "Calls who" ">" #'sly-calls-who
:desc "Lookup format directive" "~" #'hyperspec-lookup-format
:desc "Lookup reader macro" "#" #'hyperspec-lookup-reader-macro
:desc "Apropos" "a" #'sly-apropos
:desc "Who binds" "b" #'sly-who-binds
:desc "Disassemble symbol" "d" #'sly-disassemble-symbol
:desc "Describe symbol" "h" #'sly-describe-symbol
:desc "HyperSpec lookup" "H" #'sly-hyperspec-lookup
:desc "Who macro-expands" "m" #'sly-who-macroexpands
:desc "Apropos package" "p" #'sly-apropos-package
:desc "Who references" "r" #'sly-who-references
:desc "Who specializes" "s" #'sly-who-specializes
:desc "Who sets" "S" #'sly-who-sets)
(:prefix "r" ; ("r" . "repl")
:desc "Clear REPL" "c" #'sly-mrepl-clear-repl
:desc "Load System" "l" #'sly-asdf-load-system
:desc "Quit connection" "q" #'sly-quit-lisp
:desc "Restart connection" "r" #'sly-restart-inferior-lisp
:desc "Reload Project" "R" #'+lisp/reload-project
:desc "Sync REPL" "s" #'sly-mrepl-sync)
(:prefix "s" ; ("s" . "stickers")
:desc "Toggle breaking stickers" "b" #'sly-stickers-toggle-break-on-stickers
:desc "Clear defun stickers" "c" #'sly-stickers-clear-defun-stickers
:desc "Clear buffer stickers" "C" #'sly-stickers-clear-buffer-stickers
:desc "Fetch stickers" "f" #'sly-stickers-fetch
:desc "Replay stickers" "r" #'sly-stickers-replay
:desc "Add/remove sticker" "s" #'sly-stickers-dwim)
(:prefix "t" ; ("t" . "test")
:desc "Test system" "s" #'sly-asdf-test-system)
(:prefix "T" ; ("T" . "trace")
:desc "Toggle" "t" #'sly-toggle-trace-fdefinition
:desc "Toggle (fancy)" "T" #'sly-toggle-fancy-trace
:desc "Untrace all" "u" #'sly-untrace-all))))
;; The hyperspec must be installed first. Adapt the path below:
(after! hyperspec
(setq! common-lisp-hyperspec-root
(concat "file://"
(expand-file-name "~/common-lisp/.hyperspec/HyperSpec/")))
(setq! common-lisp-hyperspec-symbol-table
(concat common-lisp-hyperspec-root "Data/Map_Sym.txt"))
(setq! common-lisp-hyperspec-issuex-table
(concat common-lisp-hyperspec-root "Data/Map_IssX.txt")))
;; . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
;;; - RACKET
;; <https://www.racket-mode.com>
(after! racket-mode
(set-popup-rule! "^\\*Racket REPL" :size 0.3 :quit nil :ttl nil)
(set-popup-rule! "^\\*Racket Describe" :size 0.42 :quit t :select t)
(set-eval-handler! 'racket-mode #'racket-send-region)
(setq! racket-xp-eldoc-level 'minimal)
;; Make sure that the last character of the sexp is not cut off
(advice-add #'racket-send-last-sexp
:around #'evil-collection-elisp-mode-last-sexp)
(advice-add #'racket-expand-last-sexp
:around #'evil-collection-elisp-mode-last-sexp)
(when (modulep! indent-guides)
(add-hook! 'racket-mode-hook (indent-bars-mode -1)))
;; Change some of Doom's default Racket keybindings
(map! (:localleader
:map racket-mode-map
"a" #'racket-align
"A" #'racket-unalign
"f" #'racket-fold-all-tests
"F" #'racket-unfold-all-tests
"h" nil ; rebind to prefix "d", key "d"
"i" #'racket-unicode-input-method-enable
"l" #'racket-logger
"o" #'racket-profile
"p" #'racket-cycle-paren-shapes
"t" #'racket-test
"u" #'racket-backward-up-list
"y" #'racket-insert-lambda
"s" nil ; rebind to prefix "r", key "r"
"R" nil ; rebind to prefix "r", key "s"
(:prefix ("r" . "run")
"r" #'racket-run
"s" #'racket-run-and-switch-to-repl
"m" #'racket-run-module-at-point)
(:prefix ("m" . "macros")
"d" #'racket-expand-definition
"e" #'racket-expand-last-sexp
"r" #'racket-expand-region
"a" #'racket-expand-again)
(:prefix ("g" . "goto")
"b" #'racket-unvisit
"d" #'xref-find-definitions ; replace obsolete command
"m" #'racket-visit-module
"r" #'racket-open-require-path)
(:prefix ("e" . "eval")
"d" #'racket-send-definition
"e" #'racket-send-last-sexp
"r" #'racket-send-region)
(:prefix ("h" . "help")
"d" #'racket-xp-describe
"s" #'racket-describe-search
"[" #'racket-describe-back
"]" #'racket-describe-forward)
:map racket-repl-mode-map
"l" #'racket-logger
"h" nil ; rebind to "d"
"d" #'racket-repl-documentation
"y" #'racket-insert-lambda
"u" #'racket-backward-up-list
(:prefix ("m" . "macros")
"d" #'racket-expand-definition
"e" #'racket-expand-last-sexp
"f" #'racket-expand-file
"r" #'racket-expand-region)
(:prefix ("g" . "goto")
"b" #'racket-unvisit
"m" #'racket-visit-module
"d" #'racket-repl-visit-definition))))
;; ____________________________________________________________________________
;;; OCAML
(use-package! utop
:when (and (modulep! :lang ocaml) (modulep! :tools eval))
:config
(set-repl-handler! 'tuareg-mode #'utop)
(set-eval-handler! 'tuareg-mode #'utop-eval-region)
(set-popup-rule! "^\\*utop\\*" :size 0.3 :quit nil :ttl nil)
(setq! utop-command "opam exec -- dune utop . -- -emacs")
(add-hook! 'utop-mode-hook
;; HACK: Thats how to get completions from Merlin in Utop
;; <https://github.com/ocaml-community/utop/issues/455>
(progn (merlin-mode +1) (merlin-mode -1) (merlin-mode +1))))
;; ____________________________________________________________________________
;;; LOAD EXTERNAL ELISP
;; Private user information
(use-package! my-private)
;; Personal Elisp
(use-package! my-tools)
;; MJJ blog machinery
(use-package! mjj-publish)
;; ____________________________________________________________________________
;;; COMMENTARY
;; Place your private configuration here! Remember, you do not need to run 'doom
;; sync' after modifying this file!
;; Some functionality uses this to identify you, e.g. GPG configuration, email
;; clients, file templates and snippets. It is optional.
;; (setq user-full-name "John Doe"
;; user-mail-address "john@doe.com")
;; Doom exposes five (optional) variables for controlling fonts in Doom:
;;
;; - `doom-font' -- the primary font to use
;; - `doom-variable-pitch-font' -- a non-monospace font (where applicable)
;; - `doom-big-font' -- used for `doom-big-font-mode'; use this for
;; presentations or streaming.
;; - `doom-symbol-font' -- for symbols
;; - `doom-serif-font' -- for the `fixed-pitch-serif' face
;;
;; See 'C-h v doom-font' for documentation and more examples of what they
;; accept. For example:
;;
;; (setq doom-font (font-spec :family "Iosevka" :size 16)
;; doom-variable-pitch-font (font-spec :family "Iosevka Aile" :size 16))
;;
;; If you or Emacs can't find your font, use 'M-x describe-font' to look them
;; up, `M-x eval-region' to execute elisp code, and 'M-x doom/reload-font' to
;; refresh your font settings. If Emacs still can't find your font, it likely
;; wasn't installed correctly. Font issues are rarely Doom issues!
;; There are two ways to load a theme. Both assume the theme is installed and
;; available. You can either set `doom-theme' or manually load a theme with the
;; `load-theme' function. This is the default:
;; (setq doom-theme 'doom-bluloco-light)
;; This determines the style of line numbers in effect. If set to `nil', line
;; numbers are disabled. For relative line numbers, set this to `relative'.
;; (setq display-line-numbers-type nil)
;; If you use `org' and don't want your org files in the default location below,
;; change `org-directory'. It must be set before org loads!
;; (setq org-directory "~/Documents/org/")
;; Whenever you reconfigure a package, make sure to wrap your config in an
;; `after!' block, otherwise Doom's defaults may override your settings. E.g.
;;
;; (after! PACKAGE
;; (setq x y))
;;
;; The exceptions to this rule:
;;
;; - Setting file/directory variables (like `org-directory')
;; - Setting variables which explicitly tell you to set them before their
;; package is loaded (see 'C-h v VARIABLE' to look up their documentation).
;; - Setting doom variables (which start with 'doom-' or '+').
;;
;; Here are some additional functions/macros that will help you configure Doom.
;;
;; - `load!' for loading external *.el files relative to this one
;; - `use-package!' for configuring packages
;; - `after!' for running code after a package has loaded
;; - `add-load-path!' for adding directories to the `load-path', relative to
;; this file. Emacs searches the `load-path' when you load packages with
;; `require' or `use-package'.
;; - `map!' for binding new keys
;;
;; To get information about any of these functions/macros, move the cursor over
;; the highlighted symbol at press 'K' (non-evil users must press 'C-c c k').
;; This will open documentation for it, including demos of how they are used.
;; Alternatively, use `C-h o' to look up a symbol (functions, variables, faces,
;; etc).
;;
;; You can also try 'gd' (or 'C-c c d') to jump to their definition and see how
;; they are implemented.