-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.el
1428 lines (1222 loc) · 44 KB
/
config.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
;; EMACS CONFIG
; see `https://blog.aaronbieber.com/2015/05/24/fronmnent variable HOME, (at Users/name or wherever), create .emacs.d there
;; remember -- you _MUST_ run 'all-the-icons-install-fonts' AND 'nerd-icons-install-fonts' then install the fonts to get that working ;; NOTE now run `nerd-icons-install-fonts' then install the fonts to get that working
;; see 'https://www.emacswiki.org/emacs/BookMarks' for bookmark usage
;; NOTE sometimes you gotta run package-refresh-contents
;; (uinversal-argument) into (rectangle-number-lines)
;; NOTE see 'https://irreal.org/blog' for some emacs stuff
;; NOTE see 'https://codelearn.me/' for more emacs stuff
;; NOTE: using --eval on windows: emacs -Q --batch --eval '(message \"Hi!\")'
;; NOTE: (kill-new (shell-command-to-string "gcc --help")) runs a shell command, converts the output to a string, then puts it into the kill-ring
;; Make startup faster by reducing the frequency of gc. Default is 800kb -- measured in bytes.
(setq gc-cons-threshod (* 50 1000 1000))
;;;;;;;;;;;;;;;;
;; DEFUN HELL ;;
;;;;;;;;;;;;;;;;
;; The POSIX Programmer's Manual has its own dedicated sections in man, namely 0p (header files), 1p (commands) and 3p (functions).
(defun posix-man ()
"Man just POSIX pages."
(interactive)
(man (format "-s 0p,1p,3p %s"
(completing-read "man (0p,1p,3p): "
`(,(if (thing-at-point 'symbol t)
(thing-at-point 'symbol t)
""))))))
;; Add prompt indicator to `completing-read-multiple'.
;; We display [CRM<separator>], e.g., [CRM,] if the separator is a comma.
(defun crm-indicator (args)
(cons (format "[CRM%s] %s"
(replace-regexp-in-string
"\\`\\[.*?]\\*\\|\\[.*?]\\*\\'" ""
crm-separator)
(car args))
(cdr args)))
(defun kill-current-buffer ()
"kills the current buffer"
(interactive)
(kill-buffer (current-buffer)))
(defun eww-clipboard ()
"eww WHATEVER is in the clipboard"
(interactive)
(let ((select-enable-clipboard t)
(gui--last-selected-text-clipboard nil))
(eww (current-kill 0))))
(advice-add #'completing-read-multiple :filter-args #'crm-indicator)
;; (defun append-comment ()
;; "append comment at eol and move to eol (evil-only: enter insert move)"
;; (interactive)
;; (atomic-change-group
;; (end-of-line)
;; (sp-comment)
;; (if (bound-and-true-p)
;; (evil-append-line nil)
;; (end-of-line))))
(defun my/visual-comment-or-uncomment-region (&optional start end)
"comments out a region"
(interactive "r")
(evilnc-comment-or-uncomment-region start end))
(defun temp-notes ()
"Brings up `*TEMP-NOTES*' in org-mode"
(interactive)
(switch-to-buffer (get-buffer-create "*TEMP-NOTES*"))
(org-mode))
(defun toggle-linums ()
"Toggle between relative & absolute line numbers."
(interactive)
(if (eq display-line-numbers-type t)
(setq display-line-numbers-type 'relative)
(setq display-line-numbers-type t)))
(defun relative-linums ()
(interactive)
(setq display-line-numbers-type 'relative))
(defun obs-1080p ()
"set the frame size to 1900x1080 pixels because for some raisin emacs gives a free 16 horizontal pixels."
(interactive)
(set-frame-size (selected-frame) 1920 (- 1080 16) t))
(defun obs-720p ()
"set the frame size to 1900x1080 pixels because for some raisin emacs gives a free 16 horizontal pixels."
(interactive)
(set-frame-size (selected-frame) 1280 (- 720 16) t))
(defun ymd-date ()
"lol lmao"
(interactive)
(insert (format-time-string "%Y-%m-%d")))
(defun my/shell-right ()
"foo"
(interactive)
(my/vsplit-then-move-right)
(shell))
(defun my/shell-down ()
"foo"
(interactive)
(my/split-then-move-down)
(shell))
(defun my/ibuffer-toggle ()
"Toggle the ibuffer list."
(interactive)
(if (string= (buffer-name) "*Ibuffer*")
(kill-buffer-and-window)
(progn
(ibuffer-list-buffers)
(pop-to-buffer "*Ibuffer*")
(ibuffer-mark-unsaved-buffers))))
(defun rename-this-file (&optional new-name)
"Rename buffer's current file to NEW-NAME."
(interactive "*FRename current file to: ")
(when (buffer-file-name)
(if (file-exists-p new-name)
(message "%s already exists!" new-name)
(let ((old-buffer (buffer-name)))
(rename-file (buffer-file-name) new-name)
(find-file new-name)
(kill-buffer old-buffer)))))
(defun my/shell-command-region (&optional point mark)
(interactive "r")
(let ((command (buffer-substring point mark)))
(shell-command command)))
;; NOTE: unused atm
(defun delete-compile-window-if-successful (buf desc)
"Bury a compilation buffer if succeeded without warnings"
(when (and (buffer-live-p buf) (string-match "finished" desc))
(delete-window (get-buffer-window buf))))
;; (add-hook 'compilation-finish-functions #'delete-compile-window-if-successful)
;;;;;;;;;;;;;;;;;;;;;;;;
;; PACKAGE MANAGEMENT ;;
;;;;;;;;;;;;;;;;;;;;;;;;
(require 'package)
(add-to-list 'package-archives '("gnu" . "https://elpa.gnu.org/packages/") t)
(add-to-list 'package-archives '("org" . "https://orgmode.org/elpa/") t)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
(add-to-list 'package-archives '("melpa-stable" . "https://stable.melpa.org/packages/") t)
(setq package-enable-at-startup nil)
(package-initialize)
;; bootstrap straight.el
(defvar bootstrap-version)
(let ((bootstrap-file
(expand-file-name
"straight/repos/straight.el/bootstrap.el"
(or (bound-and-true-p straight-base-dir)
user-emacs-directory)))
(bootstrap-version 7))
(unless (file-exists-p bootstrap-file)
(with-current-buffer
(url-retrieve-synchronously
"https://raw.githubusercontent.com/radian-software/straight.el/develop/install.el"
'silent 'inhibit-cookies)
(goto-char (point-max))
(eval-print-last-sexp)))
(load bootstrap-file nil 'nomessage))
;; install use-package with straight
;; setup use-package
;; NOTE: see `https://github.com./jweiegley/use-package' for usage
(unless (package-installed-p 'use-package)
(package-refresh-contents)
(package-install 'use-package))
(eval-when-compile
(require 'use-package))
(setq use-package-always-ensure t) ;; NOTE: THIS
(straight-use-package 'use-package)
(setq package-check-signature nil)
(use-package gnu-elpa-keyring-update)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; VANILLA (stop using use-package for these eventually) ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; dired HAS to be after evil & evil collection
;; HAND OVER THE RELATIVE LINUMS NOW!
;;(add-hook 'prog-mode-hook 'relative-linums)
;; disbale blinking cursor (i.e. it stops blinking after 0 blinks)
(blink-cursor-mode 0)
;; allow remembering risky commands
(advice-add 'risky-local-variable-p :override #'ignore)
;; turn on RELATIVE line numbers
(column-number-mode t) ; foo
(setq display-line-numbers-type 'relative)
(global-display-line-numbers-mode t)
;; read this `https://www.emacswiki.org/emacs/IndentingC'
(setq-default tab-width 4)
(setq c-default-style "linux")
(setq c-basic-offset 4)
;; enable local variables PLEASE
(setq enable-local-variables t)
(setq inhibit-startup-message t)
(tool-bar-mode -1)
(tooltip-mode -1)
(toggle-scroll-bar -1)
(customize-set-variable 'scroll-bar-mode nil)
(customize-set-variable 'horizontal-scroll-bar-mode nil)
(setq scroll-margin 8)
(setq hscroll-margin 4)
(setq scroll-step 1)
(setq auto-window-vscroll nil)
(setq scroll-up-aggressively 0)
(setq scroll-down-aggressively 0)
(set-fringe-mode 0)
(menu-bar-mode -1)
;; (setq display-time-day-and-date 0)
;; (display-time)
(setq visible-bell t)
(show-paren-mode 1)
(setq show-paren-delay 0)
(setq warning-minimum-level :error)
;; truncate regular lines
;; (set-default 'truncate-lines nil)
;; don't truncate minibuffers
;; (add-hook 'minibuffer-setup-hook (lambda () (setq truncate-lines nil)))
;; WRAP CHADS
(set-default 'truncate-lines nil)
;; NO PROMPT WARRANTS MORE THAN 1 CHARACTER
;; LOOK! FSET!!!!
(fset 'yes-or-no-p 'y-or-n-p)
;; only show trailing white space when programming
(add-hook 'prog-mode-hook (lambda () (setq-local show-trailing-whitespace t)))
;; enable folding while in prog-mode
(add-hook 'prog-mode-hook (lambda ()
(hi-lock-mode)
(highlight-regexp "TODO")
(highlight-regexp "NOTE")
(highlight-regexp "FAMPAI")
(highlight-regexp "SENPAI")
(highlight-regexp "NOTA BENE")))
(add-hook 'prog-mode-hook 'outline-minor-mode)
;; 80 character line in prog-mode
(setq-default display-fill-column-indicator-column 80)
(add-hook 'prog-mode-hook #'display-fill-column-indicator-mode)
(require 'paren)
(set-face-background 'show-paren-match (face-background 'default))
;; make ESC quit prompts
(global-set-key (kbd "<escape>") 'keyboard-escapequit)
;; shell settings
(setq eshell-scroll-to-bottom-on-input t) ;; NOTE eshell only q.q
;; make file paths clickable?
(setq shell-kill-buffer-on-exit t)
(add-hook 'shell-mode-hook 'compilation-shell-minor-mode)
;; (add-hook 'eshell-mode-hook 'compilation-shell-minor-mode) ;; it just don't work
;; (setq quick-insert-str "change inserted string by (seq-local quick-insert-str \"foo\") ")
;; enable recent file tracking
(recentf-mode 1)
(setq recentf-max-menu-items 25)
(setq recentf-max-saved-items 25)
(run-at-time nil (* 5 60) 'recentf-save-list)
;; prevent using UI dialogs for prompts
(setq use-dialog-box nil)
;; global auto revert files
(global-auto-revert-mode 1)
;; tab-bar memels
(setq tab-bar-show 1) ;; hide bar if <= 1 tabs open
(setq tab-bar-close-button-show nil) ;; hide tab close / X button
;; (setq tab-bar-new-tab-choice "*dashboard*");; buffer to show in new tabs
(setq tab-bar-new-tab-choice t) ;; lol this is the default AND I LIKE IT
(setq tab-bar-tab-hints t) ;; show tab numbers
(setq tab-bar-format '(tab-bar-format-tabs tab-bar-separator))
(tab-bar-mode 1) ;; enable tab bar
(use-package emacs
:ensure nil
:init
;; this is just generally fucked on Windows
(setq find-program "fd"
find-name-arg "")
(which-function-mode)
(setq-default header-line-format
'((which-func-mode (" " which-func-format " "))))
(setq mode-line-misc-info
;; We remove Which Function Mode from the mode line, because it's mostly
;; invisible here anyway.
(assq-delete-all 'which-function-mode mode-line-misc-info))
;; Do not allow the cursor in the minibuffer prompt
(setq minibuffer-prompt-properties
'(read-only t cursor-intangible t face minibuffer-prompt))
(add-hook 'minibuffer-setup-hook #'cursor-intangible-mode)
;; Emacs 28: Hide commands in M-x which do not work in the current mode.
;; Vertico commands are hidden in normal buffers.
(setq read-extended-command-predicate
#'command-completion-default-include-p)
;; Enable recursive minibuffers
(setq enable-recursive-minibuffers t)
;; crank up doc-view resolution so things dont look like ASS
(setq doc-view-resolution 300)
:bind-keymap
("C-x h" . help-map)
:bind
;; ("C-t n" . tab-bar-new-tab)
;; ("C-t q" . tab-bar-close-tab)
("C-c k" . kill-current-buffer)
("C-c b" . my/ibuffer-toggle)
("C-c l" . toggle-linums))
(use-package desktop
:ensure nil
:config
;; add desktops dir to desktop-read search path
(add-to-list 'desktop-path "~/.emacs.d/desktops/"))
(use-package compile
:ensure nil
:init
(setq compilation-scroll-output t)
(setq compilation-ask-about-save nil
compilation-save-buffers-predicate (lambda ()
(string-prefix-p compilation-directory (file-truename (buffer-file-name)))))
(setq compilation-skip-threshold 2)
(defun colorize-compilation-buffer ()
(let ((inhibit-read-only t))
(ansi-color-apply-on-region (point-min) (point-max))))
(defun goldfishbrain-compile (&optional command)
"compile but no default & no history (recompile still remembers). So you can run console commands ezpz via config."
(interactive "sCMPL> ")
(compile command))
(defun set-compilation-skip-level ()
"Sets the compilation skip level (for next-error & prev-error). Accepts 'errors 'warnings+ and 'all."
(interactive)
(let ((lvl (completing-read "set compilation skip threshold (for next-error & prev-error): " '(errors errors-and-warnings all))))
(setq compilation-skip-threshold (pcase lvl (errors 2) (errors-and-warnings 1) (all 0)))))
:hook
(compilation-filter . colorize-compilation-buffer)
:bind
("C-x c" . goldfishbrain-compile)
("C-x C" . set-compilation-skip-level)
("C-c r" . recompile))
(use-package org
:ensure nil
:init
(define-prefix-command 'my-org-prefix)
(global-set-key (kbd "C-a") 'my-org-prefix)
:config
(setq org-M-RET-may-split-line nil)
(setq org-image-actual-width nil)
;; (evil-global-set-key 'normal (kbd "<leader> a") 'my-org-prefix)
;; (evil-collection-define-key 'normal 'org-mode-map
;; "<return>" 'org-open-at-point)
:bind
(:map org-mode-map
("C-a C-o" . org-open-at-point)
("C-a C-h" . org-metaleft)
("C-a C-j" . org-metadown)
("C-a C-k" . org-metaup)
("C-a C-l" . org-metaright)
("C-a H" . org-shiftmetaleft)
("C-a J" . org-shiftmetadown)
("C-a K" . org-shiftmetaup)
("C-a L" . org-shiftmetaright)
("C-a #" . org-update-checkbox-count)
("C-a c" . org-toggle-checkbox)
("C-a i" . org-insert-item)
("C-a A" . org-insert-heading)
("C-a a" . org-insert-subheading)
("C-a C-t" . org-todo)
("C-a t" . org-insert-todo-subheading)
("C-a T" . org-insert-todo-heading)))
;; ("C-a h" . org-meta-left)
;; ("C-a j" . org-meta-down)
;; ("C-a k" . org-meta-up)
;; ("C-a l" . org-meta-right)
;; ("C-a H" . org-shiftmeta-left)
;; ("C-a J" . org-shiftmeta-down)
;; ("C-a K" . org-shiftmeta-up)
;; ("C-a L" . org-shiftmeta-right)
;; ("C-a #" . org-update-checkbox-count)
;; ("C-a c" . org-toggle-checkbox)
;; ("C-a i" . org-insert-item)
;; ("C-a A" . org-insert-heading)
;; ("C-a a" . org-insert-subheading)
;; ("C-a t" . org-insert-todo-subheading)
;; ("C-a T" . org-insert-todo-heading))
;; eglot config -- BUILT IN WOW!
(use-package eglot
:ensure nil
:after evil
;; :demand t
:init
(define-prefix-command 'my-lsp-prefix)
(evil-global-set-key 'normal (kbd "<leader> l") 'my-lsp-prefix)
(evil-global-set-key 'visual (kbd "<leader> l") 'my-lsp-prefix)
:config
(setq eglot-autoshutdown t)
(setq eglot-report-progress nil)
(setq eglot-events-buffer-size 0)
(setq eldoc-echo-area-use-multiline-p nil)
(setq read-process-output-max (* 1024 1024))
(add-to-list 'eglot-server-programs '((c++-mode c-mode) "clangd"))
;; (evil-collection-define-key 'normal 'eglot)
;; (defun my/diagnostics-subline (&optional point mark)
;; (interactive "r")
;; (message "%s" (eglot--make-diag (current-buffer) point mark nil nil)))
;; (defun my/diagnostics-in-buffer (&optional point mark)
;; (interactive "r")
;; (message "%s x %s" point mark))
:bind
(:map evil-normal-state-map
("<leader> l r" . eglot-rename)
("<leader> l q" . eglot-code-actions-quickfix)
("<leader> l a" . eglot-code-actions)
("<leader> l a" . eglot-code-actions)
;; ("<leader> l i" . eglot-inlay-hints-mode)
("<leader> l =" . eglot-format-buffer)
("<leader> l d" . my/momentary-diagnostics-at-point)
:map evil-visual-state-map
("<leader> l a" . eglot-code-actions)
("<leader> l = " . eglot-format))
:hook
(c-mode . eglot-ensure)
(c++-mode . eglot-ensure))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; (use-package imenu ;;
;; :ensure nil ;;
;; :after evil ;;
;; :bind ;;
;; (:map evil-normal-state-map ;;
;; ("<leader> i" . imenu))) ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(use-package c-mode
:ensure nil
:bind
(:map evil-normal-state-map
("<leader> h p" . posix-man)))
;; put it after evil-collection PLS
(use-package comint
:ensure nil
:after evil-collection
:config
(defun append-at-last-prompt ()
"jump to last comint prompt"
(interactive)
(goto-char (cdr comint-last-prompt))
(evil-append-line nil))
(evil-collection-define-key 'normal 'comint-mode-map
"q" 'quit-window
"A" 'append-at-last-prompt))
;; (evil-collection-define-key 'insert 'comint-mode-map
;; "C-n" 'comint-next-input ; this is the default btw
;; "C-p" 'comint-previous-input)) ;; WHY isnt this working?
(use-package isearch
:ensure nil
:after evil
:config
(define-prefix-command 'my-isearch-prefix)
(global-set-key (kbd "C-s") 'my-isearch-prefix)
(setq search-whitespace-regexp ".*?") ; FUZZY ENOUGH
(setq isearch-lax-whitespace t
isearch-regexp-lax-whitespace t)
(setq isearch-repeat-on-direction-change t)
(setq isearch-wrap-pause 'no) ;; dings on wrap
(defun my/occur-from-isearch ()
(interactive)
(let ((query (if isearch-regexp
isearch-string
(regexp-quote isearch-string))))
(isearch-update-ring isearch-string isearch-regexp)
(let (search-nonincremental-instead)
(ignore-errors (isearch-done t t)))
(occur query)))
(defun my/multi-occur-from-isearch ()
(interactive)
(let ((query (if isearch-regexp
isearch-string
(regexp-quote isearch-string))))
(isearch-update-ring isearch-string isearch-regexp)
(let (search-nonincremental-instead)
(ignore-errors (isearch-done t t)))
(multi-occur (seq-filter #'buffer-file-name (buffer-list)) query)))
:bind
("C-j" . isearch-repeat-forward)
("C-k" . isearch-repeat-backward)
("C-s o" . isearch-forward-symbol-at-point)
("C-s ." . isearch-forward-thing-at-point)
("C-s s" . isearch-forward)
("C-s S" . isearch-backward)
(:map evil-normal-state-map
("<leader> s" . isearch-forward)
("<leader> S" . isearch-backward))
(:map isearch-mode-map
("C-w" . isearch-yank-word)
("C-o" . my/occur-from-isearch)
("C-O" . my/multi-occur-from-isearch)
("C-j" . isearch-repeat-forward)
("C-k" . isearch-repeat-backward)))
;; NOTE: also check out multi-occur it looks BASED
;; NOTE: IT IS BASED -- THE NOTE & TODO AGGREGATOR I ALWAYS NEEDED
(use-package replace
:ensure nil
:after evil
:config
(defun file-buffers-occur (&optional str)
"aaa"
(interactive "sFile Buffer(s) Occur: ")
(multi-occur (seq-filter #'buffer-file-name (buffer-list)) str))
:bind
(:map evil-normal-state-map
("<leader> o" . occur)
("<leader> O" . file-buffers-occur)))
(use-package tex-mode
:ensure nil
:hook
(tex-mode . company-mode))
;;;;;;;;;;
;; EVIL ;;
;;;;;;;;;;
(setq evil-want-keybinding nil)
(use-package evil
:commands (evil-set-evil-global-set-key)
:init
(setq evil-undo-system 'undo-redo)
(setq evil-want-integration t)
(define-prefix-command 'evil-help-prefix)
(evil-mode)
:config
(evil-set-leader 'normal (kbd "SPC"))
(evil-set-leader 'visual (kbd "SPC"))
(evil-global-set-key 'normal (kbd "<leader> h") 'evil-help-prefix)
(defun my/goto-eldoc ()
"Go to the eldoc window in frame."
(interactive)
(if (not (get-buffer-window (eldoc-doc-buffer)))
(eldoc t))
(select-window (get-buffer-window (eldoc-doc-buffer))))
(defun my/goto-help ()
"Go to the eldoc window in frame."
(interactive)
(select-window (get-buffer-window (help-buffer))))
(defun my/goto-compile-buffer ()
"Go to the compilation buffer in frame."
(interactive)
(cond ((get-buffer-window "*compilation*") (select-window (get-buffer-window "*compilation*")))
((buffer-live-p (get-buffer "*compilation*")) (set-window-buffer (selected-window) (get-buffer "*compilation*")))
(t (message "No compilation buffer!"))))
(defun my/vsplit-then-move-right ()
"Split the current window right, then move into the new window."
(interactive)
(split-window-right)
(windmove-right))
(defun my/split-then-move-down ()
"Split the current window below, then move into the new window."
(interactive)
(split-window-below)
(windmove-down))
(evil-define-motion my/visual-rectangle-number-lines (count)
"breh"
:type block
:jump t
(rectangle-number-lines evil-visual-beginning evil-visual-end (or count 0) "%d"))
:bind
("C-c '" . evil-show-marks)
("C-c f" . evil-show-files)
(:map evil-normal-state-map
("<leader> x" . eval-last-sexp)
("g K" . my/goto-eldoc)
("g c" . my/goto-compile-buffer)
("g h" . my/goto-help)
;; ("g b" . scratch-buffer)
("C-w V" . my/vsplit-then-move-right)
("C-w S" . my/split-then-move-down)
;; NOTE: TOO FAST
;; ("C-h" . evil-window-left)
;; ("C-j" . evil-window-down)
;; ("C-k" . evil-window-up)
;; ("C-l" . evil-window-right)
("<leader> i" . imenu)
("<leader> h v" . describe-variable)
("<leader> h f" . describe-function)
("<leader> h k" . describe-key)
("<leader> h o" . describe-symbol)
("-" . dired-jump)
("g S" . project-shell)
("<leader> f" . find-file)
("<leader> b" . switch-to-buffer)
("<leader> r" . recentf)
("Z Q" . kill-current-buffer) ;; not bad tbqh
("[ t" . tab-bar-switch-to-prev-tab)
("] t" . tab-bar-switch-to-next-tab)
("] q" . next-error)
("[ q" . previous-error)
:map evil-visual-state-map
("#" . my/visual-rectangle-number-lines)
("<leader> x" . eval-region)
("<leader> h" . evil-first-non-blank)
("<leader> l" . evil-end-of-line)
("<leader> !" . my/shell-command-region)
("] q" . next-error)
("[ q" . previous-error)
("C-w V" . my/vsplit-then-move-right)
("C-w S" . my/split-then-move-down)))
(use-package evil-collection
:after evil
:config
;; prevent overwriting bindings for next-error and previous-error set earlier
(setq evil-collection-key-blacklist '("[ q" "] q"))
(evil-collection-init))
;;;;;;;;;;;
;; DIRED ;;
;;;;;;;;;;;
(use-package dired
:ensure nil
:commands (dired dired-jump)
:custom ((dired-listing-switches "-alh --group-directories-first"))
:hook ((dired-mode . dired-omit-mode)
(dired-mode . dired-hide-details-mode)
;; (dired-mode . (display-line-numbers . 'visual))
(dired-mode . relative-linums)
(dired-mode . display-line-numbers-mode))
:init
(defun my/dired-recursive (&optional dirname)
"Recursively open a file in dired."
(interactive "GDired recursive (directory): ")
(dired dirname "-laRgho"))
:config
(setq dired-auto-revert-buffer t)
(setq dired-do-revert-buffer t)
(setq dired-dwim-target t)
(setq dired-mouse-drag-files t) ; added in Emacs 29
(setq mouse-drag-and-drop-region-cross-program t) ; added in Emacs 29
(evil-collection-define-key 'normal 'dired-mode-map
" " nil
"h" 'dired-up-directory
"l" 'dired-find-file
"zc" 'dired-kill-subdir
"zo" 'dired-maybe-insert-subdir)
(define-key dired-mode-map (kbd "SPC") nil)
:bind
("C-x f" . find-name-dired)
("C-x D" . my/dired-recursive))
;;;;;;;;;;
;; REST ;;
;;;;;;;;;;
;; temporarily highlights modified regions
(use-package evil-goggles
:config
(evil-goggles-mode)
;; optionally use diff-mode's faces; as a result, deleted text
;; will be highlighed with `diff-removed` face which is typically
;; some red color (as defined by the color theme)
;; other faces such as `diff-added` will be used for other actions
(evil-goggles-use-diff-faces))
(use-package company
:after eglot
:config
;; (defun disable-auto-complete-mode ()
;; "disables auto-complete so that way company mode takes over"
;; (auto-complete-mode -1)
;; (message "auto-complete-mode disabled in current buffer!"))
(setq company-idle-delay 0.00)
(setq company-tooltip-idle-delay 0.00)
(global-company-mode))
;; :hook
;; (prog-mode . company-mode)
;; (company-mode . disable-auto-complete-mode)
;; (lisp-mode . company-mode)
;; (c-mode . company-mode)
;; (c++-mode . company-mode))
;; (use-package auto-complete
;; :bind ("<f7>" . auto-complete-mode)
;; :diminish auto-complete-mode
;; :hook (prog-mode . auto-complete-mode)
;; :config
;; (ac-config-default))
(use-package yasnippet
;; :after evil
:defer t
:init
(setq yas-indent-line 'fixed)
;; (defcustom yas-cpp-class nil
;; "Class name of current CPP for yasnippet."
;; :type 'string
;; :local t)
:config
(yas-reload-all)
:hook
(c-mode . yas-minor-mode)
(tex-mode . yas-minor-mode)
(latex-mode . yas-minor-mode)
(gdscript-mode . yas-minor-mode)
;; (c++-mode . yas-minor-mode)
:bind
("M-y". yas-expand)
("M-f". yas-expand)
("C-M-y". yas-insert-snippet)
(:map evil-normal-state-map
("<leader> y" . yas-expand)
:map evil-visual-state-map
("<leader> y" . yas-expand)))
(use-package shell-here
:after evil
:bind (:map evil-normal-state-map
("g s" . shell-here)))
;; (use-package capf-autosuggest :hook (comint-mode . capf-autosuggest-mode))
;; this can stay
;; TODO: make C comments better
(use-package evil-nerd-commenter
:after evil
:config
;; package wasn't automatically addingin the comment text object; do it manually
(define-key evil-inner-text-objects-map evilnc-comment-text-object 'evilnc-inner-commenter)
(define-key evil-outer-text-objects-map evilnc-comment-text-object 'evilnc-outer-commenter)
:bind
(:map evil-normal-state-map
("<leader> c a" . append-comment)
("<leader> c i" . evilnc-comment-or-uncomment-lines)
("<leader> c c" . evilnc-copy-and-comment-lines)
("<leader> c p" . evilnc-comment-or-uncomment-paragraphs)
("<leader> c b" . evilnc-comment-box) ;; tbh this works better here for some reason
:map evil-visual-state-map
("<leader> c i" . evilnc-comment-or-uncomment-lines)
("<leader> c c" . evilnc-copy-and-comment-lines)
("<leader> c r" . my/visual-comment-or-uncomment-region)))
;; NOTE: just not working well with evil & windows :(
;; (use-package dirvish
;; :init
;; (setq dired-mouse-drag-files t) ; added in Emacs 29
;; (setq mouse-drag-and-drop-region-cross-program t) ; added in Emacs 29
;; (dirvish-override-dired-mode)
;; :config
;; ;; (dirvish-peek-mode) ; Preview files in minibuffer
;; ;; (dirvish-side-follow-mode) ; similar to `treemacs-follow-mode'
;; (setq dirvish-mode-line-format '(:left (sort symlink) :right (omit yank index)))
;; (setq dirvish-attributes '(all-the-icons file-time file-size collapse subtree-state vc-state git-msg))
;; (setq delete-by-moving-to-trash t)
;; (setq dired-listing-switches "-l --almost-all --human-readable --group-directories-first --no-group") (dirvish-override-dired-mode))
(use-package dired-hide-dotfiles
:hook (dired-mode . dired-hide-dotfiles-mode)
:config
(evil-collection-define-key 'normal 'dired-mode-map
"H" 'dired-hide-dotfiles-mode))
;; (use-package all-the-icons-dired
;; :hook
;; (dired-mode . all-the-icons-dired-mode)
;; (wdired-mode . (lambda () (message "disable pls") (all-the-icons-dired-mode -1))))
;; see `https://github.com/Fuco1/smartparens/wiki'
(use-package smartparens
;; :after evil
:diminish smartparens-mode
:config
(defun sp-wrap-single-quote (&optional arg)
"bruh."
(interactive "P")
(sp-wrap-with-pair "'"))
(defun sp-wrap-double-quote (&optional arg)
"bruh."
(interactive "P")
(sp-wrap-with-pair "\""))
(sp-local-pair 'emacs-lisp-mode "'" nil :actions nil)
(sp-local-pair 'emacs-lisp-mode "`" "'")
(setq sp-highlight-pair-overlay nil)
(smartparens-global-mode 1)
:bind
("C-c C-l" . sp-forward-sexp)
("C-c C-h" . sp-backward-sexp)
(:map evil-insert-state-map
("C-;" . sp-comment)
("C-l" . sp-forward-sexp)
("C-h" . sp-backward-sexp)
("C-'" . sp-wrap-single-quote)
("C-\"" . sp-wrap-double-quote)
("C-)" . sp-wrap-round)
("C-}" . {{sp-wrap-curly}})
("C-]" . sp-wrap-square)
("C-," . sp-unwrap-sexp)
:map evil-normal-state-map
("<leader> '" . sp-wrap-single-quote)
("<leader> \"" . sp-wrap-double-quote)
("<leader> )" . sp-wrap-round)
("<leader> }" . sp-wrap-curly)
("<leader> ]" . sp-wrap-square)
("<leader> [" . sp-unwrap-sexp)
("<leader> ," . sp-unwrap-sexp)
:map evil-visual-state-map
("<leader> '" . sp-wrap-single-quote)
("<leader> \"" . sp-wrap-double-quote)
("<leader> (" . sp-wrap-round)
("<leader> {" . sp-wrap-curly)
("<leader> ]" . sp-wrap-square)
("<leader> ," . sp-unwrap-sexp)))
;; EHHHHHHH
(use-package compiler-explorer
:straight (compiler-explorer
:type git
:host github
:repo "mkcms/compiler-explorer.el"))
(use-package disaster)
(use-package markdown-mode
:diminish (markdown-mode gfm-mode)
:commands (markdown-mode gfm-mode)
:mode (("README\\.md\\'" . gfm-mode)
("\\.md'" . markdown-mode)
("\\.markdown\\'" . markdown-mode))
:init (setq markdown-command "multimarkdown"))
(use-package vmd-mode) ;; enable to begin previewing markdown
(use-package lua-mode
:diminish lua-mode
:config
(setq lua-indent-level 2))
(use-package js2-mode
:init
(setq js2-bounce-indent-p t))
(use-package json-mode)
(use-package csharp-mode
:config
(add-to-list 'auto-mode-alist '("\\.cs\\'" . csharp-mode)))
(use-package ws-butler
:diminish ws-butler-mode
:hook (prog-mode . ws-butler-mode))
(use-package all-the-icons) ;; you HAVE to install the fonts for windows (run all-the-icons-install-fonts)
;; (use-package all-the-icons-ibuffer
;; :after all-the-icons
;; :hook
;; (ibuffer-mode . all-the-icons-ibuffer-mode))
(use-package which-key
:diminish which-key-mode
:init (which-key-mode)
:config (setq which-key-idle-delay 0.3))
;; just use C-x g damnid
(use-package magit)
(use-package imenu-list
:init
(setq imenu-list-focus-after-activation t)
:bind
("C-c i" . imenu-list-minor-mode))
(use-package rainbow-delimiters
:diminish rainbow-delimiters-mode
:hook (prog-mode . rainbow-delimiters-mode))
(use-package highlight-indent-guides
:diminish highlight-indent-guides-mode
:hook (prog-mode . highlight-indent-guides-mode)
:config (setq highlight-indent-guides-method 'character))
(use-package projectile
;; :after rg
;; :commands projectile-command-map
:diminish projectile-mode
:init
(define-prefix-command 'projectile-prefix)
(projectile-mode)
:config
(setq projectile-completion-system 'auto)
(setq projectile-switch-project-action #'projectile-dired)
(evil-global-set-key 'normal (kbd "<leader> p") 'projectile-command-map) ;; why here?
(projectile-mode 1)
(defun my/find-other-file()
"Use projectile-find-other-file if in a project, o.w. ido-find-alternate-file"
(interactive)
(unless (buffer-file-name) (user-error "not visiting a file buffer!"))
(if (projectile-project-p)
(condition-case nil (projectile-find-other-file)
(error (let ((file (file-name-base (buffer-file-name))))
(find-file
(read-file-name "find alternate: " nil
(buffer-name) t file)))))
(ido-find-alternate-file)))
:bind
("C-c p" . projectile-command-map)
(:map evil-normal-state-map
("g a" . my/find-other-file)
("<leader> B" . projectile-switch-to-buffer)))