-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.el
4079 lines (3466 loc) · 150 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
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
(add-load-path! (concat doom-user-dir "lisp"))
(require 'eeowaa-lib)
(require 'xdg)
(require 'cli-help)
(require 'eeowaa-refresh)
;; NOTE: These are providing nothing of value right now
;; (require 'eeowaa-debug)
;; (require 'eeowaa-project)
(when initial-window-system
(require 'transient-childframe)
(when (modulep! :tools magit)
(after! magit
;; Revert Doom's configuration
(setq transient-display-buffer-action
(tc-transient-childframe--display-buffer-action)))))
(setq default-input-method "latin-postfix")
(unless initial-window-system
(remove-hook 'company-mode 'company-box-mode))
(after! company-box
(cl-pushnew 'company-echo-metadata-frontend company-frontends)
(add-hook! company-box-mode
(defun my/company-box-toggles-h ()
(if company-box-mode
(delq! 'company-echo-metadata-frontend company-frontends)
(cl-pushnew 'company-echo-metadata-frontend company-frontends)))))
(after! company-box
(add-to-list 'company-box-frame-parameters '(tab-bar-lines-keep-state . t)))
(setq company-idle-delay nil)
(setq company-box-doc-delay 0.3) ;; This feels a bit smoother than no delay
(defadvice! my/move-company-box-doc-frame-a (company-box-frame)
:after #'company-box--update-frame-position
(when-let ((parent-frame (frame-parent company-box-frame))
(doc-frame (frame-local-getq company-box-doc-frame parent-frame))
(_ (frame-visible-p doc-frame)))
(company-box-doc--set-frame-position doc-frame)))
(when (modulep! company +childframe)
(after! company
(add-hook! 'evil-normal-state-entry-hook
(defun +company-abort-h ()
(when company-candidates
(company-abort))))))
(defadvice! my/consult-org-heading-hide-preview-a (fn &rest args)
:around #'consult-org-heading
(let (consult-preview-key)
(apply fn args)))
(defun my/dedicate-window-temporarily ()
"Dedicate the selected window until `display-buffer' is called again."
(interactive)
(if-let ((window (selected-window))
(dedicated (window-dedicated-p window)))
(message "Window is already dedicated with flag `%s'" dedicated)
(set-window-dedicated-p window 'until-next-display-buffer)
(eval (macroexpand-1
`(add-transient-hook! #'display-buffer :after
(when (eq (window-dedicated-p ,window) 'until-next-display-buffer)
(set-window-dedicated-p ,window nil)))))
(message "Window is dedicated until the next `display-buffer'")))
(defun my/toggle-window-dedicated ()
"Toggle the current window's `window-dedicated-p' flag.
If the flag is already set, it is set to `nil', otherwise it is
set to `t'. Use with caution in side windows and other windows
with special dedication semantics."
(interactive)
(if (set-window-dedicated-p nil (not (window-dedicated-p)))
(prog1 t (message "Window is strongly dedicated"))
(prog1 nil (message "Window is no longer dedicated"))))
(define-key! evil-window-map
;; replaces `+workspace/close-window-or-workspace'
"d" #'my/dedicate-window-temporarily
"D" #'my/toggle-window-dedicated)
(setq all-the-icons-scale-factor 1.0)
(setq extended-command-suggest-shorter nil)
;; Mostly stolen from tecosaur's config
(setq frame-title-format
'(""
(:eval
(if (s-contains-p org-roam-directory (or buffer-file-name ""))
(replace-regexp-in-string
".*/[0-9]*-?" "☰ "
(subst-char-in-string ?_ ? buffer-file-name))
"%b"))
(:eval
(let ((project-name (projectile-project-name)))
(unless (string= "-" project-name)
(format (if (and (buffer-modified-p) (vimish-tab-force-updating-p))
" ◉ %s"
" ● %s") project-name))))))
(setf (alist-get 'fullscreen initial-frame-alist) 'maximized)
(after! col-highlight
(require 'hl-line)
(eeowaa-use-face col-highlight hl-line))
(use-package! info-colors
:commands (info-colors-fontify-node))
(add-hook 'Info-selection-hook 'info-colors-fontify-node)
(after! whitespace
(require 'flycheck)
(eeowaa-use-face whitespace-trailing flycheck-error))
(defvar my/show-trailing-whitespace t)
(defvar my/trailing-whitespace-mode-alist
'((rfc-mode . nil)
(x509-asn1-mode . nil)
;; Trailing tabs are fine
(tsv-mode . "\\( +\\)$")
;; Two trailing spaces are fine, but no other kind of trailing whitespace
(markdown-mode . "\\S-\\( \\| \\{3,\\}\\|\\s-*\t\\s-*\\)$")))
(defun my/show-trailing-whitespace-maybe-h ()
(let* ((element (cl-some (lambda (e)
(when (derived-mode-p (car-safe e)) e))
my/trailing-whitespace-mode-alist))
(value (if (consp element)
(cdr element)
my/show-trailing-whitespace)))
(when value
(when (stringp value)
(setq-local whitespace-trailing-regexp value))
(cl-pushnew 'trailing whitespace-style)
(whitespace-turn-on))))
(add-hook 'whitespace-mode-hook
#'my/show-trailing-whitespace-maybe-h)
(setq text-quoting-style 'grave)
(setq display-raw-bytes-as-hex t)
(unless initial-window-system
(setq-default wrap-prefix "↪ "))
;; Automatically highlight differences in hunks, down to the symbol.
;;
;; FIXME Highlighting for an added line spills over to the first character of
;; the other buffer.
;;
(setq vdiff-auto-refine t
vdiff-default-refinement-syntax-code "w_")
(after! vdiff
;; Do not highlight lines in `vdiff-mode'.
(add-hook! 'vdiff-mode-hook :append (hl-line-mode -1))
;; Use `C-l' to immediately update the diff (otherwise, just wait
;; `vdiff--after-change-refresh-delay' seconds).
(setq-hook! 'vdiff-mode-hook
revert-buffer-function (lambda (&rest _) (vdiff-refresh))
eeowaa-refresh-force t)
;; Bind `vdiff-mode-prefix-map' to a convenient key.
;;
;; FIXME Use one of Doom's idiomatic key binding mechanisms for better
;; integration with leader keys (e.g. M-SPC in insert state) and which-key.
;;
(evil-define-key 'normal vdiff-mode-map (kbd "SPC v") vdiff-mode-prefix-map)
(evil-define-key 'normal vdiff-3way-mode-map (kbd "SPC v") vdiff-mode-prefix-map))
;; TODO Bind `vdiff-magit' command to a transient key in magit. For the time
;; being, just use `M-x vdiff-magit RET' to open the transient.
(after! magit
(require 'vdiff-magit))
;; TODO Integrate vdiff folding with `:editor fold'.
;; TODO Integrate vdiff window configuration with `:ui workspaces' (reference
;; how Doom configures `ediff' for this).
;; TODO Configure `vdiff-3way-mode', `vdiff-magit-resolve', and
;; `vdiff-magit-compare' to work similarly to my git-vimdiff shell script.
(setq window-sides-vertical t)
(setq switch-to-buffer-obey-display-actions t)
(setq display-buffer-base-action '((display-buffer-same-window) . nil))
(setq window-resize-pixelwise t)
(map! "C-`" #'window-toggle-side-windows)
;; "C-~" #'+popup/raise
;; "C-x p" #'+popup/other
;; `always' is just a no-op that returns `t'
(defadvice! my/never-hide-modeline-a (&rest _)
"Never hide the modeline"
:around 'hide-mode-line-mode
#'always)
(after! doom-themes-ext-treemacs
(defadvice! my/show-treemacs-modeline-a (&rest _)
"Show the treemacs modeline"
:around 'doom-themes-hide-modeline
#'always))
(remove-hook '+popup-buffer-mode-hook #'+popup-set-modeline-on-enable-h)
(defadvice! my/tab-bar-theme-a (theme &rest _)
"Tweak the style of the tab bar."
:after '(load-theme consult-theme)
(if (string-match-p "\\`ef-" (symbol-name theme))
(ef-themes-with-colors
(custom-set-faces
`(tab-bar ((,c :background ,bg-inactive :foreground ,fg-intense)))))
(eeowaa-use-face tab-bar mode-line-inactive)))
(setq doom-theme
(if initial-window-system
'ef-bio
'ef-tritanopia-dark))
(after! (:and solaire-mode (:or vertico ivy))
(let ((face (cond
((facep 'vertico-current) 'vertico-current)
((facep 'ivy-current-match) 'ivy-current-match)
(t (error "Could not determine face")))))
(custom-theme-set-faces! 'doom-outrun-electric
`(solaire-hl-line-face :background
,(face-attribute face :background)))))
;; Define fonts that I like
(setq my/fonts '(("Iosevka Comfy Fixed" ;; Remove " Fixed" if you want ligatures
:variable-pitch "Iosevka Comfy Duo"
:serif "Iosevka Comfy Motion Fixed"
:default-size 22)
("Source Code Pro"
:default-size 22)
("Terminus"
:default-size 30)
("Comic Mono"
:variable-pitch "Comic Neue"
:default-size 24)))
;; Define a fuction to change the fonts
(defun my/select-font (font &optional size)
"Change the current fonts to a collection in `my/fonts'.
If SIZE is omitted, the default will be used.
When called interactively, reload the fonts in the current session."
(interactive (list (completing-read "Font family: "
(mapcar #'car my/fonts) nil t)
nil))
(let* ((f (lambda (x y) (and x y (font-spec :family x :size y))))
(p (or (alist-get font my/fonts nil nil #'string=)
(error "\"%s\" not found in `my/fonts'" font)))
(variable-pitch-font (plist-get p :variable-pitch))
(serif-font (plist-get p :serif))
(default-size (plist-get p :default-size)))
(unless size
(setq size (if (interactive-p)
(eeowaa-read-positive-int "Font size: " default-size)
default-size)))
(setq doom-font (funcall f font size)
doom-variable-pitch-font (funcall f variable-pitch-font size)
doom-serif-font (funcall f serif-font size)))
(and (interactive-p) (doom/reload-font)))
;; Set the font
(my/select-font "Iosevka Comfy Fixed")
(setq emojify-download-emojis-p t)
(after! hl-todo
(setq hl-todo-keyword-faces
(append '(("TESTME" font-lock-constant-face bold)
("PREREQ" font-lock-doc-face bold)
("DEBUG" font-lock-preprocessor-face bold))
hl-todo-keyword-faces)))
(defmacro my/defhydra (name body &optional docstring &rest heads)
"Define a hydra, expanding `my/hydra-key' forms in HEADS.
See the help text for `defhydra' for a description of arguments."
(declare (indent defun) (doc-string 3))
(let ((heads (mapcar (lambda (head)
(if (eq (car head) 'my/hydra-key)
(macroexpand head)
head))
heads)))
`(defhydra ,name ,body ,docstring ,@heads)))
(defmacro my/hydra-key (key cmd hint &optional predicate)
"Add a key to a hydra defined by `my/defhydra'.
Press KEY to eval CMD described by HINT.
If PREDICATE is `nil', do not propertize the text.
If PREDICATE is `t', then propertize the text according to the
variable whose symbol name equals that of CMD. (This is often
useful when CMD is a function that toggles a minor mode.)
If PREDICATE is any other non-`nil' value, then propertize the
text according to that value at runtime.
In order to propertize text, the DOCSTRING argument in the
`my/defhydra' should contain a \"_KEY_: ?LABEL?\" string
corresponding those arguments of this macro. For example:
(my/defhydra hydra-minor-modes (:hint nil)
\"_v_: ?v?, _r_: ?r?\"
(my/hydra-key \"v\" view-mode \"View\" t)
(my/hydra-key \"r\"
(read-only-mode 'toggle)
\"Read-Only\"
buffer-read-only)"
(if (null predicate)
`(,key ,cmd ,hint)
`(,key ,cmd (propertize ,hint
'face
(if ,(if (eq t predicate)
cmd
predicate)
'bold
'italic)))))
(after! projectile
(global-set-key (kbd "C-c r") 'hydra-run/body)
(defhydra hydra-run (:color blue :hint none)
"
confi_g_ure -> ?g?
_c_ompile ---> ?c?
_t_est ------> ?t?
_r_un -------> ?r?
_i_nstall ---> ?i?
_p_ackage ---> ?p?
"
("g" (let ((compilation-read-command)) (funcall #'projectile-configure-project nil))
(format "%s" projectile-project-configure-cmd))
("c" (let ((compilation-read-command)) (funcall #'projectile-compile-project nil))
(format "%s" projectile-project-compilation-cmd))
("t" (let ((compilation-read-command)) (funcall #'projectile-test-project nil))
(format "%s" projectile-project-test-cmd))
("r" (let ((compilation-read-command)) (funcall #'projectile-run-project nil))
(format "%s" projectile-project-run-cmd))
("i" (let ((compilation-read-command)) (funcall #'projectile-install-project nil))
(format "%s" projectile-project-install-cmd))
("p" (let ((compilation-read-command)) (funcall #'projectile-package-project nil))
(format "%s" projectile-project-package-cmd))))
(global-set-key (kbd "C-c g") 'hydra-game/body)
(defhydra hydra-game (:color blue :hint nil)
"
^Arcade^ ^Puzzle^ ^Board^ ^Text^ ^Self-Playing^
^-^-----------^-^--------------------------------------------^-^-----------
_t_: Tetris _5_: 5x5 _g_: Gomoku _a_: Dunnet _l_: Life
_s_: Snake _b_: Blackbox _i_: Solitaire _d_: Doctor _h_: Hanoi
_p_: Pong _m_: Mpuz ^ ^ ^ ^ _z_: Zone
^ ^ _o_: Bubbles
"
;; Arcade
("t" tetris)
("s" snake)
("p" pong)
;; Puzzle
("5" 5x5)
("b" blackbox)
("m" mpuz)
("o" bubbles)
;; Board
("i" solitaire)
("g" gomoku)
;; Text
("a" dunnet)
("d" doctor)
;; Self-Playing
("l" life)
("h" hanoi)
("z" zone)
;; Other
("q" nil))
(when (locate-library "counsel-spotify")
(global-set-key (kbd "C-c s") 'hydra-spotify/body)
(defhydra hydra-spotify (:color blue :hint nil)
"
^Playback control^ ^Collection^ ^Song^ ^Open Spotify^
^---^----------------^-^--------------^-^-------------------------------
_SPC_: Play/Pause _l_: Playlist _s_: By name _o_: Application
_n_: Next _a_: Artist _A_: By artist _w_: Web player
_p_: Previous _r_: Record _R_: By record _i_: Integrations
"
;; Playback Control
("SPC" counsel-spotify-toggle-play-pause :color red)
("n" counsel-spotify-next :color red)
("p" counsel-spotify-previous :color red)
;; Collection
("l" counsel-spotify-search-playlist)
("a" counsel-spotify-search-artist)
("r" counsel-spotify-search-album)
;; Song
("s" counsel-spotify-search-track)
("A" counsel-spotify-search-tracks-by-artist)
("R" counsel-spotify-search-tracks-by-album)
;; Open Spotify
("o" (cond
((featurep :system 'macos) (call-process "open" nil nil nil "-a" "spotify"))
((featurep :system 'linux) (call-process "xdg-open" nil nil nil "spotify"))
(t (user-error! "Unsupported operating system"))))
("w" (browse-url "https://open.spotify.com"))
("i" (browse-url "https://developer.spotify.com/my-applications"))
;; Other
("q" nil)))
(global-set-key (kbd "C-c c") 'hydra-timeclock/body)
(defhydra hydra-timeclock (:color blue)
"Timeclock"
("i" timeclock-in "In")
("o" timeclock-out "Out")
("c" timeclock-change "Change")
("e" timeclock-visit-timelog "Edit")
("g" timeclock-reread-log "Reload")
("s" timeclock-status-string "Status")
("r" my/timeclock-report "Report")
("q" nil "Quit"))
(global-set-key (kbd "C-c d") 'hydra-debug/body)
(defhydra hydra-debug ()
"Debug"
("d" hydra-debug-debugger/body "Debugger" :exit t)
("b" hydra-debug-breakpoints/body "Breakpoints" :exit t)
("w" hydra-debug-watchpoints/body "Watchpoints" :exit t)
("t" hydra-debug-traps/body "Traps" :exit t)
("SPC" ignore nil :color red))
(defhydra hydra-debug-debugger (:color pink)
;; Stepping
("d" debugger-step-through "step in" :exit t :column "run")
("J" debugger-jump "step out" :exit t)
("c" debugger-continue "continue" :exit t)
;; Breakpoints
("gb" debugger-frame "set" :column "break")
("u" debugger-frame-clear "unset")
("gl" debugger-list-functions "list")
;; Evaluation
("E" debugger-eval-expression "print" :column "sexp")
("R" debugger-record-expression "record")
("RET" backtrace-help-follow-symbol "follow")
;; Visibility
("zo" backtrace-multi-line "open" :column "fold")
("zc" backtrace-single-line "close")
("." backtrace-expand-ellipses "expand")
;; Toggles
("p" backtrace-toggle-locals "locals" :column "toggle")
(":" backtrace-toggle-print-gensym "uninterned")
("#" backtrace-toggle-print-circle "circular")
;; Exiting
("q" debugger-quit "toplevel nonstop" :column "exit")
("r" debugger-return-value "return with value")
("SPC" hydra-debug/body "Menu" :exit t)
("C-g" ignore nil :exit t))
; Unassigned:
; backtrace-forward-frame
; backtrace-backward-frame
(defhydra hydra-debug-breakpoints ()
"Breakpoints"
("b" debug-on-entry "Set")
("u" cancel-debug-on-entry "Unset")
("l" (message "%s" (debug--function-list)) "List")
("SPC" hydra-debug/body "Menu" :exit t))
(defhydra hydra-debug-watchpoints ()
"Watchpoints"
("s" debug-on-variable-change "Set")
("u" cancel-debug-on-variable-change "Unset")
("l" (message "%s" (debug--variable-list)) "List")
("SPC" hydra-debug/body "Menu" :exit t))
(my/defhydra hydra-debug-traps ()
"Traps"
(my/hydra-key
"e" toggle-debug-on-error "Error" debug-on-error)
(my/hydra-key
"q" toggle-debug-on-quit "Quit (C-g)" debug-on-quit)
(my/hydra-key
"u" (lambda (event)
(interactive `(,(intern (completing-read "Signal: " '(sigusr1 sigusr2 nil)))))
(setq debug-on-event event))
"User event" debug-on-event)
(my/hydra-key
"s" (lambda ()
(interactive)
(setq debug-on-signal (not debug-on-signal))
(message "Debug on Signal %s globally"
(if debug-on-signal "enabled" "disabled")))
"Signal" debug-on-signal)
(my/hydra-key
"m" (lambda (regexp)
(interactive `(,(read-regexp "Message regexp: ")))
(setq debug-on-message regexp))
"Message" (not (or (null debug-on-message) (string-empty-p debug-on-message))))
("SPC" hydra-debug/body "Menu" :exit t))
(global-set-key (kbd "C-c t") 'hydra-table/body)
(defhydra hydra-table ()
"table.el"
("n" hydra-table-navigate/body "Navigate" :exit t)
("i" hydra-table-insert/body "Insert" :exit t)
("d" hydra-table-delete/body "Delete" :exit t)
("s" hydra-table-span-or-split/body "Span or Split" :exit t)
("r" hydra-table-resize/body "Resize" :exit t)
("j" hydra-table-justify/body "Justify" :exit t)
("e" hydra-table-export/body "Export" :exit t)
("SPC" ignore nil :color red))
(defhydra hydra-table-navigate ()
"Navigation"
("1" (progn (table-goto-top-left-corner)
(forward-char) (forward-line)))
("2" (progn (table-goto-top-right-corner)
(backward-char) (forward-line)))
("3" (progn (table-goto-bottom-left-corner)
(forward-char) (forward-line -1)))
("4" (progn (table-goto-bottom-right-corner)
(backward-char) (forward-line -1)))
("f" table-forward-cell)
("b" table-backward-cell)
("SPC" hydra-table/body "Menu" :exit 1))
(defhydra hydra-table-insert ()
"Insert"
("t" table-insert "table")
("r" table-insert-row "row")
("c" table-insert-column "column")
("s" table-insert-sequence "sequence")
("SPC" hydra-table/body "Menu" :exit 1))
(defhydra hydra-table-delete ()
"Delete"
("r" table-delete-row "row")
("c" table-delete-column "column")
("SPC" hydra-table/body "Menu" :exit 1))
(defhydra hydra-table-span-or-split ()
"Span or Split"
("h" (table-span-cell 'left))
("j" (table-span-cell 'below))
("k" (table-span-cell 'above))
("l" (table-span-cell 'right))
("|" table-split-cell-horizontally)
("-" table-split-cell-vertically)
("SPC" hydra-table/body "Menu" :exit 1))
(defhydra hydra-table-resize ()
"Resize"
("}" table-heighten-cell "heighten")
("{" table-shorten-cell "shorten")
(">" table-widen-cell "widen")
("<" table-narrow-cell "narrow")
("SPC" hydra-table/body "Menu" :exit 1))
(defhydra hydra-table-justify ()
"Justify"
("a" hydra-table-justify-cell/body "Cell" :exit t)
("r" hydra-table-justify-row/body "Row" :exit t)
("c" hydra-table-justify-column/body "Column" :exit t)
("SPC" hydra-table/body "Menu" :exit 1))
(defhydra hydra-table-justify-cell ()
"Justify Cell"
("h" (table-justify-cell 'left))
("j" (table-justify-cell 'bottom))
("k" (table-justify-cell 'top))
("l" (table-justify-cell 'right))
("c" (table-justify-cell 'center) "center")
("m" (table-justify-cell 'middle) "middle")
("n" (table-justify-cell 'none) "none")
("SPC" hydra-table/body "Menu" :exit 1))
(defhydra hydra-table-justify-row ()
"Justify Row"
("h" (table-justify-row 'left))
("j" (table-justify-row 'bottom))
("k" (table-justify-row 'top))
("l" (table-justify-row 'right))
("c" (table-justify-row 'center) "center")
("m" (table-justify-row 'middle) "middle")
("n" (table-justify-row 'none) "none")
("SPC" hydra-table/body "Menu" :exit 1))
(defhydra hydra-table-justify-column ()
"Justify Column"
("h" (table-justify-column 'left))
("j" (table-justify-column 'bottom))
("k" (table-justify-column 'top))
("l" (table-justify-column 'right))
("c" (table-justify-column 'center) "center")
("m" (table-justify-column 'middle) "middle")
("n" (table-justify-column 'none) "none")
("SPC" hydra-table/body "Menu" :exit 1))
(defhydra hydra-table-export ()
"Export to"
("h" (table-generate-source 'html) "HTML")
("l" (table-generate-source 'latex) "LaTeX")
("c" (table-generate-source 'cals) "CALS")
("SPC" hydra-table/body "Menu" :exit 1))
(setq imenu-list-mode-line-format " Ilist"
imenu-list-position 'right
imenu-list-size 35) ;; same as treemacs
(after! imenu-list
(setq-hook! 'imenu-list-major-mode-hook
revert-buffer-function #'imenu-list-refresh))
(setq my/imenu-list-text-scale -1)
(after! imenu-list
(defun my/imenu-list-text-scale-h ()
(text-scale-increase my/imenu-list-text-scale))
(add-hook 'imenu-list-major-mode-hook #'my/imenu-list-text-scale-h))
(remove-hook! '(prog-mode-hook
text-mode-hook
conf-mode-hook)
#'highlight-indent-guides-mode)
(setq +ligatures-in-modes '(org-mode)
+ligatures-extras-in-modes '(org-mode))
(if initial-window-system
;; Just display an icon for file-visiting buffers
(setq doom-modeline-highlight-modified-buffer-name nil)
;; Highlight the names of file-visiting buffers
(setq doom-modeline-highlight-modified-buffer-name t)
(defadvice! my/doom-modeline-ignore-modification-a (fn &rest args)
:around '(doom-modeline-segment--buffer-info
doom-modeline-segment--buffer-info-simple)
(letf! (defadvice my/doom-modeline-buffer-modification-a (&rest _)
:after-while #'buffer-modified-p
buffer-file-name)
(apply fn args))))
;; NOTE `font-dest' is ripped straight from `nerd-icons-install-fonts'
(require 'nerd-icons)
(let ((font-dest (cond
((member system-type '(gnu gnu/linux gnu/kfreebsd))
(concat (or (getenv "XDG_DATA_HOME")
(concat (getenv "HOME") "/.local/share"))
"/fonts/"
nerd-icons-fonts-subdirectory))
((eq system-type 'darwin)
(concat (getenv "HOME")
"/Library/Fonts/"
nerd-icons-fonts-subdirectory)))))
(unless (cl-every (lambda (font-name)
(file-exists-p (concat font-dest font-name)))
nerd-icons-font-names)
(nerd-icons-install-fonts t)))
(setq column-number-indicator-zero-based nil)
(after! evil-goggles
(defcustom my/evil-goggles-enable-jump t
"If non-nil, enable jump support."
:type 'boolean :group 'evil-goggles)
(defface my/evil-goggles-jump-face '((t (:inherit evil-goggles-default-face)))
"Face for jump action"
:group 'evil-goggles-faces)
(defun my/evil-goggles--jump-advice (&rest _)
"Advice for commands that move point across lines."
(let ((beg (line-beginning-position))
(end (1+ (line-end-position))))
(evil-goggles--show-async-hint beg end)))
;; `my/evil-goggles--jump-advice' is useful in many different contexts:
;; not just as advice, and not just within `evil-goggles'. Defining an alias
;; helps to generalize the function.
(defalias 'my/flash-line #'my/evil-goggles--jump-advice "Flash the current line.")
;; Adding entries for `better-jumper-jump-{forward,backward}' and/or
;; `evil-jump-{forward,backward}' to `evil-goggles--commands' does not work
;; as expected (the line does not flash after a jump). However, a hook works.
(after! better-jumper
(add-to-list 'better-jumper-post-jump-hook #'my/flash-line))
(dolist (command '(evil-scroll-line-to-center))
(cl-pushnew `(,command
:face my/evil-goggles-jump-face
:switch my/evil-goggles-enable-jump
:advice my/evil-goggles--jump-advice)
evil-goggles--commands)))
(map! :nv "gt" #'+tabs:next-window-tab
:nv "gT" #'+tabs:prev-window-tab
(:after evil-collection-magit
(:map magit-status-mode-map
:nv "gt" #'+tabs:next-window-tab
:nv "gT" #'+tabs:prev-window-tab)
(:map magit-log-mode-map
:nv "gt" #'+tabs:next-window-tab
:nv "gT" #'+tabs:prev-window-tab)
(:map magit-revision-mode-map
:nv "gt" #'+tabs:next-window-tab
:nv "gT" #'+tabs:prev-window-tab)))
;; NOTE Bindings for `info-mode' are set by `evil-collection-info-setup', which
;; is not called directly in `evil-collection-info'. Apparently this sort of
;; configuration is special, as evidenced by the `info' entry in the
;; `evil-collection-config' custom option. Advice provides an easy workaround:
(defadvice! my/window-tab-info-bindings-a (&rest _)
:after #'evil-collection-info-setup
(evil-collection-define-key 'normal 'Info-mode-map
"gt" #'+tabs:next-window-tab
"gT" #'+tabs:prev-window-tab))
(define-key! evil-window-map
"C" #'+tabs/close-window
"gf" #'+tabs:new-ffap-window-tab
"gF" #'+tabs:new-ffap-with-line-window-tab
"gd" #'+tabs:new-lookup-definition-window-tab)
;; NOTE This overrides `+workspace/new'
(map! :n "C-t" #'+tabs:new-duplicate-window-tab)
(after! evil-ex
(evil-ex-define-cmd "tabnew" #'+tabs:new-blank-window-tab)
(evil-ex-define-cmd "tabe[dit]" #'+tabs:new-window-tab)
(evil-ex-define-cmd "tabf[ind]" #'+tabs:new-project-window-tab)
(evil-ex-define-cmd "tabd[uplicate]" #'+tabs:new-duplicate-window-tab)
(evil-ex-define-cmd "tabc[lose]" #'+tabs:close-window-tab)
(evil-ex-define-cmd "tabo[nly]" #'+tabs:close-other-window-tabs)
(evil-ex-define-cmd "tabn[ext]" #'+tabs:next-window-tab)
(evil-ex-define-cmd "tabN[ext]" #'+tabs:prev-window-tab)
(evil-ex-define-cmd "tabp[rev]" #'+tabs:prev-window-tab)
(evil-ex-define-cmd "tabr[ewind]" #'+tabs:first-window-tab)
(evil-ex-define-cmd "tabfir[st]" #'+tabs:first-window-tab)
(evil-ex-define-cmd "tabl[ast]" #'+tabs:last-window-tab)
(evil-ex-define-cmd "tabm[ove]" #'+tabs:move-window-tab))
(setq tab-bar-separator ""
tab-line-separator "")
(after! tab-bar
(setq tab-bar-tab-face-function #'tab-bar-tab-face-default))
(defadvice! my/ergonomic-eww-bindings-a (&rest _)
:after #'evil-collection-eww-setup
(evil-collection-define-key 'normal 'eww-mode-map
;; open this up for `vimish-tab'
(kbd "gt") nil))
(setq display-time-day-and-date t ;; show the DoW and date in addition to the time
display-time-load-average-threshold 0) ;; always display the load average
(after! vimish-tab
(dolist (entry display-buffer-alist)
(when-let ((condition (car entry))
(fn-name (and (symbolp condition) (symbol-name condition)))
(_ (string-match "\\`buffer-group-member-p--\\(.+\\)\\'" fn-name))
(group (intern (match-string 1 fn-name)))
(action (and (listp (cdr entry)) (cdr entry)))
(alist (cdr action)))
(when (memq 'side (mapcar #'car alist))
(mapc (lambda (mode) (cl-pushnew mode vimish-tab-exclude-names))
(buffer-group-plist-get group :names))
(mapc (lambda (mode) (cl-pushnew mode vimish-tab-exclude-modes))
(buffer-group-plist-get group :modes)))))
;; Treemacs buffers are treated specially
(cl-pushnew 'treemacs-mode vimish-tab-exclude-modes))
(setq doom-themes-treemacs-enable-variable-pitch nil)
(setq +treemacs-git-mode 'extended)
(require 'ace-window)
(after! treemacs
(setq treemacs-collapse-dirs 0))
(setq treemacs-read-string-input 'from-minibuffer)
(after! treemacs-evil
(defun my/treemacs-visit-next ()
"Open the next node in another window."
(interactive)
(treemacs-next-line 1)
(save-selected-window
(treemacs-visit-node-no-split 1)))
(defun my/treemacs-visit-previous ()
"Open the previous node in another window."
(interactive)
(treemacs-previous-line 1)
(save-selected-window
(treemacs-visit-node-no-split 1)))
(define-key! evil-treemacs-state-map
"J" #'my/treemacs-visit-next
"K" #'my/treemacs-visit-previous))
(after! (:and treemacs ace-window)
(setq aw-ignored-buffers (delq 'treemacs-mode aw-ignored-buffers)))
(setq treemacs-show-cursor t)
;; No need for the fringe indicator with `hl-line' mode and visible cursor
(after! doom-themes-ext-treemacs
(with-eval-after-load 'treemacs
(setq treemacs-fringe-indicator-mode nil)))
;; Use a solid box cursor instead of an underline
(setq-hook! 'treemacs-mode-hook
evil-treemacs-state-cursor 'box)
(after! doom-themes-ext-treemacs
(with-eval-after-load 'treemacs
(remove-hook 'treemacs-mode-hook #'doom-themes-hide-fringes-maybe)
(advice-remove #'treemacs-select-window #'doom-themes-hide-fringes-maybe)))
(setq treemacs-text-scale -1)
(after! treemacs
(defun my/treemacs-revert-buffer-function (&rest _)
(my/treemacs-modify-icons)
(treemacs-refresh))
(setq-hook! 'treemacs-mode-hook
revert-buffer-function #'my/treemacs-revert-buffer-function))
;; REVIEW Consider detecting troublesome icons and automatically falling back to
;; the default icon for text files.
(defvar my/treemacs-icon-extension-alist
'(("org" . ("org_archive"))
("sh" . ("bat"))
("txt" . ("Pipfile"))
("json" ;; "configuration" icon
. ("project"
"Pipfile.lock"
"Cargo.lock"
"Cargo.toml"))
("xlsx" . ("ods"))
;; TODO Match on file "vcs/dir-.+-closed\\.svg"
("dir-closed"
. ("src-closed"
"test-closed"
"bin-closed"
"build-closed"
"git-closed"
"github-closed"
"public-closed"
"private-closed"
"temp-closed" "tmp-closed"
"readme-closed" "docs-closed"
"screenshots-closed" "icons-closed"))
;; TODO Match on file "vcs/dir-.+-open\\.svg"
("dir-open"
. ("src-open"
"test-open"
"bin-open"
"build-open"
"git-open"
"github-open"
"public-open"
"private-open"
"temp-open" "tmp-open"
"readme-open" "docs-open"
"screenshots-open" "icons-open")))
"Alist of file extension mappings for Treemacs icons.
The `car' of each element is a file extension with a desirable
Treemacs icon; the `cdr' is a list of file extensions that should
use that same icon.
If the `car' is a string, it is treated case-insensitively, as
Treemacs defines string extensions as lowercase. See the
`treemacs-icons' package for more info; for a quick reference,
see how `treemacs-create-theme' is used to define the \"Default\"
Treemacs theme.")
(defvar my/treemacs-fallback-icon-alist
'((dir-closed . " +\t")
(dir-open . " -\t")
(root-closed . " +\t")
(root-open . " -\t"))
"Alist of file extension mappings for Treemacs TUI icons.
The `car' of each element is a file extension or a symbol
representing a special Treemacs entry (see documentation for the
EXTENSIONS argument of `treemacs-create-icon' for more info).
The `cdr' of each element is a string to use in place of an icon
in TTY Emacs (or whenever Treemacs cannot render icons).")
(defvar my/treemacs-fallback-icon-default " \t"
"Default fallback string for TUI icons.
This string is used as the TUI icon for all Treemacs entries not
matched in `my/treemacs-icon-fallback-alist'.")
(defun my/treemacs-fallback-icon (extension)
"Return the fallback icon corresponding to EXTENSION."
(when (stringp extension)
(setq extension (downcase extension)))
(or (alist-get extension my/treemacs-fallback-icon-alist)
my/treemacs-fallback-icon-default))
(after! treemacs
(defun my/treemacs-modify-icons (&optional theme)
"Modify the icons for the Treemacs THEME (default current).
The following variables are consulted when modifying the theme:
`my/treemacs-icon-extension-alist'
`my/treemacs-fallback-icon-alist'
`my/treemacs-fallback-icon-default'
Call this function after `treemacs-create-theme' is called to
ensure your customizations take hold."
(unless (treemacs-theme-p theme)
(setq theme (if (stringp theme)
(treemacs--find-theme theme)
treemacs--current-theme)))
(let ((gui-icons (treemacs-theme->gui-icons theme))
(tui-icons (treemacs-theme->tui-icons theme)))
;; Modify GUI icons
(dolist (entry my/treemacs-icon-extension-alist)
(let* ((key (car entry))
(gui-icon (treemacs-get-icon-value (if (stringp key) (downcase key) key)))
(extension-list (cdr entry)))
(dolist (ext extension-list)
(ht-set! gui-icons (if (stringp ext) (downcase ext) ext) gui-icon))))
;; Modify TUI icons
(treemacs--maphash tui-icons (extension _)
(ht-set! tui-icons extension (my/treemacs-fallback-icon extension)))))
;; FIXME: This advice either causes errors or fails to run
(undefadvice! my/treemacs-modify-icons-a (theme &rest _)
:after #'treemacs-create-theme
:before #'treemacs-load-theme
(my/treemacs-modify-icons theme))
;; FIXME: This doesn't work, either (this is easy to see when
;; `doom-themes-treemacs-theme' is set to `doom-color', or when running in TTY
;; Emacs). The only workaround I've found is to run `my/treemacs-modify-icons'
;; manually after opening Treemacs, closing the Treemacs window via
;; `treemacs-kill-buffer', and then opening Treemacs again.
(add-hook! 'doom-load-theme-hook :append #'my/treemacs-modify-icons)
;; FIXME This function does not work when the Treemacs window is selected.
;; Also, the Treemacs window is always selected after this function runs, and
;; I'd rather keep the current window selected.
(defun my/treemacs-select-theme ()
"Select and load a new Treemacs theme.
Closes and re-opens Treemacs to apply the new theme."
(interactive)
(call-interactively #'treemacs-load-theme)
(unless (eq (treemacs-current-visibility) 'none)
(treemacs-select-window)
(treemacs-kill-buffer)
(treemacs)))
(defun my/treemacs-current-theme ()
"Return the name of the current Treemacs theme."
(treemacs-theme->name treemacs--current-theme)))
(defun my/treemacs-workaround-fix ()
"Run this command if Treemacs fails to open"
(interactive)