-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathemacs.el
1294 lines (1169 loc) · 41.1 KB
/
emacs.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
;;; personal configuration -*- lexical-binding: t -*-
;;; Packages
(require 'package)
(dolist (archive '(("melpa" . "https://melpa.org/packages/")
("elpa-devel" . "https://elpa.gnu.org/devel/")
("nongnu" . "https://elpa.nongnu.org/nongnu/")))
(add-to-list 'package-archives archive))
;; Refresh packages
;; (package-refresh-contents)
;; Install missing packages:
;; (package-install-selected-packages)
;; Remove unused packages:
;; (package-autoremove)
(setq package-selected-packages '(avy
browse-at-remote
;; surround ; it bugs meow
;; eglot-java
cape
clojure-ts-mode
consult
corfu
copilot
cue-mode
dape
denote
diminish
eat
edit-indirect ; for editing blocks in markdown-mode
eglot
ellama
embark
embark-consult
engine-mode
evil
flymake-shellcheck
forge
htmlize
gif-screencast
go-mode
graphviz-dot-mode
grip-mode
gptel
iedit
inf-clojure
jarchive
jinx
json-mode
keycast
key-chord
kubed
link-hint
lua-mode
magit
marginalia
markdown-mode
md4rd
meow
mermaid-mode
modus-themes
nov
olivetti
orderless
org-download
org-modern
ox-gfm
ox-slack
package-lint
pinentry
pdf-tools
plz
sly
sx
use-package
vertico
wgrep
yaml-mode
yaml-pro))
(setq use-package-enable-imenu-support t
use-package-compute-statistics t
apt-profile (if (file-directory-p "~/dev/nu/") 'work 'home)
apt-base-path (if (eq apt-profile 'home)
"~/dev/"
"~/dev/nu"))
(eval-when-compile
(require 'use-package))
(require 'diminish)
(require 'apt-mac-os nil 'noerror)
(use-package emacs
:init
(when (string= system-type 'darwin)
;; translate super to control
(setq ns-command-modifier 'control
insert-directory-program "gls"))
;; start the initial frame maximized
(add-to-list 'initial-frame-alist '(fullscreen . maximized))
;; start every frame maximized
(add-to-list 'default-frame-alist '(fullscreen . maximized))
(setq custom-file (make-temp-file "emacs-custom-"))
(unless (daemonp)
(advice-add #'display-startup-echo-area-message :override #'ignore))
(setq vc-follow-symlinks t
use-short-answers t
enable-recursive-minibuffers t
initial-scratch-message nil
inhibit-startup-screen t
inhibit-startup-echo-area-message user-login-name
initial-major-mode 'fundamental-mode
bookmark-set-fringe-mark nil
context-menu-mode t
completion-cycle-threshold 2
;; Enable indentation+completion using the TAB key.
;; Completion is often bound to M-TAB.
tab-always-indent 'complete
;; completions-detailed t
compilation-scroll-output 't
sentence-end-double-space nil
auth-sources '("~/.authinfo.gpg")
isearch-lazy-count t
async-shell-command-buffer 'new-buffer
;; save buffers in project context (instead of all buffers)
save-some-buffers-default-predicate #'save-some-buffers-root)
;; personal
(setq apt-narrow-screen t)
(dolist (cmd '(narrow-to-region
upcase-region
downcase-region
narrow-to-page
scroll-left
scroll-right))
(put cmd 'disabled nil))
;; triggered automatically on long *files*
;; (not on text inserted in a buffer)
(global-so-long-mode)
;; lock file, backup file
(let ((backup-dir "~/.emacs.d/backups"))
(unless (file-exists-p backup-dir)
(make-directory backup-dir)))
(setq-default lock-file-name-transforms '(("\\`/.*/\\([^/]+\\)\\'" "~/.emacs.d/backups/\\1" t))
auto-save-file-name-transforms '(("\\`/.*/\\([^/]+\\)\\'" "~/.emacs.d/backups/\\1" t))
backup-directory-alist '((".*" . "~/.emacs.d/backups/"))
version-control t
backup-by-copying t
vc-make-backup-files t
kept-new-versions 5
kept-new-versions 3
delete-old-versions t
auto-save-default t
auto-save-timeout 20
auto-save-interval 200
ring-bell-function #'ignore)
(setq-default indent-tabs-mode nil ; Don't use tabs for indentation
tab-width 4
c-basic-offset 4)
;; faces
;; DejaVu is great, but it has this bug:
;; https://old.reddit.com/r/emacs/comments/3wmw8z/dejavu_sans_mono_line_height_bug/
;; (set-face-attribute 'default nil :height 260 :family "DejaVu Sans Mono")
;; from https://git.sr.ht/~protesilaos/iosevka-comfy
;; (defun font-exists-p (font)
;; "check if font exists"
;; (if (null (x-list-fonts font)) nil t))
;; brew install --cask font-iosevka-comfy
(set-face-attribute 'default nil :height 180 :family "Iosevka Comfy")
(set-face-attribute 'variable-pitch nil :family "Helvetica" :height 180)
(recentf-mode)
(define-minor-mode apt-sticky-buffer-mode
"Make the current window always display this buffer."
:init-value nil
:lighter " sticky"
nil
(set-window-dedicated-p (selected-window) apt-sticky-buffer-mode))
:bind
(("C-o" . other-window)
("M-o" . other-frame)
("M-," . pop-tag-mark)
("C-c f d" . delete-file)
("C-z" . zap-up-to-char)
("M-Z" . zap-up-to-char)
("C-S-p" . previous-buffer)
("C-S-n" . next-buffer)
("M-g s" . sh-send-line-or-region-and-step)
("C-S-r" . raise-sexp)
("C-S-r" . raise-sexp)
("C-M-S-x" . apt-mac-os-switch-safari)
("C-M-S-v" . apt-mac-os-switch-slack)))
(use-package hideshow
:hook (prog-mode . hs-minor-mode)
:bind
("C-S-h" . hs-hide-all)
("C-S-d" . hs-show-block))
(use-package modus-themes
;; modus' variables need to be set *before* the package is loaded
;; change require reloading the theme:
;; (modus-themes-load-vivendi)
:custom
(modus-themes-headings
'((1 . (variable-pitch 1.7))
(2 . (variable-pitch 1.5))
(3 . (variable-pitch 1.3))
(4 . (variable-pitch 1))
(5 . (variable-pitch 1))
(6 . (variable-pitch 1))
(7 . (variable-pitch 1))
(8 . (variable-pitch 1))
(t . (monochrome))))
(modus-themes-italic-constructs nil)
(modus-themes-bold-constructs nil)
(modus-themes-tabs-accented nil)
(modus-themes-mode-line '(accented borderless (padding . 4) (height . 0.9)))
(modus-themes-hl-line nil)
(modus-themes-paren-match nil)
(modus-themes-links '(neutral-underline background))
(modus-themes-completions '((matches . (extrabold))
(selection . (semibold accented))
(popup . (accented intense))))
(modus-themes-region '(accented)))
;; emacs-mac specific. See https://github.com/d12frosted/homebrew-emacs-plus#system-appearance-change
(defun apt-apply-theme (appearance)
"Load theme, taking current system APPEARANCE into consideration."
(mapc #'disable-theme custom-enabled-themes)
(pcase appearance
('light (load-theme 'modus-operandi t))
('dark (load-theme 'modus-vivendi t))))
(add-hook 'ns-system-appearance-change-functions #'apt-apply-theme)
(use-package hl-line
:hook ((prog-mode text-mode) . hl-line-mode))
(use-package tool-bar
:if
(display-graphic-p)
:config
(tool-bar-mode -1))
(use-package apt-helpers
:load-path
(lambda () (expand-file-name "dotfiles/elisp" apt-base-path))
:bind
(("C-c f D" . apt-delete-file-and-buffer)
("C-S-c" . apt-connect-or-compile)
("C-S-s" . apt-switch-to-scratch)
("C-S-e" . apt-switch-to-emacs-init)
("C-S-m" . apt-pop-to-messages-buffer))
:demand t)
(use-package apt-mac-os
:load-path
(lambda () (expand-file-name "dotfiles/elisp/apt-mac-os.el" apt-base-path)))
(use-package apt-text-extras
:load-path
(lambda () (expand-file-name "dotfiles/elisp/apt-text-extras.el" apt-base-path))
:bind
(("C-S-w" . apt-forward-to-whitespace)))
(use-package dired
:custom
((dired-use-ls-dired t)
(dired-dwim-target t))
:bind (:map dired-mode-map
("C-o" . other-window)
("C-c C-o" . dired-display-file)))
(use-package elisp-mode
:diminish emacs-lisp-mode)
(use-package nuai
:if
(file-directory-p "~/dev/nu/nuai.el/")
:load-path
"~/dev/nu/nuai.el/"
:bind ("C-c a" . nuai))
(use-package icomplete
:disabled t
:init
(defun apt--enable-truncate-lines
()
"A trivial function that sets `truncate-lines` to t, just
for better naming in the hooks it is listed."
(setq truncate-lines t))
(add-hook 'minibuffer-setup-
hook
#'apt--enable-truncate-lines)
:custom
((icomplete-show-matches-on-no-input t)
(icomplete-delay-completions-threshold 0)
(icomplete-max-delay-chars 0)
(icomplete-compute-delay 0))
:config
(icomplete-vertical-mode))
(use-package savehist
:init
(savehist-mode))
(use-package vertico
:bind (:map vertico-map
("C-l" . #'vertico-multiform-vertical))
: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))
;; Tidy shadowed file names
:hook
(rfn-eshadow-update-overlay . vertico-directory-tidy))
(use-package vertico-multiform
:after
vertico
:init
(vertico-multiform-mode)
(setq vertico-multiform-commands
'((consult-imenu buffer indexed)
(execute-extended-command flat))
vertico-multiform-categories
'((file grid)
(consult-grep buffer))))
(use-package comint
:custom
((comint-move-point-for-output 'others)
(comint-input-ignoredups t)))
(use-package windmove
:config
(windmove-default-keybindings))
(use-package flymake
:bind
(:map flymake-mode-map
("M-n" . flymake-goto-next-error)
("M-p" . flymake-goto-prev-error)))
(use-package pulse
:init
(defun pulse-line (&rest _)
"Pulse the current line."
(pulse-momentary-highlight-one-line (point)))
(dolist (command '(scroll-up-command
scroll-down-command
recenter-top-bottom
other-window
other-frame))
(advice-add command :after #'pulse-line)))
(use-package elec-pair
:init
(defun apt-inhibit-electric-pair-mode (_char)
;; do not use electrict pair mode in minifuffer, as
;; it is common to use a single parens for searching
(minibufferp))
(setq electric-pair-inhibit-predicate #'apt-inhibit-electric-pair-mode)
:config
(electric-pair-mode))
(use-package markdown-mode
:defer t
:custom
(markdown-fontify-code-blocks-natively t)
;; https://github.com/jrblevin/markdown-mode/issues/578
(markdown-nested-imenu-heading-index nil)
:init
;; (add-hook 'markdown-mode-hook 'variable-pitch-mode)
;; (add-hook 'markdown-mode-hook
;; (lambda ()
;; (dolist (face '(markdown-inline-code-face
;; markdown-code-face
;; markdown-table-face))
;; (set-face-attribute 'default nil :height 190 :family "Iosevka Comfy"))))
)
(use-package winner
:init
(add-hook 'after-init-hook #'winner-mode))
(use-package which-key
:disabled t
:custom
((which-key-show-early-on-C-h t)
;; make sure which-key doesn't show automatically,
;; but refreshes quickly after it is triggered.
(which-key-idle-delay 10000)
(which-key-idle-secondary-delay 0.05))
:config
(which-key-mode)
:diminish which-key-mode)
(use-package marginalia
:init
(defun marginalia-use-builtin ()
(mapc
(lambda (x)
(setcdr x (cons 'builtin (remq 'builtin (cdr x)))))
marginalia-annotator-registry))
:bind
(:map minibuffer-local-map
("M-A" . marginalia-cycle))
:init
(marginalia-mode)
(marginalia-use-builtin))
(use-package corfu
:init
(global-corfu-mode)
:custom
(corfu-auto nil)
:bind
(:map corfu-map ("SPC" . corfu-insert-separator)))
(use-package consult
:bind
(("C-c k" . consult-kmacro)
("C-x b" . consult-buffer)
("C-x 4 b" . consult-buffer-other-window)
("C-x 5 b" . consult-buffer-other-frame)
("M-y" . consult-yank-pop)
("M-s l" . consult-line)
("M-s k" . consult-keep-lines)
("M-s r" . consult-ripgrep)
("M-g f" . consult-flymake)
("M-g i" . consult-imenu))
:init
(setq register-preview-delay 0.5
register-preview-function #'consult-register-format
xref-show-xrefs-function #'consult-xref
xref-show-definitions-function #'consult-xref
consult-preview-excluded-files '(".*\\.org$"))
:config
(defun apt-ripgrep-insert-glob
()
(interactive)
(insert " -- -g *."))
(defvar my-consult-ripgrep-map
(let ((map (make-sparse-keymap)))
(define-key map "\M-g" #'apt-ripgrep-insert-glob)
map))
(consult-customize consult-ripgrep :keymap my-consult-ripgrep-map))
(require 'apt-project-extras nil 'noerror)
(use-package project
:bind
(("C-x p P" . apt-open-project-in-new-tab)
(:map project-prefix-map
("r" . #'consult-ripgrep)
("t" . apt-project-switch-between-test-and-implementation)))
:config
;; Use this on a new config:
;; (project-remember-projects-under "/Users/andre.peric/dev/nu/")
;; (project-remember-projects-under "~/dev/peric")
(add-to-list 'project-switch-commands '(consult-ripgrep "Ripgrep") t)
(add-to-list 'project-switch-commands '(magit-project-status "Magit") t)
(define-key project-prefix-map "m" #'magit-project-status)
(define-key project-prefix-map "!" #'project-shell-command)
(add-to-list 'project-switch-commands '(project-shell-command "Shell command") t))
(use-package embark
:bind
(("C-;" . embark-act))
:init
(setq prefix-help-command #'embark-prefix-help-command)
:config
;; Hide the mode line of the Embark live/completions buffers
(add-to-list 'display-buffer-alist
'("\\`\\*Embark Collect \\(Live\\|Completions\\)\\*"
nil
(window-parameters (mode-line-format . none)))))
(use-package embark-consult
:after (embark consult))
(use-package orderless
:custom
(completion-styles '(orderless basic initials))
;; TODO: Use add-to-list instead?
;; (https://github.com/joaotavora/eglot/issues/131)
(completion-category-overrides '((file (styles basic partial-completion)))))
(use-package vilpy
;; mkdir -p ~/dev/peric && cd ~/dev/peric && git clone https://github.com/Andre0991/vilpy.git
:load-path
(lambda () (expand-file-name "vilpy" apt-base-path))
:hook
((emacs-lisp-mode
clojure-mode
clojure-ts-mode
sly-mode) . vilpy-mode)
:diminish vilpy-mode
:config
(vilpy-define-key vilpy-mode-map "9" 'vilpy-parens)
(vilpy-define-key vilpy-mode-map "," 'special-vilpy-barf)
(vilpy-define-key vilpy-mode-map "." 'special-vilpy-slurp)
(vilpy-define-key vilpy-mode-map "b" 'special-vilpy-eval-buffer)
(vilpy-define-key vilpy-mode-map "B" 'special-vilpy-back)
(vilpy-define-key vilpy-mode-map "i" 'inf-clojure-set-ns)
(vilpy-define-key vilpy-mode-map "o" 'inf-clojure-clear-repl-buffer))
(use-package breadcrumb
:disabled t
;; mkdir -p ~/dev/peric && cd ~/dev/peric && git clone https://github.com/joaotavora/breadcrumb.git
:load-path
(lambda () (expand-file-name "breadcrumb" apt-base-path))
:hook
((clojure-mode
clojure-ts-mode
sly-mode) . breadcrumb-local-mode)
:diminish breadcrumb-local-mode)
(use-package consult-gh
;; mkdir -p ~/dev/peric && cd ~/dev/peric && git clone https://github.com/armindarvish/consult-gh.git
:load-path
(lambda () (expand-file-name "consult-gh" apt-base-path))
:custom
(consult-gh-default-clone-directory "~/dev/nu")
(consult-gh-repo-maxnum 999)
(consult-gh-code-maxnum 100)
:config
(add-to-list 'consult-gh-default-orgs-list "Nubank")
(require 'consult-gh-embark)
:diminish consult-gh-mode)
(use-package clojure-mode
:disabled t
:custom
(clojure-align-forms-automatically t)
:diminish clojure-mode
:init
(add-hook 'clojurec-mode-hook (lambda () (diminish 'clojure-mode)))
(add-hook 'clojurescript-mode-hook (lambda () (diminish 'clojure-mode))))
(use-package clojure-ts-mode
:disabled t
:hook (clojure-ts-mode . (lambda ()
;; replicating clojure-mode settings
(setq-local comment-add 1)
(setq-local indent-tabs-mode nil
parse-sexp-ignore-comments t
multibyte-syntax-as-symbol t
open-paren-in-column-0-is-defun-start nil
fill-paragraph-function #'clojure-fill-paragraph
adaptive-fill-function #'clojure-adaptive-fill-function
normal-auto-fill-function #'clojure-auto-fill-function
;; CLOJURE INDENT
indent-line-function #'clojure-indent-line
indent-region-function #'clojure-indent-region
aggressive-indent-region-function #'clojure-indent-region
lisp-indent-function #'clojure-indent-function
lisp-doc-string-elt-property 'clojure-doc-string-elt
clojure-expected-ns-function #'clojure-expected-ns
add-log-current-defun-function #'clojure-current-defun-name
beginning-of-defun-function #'clojure-beginning-of-defun-function))))
(use-package eglot
;; TODO: run this in a bootstrap context
;; upgrade (required once, then it's updated with other packages):
;; (eglot-upgrade-eglot)
:init
(setq apt-eldoc-echo-area-use-multiline-p (if apt-narrow-screen
nil
5))
(defun apt-eglot-hooks
()
;; This displays full docs for clojure functions.
;; See https://github.com/joaotavora/eglot/discussions/894
(setq-local eldoc-documentation-strategy
#'eldoc-documentation-compose
eldoc-echo-area-use-multiline-p
apt-eldoc-echo-area-use-multiline-p))
(defun apt-eglot-format-if-clojure
(&rest _)
(when (and buffer-file-name
(derived-mode-p 'clojure-mode)
(bound-and-true-p eglot-managed-mode-hook)
(bound-and-true-p inf-clojure-minor-mode)
(buffer-modified-p))
(eglot-format)))
(dolist (mode '(clojure-ts-mode-hook
clojure-mode-hook
go-mode-hook
go-ts-mode-hook))
(add-hook mode 'eglot-ensure))
:custom
(eglot-confirm-server-initiated-edits nil)
(eglot-connect-timeout 300)
:bind
("C-c l a" . eglot-code-actions)
("C-c l l" . eglot)
("C-c l q" . eglot-shutdown)
("C-c l r" . eglot-rename)
("C-c l u" . xref-find-references)
("C-c l w" . (lambda ()
(interactive)
(let ((current-prefix-arg '(4))) (call-interactively 'xref-find-references))))
:config
(add-to-list 'eglot-server-programs '(markdown-mode . ("ltex-ls")))
(add-to-list 'eglot-server-programs '(org-mode . ("ltex-ls")))
(dolist (command '(other-window
other-frame))
;; TODO: might timeout and make Emacs lag
;; (advice-add command :before #'apt-eglot-format-if-clojure)
)
(add-hook 'eglot-managed-mode-hook
;; This displays full docs for clojure functions.
;; See https://github.com/joaotavora/eglot/discussions/894
#'apt-eglot-hooks)
)
(use-package dape
;; :preface
;; By default dape shares the same keybinding prefix as `gud'
;; If you do not want to use any prefix, set it to nil.
;; (setq dape-key-prefix "\C-x\C-a")
;; :hook
;; Save breakpoints on quit
;; ((kill-emacs . dape-breakpoint-save)
;; Load breakpoints on startup
;; (after-init . dape-breakpoint-load))
;; :config
;; Turn on global bindings for setting breakpoints with mouse
;; (dape-breakpoint-global-mode)
;; Info buffers to the right
;; (setq dape-buffer-window-arrangement 'right)
;; Info buffers like gud (gdb-mi)
;; (setq dape-buffer-window-arrangement 'gud)
;; (setq dape-info-hide-mode-line nil)
;; Pulse source line (performance hit)
;; (add-hook 'dape-display-source-hook 'pulse-momentary-highlight-one-line)
;; Showing inlay hints
;; (setq dape-inlay-hints t)
;; Save buffers on startup, useful for interpreted languages
;; (add-hook 'dape-start-hook (lambda () (save-some-buffers t t)))
;; Kill compile buffer on build success
;; (add-hook 'dape-compile-hook 'kill-buffer)
;; Projectile users
;; (setq dape-cwd-fn 'projectile-project-root)
)
;; Enable repeat mode for more ergonomic `dape' use
;; (use-package repeat
;; :config
;; (repeat-mode))
(use-package jarchive
:config
(jarchive-setup)
:after (eglot))
(use-package inf-clojure
:custom
(inf-clojure-enable-eldoc nil)
(inf-clojure-mode-line nil)
:init
(add-hook 'inf-clojure-mode-hook (lambda () (diminish 'inf-clojure-mode)))
;; (add-hook 'inf-clojure-mode-hook (lambda () (sticky-buffer-mode)))
(add-hook 'inf-clojure-minor-mode-hook (lambda () (diminish 'inf-clojure-minor-mode)))
:load-path
(lambda () (expand-file-name "inf-clojure" apt-base-path)))
(require 'apt-inf-clojure nil 'noerror)
(define-key global-map (kbd "C-S-b") #'apt-inf-clojure-open-bb)
(use-package browse-at-remote
:custom
(browse-at-remote-prefer-symbolic nil)
:bind
("C-c g o" . browse-at-remote-kill)
("C-c g O" . browse-at-remote))
(require 'apt-smerge-extras nil 'noerror)
(require 'apt-tab-bar-extras nil 'noerror)
(use-package tab-bar
:custom
(tab-bar-new-tab-choice "*scratch*")
:bind
("C-x t c" . tab-new)
("C-x t a" . apt-tab-bar-auto-rename-tab)
("C-x t k" . tab-bar-close-tab)
("C-x t n" . tab-bar-new-tab)
("C-x t r" . tab-rename))
(use-package nu-andre
:when (eq 'work apt-profile)
:load-path
(lambda () (expand-file-name "nu-andre-el" apt-base-path))
:bind
("C-S-l" . apt-lein-socket-repl)
:demand t)
(use-package forge
;; initial configuration:
;; https://gist.github.com/erikmd/8f1e892abb997fcb63ea2359137f4ae9
;; and
;; https://practical.li/spacemacs/source-control/forge-configuration/
;; (note: remember to enable SSO for the created token)
:after (magit)
:config
;; Display only unread
;; https://github.com/magit/forge/discussions/341
(fset 'forge--list-notifications-all
(symbol-function 'forge--list-notifications-unread))
:bind
("C-c f l" . forge-edit-topic-labels)
("C-c f w" . forge-copy-url-at-point-as-kill)
("C-c f b" . forge-browse-pullreq))
(use-package iedit
:init
(with-eval-after-load 'embark
(define-key embark-general-map (kbd "I") #'iedit-mode)
(define-key embark-command-map (kbd "I") #'iedit-mode))
:bind
("C-M-;" . iedit-mode) ;; prevents conflict with `embark`
:custom
(iedit-toggle-key-default nil))
(use-package wgrep
:custom
(wgrep-auto-save-buffer t))
(use-package isa
:if
(file-directory-p "~/dev/nu/isa.el/")
:load-path
"~/dev/nu/isa.el/"
:bind ("C-c i" . isa))
;;; nu indentation
(when (eq 'work apt-profile)
(let ((nu-clj-indentation-path "~/dev/nu/nudev/ides/emacs/"))
(when (file-directory-p nu-clj-indentation-path)
(require 'nu-clj-indentation (expand-file-name "nu-clj-indentation" nu-clj-indentation-path))))
(eval-after-load 'clojure-mode
'(set-nu-clj-indent)))
(use-package howm
:defer t
:init
(setq howm-view-use-grep t
howm-view-grep-command "rg"
howm-view-grep-option "-nH --no-heading --color never"
howm-view-grep-extended-option nil
howm-view-grep-fixed-option "-F"
howm-view-grep-expr-option nil
howm-view-grep-file-stdin-option nil)
:config
;; do not override `C-h`
(define-key howm-menu-mode-map "\C-h" nil)
(define-key riffle-summary-mode-map "\C-h" nil)
(define-key howm-view-contents-mode-map "\C-h" nil))
(use-package autorevert
:diminish auto-revert-mode)
(use-package eldoc
:diminish eldoc-mode)
(use-package nuact
:if (file-directory-p "~/dev/nu/nuact.el")
:load-path "~/dev/nu/nuact.el"
:init
(with-eval-after-load 'vilpy
(define-key vilpy-mode-map (kbd "<C-return>") #'nuact))
(with-eval-after-load 'inf-clojure
(define-key inf-clojure-mode-map (kbd "<C-return>") #'nuact)
(define-key inf-clojure-minor-mode-map (kbd "<C-return>") #'nuact)))
(use-package md4rd
:after eww
:preface
(defun md4rd-open-post (url &rest _args)
(md4rd--fetch-comments (concat (string-replace "www" "old" url) ".json")))
:init
(push (cons
(rx line-start "http" (zero-or-one "s") "://www.reddit.com/" (one-or-more anychar))
#'md4rd-open-post)
browse-url-handlers)
:custom
(md4rd-subs-active '(emacs clojure neovim))
:config
(add-hook 'md4rd-mode-hook 'md4rd-indent-all-the-lines))
(use-package pdf-tools
:init
(defun apt-abort-if-file-too-large-unless-pdf
(fn size op-type filename &optional offer-raw)
(unless (string-match-p "\\.pdf\\'" filename)
(funcall fn size op-type filename offer-raw)))
(defun apt-match-system-appearance
()
(when (and (eql 'dark ns-system-appearance)
(not (pdf-view-midnight-minor-mode)))
(pdf-view-midnight-minor-mode)))
(advice-add #'abort-if-file-too-large :around #'apt-abort-if-file-too-large-unless-pdf)
:mode ("\\.pdf\\'" . pdf-view-mode)
:magic ("%PDF" . pdf-view-mode)
:config
;; assumes (pdf-tools-install) worked once before
(pdf-tools-install-noverify)
(setq pdf-view-midnight-colors '("#ffffff" . "#000000"))
(add-hook 'pdf-view-mode-hook 'apt-match-system-appearance))
(use-package denote
:init
(defun apt-commit-denote
()
(interactive)
(when (and buffer-file-name
(string-prefix-p (expand-file-name "denote" apt-base-path) buffer-file-name))
;; as `start-process` is async, the first one might end before the second call.
;; but this does not matter much: in the worst case, new files will end up commited
;; anyway in the next save.
(message "commiting!")
(start-process "apt-git-add" nil "git" "add" ".")
(start-process "apt-git-commit" nil "git" "commit" "-am" "Update")
(start-process "apt-git-push" nil "git" "push" "origin" "main")))
(defun apt-denote-project
()
(interactive)
(project-switch-project "~/dev/peric/denote"))
(defun apt-open-journal
()
(interactive)
(find-file "/Users/andre.peric/dev/peric/denote/20231110T141240--journal__nu.org"))
(add-hook 'after-save-hook #'apt-commit-denote)
(add-hook 'dired-mode-hook #'denote-dired-mode-in-directories)
:custom
(denote-directory (expand-file-name "~/dev/peric/denote"))
(denote-known-keywords '("emacs" "tech"))
(denote-dired-directories (list denote-directory))
:bind
("C-S-d" . apt-denote-project)
("C-S-j" . apt-open-journal))
(use-package browse-url
;; enable when using xwidgets
:disabled t
:custom
(browse-url-browser-function 'xwidget-webkit-browse-url)
(browse-url-secondary-browser-function 'browse-url-default-browser))
(use-package shr
:custom
(shr-use-xwidgets-for-media t)
(shr-max-width 65)
(shr-inhibit-images t)
(shr-use-colors nil)
(shr-max-image-proportion 0.7)
(shr-image-animate nil))
(use-package shr-heading
:commands
shr-heading-setup-imenu
shr-heading-next
shr-heading-previous)
(use-package eww
:defer t
:preface
(defvar apt-reddit-url-regex
(rx line-start "http" (zero-or-one "s") "://www.reddit.com/" (one-or-more anychar)))
(defvar apt-stack-overflow-url-regex
(rx line-start "http" (zero-or-one "s") "://stackoverflow.com/questions" (one-or-more anychar)))
(defun apt-sx-open-link
()
(interactive)
(sx-open-link (eww-current-url)))
(defun apt-exec-cmd-if-url-matches ()
(cond ((string-match-p apt-reddit-url-regex (or (eww-current-url) ""))
(message "Opening md4rd...")
(md4rd-open-post (eww-current-url)))
((string-match-p apt-stack-overflow-url-regex (or (eww-current-url) ""))
(message "Opening sx...")
(apt-sx-open-link))))
:custom
(eww-search-prefix "https://www.google.com/search?q=")
:bind
(:map eww-mode-map
("x" . apt-sx-open-link)
;; ("P" . pocket-reader-eww-add-page)
("{" . backward-paragraph)
("}" . forward-paragraph)
("C-c C-p" . shr-heading-previous)
("C-c C-n" . shr-heading-next))
:hook ((eww-mode . shr-heading-setup-imenu)
(eww-after-render . apt-exec-cmd-if-url-matches)))
(use-package gif-screencast
;; on first run, might need to reset permissions:
;; https://apple.stackexchange.com/questions/374158/why-is-screencapture-taking-the-screenshot-of-the-desktop-image-and-not-the-wind
:custom
(gif-screencast-args '("-x")) ;; To shut up the shutter sound of `screencapture' (see `gif-screencast-command').
(gif-screencast-cropping-program "mogrify") ;; Optional: Used to crop the capture to the Emacs frame.
(gif-screencast-capture-format "ppm")
:bind
(("<f9>" . (lambda ()
(interactive)
(keycast-mode)
(gif-screencast-start-or-stop)))))
(use-package xwidget
:bind
(:map xwidget-webkit-mode-map
("l" . xwidget-webkit-back)
("r" . xwidget-webkit-forward)
("o" . xwidget-webkit-browse-url)
("g" . xwidget-webkit-reload)))
(use-package vc
:bind
("C-x v F" . vc-pull))
(use-package link-hint
:ensure t
:bind
("C-c o" . link-hint-open-link)
("C-c O" . link-hint-copy-link))
(use-package sx
:defer t)
(use-package nov
:custom (nov-text-width 80)
:mode ("\\.epub\\'" . nov-mode))
(use-package engine-mode
:ensure t
:custom
(engine/browser-function 'eww-browse-url)
:config
(engine-mode t)
(defengine google
"http://www.google.com/search?ie=utf-8&oe=utf-8&q=%s"
:keybinding "g")
(defengine github
"https://github.com/search?ref=simplesearch&q=%s"
:keybinding "h")
(defengine stack-overflow
"https://stackoverflow.com/search?q=%s"
:keybinding "s")
(defengine wikipedia
"http://www.wikipedia.org/search-redirect.php?language=en&go=Go&search=%s"
:keybinding "w"))
(use-package grip-mode)
(use-package sly
:defer t
:custom
(inferior-lisp-program "clisp")
:config
(with-eval-after-load 'vilpy
(add-to-list 'vilpy--handlers-alist
'(:sly . ((:decider-fn . (lambda () (bound-and-true-p sly-mode)))
(:eval-last-sexp . sly-eval-last-expression)
(:eval-defun . sly-eval-defun)
(:eval-region . sly-eval-region)
(:eval-buffer . sly-eval-buffer)
(:describe-symbol . sly-describe-symbol))))))
(use-package vc-backup
:disabled t
;; usage: go to a backup file in the `backup-directory-alist`
;; and use `vc-print-log` (C-x v l)