-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathinit.el
1398 lines (1220 loc) · 38.7 KB
/
init.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
;; -*- lexical-binding: t -*-
;;;;; Macros
(defmacro after (feature &rest forms)
(declare (indent 1) (debug t))
`(,(if (or (not (bound-and-true-p byte-compile-current-file))
(if (symbolp feature)
(require feature nil :no-error)
(load feature :no-message :no-error)))
#'progn
#'with-no-warnings)
(with-eval-after-load ',feature ,@forms)))
(defmacro use-feature (name &rest args)
(declare (indent 1))
`(use-package ,name
:ensure nil
,@args))
;;;;; Packages
(require 'package)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
(use-package no-littering :demand t)
(use-package use-package-chords :demand t)
(use-package system-packages)
(use-feature use-package-ensure-system-package :demand t)
;;;;; Bootstrap
(use-feature emacs
:custom
(history-delete-duplicates t)
(scroll-conservatively 101)
(scroll-preserve-screen-position 'always)
(echo-keystrokes 1e-6)
(delete-by-moving-to-trash t)
(ring-bell-function #'ignore)
(create-lockfiles nil)
(enable-recursive-minibuffers t)
(redisplay-skip-fontification-on-input t)
(frame-resize-pixelwise t)
(read-process-output-max (* 1024 1024))
(use-short-answers t)
(x-underline-at-descent-line t)
(cursor-type 'bar)
(cursor-in-non-selected-windows nil)
(line-spacing 2)
(tab-width 2)
(fill-column 100)
(ns-right-alternate-modifier 'none))
(use-feature cus-edit
:custom
(custom-file (make-temp-file "emacs-custom")))
(use-feature advice
:custom
(ad-redefinition-action 'accept))
(use-feature novice
:custom
(disabled-command-function nil))
;;;;; Processes, Shells, Compilation
(use-feature comint
:bind
(:map comint-mode-map
([remap comint-previous-input] . comint-previous-matching-input-from-input)
([remap comint-next-input] . comint-next-matching-input-from-input))
:custom
(comint-prompt-read-only t)
(comint-input-ignoredups t)
(comint-scroll-show-maximum-output nil)
:hook
(kill-buffer . write-input-ring-for-shellish-modes)
(kill-emacs . write-input-ring-for-all-shellish-modes)
:config
(defun write-input-ring-for-shellish-modes ()
(when (derived-mode-p 'comint-mode)
(comint-write-input-ring)))
(defun write-input-ring-for-all-shellish-modes ()
(dolist (buffer (buffer-list))
(with-current-buffer buffer (write-input-ring-for-shellish-modes)))))
(use-feature compile
:custom
(compilation-always-kill t)
(compilation-ask-about-save nil)
:init
(add-hook 'compilation-finish-functions #'alert-after-finish-in-background))
(use-package mistty
:bind
("C-x m" . mistty-in-project)
(:map project-prefix-map ("t" . mistty-in-project))
:custom
(mistty-detect-foreign-overlays nil))
(use-feature executable
:hook
(after-save . executable-make-buffer-file-executable-if-script-p))
;;;;; Files & History
(use-feature files
:custom
(require-final-newline t)
(confirm-kill-processes nil)
(make-backup-files nil)
(auto-save-file-name-transforms `((".*" ,temporary-file-directory t)))
(find-sibling-rules '(("\\([^/.]+\\)\\..*\\'" "\\1.*")))
(revert-buffer-quick-short-answers t)
(enable-local-variables :safe)
:chords
(";f" . find-file)
(":F" . find-sibling-file)
:bind
("s-S" . rename-visited-file)
("s-W" . delete-visited-file)
("s-," . find-user-init-file)
([remap save-buffers-kill-terminal] . restart-emacs)
:config
(defun find-user-init-file ()
(interactive)
(find-file user-init-file))
(defun delete-visited-file ()
(interactive)
(let ((filename (buffer-file-name)))
(when filename
(delete-file filename delete-by-moving-to-trash)
(message "Deleted file %s" filename)
(kill-buffer))))
(advice-add 'rename-visited-file :around #'rename-file-maybe-make-directories)
(defun rename-file-maybe-make-directories (f &rest args)
(maybe-make-directories (nth 0 args))
(apply f args))
(defun maybe-make-directories (&optional target-file-name)
(let* ((target-file-name (or target-file-name buffer-file-name))
(dir (file-name-directory target-file-name)))
(unless (file-exists-p dir)
(make-directory dir t))))
(push #'maybe-make-directories find-file-not-found-functions))
(use-feature ffap
:hook
(after-init . ffap-bindings))
(use-feature savehist
:custom
(savehist-additional-variables
'(search-ring regexp-search-ring comint-input-ring projector-command-history corfu-history))
:hook
(after-init . savehist-mode))
(use-feature saveplace
:custom
(save-place-limit nil)
:hook
(after-init . save-place-mode))
(use-feature recentf
:custom
(recentf-max-saved-items nil)
:hook
(after-init . recentf-mode))
(use-feature dired
:custom
(dired-use-ls-dired nil)
(dired-recursive-deletes 'always))
(use-package dirvish
:bind
(:map dired-mode-map ([remap dired-summary] . dirvish-dispatch))
:hook
(after-init . dirvish-override-dired-mode)
:custom
(dirvish-mode-line-position 'disable))
(use-feature dirvish-subtree
:after
(dirvish all-the-icons)
:bind
(:map dired-mode-map ("TAB" . dirvish-subtree-toggle))
:custom
(dirvish-attributes '(subtree-state all-the-icons collapse file-size)))
(use-feature dirvish-side
:after dirvish
:bind
("s-\\" . dirvish-side))
;;;;; Editing
(use-package transform-symbol-at-point
:bind
("s-;" . transform-symbol-at-point-map))
(use-package electric-operator
:hook
((text-mode prog-mode) . electric-operator-mode)
:config
(dolist (char '("-" "*"))
(electric-operator-add-rules-for-mode 'emacs-lisp-mode (cons char nil)))
(dolist (mode '(js-ts-mode typescript-ts-mode text-mode))
(electric-operator-add-rules-for-mode mode (cons ":" ": "))))
(use-feature indent
:custom
(standard-indent 2)
(tab-always-indent 'complete))
(use-feature newcomment
:bind
("s-/" . comment-line))
(use-feature simple
:custom
(indent-tabs-mode nil)
(set-mark-command-repeat-pop t)
(save-interprogram-paste-before-kill t)
(kill-do-not-save-duplicates t)
(line-move-visual nil)
(async-shell-command-buffer 'new-buffer)
(shell-command-prompt-show-cwd t)
(backward-delete-char-untabify-method 'all)
(read-extended-command-predicate #'command-completion-default-include-p)
(completion-show-help nil)
:bind
("DEL" . backward-delete-char-untabify)
("M-`" . list-processes)
("s-P" . execute-extended-command)
("s-z" . undo-only)
("s-Z" . undo-redo)
([remap newline] . reindent-then-newline-and-indent)
("<escape>" . keyboard-escape-quit)
("<s-return>" . eol-then-newline)
(:map minibuffer-local-map
("<escape>" . abort-recursive-edit)
("M-TAB" . previous-complete-history-element)
("<M-S-tab>" . next-complete-history-element))
:hook
((text-mode markdown-ts-mode) . auto-fill-mode)
(before-save . progish-delete-trailing-whitespace)
(after-init . column-number-mode)
:config
(defun delete-region-instead-of-kill (f &rest args)
(cl-letf (((symbol-function 'kill-region) #'delete-region))
(apply f args)))
(advice-add 'backward-kill-word :around #'delete-region-instead-of-kill)
(defun progish-delete-trailing-whitespace ()
(when (derived-mode-p 'prog-mode)
(delete-trailing-whitespace)))
(defun keyboard-quit-minibuffer-first (f &rest args)
(if-let* ((minibuffer (active-minibuffer-window)))
(with-current-buffer (window-buffer minibuffer)
(minibuffer-keyboard-quit))
(apply f args)))
(advice-add 'keyboard-quit :around #'keyboard-quit-minibuffer-first)
(defun pop-to-mark-command-until-new-point (f &rest args)
(let ((p (point)))
(dotimes (_i 10)
(when (= p (point))
(apply f args)))))
(defun move-beginning-of-line-or-indentation (f &rest args)
(let ((orig-point (point)))
(back-to-indentation)
(when (= orig-point (point))
(apply f args))))
(defun eol-then-newline ()
(interactive)
(move-end-of-line nil)
(reindent-then-newline-and-indent))
(advice-add 'pop-to-mark-command :around #'pop-to-mark-command-until-new-point)
(advice-add 'move-beginning-of-line :around #'move-beginning-of-line-or-indentation)
(advice-add 'beginning-of-visual-line :around #'move-beginning-of-line-or-indentation))
(use-package expreg
:bind
("C-," . expreg-expand)
("C-." . expreg-contract))
(use-feature subword
:hook
(after-init . global-subword-mode))
(use-feature delsel
:hook
(after-init . delete-selection-mode))
(use-feature elec-pair
:hook
(after-init . electric-pair-mode))
(use-feature electric
:custom
(electric-quote-string t)
:hook
(after-init . electric-quote-mode))
(use-package avy
:chords
("jj" . avy-goto-char-timer)
("jk" . avy-goto-word-1)
("jl" . avy-goto-line))
(use-package ace-link
:bind
("M-g e" . avy-jump-error)
:config
(ace-link-setup-default)
(defun avy-jump-error-next-error-hook ()
(let ((compilation-buffer (compilation-find-buffer)))
(quit-window nil (get-buffer-window compilation-buffer))
(recenter)))
(defun avy-jump-error ()
(interactive)
(let ((compilation-buffer (compilation-find-buffer))
(next-error-hook '(avy-jump-error-next-error-hook)))
(when compilation-buffer
(with-current-buffer compilation-buffer
(when (derived-mode-p 'compilation-mode)
(pop-to-buffer compilation-buffer)
(ace-link-compilation)))))))
(use-package multiple-cursors
:bind
("s-d" . mc/mark-next-like-this)
("C-c s-d" . mc/mark-all-like-this-dwim)
:hook
(before-save . mc/keyboard-quit))
(use-feature misc
:bind
("s-D" . duplicate-dwim))
(use-package jinx
:ensure-system-package (enchant-2 . enchant)
:hook
(emacs-startup . global-jinx-mode)
:bind
("M-$" . jinx-correct))
;;;;; Completion
(use-feature cursor-sensor
:custom
(minibuffer-prompt-properties '(read-only t cursor-intangible t face minibuffer-prompt))
:hook
(minibuffer-setup . cursor-intangible-mode)
:config
(defun maybe-delete-char (f &rest args)
(unless (and (minibufferp) (<= (point) (minibuffer-prompt-end)) (eq -1 (nth 0 args)))
(apply f args)))
(advice-add 'delete-char :around #'maybe-delete-char))
(use-package vertico
:demand t
:custom
(vertico-count 20)
(vertico-scroll-margin (/ vertico-count 2))
:hook
(after-init . vertico-mode))
(use-feature vertico-directory
:after vertico
:bind
(:map vertico-map
("RET" . vertico-directory-enter)
("DEL" . vertico-directory-delete-char)))
(use-feature vertico-quick
:after vertico
:chords
(:map vertico-map ("jl" . vertico-quick-exit)))
(use-feature completion-preview
:hook
(prog-mode . completion-preview-mode)
:bind
(:map
completion-preview-active-mode-map
([remap forward-word] . completion-preview-insert-word)
([remap forward-sexp] . completion-preview-insert-sexp)))
(use-package corfu
:hook
(after-init . global-corfu-mode)
:custom
(corfu-scroll-margin (/ corfu-count 2))
:bind
(:map corfu-map ("RET" . corfu-send)))
(use-feature corfu-popupinfo
:after corfu
:hook
(corfu-mode . corfu-popupinfo-mode))
(use-feature corfu-quick
:after corfu
:chords
(:map corfu-map ("jl" . corfu-quick-complete)))
(use-feature corfu-history
:after corfu
:hook
(corfu-mode . corfu-history-mode))
(use-feature corfu-info
:after corfu)
(use-package kind-icon
:after corfu
:custom
(kind-icon-default-face 'corfu-default)
:init
(add-to-list 'corfu-margin-formatters #'kind-icon-margin-formatter))
(use-package orderless
:custom
(completion-styles '(orderless)))
(use-package marginalia
:bind
("C-?" . marginalia-cycle)
:hook
(after-init . marginalia-mode))
(use-package consult
:bind
([remap goto-line] . consult-goto-line)
([remap yank-pop] . consult-yank-pop)
([remap isearch-forward] . consult-line)
("C-c C-t" . consult-theme)
:chords
(";s" . consult-buffer)
(":G" . consult-ripgrep)
(";r" . consult-imenu)
(":R" . consult-imenu-multi)
:custom
(consult-preview-key "M-."))
(use-package affe
:custom
(affe-regexp-compiler #'affe-orderless-regexp-compiler)
:chords
(";g" . affe-grep)
:init
(defun affe-orderless-regexp-compiler (input _type _ignorecase)
(setq input (cdr (orderless-compile input)))
(cons input (apply-partially #'orderless--highlight input t))))
(use-package embark
:custom
(prefix-help-command #'embark-prefix-help-command)
:bind
("C-;" . embark-act)
([remap describe-bindings] . embark-bindings)
:config
(defun embark-which-key-indicator ()
(lambda (&optional keymap targets prefix)
(if (null keymap)
(which-key--hide-popup-ignore-command)
(which-key--show-keymap
(if (eq (plist-get (car targets) :type) 'embark-become)
"Become"
(format "Act on %s '%s'%s"
(plist-get (car targets) :type)
(embark--truncate-target (plist-get (car targets) :target))
(if (cdr targets) "…" "")))
(if prefix
(pcase (lookup-key keymap prefix 'accept-default)
((and (pred keymapp) km) km)
(_ (key-binding prefix 'accept-default)))
keymap)
nil nil t (lambda (binding)
(not (string-suffix-p "-argument" (cdr binding))))))))
(setopt embark-indicators
'(embark-which-key-indicator
embark-highlight-indicator
embark-isearch-highlight-indicator))
(defun embark-hide-which-key-indicator (fn &rest args)
(which-key--hide-popup-ignore-command)
(let ((embark-indicators
(remq #'embark-which-key-indicator embark-indicators)))
(apply fn args)))
(advice-add #'embark-completing-read-prompter :around #'embark-hide-which-key-indicator))
(use-package embark-consult
:demand t
:after
(embark consult)
:hook
(embark-collect-mode . consult-preview-at-point-mode))
(use-feature hippie-exp
:custom
(hippie-expand-verbose nil)
(hippie-expand-try-functions-list
'(try-expand-dabbrev-visible
try-expand-dabbrev
try-expand-dabbrev-matching-buffers
try-expand-dabbrev-from-kill
try-complete-file-name-partially
try-complete-file-name
try-expand-dabbrev-other-buffers))
:bind
([remap dabbrev-expand] . hippie-expand)
("M-'" . hippie-expand-line)
:hook
((emacs-lisp-mode ielm-mode) . hippie-expand-allow-lisp-symbols)
:init
(defun try-expand-dabbrev-matching-buffers (old)
(let ((hippie-expand-only-buffers `(,major-mode)))
(try-expand-dabbrev-all-buffers old)))
(defun try-expand-dabbrev-other-buffers (old)
(let ((hippie-expand-ignore-buffers `(,major-mode)))
(try-expand-dabbrev-all-buffers old)))
(defun hippie-expand-case-sensitive (f &rest args)
(let ((case-fold-search nil))
(apply f args)))
(defun hippie-expand-maybe-kill-to-eol (f &rest args)
(unless (eolp)
(kill-line))
(apply f args))
(defalias 'hippie-expand-line (make-hippie-expand-function
'(try-expand-line
try-expand-line-all-buffers)))
(advice-add 'hippie-expand :around #'hippie-expand-case-sensitive)
(advice-add 'hippie-expand-line :around #'hippie-expand-maybe-kill-to-eol)
(defun hippie-expand-allow-lisp-symbols ()
(setq-local hippie-expand-try-functions-list
(append '(try-complete-lisp-symbol-partially
try-complete-lisp-symbol)
hippie-expand-try-functions-list))))
(use-package tempel
:init
(defun tempel-setup-capf ()
(setq-local completion-at-point-functions (cons #'tempel-expand completion-at-point-functions)))
:hook
((prog-mode text-mode eglot-managed-mode) . tempel-setup-capf))
(use-package tempel-collection
:after tempel
:init
(tempel-key "s-." todo global-map))
;;;;; Navigation & Search
(use-feature ns-win
:custom
(ns-pop-up-frames nil))
(use-feature window
:chords
(";w" . toggle-split-window)
(":W" . delete-other-windows)
:custom
(switch-to-buffer-obey-display-actions t)
(split-width-threshold (- (window-width) 10))
:config
(defun do-not-split-more-than-two-non-side-windows (window &optional horizontal)
(if (and horizontal (> (length (--filter (not (window-parameter it 'window-side)) (window-list))) 1))
nil
t))
(advice-add 'window-splittable-p :before-while #'do-not-split-more-than-two-non-side-windows)
(defun toggle-split-window ()
(interactive)
(if (eq last-command 'toggle-split-window)
(progn
(jump-to-register :toggle-split-window)
(setq this-command 'toggle-unsplit-window))
(window-configuration-to-register :toggle-split-window)
(switch-to-buffer-other-window nil))))
(use-package rg
:ensure-system-package rg
:hook
(after-init . rg-enable-default-bindings))
(use-package wgrep-ag
:after rg
:custom
(wgrep-auto-save-buffer t)
:hook
(rg-mode . wgrep-ag-setup))
(use-package bm
:bind
("s-1" . bm-toggle)
("s-2" . bm-next)
("s-@" . bm-previous)
:custom
(bm-cycle-all-buffers t))
(use-feature imenu
:custom
(imenu-auto-rescan t)
:hook
(emacs-lisp-mode . hemacs-imenu-elisp-expressions)
:config
(defun hemacs-imenu-elisp-expressions ()
(dolist (pattern '((nil "^[[:space:]]*(def \\(.+\\)$" 1)
("Features" "^(use-feature \\(.+\\)$" 1)
("Sections" "^;;;;; \\(.+\\)$" 1)))
(add-to-list 'imenu-generic-expression pattern))))
(use-feature project
:demand t
:bind-keymap
("s-p" . project-prefix-map)
:chords
(";t" . project-find-file)
:custom
(project-switch-use-entire-map t)
(project-mode-line t)
(project-vc-extra-root-markers '(".tool-versions")))
(use-package projector
:bind
("C-x RET" . projector-run-shell-command-project-root)
(:map comint-mode-map ("s-R" . projector-rerun-buffer-process))
(:map project-prefix-map ("RET" . projector-run-shell-command-project-root))
:custom
(projector-project-package 'project))
(use-package beginend
:hook
(after-init . beginend-global-mode))
;;;;; External Utilities
(use-package gptel)
(use-package emacs-everywhere)
(use-package direnv
:hook
(after-init . direnv-mode))
(use-package alert
:custom
(alert-default-style 'osx-notifier)
:init
(defun alert-after-finish-in-background (buf str)
(when (or (not (get-buffer-window buf 'visible)) (not (frame-focus-state)))
(alert str :buffer buf))))
(use-package terminal-here
:bind
("C-c o t" . terminal-here))
(use-package reveal-in-folder
:bind
("C-c o f" . reveal-in-folder))
(use-package list-environment)
;;;;; Major Modes
(use-package csv-mode
:hook
(csv-mode . csv-align-mode))
(use-feature org
:bind
(:map org-mode-map ("C-c C-." . org-todo))
:custom
(org-support-shift-select t)
(org-startup-indented t)
:config
(advice-add 'org-switch-to-buffer-other-window :override #'switch-to-buffer-other-window))
(use-package org-autolist
:after org
:hook
(org-mode . org-autolist-mode))
(use-feature sgml-mode
:bind
(:map html-mode-map
("<C-return>" . html-newline-dwim))
:chords
(:map html-mode-map
("<>" . sgml-close-tag))
:hook
(sgml-mode . sgml-electric-tag-pair-mode)
:config
(defun run-prog-mode-hooks ()
(run-hooks 'prog-mode-hook))
(add-hook 'sgml-mode-hook #'run-prog-mode-hooks)
(modify-syntax-entry ?= "." html-mode-syntax-table)
(modify-syntax-entry ?\' "\"'" html-mode-syntax-table)
(defun html-newline-dwim ()
(interactive)
(move-end-of-line nil)
(reindent-then-newline-and-indent)
(sgml-close-tag)
(move-beginning-of-line nil))
(bind-key "'" "’" html-mode-map (eq 0 (car (syntax-ppss)))))
(use-package web-mode
:mode
("\\.erb\\'" . web-mode)
("\\.php\\'" . web-mode)
("\\.hbs\\'" . web-mode)
("\\.handlebars\\'" . web-mode)
("\\.ecr\\'" . web-mode)
:bind
(:map web-mode-map
("<C-return>" . html-newline-dwim)
("C-c C-." . tsx-ts-mode))
:custom
(web-mode-enable-auto-quoting nil)
(web-mode-enable-current-element-highlight t))
(use-package lorem-ipsum)
(use-package emmet-mode
:hook
(sgml-mode web-mode))
(use-package markdown-ts-mode
:mode
("\\.md\\'" . markdown-ts-mode)
:config
(add-to-list 'treesit-language-source-alist '(markdown "https://github.com/tree-sitter-grammars/tree-sitter-markdown" "split_parser" "tree-sitter-markdown/src"))
(add-to-list 'treesit-language-source-alist '(markdown-inline "https://github.com/tree-sitter-grammars/tree-sitter-markdown" "split_parser" "tree-sitter-markdown-inline/src")))
(use-package gh-md
:after markdown-ts-mode
:bind
(:map markdown-ts-mode-map ("C-c b" . gh-md-render-buffer)))
(use-feature css-mode
:custom
(css-indent-offset 2))
(use-package less-css-mode
:custom
(less-css-lessc-options '("--no-color" "-x")))
(use-feature js
:mode
("\\.mjs\\'" . js-ts-mode)
:custom
(js-indent-level 2))
(use-package nodejs-repl)
(use-package graphql-ts-mode
:config
(add-to-list 'treesit-language-source-alist '(graphql "https://github.com/bkegley/tree-sitter-graphql")))
(use-package dotenv-mode)
(use-feature typescript-ts-mode
:demand t
:bind
(:map tsx-ts-mode-map
("C-c C-." . web-mode)))
(use-package ts-comint)
(use-package jest-test-mode
:hook
(typescript-ts-base-mode js-base-mode))
(use-package format-all
:bind
("C-M-\\" . format-all-buffer))
(use-package slim-mode
:custom
(slim-backspace-backdents-nesting nil))
(use-feature ruby-ts-mode
:bind
(:map ruby-ts-mode-map (":" . smart-ruby-colon))
:init
(defun smart-ruby-colon ()
(interactive)
(let ((space-needed
(and (looking-back "[[:word:]]" nil)
(not (memq (get-text-property (- (point) 1) 'face)
'(font-lock-type-face tree-sitter-hl-face:type))))))
(call-interactively #'self-insert-command)
(when space-needed (insert " ")))))
(use-package ruby-end
:custom
(ruby-end-insert-newline nil))
(use-package ruby-tools
:demand t
:after ruby-mode)
(use-package yard-mode
:hook
(ruby-base-mode . yard-mode))
(use-package rspec-mode
:after ruby-mode
:bind
(:map rspec-compilation-mode-map ("s-R" . rspec-rerun)))
(use-package minitest
:after ruby-mode
:hook
(ruby-base-mode . minitest-mode)
:custom
(minitest-keymap-prefix (kbd "C-c ."))
:bind
(:map minitest-compilation-mode-map ("s-R" . minitest-rerun)))
(use-package inf-ruby
:hook
(ruby-base-mode . inf-ruby-minor-mode)
(compilation-filter . inf-ruby-auto-enter)
(after-init . inf-ruby-switch-setup))
(use-package rbs-mode)
(use-package projectile-rails
:bind
(:map projectile-rails-mode-map ("C-c r" . projectile-rails-command-map))
:hook
(after-init . projectile-rails-global-mode))
(use-package rails-i18n)
(use-package haml-mode)
(use-package coffee-mode)
(use-package sass-mode)
(use-feature go-ts-mode
:demand t)
(use-package crystal-mode)
(use-package inf-crystal
:hook
(crystal-mode . inf-crystal-minor-mode))
(use-feature elixir-ts-mode
:demand t)
(use-package mix
:hook
(elixir-ts-mode . mix-minor-mode))
(use-feature dockerfile-ts-mode
:demand t)
(use-feature yaml-ts-mode
:demand t)
(use-feature lua-ts-mode
:custom
(lua-ts-indent-offset 2))
;;;;; Version Control
(use-feature ediff
:custom
(ediff-window-setup-function 'ediff-setup-windows-plain))
(use-feature vc-hooks
:custom
(vc-follow-symlinks t))
(use-feature diff-mode
:custom
(diff-font-lock-prettify t))
(use-package git-modes)
(use-package magit
:bind
("s-m" . magit-status)
("s-g" . magit-dispatch)
(:map project-prefix-map ("m" . magit-project-status))
:custom
(magit-status-goto-file-position t)
(magit-status-show-hashes-in-headers t)
(magit-branch-prefer-remote-upstream t)
(magit-diff-refine-hunk 'all)
(magit-no-confirm t)
:config
(after alert
(defun magit-process-alert-after-finish-in-background (f &rest args)
(let* ((process (nth 0 args))
(event (nth 1 args))pp
(buf (process-get process 'command-buf))
(buff-name (buffer-name buf)))
(when (and buff-name (stringp event) (s-match "magit" buff-name) (s-match "finished" event))
(alert-after-finish-in-background buf (concat (capitalize (process-name process)) " finished")))
(apply f (list process event))))
(advice-add 'magit-process-sentinel :around #'magit-process-alert-after-finish-in-background)))
(use-package forge)
(use-package magit-todos
:after magit
:init
(transient-append-suffix 'magit-dispatch "Q"
'(":" "TODO list" magit-todos-list)))
(use-package browse-at-remote
:custom
(browse-at-remote-add-line-number-if-no-region-selected nil)
(browse-at-remote-prefer-symbolic nil)
:init
(after magit
(transient-append-suffix 'magit-dispatch "h"
'("R" "Browse at remote" browse-at-remote))))
;;;;; Emacs Lisping
(use-package helpful
:bind
([remap describe-function] . helpful-callable)
([remap describe-command] . helpful-command)
([remap describe-variable] . helpful-variable)
([remap describe-key] . helpful-key)
([remap display-local-help] . helpful-at-point))
(use-package elisp-slime-nav
:hook
((emacs-lisp-mode ielm-mode) . turn-on-elisp-slime-nav-mode))
(use-feature eldoc
:hook
(after-init . global-eldoc-mode)
:custom
(eldoc-documentation-strategy 'eldoc-documentation-compose-eagerly)
(eldoc-echo-area-prefer-doc-buffer t)
(eldoc-echo-area-use-multiline-p nil))
;;;;; Childframes & Posframes
(use-package eldoc-box
:bind
("s-?" . eldoc-box-help-at-point))
(use-package posframe
:config
(defun hemacs-posframe-arghandler (f &rest args)
(apply f (car args) (plist-put (cdr args) :internal-border-width (frame-char-height))))
(advice-add 'posframe-show :around #'hemacs-posframe-arghandler))
(use-package transient-posframe
:custom
(transient-posframe-poshandler #'posframe-poshandler-point-bottom-left-corner)
(transient-posframe-min-height 1)
(transient-posframe-min-width 1)
:hook
(after-init . transient-posframe-mode))
(use-package which-key-posframe
:custom
(which-key-posframe-poshandler #'posframe-poshandler-point-bottom-left-corner)
:hook
(after-init . which-key-posframe-mode))
(use-package frog-menu
:custom
(frog-menu-avy-padding t))
(use-package frog-jump-buffer
:chords
(";a" . frog-jump-buffer)
:custom
(frog-jump-buffer-posframe-handler #'posframe-poshandler-frame-center)
(frog-jump-buffer-default-filters-capital-letters t)
(frog-jump-buffer-project-package 'project)
:config
(dolist
(regexp
'("TAGS"
"^\\magit-"
"^\\*Compile-log"
"-debug\\*$"
"^\\:"
"^\\*helpful"
"^\\*Async"
"errors\\*$"
"^\\*Backtrace"
"stderr\\*$"
"EGLOT"
"^\\*Flymake"
"^\\*Warnings"
"^\\*eldoc"
"\\^*Shell Command"))