-
Notifications
You must be signed in to change notification settings - Fork 1
/
init.el
1729 lines (1462 loc) · 56.2 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
;;; init.el --- My personal emacs config -*- lexical-binding: t; -*-
;; Author: Kevin Borling <https://github.com/kborling>
;; Version: 1.2.0
;; Keywords: configuration
;; URL: https://github.com/kborling/emacs-config
;; Homepage: https://github.com/kborling/emacs-config
;; Package-Requires: ((emacs "29"))
;;; Commentary:
;; Copyright (C) 2023 Kevin Borling
;; My personal Emacs config.
;;; Code:
;; Backups ========================================== ;;
;; Auto-revert mode
(setopt
auto-revert-interval 0.5
auto-revert-verbose t)
(add-hook 'after-init-hook #'global-auto-revert-mode)
;; Backup stored in /tmp
(setq
backup-directory-alist
`((".*" . ,temporary-file-directory))
auto-save-file-name-transforms
`((".*" , temporary-file-directory t))
backup-by-copying t
version-control t
delete-old-versions t
kept-new-versions 6
kept-old-versions 2
create-lockfiles nil)
;; User ============================================= ;;
(setq user-full-name "Kevin Borling"
user-mail-address "[email protected]")
;; Defaults ========================================= ;;
(setq
frame-title-format '("%b")
use-short-answers t
ring-bell-function 'ignore
visible-bell nil
sentence-end-double-space nil
fill-column 100
column-number-mode t
apropos-do-all t
mouse-yank-at-point t
require-final-newline t
load-prefer-newer t
set-mark-command-repeat-pop t
global-mark-ring-max 50000
bookmark-save-flag 1)
;; (setq-default cursor-type 'hollow)
;; Remember cursor place
(setq
save-place-file (locate-user-emacs-file "saveplace")
save-place-forget-unreadable-files t)
(save-place-mode 1)
;; Enable indentation+completion using the TAB key.
(setq tab-always-indent 'complete)
(setq-default indent-tabs-mode nil
tab-stop-list ()
tab-width 2
c-basic-offset 4
sgml-basic-offset 4
js-switch-indent-offset 4)
(show-paren-mode 1)
;; Treat Camelcase as words
(global-subword-mode 1)
;; Delete marked region when input
(add-hook 'after-init-hook #'delete-selection-mode)
;; Smooth scrolling
(add-hook 'after-init-hook #'pixel-scroll-precision-mode)
(autoload 'zap-up-to-char "misc"
"Kill up to, but not including ARGth occurrence of CHAR." t)
;; Improve LSP performance
(fset #'jsonrpc--log-event #'ignore)
(add-hook 'focus-out-hook 'garbage-collect)
;; Package ============================================= ;;
(require 'package)
(setq package-archives
'(("elpa" . "https://elpa.gnu.org/packages/")
("elpa-devel" . "https://elpa.gnu.org/devel/")
("org" . "https://orgmode.org/elpa/")
("nongnu" . "https://elpa.nongnu.org/nongnu/")
("melpa" . "https://melpa.org/packages/")))
;; Highest number gets priority (what is not mentioned has priority 0)
(setq package-archive-priorities
'(("elpa" . 2)
("nongnu" . 1)))
;; (setq package-pinned-packages
;; '((corfu . "elpa-devel")))
(unless package--initialized
(package-initialize))
(unless package-archive-contents
(package-refresh-contents))
;; Initialize use-package on non-Linux platforms
(unless (package-installed-p 'use-package)
(package-install 'use-package))
(eval-when-compile
(require 'use-package))
(setq use-package-always-ensure t)
(if (>= emacs-major-version 30)
;; Use the built-in vc-use-package in Emacs 30+
(require 'vc-use-package)
;; Otherwise, install and require it from GitHub
(unless (package-installed-p 'vc-use-package)
(package-vc-install "https://github.com/slotThe/vc-use-package"))
(require 'vc-use-package))
;; Electric Pairs ====================================== ;;
;; make electric-pair-mode work on more brackets
(use-package elec-pair
:ensure nil
:config
(setq
electric-pair-inhibit-predicate 'electric-pair-conservative-inhibit
electric-pair-preserve-balance t
electric-pair-pair
'((8216 . 8217)
(8220 . 8221)
(171 . 187))
electric-pair-skip-self 'electric-pair-default-skip-self
electric-pair-skip-whitespace nil
electric-pair-skip-whitespace-chars '(9 10 32)))
;; (electric-pair-mode -1)
(use-package electric
:ensure nil
:config
(setq
electric-quote-context-sensitive t
electric-quote-paragraph t
electric-quote-string nil
electric-quote-replace-double t)
;; (electric-quote-mode -1)
(electric-indent-mode -1)
(add-hook 'prog-mode-hook #'electric-indent-local-mode))
;; Hooks ============================================= ;;
;; (add-hook 'emacs-startup-hook 'toggle-frame-maximized)
(add-hook 'before-save-hook #'delete-trailing-whitespace)
;; Keybindings ======================================= ;;
(let ((map global-map))
;; Remove suspend
(define-key map (kbd "C-z") nil)
(define-key map (kbd "C-x C-z") nil)
(define-key map (kbd "C-h C-r") #'restart-emacs)
(define-key map (kbd "C-c C-r") #'query-replace)
(define-key map (kbd "C-;") #'comment-line)
(define-key map (kbd "C-x f") #'project-find-file)
(define-key map (kbd "C-x /") #'set-fill-column)
(define-key map (kbd "M-(") #'insert-pair)
(define-key map (kbd "M-\"") #'insert-pair)
(define-key map (kbd "M-{") #'insert-pair)
(define-key map (kbd "M-[") #'insert-pair)
(define-key map (kbd "C-c C-p") #'previous-buffer)
(define-key map (kbd "C-c C-n") #'next-buffer)
(define-key map (kbd "C-o") #'other-window)
;; Misc
(define-key map (kbd "C-x b") #'ibuffer)
(define-key map (kbd "M-z") #'zap-up-to-char)
(define-key map (kbd "C-z") #'zap-to-char)
;; isearch
(define-key map (kbd "C-s") #'isearch-forward-regexp)
(define-key map (kbd "C-r") #'isearch-backward-regexp)
(define-key map (kbd "C-M-s") #'isearch-forward-symbol-at-point)
;; Open stuff
(define-key map (kbd "C-c t e") #'eshell)
(define-key map (kbd "C-c t t") #'ansi-term)
(define-key map (kbd "C-c t d") #'dired-jump-other-window)
(define-key map (kbd "C-c t s") #'sr-speedbar-toggle)
;; Toggle stuff
(define-key map (kbd "C-c t f") #'toggle-frame-fullscreen))
;; Theming ================================================ ;;
(setq-default line-spacing 2)
(defvar default-font-size
(cond
((eq system-type 'windows-nt) 100)
((eq system-type 'gnu/linux) 120)
((eq system-type 'darwin) 160)))
(defvar default-font-family
(cond
((eq system-type 'windows-nt) "Cascadia Code")
((eq system-type 'gnu/linux) "Inconsolata")
((eq system-type 'darwin) "Inconsolata")))
(set-face-attribute 'default nil
:family default-font-family :weight 'regular :height default-font-size)
(set-face-attribute 'bold nil
:family default-font-family :weight 'medium)
(set-face-attribute 'italic nil
:family default-font-family :weight 'regular :slant 'italic)
(set-face-attribute 'variable-pitch nil
:family "Berkeley Mono Variable" :height (+ default-font-size 20) :weight 'regular)
(set-fontset-font t 'unicode
(font-spec :name "Inconsolata Light" :size 16) nil)
;; Custom themes
(use-package haki-theme)
(use-package acme-theme)
(use-package uwu-theme
:vc (:fetcher github :repo "kborling/uwu-theme")
:config
(setq
uwu-distinct-line-numbers 'nil
uwu-scale-org-headlines t
uwu-use-variable-pitch t)
(load-theme 'uwu t))
;; Recent Files ====================================== ;;
(use-package recentf
:ensure nil
:config
(setq
recentf-save-file (locate-user-emacs-file "recentf")
recentf-max-saved-items 50
recentf-exclude '(".gz" ".xz" ".zip" "/elpaca/" "/elpa/" "/opt/" "/.rustup/" "/elpa/" "/ssh:" "/sudo:" "/node_modules/" "/nix/"))
:init
(add-hook 'after-init-hook #'recentf-mode))
;; Exec Path ========================================= ;;
(use-package exec-path-from-shell
:ensure t
:if (memq window-system '(mac ns x))
:config
(setq exec-path-from-shell-variables '("PATH" "GOPATH"))
(exec-path-from-shell-initialize))
;; Diminish ========================================== ;;
(use-package diminish
:config
(diminish 'subword-mode)
(diminish 'eldoc-mode))
;; Which Key ========================================= ;;
(use-package which-key
:defer 0
:diminish
:config
(which-key-mode)
(setq which-key-idle-delay 1))
;; Crux ============================================== ;;
(use-package crux
:bind (("C-a" . crux-move-beginning-of-line)
("C-k" . crux-smart-kill-line)
("M-<return>" . crux-smart-open-line-above)
("C-x w" . crux-rename-file-and-buffer)
("C-c C-d" . crux-duplicate-current-line-or-region)
("C-c M-d" . crux-duplicate-and-comment-current-line-or-region)
("C-x 4 t" . crux-transpose-windows)
("C-^" . crux-top-join-line)
([(shift return)] . crux-smart-open-line)))
(global-set-key [remap kill-whole-line] #'crux-kill-whole-line)
;; Highlight Todo ====================================== ;;
(use-package hl-todo
:config
(global-hl-todo-mode))
;; Rainbow Mode ======================================== ;;
(use-package rainbow-mode
:diminish
:hook ((prog-mode) . rainbow-mode))
;; Magit =============================================== ;;
(use-package transient)
(use-package ssh-agency :vc (:fetcher github :repo "magit/ssh-agency"))
(use-package magit
:bind (("C-c g g" . magit-status)
("C-c g s" . magit-status)
("C-c g i" . magit-init)
("C-c g c" . magit-clone)
("C-c g l" . magit-pull)
("C-c g p" . magit-push)
("C-c g f" . magit-fetch-all)
("C-c g b" . magit-branch)
("C-c g d" . magit-diff)
("C-c g r" . magit-remote)
("C-c g z" . magit-stash)
("C-c g Z" . magit-apply)))
;; :config
;; (setq magit-status-sections-hook
;; '(magit-insert-error-header
;; magit-insert-head-branch-header
;; magit-insert-unstaged-changes
;; magit-insert-staged-changes
;; magit-insert-unpushed-to-pushremote))
;; (setq magit-status-headers-hook nil))
;; Marginalia ======================================== ;;
;; (use-package marginalia
;; :bind (("M-A" . marginalia-cycle)
;; :map minibuffer-local-map
;; ("M-A" . marginalia-cycle))
;; :init
;; (marginalia-mode))
;; Corfu ============================================= ;;
(use-package corfu
:hook ((prog-mode . corfu-mode)
(shell-mode . corfu-mode)
(eshell-mode . corfu-mode))
:custom
(corfu-cycle t) ;; Enable cycling for `corfu-next/previous'
(corfu-auto nil) ;; Enable auto completion
(corfu-separator ?\s) ;; Orderless field separator
(corfu-quit-no-match 'separator) ;; Don't quit if there is `corfu-separator' inserted
(corfu-echo-documentation nil) ;; Disable documentation in the echo area
(corfu-scroll-margin 4)
:config
(corfu-popupinfo-mode 1)
(setq corfu-popupinfo-delay 0.2)
(corfu-history-mode 1)
(define-key corfu-map (kbd "<tab>") #'corfu-complete)
(defun corfu-move-to-minibuffer ()
"Use corfu for completions in the minibuffer."
(interactive)
(let (completion-cycle-threshold completion-cycling)
(apply #'consult-completion-in-region completion-in-region--data)))
(define-key corfu-map "\M-m" #'corfu-move-to-minibuffer))
(use-package cape
:config
(add-to-list 'completion-at-point-functions #'cape-dabbrev)
(add-to-list 'completion-at-point-functions #'cape-file)
;;(add-to-list 'completion-at-point-functions #'cape-history)
(add-to-list 'completion-at-point-functions #'cape-keyword)
(add-to-list 'completion-at-point-functions #'cape-symbol)
;; (add-to-list 'completion-at-point-functions #'cape-line)
;; https://github.com/minad/corfu/wiki#continuously-update-the-candidates
(advice-add 'eglot-completion-at-point :around #'cape-wrap-buster))
;; Templates ================================================
(use-package tempel
;; Require trigger prefix before template name when completing.
;; :custom
;; (tempel-trigger-prefix "<")
:bind (("C-<tab>" . tempel-complete) ;; Alternative tempel-expand
("M-+" . tempel-insert)
("C-1" . tempel-previous)
("C-2" . tempel-next))
:init
;; Setup completion at point
(defun tempel-setup-capf ()
(setq-local completion-at-point-functions
(cons #'tempel-expand
completion-at-point-functions)))
(add-hook 'prog-mode-hook 'tempel-setup-capf)
(add-hook 'text-mode-hook 'tempel-setup-capf)
;; Optionally make the Tempel templates available to Abbrev,
;; either locally or globally. `expand-abbrev' is bound to C-x '.
(add-hook 'prog-mode-hook #'tempel-abbrev-mode)
;; (global-tempel-abbrev-mode)
)
(use-package tempel-collection
:after tempel)
;; TAGS ============================================== ;;
(setq path-to-ctags (locate-file "ctags" exec-path))
(defun create-tags (dir-name)
"Create tags file using 'DIR-NAME'."
(interactive "DDirectory: ")
(shell-command
(format "%s -f TAGS -e -R %s" path-to-ctags (directory-file-name dir-name))))
;; Multiple Cursors ================================== ;;
(use-package multiple-cursors
:diminish
:bind (("C->" . mc/mark-next-like-this)
("C-<" . mc/mark-previous-like-this)
("C-c C-<" . mc/mark-all-like-this)
("C-S-c C-S-c" . mc/mark-edit-lines)))
;; So Long =========================================== ;;
(use-package so-long
:config
(global-so-long-mode 1))
;; Dabbrev =========================================== ;;
(use-package dabbrev
:ensure nil
:config
(setq
dabbrev-abbrev-char-regexp "\\sw\\|\\s_"
dabbrev-abbrev-skip-leading-regexp "[$*/=~']"
dabbrev-backward-only nil
dabbrev-case-distinction 'case-replace
dabbrev-case-fold-search nil
dabbrev-case-replace 'case-replace
dabbrev-check-other-buffers t
dabbrev-eliminate-newlines t
dabbrev-upcase-means-case-search t)
(let ((map global-map))
(define-key map (kbd "M-/") #'dabbrev-expand)
(define-key map (kbd "M-\\") #'hippie-expand)
(define-key map (kbd "C-M-/") #'dabbrev-completion)))
;; (global-set-key [remap dabbrev-expand] 'hippie-expand)
;; Completion Styles ================================= ;;
(use-package minibuffer
:ensure nil
:config
(setq
completion-category-defaults nil
completion-category-overrides nil
completion-cycle-threshold 2
completion-flex-nospace nil
completion-pcm-complete-word-inserts-delimiters nil
completion-pcm-word-delimiters "-_./:| "
completion-ignore-case t
completions-detailed t
completion-show-inline-help nil)
(setq
completions-group t
completions-group-sort nil
completions-group-format
(concat
(propertize " " 'face 'completions-group-separator)
(propertize " %s " 'face 'completions-group-title)
(propertize " " 'face 'completions-group-separator
'display '(space :align-to right)))
read-buffer-completion-ignore-case t
read-file-name-completion-ignore-case t
;; enable-recursive-minibuffers t
read-answer-short t
resize-mini-windows t
minibuffer-eldef-shorten-default t
echo-keystrokes 0.25
minibuffer-prompt-properties
'(read-only t cursor-intangible t face minibuffer-prompt))
(setq-default case-fold-search t)
(add-hook 'minibuffer-setup-hook #'cursor-intangible-mode)
(file-name-shadow-mode 1)
(minibuffer-depth-indicate-mode 1)
(minibuffer-electric-default-mode 1))
(defun stop-using-minibuffer ()
"Xill the minibuffer."
(when (and (>= (recursion-depth) 1) (active-minibuffer-window))
(abort-recursive-edit)))
(add-hook 'mouse-leave-buffer-hook 'stop-using-minibuffer)
;; Modeline ============================================= ;;
(setq
mode-line-compact nil
mode-line-percent-position '(-3 "%p")
mode-line-position-column-line-format '(" %l,%c")
mode-line-defining-kbd-macro
(propertize " Macro" 'face 'mode-line-emphasis))
(setq-default mode-line-modes
(seq-filter (lambda (s)
(not (and (stringp s)
(string-match-p
"^\\(%\\[\\|%\\]\\)$" s))))
mode-line-modes))
(setq-default mode-line-format
'("%e"
mode-line-front-space
mode-line-mule-info
mode-line-client
mode-line-modified
mode-line-remote
mode-line-frame-identification
mode-line-buffer-identification
" "
mode-line-position
mode-line-modes
" "
(vc-mode vc-mode)
" "
mode-line-misc-info
mode-line-end-spaces))
;; Ibuffer ============================================== ;;
(use-package ibuffer
:ensure nil
:config
(setq
ibuffer-expert t
ibuffer-display-summary nil
ibuffer-use-other-window nil
ibuffer-show-empty-filter-groups nil
ibuffer-movement-cycle nil
ibuffer-default-sorting-mode 'filename/process
ibuffer-use-header-line t
ibuffer-default-shrink-to-minimum-size nil
ibuffer-format
'((mark modified read-only locked " "
(name 40 40 :left :elide)
" "
(size 9 -1 :right)
" "
(mode 16 16 :left :elide)
" " filename-and-process)
(mark " "
(name 16 -1)
" " filename))
ibuffer-saved-filter-groups nil
ibuffer-old-time 48)
(add-hook 'ibuffer-mode-hook #'hl-line-mode))
;; Winner =============================================== ;;
(use-package winner
:ensure nil
:config
(let ((map global-map))
(define-key map (kbd "C-c <") #'winner-redo)
(define-key map (kbd "C-c >") #'winner-undo))
:init
(add-hook 'after-init-hook #'winner-mode))
;; EAT ================================================== ;;
(use-package eat
:vc (:fetcher codeberg :repo "akib/emacs-eat")
:config
(add-hook 'eshell-load-hook #'eat-eshell-mode))
;; Fussy =============================================== ;;
(use-package fussy
:config
(setq fussy-use-cache t)
(setq fussy-filter-fn 'fussy-filter-default)
(setq fussy-compare-same-score-fn 'fussy-histlen->strlen<)
(push 'fussy completion-styles)
(advice-add 'corfu--capf-wrapper :before 'fussy-wipe-cache)
(add-hook 'corfu-mode-hook
(lambda ()
(setq-local fussy-max-candidate-limit 5000
fussy-default-regex-fn 'fussy-pattern-first-letter
fussy-prefer-prefix nil)))
(with-eval-after-load 'eglot
(add-to-list 'completion-category-overrides
'(eglot (styles fussy basic)))))
;; Fido ================================================ ;;
(use-package icomplete
:ensure nil
:init
(fido-mode)
:config
(setq icomplete-tidy-shadowed-file-names t
icomplete-show-matches-on-no-input t
icomplete-compute-delay 0
icomplete-delay-completions-threshold 50)
(global-set-key (kbd "C-=") 'fido-vertical-mode))
;; Dired ============================================= ;;
(use-package dired
:ensure nil
:config
(setq
dired-recursive-copies 'always
dired-recursive-deletes 'always
delete-by-moving-to-trash t
dired-dwim-target t
dired-auto-revert-buffer #'dired-directory-changed-p
dired-make-directory-clickable t
dired-free-space nil
dired-isearch-filenames 'dwim
dired-create-destination-dirs 'ask
dired-vc-rename-file t
dired-do-revert-buffer (lambda (dir) (not (file-remote-p dir)))
dired-kill-when-opening-new-dired-buffer t
dired-clean-up-buffers-too t
dired-clean-confirm-killing-deleted-buffers t
dired-x-hands-off-my-keys t
dired-bind-man nil
dired-bind-info nil
;; dired-use-ls-dired t
;; wdired-allow-to-change-permissions t
;; wdired-create-parent-directories t
image-dired-thumb-size 80
image-dired-thumb-margin 2
image-dired-thumb-relief 0
image-dired-thumbs-per-row 4)
(add-hook 'dired-mode-hook #'dired-hide-details-mode)
(add-hook 'dired-mode-hook #'hl-line-mode)
)
;; Xref ============================================== ;;
(use-package xref
:ensure nil
:config
(setq
xref-show-definitions-function #'xref-show-definitions-completing-read
xref-show-xrefs-function #'xref-show-definitions-buffer
xref-file-name-display 'project-relative
xref-search-program 'ripgrep))
;; ISearch =========================================== ;;
(use-package isearch
:ensure nil
:config
(setq
search-highlight t
search-whitespace-regexp ".*?"
isearch-lax-whitespace t
isearch-regexp-lax-whitespace nil
isearch-lazy-highlight t
isearch-lazy-count t
lazy-count-prefix-format nil
lazy-count-suffix-format " (%s/%s)"
isearch-yank-on-move 'shift
isearch-allow-scroll 'unlimited
isearch-repeat-on-direction-change t
lazy-highlight-initial-delay 0.5
lazy-highlight-no-delay-length 3
isearch-wrap-pause t)
(define-key minibuffer-local-isearch-map (kbd "M-/") #'isearch-complete-edit)
(let ((map isearch-mode-map))
(define-key map (kbd "C-g") #'isearch-cancel) ; instead of `isearch-abort'
(define-key map (kbd "M-/") #'isearch-complete)))
;; SaveHist ========================================== ;;
(use-package savehist
:ensure nil
:config
(setq
savehist-file (locate-user-emacs-file "savehist")
history-length 10000
history-delete-duplicates t
savehist-save-minibuffer-history t)
:init
(add-hook 'after-init-hook #'savehist-mode))
;; SmartScan ========================================== ;;
(use-package smartscan
:config
(global-smartscan-mode 1))
;; Consult ============================================ ;;
(use-package consult
:bind (;; C-c bindings (mode-specific-map)
;; ("C-c h" . consult-history)
("M-X" . consult-mode-command)
("C-c k" . consult-kmacro)
("C-h t" . consult-theme)
("C-c m" . consult-man)
("C-c i" . consult-info)
([remap Info-search] . consult-info)
;; C-x bindings (ctl-x-map)
("C-x C-z" . consult-complex-command) ;; orig. repeat-complex-command
("C-x C-b" . consult-buffer) ;; orig. switch-to-buffer
("C-x 4 b" . consult-buffer-other-window) ;; orig. switch-to-buffer-other-window
("C-x 5 b" . consult-buffer-other-frame) ;; orig. switch-to-buffer-other-frame
("C-x r b" . consult-bookmark) ;; orig. bookmark-jump
("C-x p b" . consult-project-buffer) ;; orig. project-switch-to-buffer
("C-x C-r" . consult-recent-file)
;; Custom M-# bindings for fast register access
("M-R" . consult-register-load)
("M-S" . consult-register-store) ;; orig. abbrev-prefix-mark (unrelated)
("C-M-r" . consult-register)
;; Other custom bindings
("M-y" . consult-yank-pop) ;; orig. yank-pop
;; M-g bindings (goto-map)
("M-g e" . consult-compile-error)
("M-g f" . consult-flymake) ;; Alternative: consult-flycheck
("M-g g" . consult-goto-line) ;; orig. goto-line
("M-g M-g" . consult-goto-line) ;; orig. goto-line
("M-g o" . consult-outline) ;; Alternative: consult-org-heading
("M-g m" . consult-mark)
("M-g k" . consult-global-mark)
("M-g i" . consult-imenu)
("M-g I" . consult-imenu-multi)
;; M-s bindings (search-map)
("M-s f" . consult-find)
("M-s F" . consult-fd)
;; ("M-s D" . consult-locate)
("M-s g" . consult-grep)
("M-s G" . consult-git-grep)
("M-s r" . consult-ripgrep)
("M-s l" . consult-line)
("M-s L" . consult-line-multi)
("M-s k" . consult-keep-lines)
("M-s u" . consult-focus-lines)
;; Isearch integration
("M-s e" . consult-isearch-history)
:map isearch-mode-map
("M-e" . consult-isearch-history) ;; orig. isearch-edit-string
("M-s e" . consult-isearch-history) ;; orig. isearch-edit-string
("M-s l" . consult-line) ;; needed by consult-line to detect isearch
("M-s L" . consult-line-multi)) ;; needed by consult-line to detect isearch
;; Minibuffer history
;; :map minibuffer-local-map
;; ("M-s" . consult-history) ;; orig. next-matching-history-element
;; ("M-r" . consult-history)) ;; orig. previous-matching-history-element
;; Enable automatic preview at point in the *Completions* buffer.
:hook (completion-list-mode . consult-preview-at-point-mode)
;; The :init configuration is always executed (Not lazy)
:init
(setq register-preview-delay 0.5
register-preview-function #'consult-register-format)
;; This adds thin lines, sorting and hides the mode line of the window.
(advice-add #'register-preview :override #'consult-register-window)
;; Enable consult previews
(add-hook 'completion-list-mode-hook #'consult-preview-at-point-mode)
;; Use Consult to select xref locations with preview
(setq xref-show-xrefs-function #'consult-xref
xref-show-definitions-function #'consult-xref)
;; Use `consult-completion-in-region' if fido is enabled.
;; Otherwise use the default `completion--in-region' function.
;; (setq completion-in-region-function
;; (lambda (&rest args)
;; (apply (if fido-mode
;; #'consult-completion-in-region
;; #'completion--in-region)
;; args)))
:config
(consult-customize
consult-theme
:preview-key '(:debounce 0.2 any)
consult-ripgrep consult-git-grep consult-grep
consult-bookmark consult-recent-file consult-xref
consult--source-bookmark consult--source-file-register
consult--source-recent-file consult--source-project-recent-file
:preview-key '(:debounce 0.4 any)
consult-line :prompt "Search: "
:preview-key (list (kbd "<S-down>") (kbd "<S-up>")))
(setq consult-narrow-key "<") ;; (kbd "C-+")
;; Ignore certain directories when using 'consult-find'
(setq consult-find-args "find . -not ( -wholename */.* -prune -o -name node_modules -prune )")
;; By default `consult-project-function' uses `project-root' from project.el.
;; Optionally configure a different project root function.
;;;; 2. vc.el (vc-root-dir)
;; (setq consult-project-function (lambda (_) (vc-root-dir)))
;;;; 3. locate-dominating-file
;; (setq consult-project-function (lambda (_) (locate-dominating-file "." ".git")))
;;;; 4. projectile.el (projectile-project-root)
;; (autoload 'projectile-project-root "projectile")
;; (setq consult-project-function (lambda (_) (projectile-project-root)))
)
(use-package consult-dir
:after consult
:bind (("C-x C-d" . consult-dir)
:map minibuffer-local-completion-map
("C-x C-d" . consult-dir)
("C-x C-j" . consult-dir-jump-file)))
(use-package consult-todo
:after consult
:bind (("C-x p t" . consult-todo-project)
("M-s t" . consult-todo)))
;; Embark ============================================ ;;
(use-package embark
:bind
(("C-," . embark-act)
("M-." . embark-dwim)
("C-c C-," . embark-act)
("C-c C-." . embark-act-all)
("C-c C-;" . embark-collect)
("C-h B" . embark-bindings))
:bind
([remap describe-bindings] . embark-bindings)
:custom
(prefix-help-command #'embark-prefix-help-command)
:init
;; Optionally replace the key help with a completing-read interface
(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 (consult embark)
:hook
(embark-collect-mode . consult-preview-at-point-mode))
;; Speedbar ========================================== ;;
(use-package speedbar
:ensure nil
:config
(setq speedbar-frame-width 40
speedbar-use-images nil
speedbar-show-unknown-files t)
(customize-set-variable 'speedbar-frame-parameters
'((name . "speedbar")
(title . "speedbar")
(minibuffer . nil)
(border-width . 2)
(menu-bar-lines . 0)
(tool-bar-lines . 0)
(unsplittable . t)
(left-fringe . 10))))
(use-package sr-speedbar
:after speedbar
:config
(setq sr-speedbar-skip-other-window-p t))
;; Eldoc Box ========================================= ;;
(use-package eldoc
:ensure nil
:config
(global-eldoc-mode 1)
(setq eldoc-echo-area-use-multiline-p t
eldoc-idle-delay 0.75))
(use-package eldoc-box
:after eldoc
:config
(add-hook 'eglot-managed-mode-hook #'eldoc-box-hover-mode t))
;; Project ============================================ ;;
(use-package project
:ensure nil
:config
(setq vc-directory-exclusion-list
(nconc vc-directory-exclusion-list
'("node_modules"
".sl")))
(setq project-vc-extra-root-markers '(".envrc" "package.json" ".project" ".sl")))
;; Eglot ============================================== ;;
(use-package eglot
:ensure nil
:config
(setq eglot-sync-connect 0
eglot-send-changes-idle-time 0
eglot-events-buffer-size 0
eglot-ignored-server-capabilities '(:hoverProvider
:documentHighlightProvider)
eglot-autoshutdown t
eglot-confirm-server-initiated-edits nil)
;; (add-to-list 'eglot-stay-out-of 'flymake)
;; Keybindings
(define-key eglot-mode-map (kbd "C-c c r") 'eglot-rename)
(define-key eglot-mode-map (kbd "C-c c f") 'eglot-format-buffer)
(define-key eglot-mode-map (kbd "C-c c o") 'eglot-code-action-organize-imports)
(define-key eglot-mode-map (kbd "C-c c a") 'eglot-code-actions)
(define-key eglot-mode-map (kbd "C-.") 'eglot-code-actions)
(define-key eglot-mode-map (kbd "C-c c q") 'eglot-code-action-quickfix)
(define-key eglot-mode-map (kbd "C-c c e") 'eglot-code-action-extract)
(define-key eglot-mode-map (kbd "C-c c j") 'eglot-code-action-inline)
(define-key eglot-mode-map (kbd "C-c c k") 'eglot-code-action-rewrite)
(define-key eglot-mode-map (kbd "C-c c i") 'eglot-find-implementation)
(define-key eglot-mode-map (kbd "C-c c d") 'eglot-find-declaration)
(define-key eglot-mode-map (kbd "C-c c t") 'eglot-find-typeDefinition)
(define-key eglot-mode-map (kbd "C-c c h") 'eldoc)
;; (define-key eglot-mode-map (kbd "C-c c d") 'xref-find-definitions))
;; Language Servers
;; (add-to-list 'eglot-server-programs '(gdscript-mode . ("localhost" 6008)))
(add-to-list 'eglot-server-programs '(csharp-mode . ("omnisharp" "-lsp")))
(add-to-list 'eglot-server-programs '(js-ts-mode . ("quick-lint-js" "--lsp-server")))
(add-to-list 'eglot-server-programs '(typescript-ts-mode . ("typescript-language-server" "--stdio")))
(add-to-list 'eglot-server-programs '(rust-mode . ("rls" "--stdio")))
(add-to-list 'eglot-server-programs '(rustic-mode . ("rls" "--stdio")))
(add-to-list 'eglot-server-programs '((c++-mode c-mode)
. ("clangd"
"-j=8"
"--log=error"
"--malloc-trim"
"--background-index"
"--clang-tidy"
"--cross-file-rename"
"--completion-style=detailed"
"--pch-storage=memory"
"--header-insertion=never"
"--header-insertion-decorators=0")))
(defvar node-modules-path
(let* ((global-prefix (string-trim (shell-command-to-string "npm config get --global prefix")))
(modules-path (if (eq system-type 'windows-nt)
"node_modules"
"lib/node_modules")))
(expand-file-name modules-path global-prefix)))
(add-to-list 'eglot-server-programs
`(angular-template-mode . ("ngserver"
"--stdio"
"--ngProbeLocations"
,node-modules-path
"--tsProbeLocations"
,node-modules-path
)))
;; Show all of the available eldoc information when we want it. This way Flymake errors
;; don't just get clobbered by docstrings.
(add-hook 'eglot-managed-mode-hook
(lambda ()
"Make sure Eldoc will show us all of the feedback at point."
(setq-local eldoc-documentation-strategy
#'eldoc-documentation-compose)))