summaryrefslogtreecommitdiff
path: root/config.org
blob: 6db1c62013457c77f6a791383fd1e813978870ba (plain) (blame)
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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
#+PROPERTY: header-args :tangle yes
#+startup: content


#+begin_src emacs-lisp

;;; config.el --- Emacs-Kick --- A feature rich Emacs config for (neo)vi(m)mers -*- lexical-binding: t; -*-
;; (setenv "LSP_USE_PLISTS" "true")
;; (setq gc-cons-threshold #x40000000)

(setq read-process-output-max (* 1024 1024 4))

;; (setq package-enable-at-startup nil)
(when (boundp 'pgtk-wait-for-event-timeout)
  (setq pgtk-wait-for-event-timeout 0.001))

(setq which-func-update-delay 1.0)
(setq gnutls-algorithm-priority "NORMAL:-VERS-TLS1.3")
(set-language-environment    "UTF-8")
(setq locale-coding-system   'utf-8)
(prefer-coding-system        'utf-8)
(set-default-coding-systems  'utf-8)
(set-terminal-coding-system  'utf-8)
(set-keyboard-coding-system  'utf-8)
(set-selection-coding-system 'utf-8)

(setq create-lockfiles nil)
(setq make-backup-files nil)

(setq backup-directory-alist
      `(("." . ,(expand-file-name "backup" user-emacs-directory))))
(setq tramp-backup-directory-alist backup-directory-alist)

(setq backup-by-copying-when-linked t)
(setq backup-by-copying             t) ; Backup by copying rather renaming
(setq delete-old-versions           t) ; Delete excess backup versions silently
(setq version-control               t) ; Use version numbers for backup files
(setq kept-new-versions             5)
(setq kept-old-versions             5)
#+end_src
* Visual Optimizations

  Let's define some visual optimizations to change the appearnce of Emacs.
** Opacity

    To change the appearance of Emacs, lets start with the opacity. Setting it to 90% changes Emacs to a whole new level, as the colors of your theme and your background image harmonize with each other.

#+begin_src emacs-lisp

 (add-to-list 'default-frame-alist '(alpha-background . 90))

#+end_src
* straight.el /commented out/

#+begin_src emacs-lisp
;; (setq straight-check-for-modifications nil)
;; (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))
;;
;; (straight-use-package '(project :type built-in))
;; (straight-use-package 'use-package)
;;
;; (setq straight-use-package-by-default t)
#+end_src
* emacs

#+begin_src emacs-lisp

  ;;; EMACS
  ;;  This is biggest one. Keep going, plugins (oops, I mean packages) will be shorter :)
  (setq debug-on-error t)
  (use-package emacs
    :straight nil
    :ensure nil
    :custom                                         ;; Set custom variables to configure Emacs behavior.
    (column-number-mode t)                          ;; Display the column number in the mode line.
    (auto-save-default nil)                         ;; Disable automatic saving of buffers.
    (create-lockfiles nil)                          ;; Prevent the creation of lock files when editing.
    (delete-by-moving-to-trash t)                   ;; Move deleted files to the trash instead of permanently deleting them.
    (delete-selection-mode 1)                       ;; Enable replacing selected text with typed text.
    (display-line-numbers-type 'relative)           ;; Use relative line numbering in programming modes.
    (global-auto-revert-non-file-buffers t)         ;; Automatically refresh non-file buffers.
    (history-length 25)                             ;; Set the length of the command history.
    (inhibit-startup-message t)                     ;; Disable the startup message when Emacs launches.
    (initial-scratch-message "")                    ;; Clear the initial message in the *scratch* buffer.
    (ispell-dictionary "en_US")                     ;; Set the default dictionary for spell checking.
    (make-backup-files nil)                         ;; Disable creation of backup files.
    ;; (pixel-scroll-precision-mode t)                 ;; Enable precise pixel scrolling.
    (pixel-scroll-precision-use-momentum nil)       ;; Disable momentum scrolling for pixel precision.
    (ring-bell-function 'ignore)                    ;; Disable the audible bell.
    (split-width-threshold 300)                     ;; Prevent automatic window splitting if the window width exceeds 300 pixels.
    (switch-to-buffer-obey-display-actions t)       ;; Make buffer switching respect display actions.
    (tab-always-indent 'complete)                   ;; Make the TAB key complete text instead of just indenting.
    (tab-width 4)                                   ;; Set the tab width to 4 spaces.
    (treesit-font-lock-level 4)                     ;; Use advanced font locking for Treesit mode.
    (truncate-lines t)                              ;; Enable line truncation to avoid wrapping long lines.
    (use-dialog-box nil)                            ;; Disable dialog boxes in favor of minibuffer prompts.
    (use-short-answers t)                           ;; Use short answers in prompts for quicker responses (y instead of yes)
    (warning-minimum-level :emergency)              ;; Set the minimum level of warnings to display.

    :hook ;; Add hooks to enable specific features in certain modes.
    (prog-mode . display-line-numbers-mode)
    (org-mode . display-line-numbers-mode)
    ;; (org-mode . (lambda () (display-line-numbers-mode -1)))


    :config
    (add-to-list 'custom-theme-load-path user-emacs-directory)
    ;; (load-theme 'rose-pine t)

    ;; By default emacs gives you access to a lot of *special* buffers, while navigating with [b and ]b,
    ;; this might be confusing for newcomers. This settings make sure ]b and [b will always load a
    ;; file buffer. To see all buffers use <leader> SPC, <leader> b l, or <leader> b i.
    (defun skip-these-buffers (_window buffer _bury-or-kill)
      "Function for `switch-to-prev-buffer-skip'."
      (string-match "\\*[^*]+\\*" (buffer-name buffer)))
    (setq switch-to-prev-buffer-skip 'skip-these-buffers)


    ;; Configure font settings based on the operating system.
    ;; Ok, this kickstart is meant to be used on the terminal, not on GUI.
    ;; But without this, I fear you could start Graphical Emacs and be sad :(
    (set-face-attribute 'default nil :family "Maple Mono NF"  :height 160)
    ;; (when (eq system-type 'darwin)       ;; Check if the system is macOS.
    ;; (setq mac-command-modifier 'meta)  ;; Set the Command key to act as the Meta key.
    ;; (set-face-attribute 'default nil :family "Fragment Mono" :height 130))

    ;; Save manual customizations to a separate file instead of cluttering `init.el'.
    ;; You can M-x customize, M-x customize-group, or M-x customize-themes, etc.
    ;; The saves you do manually using the Emacs interface would overwrite this file.
    ;; The following makes sure those customizations are in a separate file.
    (setq custom-file (locate-user-emacs-file "custom-vars.el")) ;; Specify the custom file path.
    (load custom-file 'noerror 'nomessage)                       ;; Load the custom file quietly, ignoring errors.

    ;; Makes Emacs vertical divisor the symbol │ instead of |.
    (set-display-table-slot standard-display-table 'vertical-border (make-glyph-code ?│))

    :init                        ;; Initialization settings that apply before the package is loaded.
    (tool-bar-mode -1)           ;; Disable the tool bar for a cleaner interface.
    (menu-bar-mode -1)           ;; Disable the menu bar for a more streamlined look.
;; (default-frame-alist '((undecorated . t)))
    (when scroll-bar-mode
      (scroll-bar-mode -1))      ;; Disable the scroll bar if it is active.

    (global-hl-line-mode -1)     ;; Disable highlight of the current line
    (global-auto-revert-mode 1)  ;; Enable global auto-revert mode to keep buffers up to date with their corresponding files.
    (indent-tabs-mode -1)        ;; Disable the use of tabs for indentation (use spaces instead).
    (recentf-mode 1)             ;; Enable tracking of recently opened files.
    (savehist-mode 1)            ;; Enable saving of command history.
    (save-place-mode 1)          ;; Enable saving the place in files for easier return.
    (winner-mode 1)              ;; Enable winner mode to easily undo window configuration changes.
    (xterm-mouse-mode 1)         ;; Enable mouse support in terminal mode.
    (file-name-shadow-mode 1)    ;; Enable shadowing of filenames for clarity.

;;oding system for files to UTF-8.
    (modify-coding-system-alist 'file "" 'utf-8)

    ;; Add a hook to run code after Emacs has fully initialized.
    (add-hook 'after-init-hook
  (lambda ()
    (message "Emacs has fully loaded. This code runs after startup.")

    ;; Insert a welcome message in the *scratch* buffer displaying loading time and activated packages.
    (with-current-buffer (get-buffer-create "*scratch*")
  (insert (format
   ";;    Welcome to Emacs!
  ;;
  ;;    Loading time : %s
  ;;    Packages     : %s
  "
   (emacs-init-time)
   (length (hash-table-keys straight--recipe-cache))))))))
#+end_src
* emacs-kickstart font

#+begin_src emacs-lisp
(defcustom ek-use-nerd-fonts t
    "Configuration for using Nerd Fonts Symbols."
    :type 'boolean
    :group 'appearance)
#+end_src
* window

#+begin_src emacs-lisp

  ;;; WINDOW
  ;; This section configures window management in Emacs, enhancing the way buffers
  ;; are displayed for a more efficient workflow. The `window' use-package helps
  ;; streamline how various buffers are shown, especially those related to help,
  ;; diagnostics, and completion.
  ;;
  ;; Note: I have left some commented-out code below that may facilitate your
  ;; Emacs journey later on. These configurations can be useful for displaying
  ;; other types of buffers in side windows, allowing for a more organized workspace.
  (use-package window
    :straight nil
    :ensure nil       ;; This is built-in, no need to fetch it.
    :custom
    (display-buffer-alist
     '(
   ;; ("\\*.*e?shell\\*"
   ;;  (display-buffer-in-side-window)
   ;;  (window-height . 0.25)
   ;;  (side . bottom)
   ;;  (slot . -1))

   ("\\*\\(Backtrace\\|Warnings\\|Compile-Log\\|[Hh]elp\\|Messages\\|Bookmark List\\|Ibuffer\\|Occur\\|eldoc.*\\)\\*"
    (display-buffer-in-side-window)
    (window-height . 0.25)
    (side . bottom)
    (slot . 0))

   ;; Example configuration for the LSP help buffer,
   ;; keeps it always on bottom using 25% of the available space:
   ("\\*\\(lsp-help\\)\\*"
    (display-buffer-in-side-window)
    (window-height . 0.25)
    (side . bottom)
    (slot . 0))

   ;; Configuration for displaying various diagnostic buffers on
   ;; bottom 25%:
   ("\\*\\(Flymake diagnostics\\|xref\\|ivy\\|Swiper\\|Completions\\)"
    (display-buffer-in-side-window)
    (window-height . 0.25)
    (side . bottom)
    (slot . 1))
   )))
#+end_src
* dired

#+begin_src emacs-lisp
(use-package dired
:straight nil
    :ensure nil                                                ;; This is built-in, no need to fetch it.
    :custom
    (dired-listing-switches "-lah --group-directories-first")  ;; Display files in a human-readable format and group directories first.
    (dired-dwim-target t)                                      ;; Enable "do what I mean" for target directories.
    (dired-guess-shell-alist-user
    '(("\\.\\(png\\|jpe?g\\|tiff\\)" "feh" "xdg-open" "open") ;; Open image files with `feh' or the default viewer.
("\\.\\(mp[34]\\|m4a\\|ogg\\|flac\\|webm\\|mkv\\)" "mpv" "xdg-open" "open") ;; Open audio and video files with `mpv'.
(".*" "open" "xdg-open")))                              ;; Default opening command for other files.
    (dired-kill-when-opening-new-dired-buffer t)               ;; Close the previous buffer when opening a new `dired' instance.
    :config
    (when (eq system-type 'darwin)
    (let ((gls (executable-find "gls")))                     ;; Use GNU ls on macOS if available.
(when gls
(setq insert-directory-program gls)))))
#+end_src
* erc

#+begin_src emacs-lisp
(use-package erc
:straight nil
    :defer t ;; Load ERC when needed rather than at startup. (Load it with `M-x erc RET')
    :custom
    (erc-join-buffer 'window)                                        ;; Open a new window for joining channels.
    (erc-hide-list '("JOIN" "PART" "QUIT"))                          ;; Hide messages for joins, parts, and quits to reduce clutter.
    (erc-timestamp-format "[%H:%M]")                                 ;; Format for timestamps in messages.
    (erc-autojoin-channels-alist '((".*\\.libera\\.chat" "#emacs"))));; Automatically join the #emacs channel on Libera.Chat.
#+end_src
* centered-cursor

[[https://entropicthoughts.com/centered-cursor-mode-in-vanilla-emacs][Centered Cursor Mode in Vanilla Emacs]]

#+begin_src emacs-lisp
(defvar my/centered-cursor-enabled nil)

(defun my/centered-cursor ()
  (interactive)
  (if my/centered-cursor-enabled
      (progn
        (setq scroll-preserve-screen-position nil
              scroll-conservatively 0
              maximum-scroll-margin 0.0
              scroll-margin 0)
        (setq my/centered-cursor-enabled nil)
        (message "centered-cursor off"))
    (progn
      (setq scroll-preserve-screen-position t
            scroll-conservatively 0
            maximum-scroll-margin 0.5
            scroll-margin 99999)
      (setq my/centered-cursor-enabled t)
      (message "centered-cursor on"))))
#+end_src
* isearch

#+begin_src emacs-lisp
(use-package isearch
:straight nil
    :ensure nil                                  ;; This is built-in, no need to fetch it.
    :config
    (setq isearch-lazy-count t)                  ;; Enable lazy counting to show current match information.
    (setq lazy-count-prefix-format "(%s/%s) ")   ;; Format for displaying current match count.
    (setq lazy-count-suffix-format nil)          ;; Disable suffix formatting for match count.
    (setq search-whitespace-regexp ".*?")        ;; Allow searching across whitespace.
    :bind (("C-s" . isearch-forward)             ;; Bind C-s to forward isearch.
    ("C-r" . isearch-backward)))          ;; Bind C-r to backward isearch.
#+end_src
* vc

#+begin_src emacs-lisp
(use-package vc
:straight nil
    :ensure nil                        ;; This is built-in, no need to fetch it.
    :defer t
    :bind
    (("C-x v d" . vc-dir)              ;; Open VC directory for version control status.
    ("C-x v =" . vc-diff)             ;; Show differences for the current file.
    ("C-x v D" . vc-root-diff)        ;; Show differences for the entire repository.
    ("C-x v v" . vc-next-action))     ;; Perform the next version control action.
    :config
    ;; Better colors for <leader> g b  (blame file)
    (setq vc-annotate-color-map
'((20 . "#f5e0dc")
    (40 . "#f2cdcd")
    (60 . "#f5c2e7")
    (80 . "#cba6f7")
    (100 . "#f38ba8")
    (120 . "#eba0ac")
    (140 . "#fab387")
    (160 . "#f9e2af")
    (180 . "#a6e3a1")
    (200 . "#94e2d5")
    (220 . "#89dceb")
    (240 . "#74c7ec")
    (260 . "#89b4fa")
    (280 . "#b4befe"))))
#+end_src

#+begin_src emacs-lisp

#+end_src
* smerge

#+begin_src emacs-lisp
(use-package smerge-mode
:straight nil
    :ensure nil                                  ;; This is built-in, no need to fetch it.
    :defer t
    :bind (:map smerge-mode-map
("C-c ^ u" . smerge-keep-upper)  ;; Keep the changes from the upper version.
("C-c ^ l" . smerge-keep-lower)  ;; Keep the changes from the lower version.
("C-c ^ n" . smerge-next)        ;; Move to the next conflict.
("C-c ^ p" . smerge-previous)))  ;; Move to the previous conflict.
#+end_src
* eldoc

#+begin_src emacs-lisp
(use-package eldoc
:straight nil
    :ensure nil                                ;; This is built-in, no need to fetch it.
	:after eglot
    :config
    (setq eldoc-idle-delay 0.0001)                  ;; Automatically fetch doc help
    (setq eldoc-echo-area-use-multiline-p t) ;; We use the "K" floating help instead
;; set to t if you want docs on the echo area
(setq eldoc-help-at-pt t)
(setq eldoc-echo-area-display-truncation-message nil)
    :init
    (global-eldoc-mode))
#+end_src
* flymake

Disabled because nix is managing the flymake configuration.

#+begin_src emacs-lisp
(use-package flymake
  :straight nil
    :ensure nil          ;; This is built-in, no need to fetch it.
    :defer t
    :hook (prog-mode . flymake-mode)
    :custom
    (flymake-margin-indicators-string
    '((error "!»" compilation-error) (warning "»" compilation-warning)
(note "»" compilation-info))))
#+end_src
* xref

#+begin_src emacs-lisp
  (use-package xref
    :straight nil
    :ensure nil)
#+end_src
* project

  #+begin_src emacs-lisp
  (use-package project
    :straight nil
    :ensure nil)
  #+end_src
* org mode

  #+begin_src emacs-lisp
  (use-package org
      :straight nil
      :ensure nil     
      :defer t
    :config
    (require 'org-tempo)
    (custom-set-faces
     '(org-document-title ((t (:height 1.6))))
     '(outline-1          ((t (:height 1.25))))
     '(outline-2          ((t (:height 1.2))))
     '(outline-3          ((t (:height 1.2))))
     '(outline-4          ((t (:height 1.2))))
     '(outline-5          ((t (:height 1.2))))
     '(outline-6          ((t (:height 1.2))))
     '(outline-7          ((t (:height 1.2))))
     '(outline-8          ((t (:height 1.2))))
     '(outline-9          ((t (:height 1.2)))))
    (org-indent-mode -1)
    (setq org-startup-folded 'content)
    (setq org-adapt-indentation t
          org-hide-leading-stars t
          org-pretty-entities t
          org-ellipsis "  ")
    (setq org-src-fontify-natively t
          org-src-tab-acts-natively t
          org-edit-src-content-indentation 0)
    (setq org-log-done                       t
          org-auto-align-tags                t
          org-tags-column                    -80
          org-fold-catch-invisible-edits     'show-and-error
          org-special-ctrl-a/e               t
          org-insert-heading-respect-content t)

  ;; (my-local-leader
  ;;   )
     
    (add-hook 'org-mode-hook 'variable-pitch-mode)
    (add-to-list 'font-lock-extra-managed-props 'display)
    (font-lock-add-keywords 'org-mode
                            `(("^.*?\( \)\(:[[:alnum:]_@#%:]+:\)$"
                               (1 `(face nil
                                         display (space :align-to (- right ,(org-string-width (match-string 2)) 3)))
                                  prepend))) t)
    (setq org-blank-before-new-entry '((heading . nil)
                                       (plain-list-item . nil))))
  #+end_src
** org-appear

#+begin_src emacs-lisp
(use-package org-appear
  :commands (org-appear-mode)
  :hook     (org-mode . org-appear-mode)
  :config
  (setq org-hide-emphasis-markers t)  ;; Must be activated for org-appear to work
  (setq org-appear-autoemphasis   t   ;; Show bold, italics, verbatim, etc.
        org-appear-autolinks      t   ;; Show links
        org-appear-autosubmarkers t)) ;; Show sub- and superscripts
#+end_src

** org agenda

We will start of with setting some sane configuration for org agenda.

#+begin_src emacs-lisp
(setq org-agenda-start-on-weekday nil
      org-agenda-block-separator  nil
      org-agenda-remove-tags      t)
#+end_src

*** org super agenda

#+begin_src emacs-lisp
(use-package org-super-agenda
  :after org
  :config
  (setq org-super-agenda-header-prefix "\n ")
  ;; Hide the thin width char glyph
  (add-hook 'org-agenda-mode-hook
            #'(lambda () (setq-local nobreak-char-display nil)))
  (org-super-agenda-mode))
#+end_src

*** org-ql

#+begin_src emacs-lisp
    (use-package org-ql
      :ensure t
      :after org)
#+end_src

*** agenda views

let us disable the predefined org agenda commands.

#+begin_src emacs-lisp
(add-to-list 'org-agenda-custom-commands
  '("d" "Day View"
 ((agenda "" ((org-agenda-overriding-header "Day View")
                      (org-agenda-span 'day)
                      (org-super-agenda-groups regular-view-groups)))
  (org-ql-block '(todo "PROG") ((org-ql-block-header "\n In Progress")))
  (org-ql-block '(todo "NEXT") ((org-ql-block-header "\n Next Up")))
          (org-ql-block '(todo "WAIT") ((org-ql-block-header "\n Backlog")))
  (org-ql-block '(priority "A") ((org-ql-block-header "\n Important"))))))

(add-to-list 'org-agenda-custom-commands
'("e" "Three-Day View"
               ((agenda "" ((org-agenda-span 3)
                            (org-agenda-start-on-weekday nil)
                            (org-deadline-warning-days 0))))))
#+end_src

** org-babel

#+begin_src emacs-lisp
#+end_src

** denote
Denote is objectively the best note taking extension, which you coul;d install. It has a very easy to parse file naming scheme and suports not only org files. It has also transclusion inclusive! if you are interested, then check it out yourself.

#+begin_src emacs-lisp
   (use-package denote
     :ensure t
     :hook (dired-mode . denote-dired-mode)
     :config
     (setq denote-rename-buffer-mode 1
denote-directory (expand-file-name "~/org/")))
#+end_src
*** denote-agenda
Denote itself focused on the last versions to have a core for note taking and to be independent of org. But of course you may extend it with your own extensions, functions and helper or even extensions by its developer. One of these extesions is =denote-agenda=, which allows you to dynamically add and remove org-agendas files based on a denote keyword. I set it to =task=, very simple. When we compare it with org-roam, It took me several days to achieve almost the same workflow, one or two external packages and around of 200 extra lines of code.

#+begin_src emacs-lisp
    (use-package denote-agenda
      :ensure t
      :config
      (setq denote-agenda-include-regexp "task")
      (denote-agenda-insinuate))
#+end_src
*** denote-menu

#+begin_src emacs-lisp
(use-package denote-menu
:ensure t
:config
(setq denote-menu-title-column-width 40
denote-menu-show-file-type nil))
#+end_src
*** denote-org

#+begin_src emacs-lisp
(use-package denote-org
    :ensure t)
#+end_src
* which-key

#+begin_src emacs-lisp

(use-package which-key
  :straight nil
  :ensure nil
  :defer t
  :hook
  (after-init . which-key-mode)
  :custom
  (which-key-idle-delay 0.3))
#+end_src
* gcmh
  gcmh is for garbage collection

#+begin_src emacs-lisp
(use-package gcmh
  :config
  (gcmh-mode 1))
#+end_src
* vertico

#+begin_src emacs-lisp
(use-package vertico
    :ensure t
    :straight t
    :hook
    (after-init . vertico-mode)
    :custom
    (vertico-count 10)
    (vertico-resize nil)
    (vertico-cycle nil)
    :bind (:map vertico-map
           ("C-j" . vertico-next)
           ("C-k" . vertico-previous))
    :config
    (advice-add #'vertico--format-candidate :around
(lambda (orig cand prefix suffix index _start)
(setq cand (funcall orig cand prefix suffix index _start))
(concat
    (if (= vertico--index index)
(propertize "» " 'face '(:foreground "#80adf0" :weight bold))
    "  ")
    cand))))
#+end_src
** vertico-posframe

#+begin_src emacs-lisp
;; (use-package vertico-posframe
;;   :init
;;   (setq vertico-posframe-parameters   '((left-fringe  . 12)    ;; Fringes
;;                                         (right-fringe . 12)
;;                                         (undecorated  . nil))) ;; Rounded frame
;;   :config
;;   (vertico-posframe-mode 1)
;;   (setq vertico-posframe-width        96                       ;; Narrow frame
;;         vertico-posframe-height       vertico-count            ;; Default height
;;         ;; Don't create posframe for these commands
;;         vertico-multiform-commands    '((consult-line    (:not posframe))
;;                                         (consult-ripgrep (:not posframe)))))
#+end_src
* consult

#+begin_src emacs-lisp
;;; CONSULT
;; Consult provides powerful completion and narrowing commands for Emacs.
;; It integrates well with other completion frameworks like Vertico, enabling
;; features like previews and enhanced register management. It's useful for
;; navigating buffers, files, and xrefs with ease.
(use-package consult
  :ensure t
  :straight t
  :defer t
  :init
  (advice-add #'register-preview :override #'consult-register-window)

  ;; (setq xref-show-xrefs-function #'consult-xref
  ;;       xref-show-definitions-function #'consult-xref)

  :config
  (setq consult-buffer-filter
        '("\\` "
          "\\`\\*Messages\\*\\'"
          "\\`\\*Warnings\\*\\'"
          "\\`\\*Compile-Log\\*\\'"
          "\\`\\*Backtrace\\*\\'"
          "\\`\\*Help\\*\\'"
          "\\`\\*scratch\\*\\'"
          "\\`\\*Completions\\*\\'"
          "\\`\\*Flymake"
          "\\`\\*lsp-help\\*\\'"
          "\\`\\*eldoc"
          "\\`\\*straight-process\\*\\'"
          "\\`\\*Native-compile-Log\\*\\'"
          "\\`\\*Async-native-compile-log\\*\\'")))
#+end_src
* markdown-mode

#+begin_src emacs-lisp
;;; MARKDOWN-MODE
;; Markdown Mode provides support for editing Markdown files in Emacs,
;; enabling features like syntax highlighting, previews, and more.
;; It’s particularly useful for README files, as it can be set
;; to use GitHub Flavored Markdown for enhanced compatibility.
(use-package markdown-mode
  :defer t
  :straight t
  :ensure t
  :mode ("README\\.md\\'" . gfm-mode)            ;; Use gfm-mode for README.md files.
  :init (setq markdown-command "multimarkdown")) ;; Set the Markdown processing command.
#+end_src
* consult

#+begin_src emacs-lisp
(use-package corfu
  :ensure t
  :straight t
  :defer t
  :custom
  (corfu-auto t)                        ;; Only completes when hitting TAB
  (corfu-auto-delay 0.08)                ;; Delay before popup (enable if corfu-auto is t)
  (corfu-auto-prefix 1)                  ;; Trigger completion after typing 1 character
  (corfu-quit-no-match t)                ;; Quit popup if no match
  (corfu-scroll-margin 5)                ;; Margin when scrolling completions
  (corfu-max-width 50)                   ;; Maximum width of completion popup
  (corfu-min-width 50)                   ;; Minimum width of completion popup
  (corfu-popupinfo-delay 0.12)            ;; Delay before showing documentation popup
  :config
  (if ek-use-nerd-fonts
    (add-to-list 'corfu-margin-formatters #'nerd-icons-corfu-formatter))
  :init
  (global-corfu-mode)
  (corfu-popupinfo-mode t))
#+end_src
* treesitter auto

#+begin_src emacs-lisp
(use-package treesit-auto
  :ensure t
  :straight t
  :after emacs
  :custom
  (treesit-auto-install 'prompt)
  :config
  (treesit-auto-add-to-auto-mode-alist 'all)
  (global-treesit-auto-mode t))
#+end_src
* embark

#+begin_src emacs-lisp
;;; EMBARK
;; Embark provides a powerful contextual action menu for Emacs, allowing
;; you to perform various operations on completion candidates and other items.
;; It extends the capabilities of completion frameworks by offering direct
;; actions on the candidates.
;; Just `<leader> .' over any text, explore it :)
(use-package embark
  :ensure t
  :straight t
  :defer t)


;;; NERD-ICONS-CORFU
;; Provides Nerd Icons to be used with CORFU.
(use-package nerd-icons-corfu
  :if ek-use-nerd-fonts
  :ensure t
  :straight t
  :defer t
  :after (:all corfu))
#+end_src
* embark consutl

#+begin_src emacs-lisp
;;; EMBARK-CONSULT
;; Embark-Consult provides a bridge between Embark and Consult, ensuring
;; that Consult commands, like previews, are available when using Embark.
(use-package embark-consult
  :ensure t
  :straight t
  :hook
  (embark-collect-mode . consult-preview-at-point-mode)) ;; Enable preview in Embark collect mode.
#+end_src
* orderless

#+begin_src emacs-lisp

(use-package orderless
    :ensure t
    :straight t
    :defer t                                    ;; Load Orderless on demand.
    :after vertico                              ;; Ensure Vertico is loaded before Orderless.
    :init
    (setq completion-styles '(orderless basic)  ;; Set the completion styles.
completion-category-defaults nil      ;; Clear default category settings.
completion-category-overrides '((file (styles partial-completion))))) ;; Customize file completion styles.
#+end_src

* marginalia

#+begin_src emacs-lisp
;; Marginalia enhances the completion experience in Emacs by adding
;; additional context to the completion candidates. This includes
;; helpful annotations such as documentation and other relevant
;; information, making it easier to choose the right option.
(use-package marginalia
  :ensure t
  :straight t
  :hook
  (after-init . marginalia-mode))
#+end_src
* nerd corfu icons

#+begin_src emacs-lisp
(use-package nerd-icons-corfu
    :if ek-use-nerd-fonts
    :ensure t
    :straight t
    :defer t
    :after (:all corfu))
#+end_src
* eglot

#+begin_src emacs-lisp
  (use-package eglot
    :ensure nil
    :straight nil
    :hook ((rust-mode . eglot-ensure)
     (nix-mode  . eglot-ensure)
     (python-mode . eglot-ensure)
     (eglot-managed-mode . (lambda () (eldoc-mode -1))))
    :bind (:map eglot-mode-map
  ("M-<return>" . eglot-code-actions)
  ("C-M-."      . xref-find-references)
  ("C-c r"      . eglot-rename))
    :config
    (add-to-list 'eglot-server-programs
   `(python-mode
   . ,(eglot-alternatives '(("basedpyright-langserver" "--stdio")
    ("pyright-langserver" "--stdio")
      "jedi-language-server"
      "pylsp"))))
    (setq eldoc-echo-area-use-multiline-p nil
    eglot-inlay-hints-mode -1)
    (add-to-list 'eglot-server-programs '(nix-mode . ("nixd"))))
#+end_src
** eglot-booster

#+begin_src emacs-lisp
(use-package eglot-booster
:straight ( eglot-booster :type git :host nil :repo "https://github.com/jdtsmith/eglot-booster")
:after eglot
:config (eglot-booster-mode))
#+end_src

** consult-eglot integration

#+begin_src emacs-lisp
(use-package consult-eglot
  :straight t
  :after (consult eglot))
#+end_src
* eldoc

#+begin_src emacs-lisp
  (use-package eldoc-box
    :ensure t
    :straight t
    :defer t)
#+end_src
* diff-hl

#+begin_src emacs-lisp

  (use-package diff-hl
    :defer t
    :straight t
    :ensure t
    :hook
    (find-file . (lambda ()
   (global-diff-hl-mode)           ;; Enable Diff-HL mode for all files.
   (diff-hl-flydiff-mode)          ;; Automatically refresh diffs.
   (diff-hl-margin-mode)))         ;; Show diff indicators in the margin.
    :custom
    (diff-hl-side 'left)                           ;; Set the side for diff indicators.
    (diff-hl-margin-symbols-alist '((insert . "┃") ;; Customize symbols for each change type.
    (delete . "-")
    (change . "┃")
    (unknown . "┆")
    (ignored . "i"))))
#+end_src
* ff

#+begin_src emacs-lisp

  (use-package magit
    :ensure t
    :straight t
    :config
    (if ek-use-nerd-fonts   ;; Check if nerd fonts are being used
    (setopt magit-format-file-function #'magit-format-file-nerd-icons)) ;; Turns on magit nerd-icons
    :defer t)
#+end_src
* indent guide

#+begin_src emacs-lisp

  (use-package indent-guide
    :defer t
    :straight t
    :ensure t
    :hook
    (prog-mode . indent-guide-mode)  ;; Activate indent-guide in programming modes.
    :config
    (setq indent-guide-char "│"))    ;; Set the character used for the indent guide.
#+end_src
* f

#+begin_src emacs-lisp

  (use-package add-node-modules-path
    :ensure t
    :straight t
    :defer t
    :custom
    ;; Makes sure you are using the local bin for your
    ;; node project. Local eslint, typescript server...
    (eval-after-load 'typescript-ts-mode
      '(add-hook 'typescript-ts-mode-hook #'add-node-modules-path))
    (eval-after-load 'tsx-ts-mode
      '(add-hook 'tsx-ts-mode-hook #'add-node-modules-path))
    (eval-after-load 'typescriptreact-mode
      '(add-hook 'typescriptreact-mode-hook #'add-node-modules-path))
    (eval-after-load 'js-mode
      '(add-hook 'js-mode-hook #'add-node-modules-path)))
#+end_src
* general

#+begin_src emacs-lisp
  (use-package general
    :straight t
    :ensure t
    :demand t
    :config
    (general-evil-setup)

    (general-create-definer my-leader
      :states '(normal visual)
      :keymaps 'override
      :prefix "SPC")

    (general-create-definer my-local-leader
      :states '(normal visual)
      :keymaps 'override
      :prefix ","))
#+end_src
* evil

#+begin_src emacs-lisp
(use-package evil
  :ensure t
  :init
  (setq evil-want-integration t)
  (setq evil-want-keybinding nil)
  (setq evil-want-C-u-delete t)       ;; Makes C-u delete on insert mode
  (setq evil-want-C-u-scroll t)       ;; Makes C-u delete on insert mode

  :config
  (evil-mode 1))


#+end_src
* avy

#+begin_src emacs-lisp
  (use-package avy
    :ensure t
    :straight t
    :after evil
    :general
    ;; (general-nmap "s" 'avy-goto-char-timer)
    ;; (general-omap "s" 'evil-avy-goto-char-timer)

    :config
    (setq avy-all-windows t
          avy-all-windows-alt t
          avy-background t
          avy-case-fold-search t
          avy-timeout-seconds 0.3
          avy-style 'at-full
          avy-keys '(?a ?s ?d ?f ?g ?h ?j ?k ?l ?q ?w ?e ?r ?t ?y ?u ?i ?o ?p))

    (evil-define-avy-motion evil-avy-goto-char-timer inclusive))
#+end_src

** avy flash behaviour

#+begin_src emacs-lisp

#+end_src
* evil packages

#+begin_src emacs-lisp
(use-package evil-collection
  :after evil
  :ensure t
  :config
  (evil-collection-init))


(use-package evil-surround
  :ensure t
  :straight t
  :after evil-collection
  :config
  (global-evil-surround-mode 1))



(use-package evil-matchit
  :ensure t
  :straight t
  :after evil-collection
  :config
  (global-evil-matchit-mode 1))
#+end_src
* undo-tree

#+begin_src emacs-lisp
  (use-package undo-tree
    :defer t
    :ensure t
    :straight t
    :hook
    (after-init . global-undo-tree-mode)
    :init
    (setq undo-tree-visualizer-timestamps t
  undo-tree-visualizer-diff t
  ;; Increase undo limits to avoid losing history due to Emacs' garbage collection.
  ;; These values can be adjusted based on your needs.
  ;; 10X bump of the undo limits to avoid issues with premature
  ;; Emacs GC which truncates the undo history very aggressively.
  undo-limit 800000                     ;; Limit for undo entries.
  undo-strong-limit 12000000            ;; Strong limit for undo entries.
  undo-outer-limit 120000000)           ;; Outer limit for undo entries.
    :config
    ;; Set the directory where `undo-tree' will save its history files.
    ;; This keeps undo history across sessions, stored in a cache directory.
    (setq undo-tree-history-directory-alist '(("." . "~/.emacs.d/.cache/undo"))))
#+end_src
* Rainbow Delimiter

#+begin_src emacs-lisp
  (use-package rainbow-delimiters
    :defer t
    :straight t
    :ensure t
    :hook
    (prog-mode . rainbow-delimiters-mode))
#+end_src
* dotenv-mode

#+begin_src emacs-lisp
  (use-package dotenv-mode
    :defer t
    :straight t
    :ensure t
    :config)
#+end_src

* envrc

#+begin_src emacs-lisp
(use-package envrc
  :hook (after-init . envrc-global-mode))
#+end_src
* pulsar /disabled/

#+begin_src emacs-lisp
  (use-package pulsar
    :defer t
    :straight t
    :ensure t
    :hook
    (after-init . pulsar-global-mode)
    :config
    (setq pulsar-pulse t)
    (setq pulsar-delay 0.025)
    (setq pulsar-iterations 10)
    (setq pulsar-face 'evil-ex-lazy-highlight)

    (add-to-list 'pulsar-pulse-functions 'evil-scroll-down)
    (add-to-list 'pulsar-pulse-functions 'flymake-goto-next-error)
    (add-to-list 'pulsar-pulse-functions 'flymake-goto-prev-error)
    (add-to-list 'pulsar-pulse-functions 'evil-yank)
    (add-to-list 'pulsar-pulse-functions 'evil-yank-line)
    (add-to-list 'pulsar-pulse-functions 'evil-delete)
    (add-to-list 'pulsar-pulse-functions 'evil-delete-line)
    (add-to-list 'pulsar-pulse-functions 'evil-jump-item)
    (add-to-list 'pulsar-pulse-functions 'diff-hl-next-hunk)
    (add-to-list 'pulsar-pulse-functions 'diff-hl-previous-hunk))
#+end_src
* doom modeline /disabled/

#+begin_src emacs-lisp
  ;;; DOOM MODELINE
  ;; The `doom-modeline' package provides a sleek, modern mode-line that is visually appealing
  ;; and functional. It integrates well with various Emacs features, enhancing the overall user
  ;; experience by displaying relevant information in a compact format.
  ;; (use-package doom-modeline
  ;;   :ensure t
  ;;   :straight t
  ;;   :defer t
  ;;   :custom
  ;;   (doom-modeline-buffer-file-name-style 'buffer-name)  ;; Set the buffer file name style to just the buffer name (without path).
  ;;   (doom-modeline-project-detection 'project)           ;; Enable project detection for displaying the project name.
  ;;   (doom-modeline-buffer-name t)                        ;; Show the buffer name in the mode line.
  ;;   (doom-modeline-vcs-max-length 25)                    ;; Limit the version control system (VCS) branch name length to 25 characters.
  ;;   :config
  ;;   (if ek-use-nerd-fonts                                ;; Check if nerd fonts are being used.
  ;;       (setq doom-modeline-icon t)                      ;; Enable icons in the mode line if nerd fonts are used.
  ;;     (setq doom-modeline-icon nil))                     ;; Disable icons if nerd fonts are not being used.
  ;;   :hook
  ;;   (after-init . doom-modeline-mode))
#+end_src
* evil-org

#+begin_src emacs-lisp
  (use-package evil-org
    :ensure t
    :straight t
    :after org
    :hook (org-mode . (lambda () evil-org-mode))
    :config
    (require 'evil-org-agenda)
    (evil-org-agenda-set-keys))
#+end_src
* nerd-icons

#+begin_src emacs-lisp
  ;;; NERD ICONS
  ;; The `nerd-icons' package provides a set of icons for use in Emacs. These icons can
  ;; enhance the visual appearance of various modes and packages, making it easier to
  ;; distinguish between different file types and functionalities.
  (use-package nerd-icons
    :if ek-use-nerd-fonts                   ;; Load the package only if the user has configured to use nerd fonts.
    :ensure t                               ;; Ensure the package is installed.
    :straight t
    :defer t)                               ;; Load the package only when needed to improve startup time.

   ;;; NERD ICONS Dired
  ;; The `nerd-icons-dired' package integrates nerd icons into the Dired mode,
  ;; providing visual icons for files and directories. This enhances the Dired
  ;; interface by making it easier to identify file types at a glance.
  (use-package nerd-icons-dired
    :if ek-use-nerd-fonts                   ;; Load the package only if the user has configured to use nerd fonts.
    :ensure t                               ;; Ensure the package is installed.
    :straight t
    :defer t                                ;; Load the package only when needed to improve startup time.
    :hook
    (dired-mode . nerd-icons-dired-mode))

  (use-package nerd-icons-completion
    :if ek-use-nerd-fonts                   ;; Load the package only if the user has configured to use nerd fonts.
    :ensure t                               ;; Ensure the package is installed.
    :straight t
    :after (:all nerd-icons marginalia)     ;; Load after `nerd-icons' and `marginalia' to ensure proper integration.
    :config
    (nerd-icons-completion-mode)            ;; Activate nerd icons for completion interfaces.
    (add-hook 'marginalia-mode-hook #'nerd-icons-completion-marginalia-setup)) ;; Setup icons in the marginalia mode for enhanced completion display.
#+end_src
* catppuccin theme

#+begin_src emacs-lisp
  ;;; CATPPUCCIN THEME
  ;; The `catppuccin-theme' package provides a visually pleasing color theme
  ;; for Emacs that is inspired by the popular Catppuccin color palette.
  ;; This theme aims to create a comfortable and aesthetic coding environment
  ;; with soft colors that are easy on the eyes.
  ;; (use-package catppuccin-theme
  ;;   :ensure t
  ;;   :straight t
  ;;   :config
  ;;   (custom-set-faces
  ;;    ;; Set the color for changes in the diff highlighting to blue.
  ;;    `(diff-hl-change ((t (:background unspecified :foreground ,(catppuccin-get-color 'blue))))))

  ;;   (custom-set-faces
  ;;    ;; Set the color for deletions in the diff highlighting to red.
  ;;    `(diff-hl-delete ((t (:background unspecified :foreground ,(catppuccin-get-color 'red))))))

  ;;   (custom-set-faces
  ;;    ;; Set the color for insertions in the diff highlighting to green.
  ;;    `(diff-hl-insert ((t (:background unspecified :foreground ,(catppuccin-get-color 'green))))))

  ;;   ;; Load the Catppuccin theme without prompting for confirmation.
  ;;   (load-theme 'catppuccin :no-confirm))
#+end_src

#+begin_src emacs-lisp
  ;;; UTILITARY FUNCTION TO INSTALL EMACS-KICK
  (defun ek/first-install ()
    "Install tree-sitter grammars and compile packages on first run..."
    (interactive)                                      ;; Allow this function to be called interactively.
    (switch-to-buffer "*Messages*")                    ;; Switch to the *Messages* buffer to display installation messages.
    (message ">>> All required packages installed.")
    (message ">>> Configuring Emacs-Kick...")
    (message ">>> Configuring Tree Sitter parsers...")
    (require 'treesit-auto)
    (treesit-auto-install-all)                         ;; Install all available Tree Sitter grammars.
    (message ">>> Configuring Nerd Fonts...")
    (require 'nerd-icons)
    (nerd-icons-install-fonts)                         ;; Install all available nerd-fonts
    (message ">>> Emacs-Kick installed! Press any key to close the installer and open Emacs normally. First boot will compile some extra stuff :)")
    (read-key)                                         ;; Wait for the user to press any key.
    (kill-emacs))                                      ;; Close Emacs after installation is complete.

  ;;; init.el ends here
#+end_src

#+begin_src emacs-lisp
 (use-package org-modern
   :ensure t
   :straight t
   )
 (with-eval-after-load 'org (global-org-modern-mode))

 (setq org-modern-star 'fold)
 (setq org-modern-fold-stars '(("◉" . "○")))
 (setq org-modern-star 'replace)
 (setq org-modern-replace-stars "◉○◉○◉")
#+end_src
* configuration/soph
** soph-modeline
*** Battery Faces

    Extracted from doom modeline

#+begin_src emacs-lisp
    (require 'battery)
    (require 'nerd-icons)

    (defface my-battery-charging
      '((t :inherit success))
      "Face for charging battery.")

    (defface my-battery-full
      '((t :inherit success))
      "Face for full battery.")

    (defface my-battery-normal
      '((t :inherit mode-line))
      "Face for normal battery.")

    (defface my-battery-warning
      '((t :inherit warning))
      "Face for low battery.")

    (defface my-battery-critical
      '((t :inherit error))
      "Face for critical battery.")

    (defface my-battery-error
      '((t :inherit error))
      "Face for battery error.")
#+end_src
*** Battery Update Function

    Function that updates the battery string with nerd icons.

#+begin_src emacs-lisp
(defvar my-battery-string nil)

(defun my-update-battery ()
  (setq my-battery-string
        (when (bound-and-true-p display-battery-mode)
          (let* ((data (and battery-status-function
                            (functionp battery-status-function)
                            (funcall battery-status-function)))
                 (status (cdr (assoc ?L data)))
                 (charging? (or (string-equal "AC" status)
                                (string-equal "on-line" status)))
                 (percentage (car (read-from-string (or (cdr (assq ?p data)) "ERR"))))
                 (valid? (and (numberp percentage)
                              (>= percentage 0)
                              (<= percentage battery-mode-line-limit)))
                 (face (if valid?
                           (cond (charging? 'my-battery-charging)
                                 ((< percentage battery-load-critical) 'my-battery-critical)
                                 ((< percentage 25) 'my-battery-warning)
                                 ((< percentage 95) 'my-battery-normal)
                                 (t 'my-battery-full))
                         'my-battery-error))
                 (icon (if valid?
                           (cond
                            ((>= percentage 100)
                             (if charging?
                                 (nerd-icons-mdicon "nf-md-battery_charging_100" :face face)
                               (nerd-icons-mdicon "nf-md-battery" :face face)))
                            ((>= percentage 90)
                             (if charging?
                                 (nerd-icons-mdicon "nf-md-battery_charging_90" :face face)
                               (nerd-icons-mdicon "nf-md-battery_90" :face face)))
                            ((>= percentage 80)
                             (if charging?
                                 (nerd-icons-mdicon "nf-md-battery_charging_80" :face face)
                               (nerd-icons-mdicon "nf-md-battery_80" :face face)))
                            ((>= percentage 70)
                             (if charging?
                                 (nerd-icons-mdicon "nf-md-battery_charging_70" :face face)
                               (nerd-icons-mdicon "nf-md-battery_70" :face face)))
                            ((>= percentage 60)
                             (if charging?
                                 (nerd-icons-mdicon "nf-md-battery_charging_60" :face face)
                               (nerd-icons-mdicon "nf-md-battery_60" :face face)))
                            ((>= percentage 50)
                             (if charging?
                                 (nerd-icons-mdicon "nf-md-battery_charging_50" :face face)
                               (nerd-icons-mdicon "nf-md-battery_50" :face face)))
                            ((>= percentage 40)
                             (if charging?
                                 (nerd-icons-mdicon "nf-md-battery_charging_40" :face face)
                               (nerd-icons-mdicon "nf-md-battery_40" :face face)))
                            ((>= percentage 30)
                             (if charging?
                                 (nerd-icons-mdicon "nf-md-battery_charging_30" :face face)
                               (nerd-icons-mdicon "nf-md-battery_30" :face face)))
                            ((>= percentage 20)
                             (if charging?
                                 (nerd-icons-mdicon "nf-md-battery_charging_20" :face face)
                               (nerd-icons-mdicon "nf-md-battery_20" :face face)))
                            ((>= percentage 10)
                             (if charging?
                                 (nerd-icons-mdicon "nf-md-battery_charging_10" :face face)
                               (nerd-icons-mdicon "nf-md-battery_10" :face face)))
                            (t (if charging?
                                   (nerd-icons-mdicon "nf-md-battery_charging_outline" :face face)
                                 (nerd-icons-mdicon "nf-md-battery_outline" :face face))))
                         (nerd-icons-mdicon "nf-md-battery_alert" :face face)))
                 (text (if valid? (format " %d%%" percentage) " N/A"))
                 (help-echo (if (and battery-echo-area-format data valid?)
                                (battery-format battery-echo-area-format data)
                              "Battery status not available")))
            (concat (propertize icon 'help-echo help-echo)
                    (propertize text 'face face 'help-echo help-echo))))))
#+end_src
*** Battery Override

Replaces the default battery display with the custom version.

#+begin_src emacs-lisp
(defun my-override-battery ()
  (when (bound-and-true-p display-battery-mode)
    (advice-add #'battery-update :after #'my-update-battery)
    (setq global-mode-string (delq 'battery-mode-line-string global-mode-string))
    (my-update-battery)))

(add-hook 'display-battery-mode-hook #'my-override-battery)
#+end_src
*** Header Line Format

The Modeline itself with Battery and Time on the right, Line:Column after VC on the left.

#+begin_src emacs-lisp
(display-time-mode 1)
(display-battery-mode 1)

(defvar lsp-modeline--code-actions-string nil)

(setq-default header-line-format
  '("%e"
(:propertize " " display (raise +0.4))
(:propertize " " display (raise -0.4))

(:propertize "λ " face font-lock-comment-face)
mode-line-frame-identification
mode-line-buffer-identification

(:eval (when-let (vc vc-mode)
 (list (propertize "   " 'face 'font-lock-comment-face)
   (propertize (truncate-string-to-width
                                (substring vc 5) 50)
   'face 'font-lock-comment-face))))

(:propertize "  %4l:%c" face mode-line-buffer-id)

(:eval (propertize
 " " 'display
 `((space :align-to
  (-  (+ right right-fringe right-margin)
 ,(+ 3
                             (string-width (or my-battery-string ""))
                             (string-width (or display-time-string ""))))))))

    (:eval my-battery-string)
" "
(:eval display-time-string)))

(setq-default mode-line-format nil)
#+end_src
** hide modeline

#+begin_src emacs-lisp
  (use-package hide-mode-line
    :straight t
    :defer t
    :bind (:map custom-bindings-map ("C-c h m" . hide-mode-line-mode)))
#+end_src
** adaptive wrap

#+begin_src emacs-lisp
(use-package adaptive-wrap
  :defer t
  :hook (visual-line-mode . adaptive-wrap-prefix-mode))
#+end_src
** gpg home

#+begin_src emacs-lisp
(setq package-gnupghome-dir "~/.gnupg")
#+end_src
** cursor

#+begin_src emacs-lisp
(blink-cursor-mode        0)
(setq-default cursor-type 'bar)
#+end_src
** highlight long lines

#+begin_src emacs-lisp
;; (setq my-whitespace-style '(face tabs lines-tail) ;; ⚠️ DEAKTIVIERT
;;       whitespace-style my-whitespace-style ;; ⚠️ DEAKTIVIERT
;;       whitespace-line-column 120 ;; ⚠️ DEAKTIVIERT
;;       fill-column 120 ;; ⚠️ DEAKTIVIERT
;;       whitespace-display-mappings ;; ⚠️ DEAKTIVIERT
;;       '((space-mark 32 [183] [46]) ;; ⚠️ DEAKTIVIERT
;;         (newline-mark 10 [36 10]) ;; ⚠️ DEAKTIVIERT
;;         (tab-mark 9 [9655 9] [92 9]))) ;; ⚠️ DEAKTIVIERT

;; in e.g. clojure-mode-hook
;; (whitespace-mode 1)
;; or globally
;; (global-whitespace-mode 1)
;; (add-hook 'prog-mode 'whitespace-mode) ;; ⚠️ KOMPLETT DEAKTIVIERT - verursacht org-mode Probleme
#+end_src
** default fixed, variable fonts

#+begin_src emacs-lisp
(defvar cashmere/font-height 170)

(when (member "Maple Mono NF" (font-family-list))
  (set-face-attribute 'default nil :font "Maple Mono NF" :height cashmere/font-height)
  (set-face-attribute 'fixed-pitch nil :family "Maple Mono NF" :height cashmere/font-height))

(when (member "Maple Mono NF" (font-family-list))
  (set-face-attribute 'variable-pitch nil :family "Maple Mono NF" :height cashmere/font-height))
#+end_src
** mixed pitch fonts (package)

#+begin_src emacs-lisp
  (use-package mixed-pitch
    :straight t
    :defer t
    :hook ((org-mode   . mixed-pitch-mode)
           (LaTeX-mode . mixed-pitch-mode)))
#+end_src
* autothemer

#+begin_src emacs-lisp
  (use-package autothemer
    :straight t
    :defer t)
#+end_src
* doom-themes

#+begin_src emacs-lisp
(use-package doom-themes
:straight t
:ensure t
:custom
;; Global settings (defaults)
(doom-themes-enable-bold t)   ; if nil, bold is universally disabled
(doom-themes-enable-italic t) ; if nil, italics is universally disabled
;; for treemacs users
(doom-themes-treemacs-theme "doom-nord-light") ; use "doom-colors" for less minimal icon theme
:config
(load-theme 'doom-nord-light t)

;; Enable flashing mode-line on errors
(doom-themes-visual-bell-config)
;; Enable custom neotree theme (nerd-icons must be installed!)
;; or for treemacs users
(doom-themes-treemacs-config)
;; Corrects (and improves) org-mode's native fontification.
(doom-themes-org-config))
#+end_src
* dirvish

#+begin_src emacs-lisp
(use-package dirvish
  :straight t
  :init
  (dirvish-override-dired-mode)

  :custom
  (dirvish-quick-access-entries
   '(("h" "~/" "Home")
     ("d" "~/Downloads/" "Downloads")
     ("p" "~/projects/" "Projects")))

  (dirvish-reuse-session 'open)
  (dirvish-attributes '(file-size))
  (dirvish-mode-line-format
   '(:left (sort file-time symlink) :right (omit yank index)))

  (dirvish-hide-details '(dirvish dirvish-side))
  (dirvish-hide-cursor '(dirvish dirvish-side))

  (dired-listing-switches
   "-l --almost-all --human-readable --group-directories-first --no-group")

  :config
  (setq dired-dwim-target t)
  (setq delete-by-moving-to-trash t)
  (setq dired-mouse-drag-files t))
#+end_src

* programming modes

** nix-mode

    #+begin_src emacs-lisp
    (use-package nix-mode
      :ensure t
      :mode "\\.nix\\'")
    #+end_src

** rust mode

   #+begin_src emacs-lisp
   (use-package rustic
     :ensure t
     :defer t)
   #+end_src 

*** org babel integration

    #+begin_src emacs-lisp
    ;; Make sure rustic gets activated in the org-src block and add the original file's source code.
    (defun org-babel-edit-prep:rust (babel-info)
      ;; This gets the second item in the "babel-info" list, which holds the code in the original src block
      (setq-local src-code (nth 1 babel-info))
      (setq-local buffer-file-name (expand-file-name (->> babel-info caddr (alist-get :tangle))))
      (setq-local buffer-src-code (replace-regexp-in-string src-code "" (my-read-file-to-string (buffer-file-name))))
      (goto-char (point-max))
      (insert buffer-src-code)
      (narrow-to-region (point-min) (+ (point-min) (length src-code)))
      (rustic-mode)
      (org-src-mode))

    (defun my-delete-hidden-text ()
      "Remove all text that would be revealed by a call to `widen'"
      (-let [p-start (point-max)]
        (widen)
        (delete-region p-start (point-max))))

    (define-advice org-edit-src-exit
        (:before (&rest _args) remove-src-block)
      (when (eq major-mode 'rustic-mode)
        (my-delete-hidden-text)))

    (define-advice org-edit-src-save
        (:before (&rest _args) remove-src-block)
      (when (eq major-mode 'rustic-mode)
        (my-delete-hidden-text)))
    #+end_src
    
** olivetti

#+begin_src emacs-lisp
  (use-package olivetti
    :defer t)
#+end_src
* olivetti global mode

#+begin_src emacs-lisp :tangle yes
(setq-default olivetti-body-width 100)
(define-globalized-minor-mode my-global-olivetti-mode olivetti-mode
  (lambda () (olivetti-mode 1)))
(my-global-olivetti-mode)
#+end_src
* declutter
** ibuffer

#+begin_src emacs-lisp

(setq ibuffer-never-show-predicates
      '(;; System buffers
        "^\\*Messages\\*$"
        "^\\*scratch\\*$"
        "^\\*Completions\\*$"
        "^\\*Help\\*$"
        "^\\*Apropos\\*$"
        "^\\*info\\*$"
        "^\\*Async-native-compile-log\\*$"

        ;; LSP Buffers
        "^\\*lsp-log\\*$"
        "^\\*clojure-lsp\\*$"
        "^\\*clojure-lsp::stderr\\*$"
        "^\\*ts-ls\\*$"
        "^\\*ts-ls::stderr\\*$"))
#+end_src
* bufler

#+begin_src emacs-lisp
  (use-package bufler
    :defer t)
#+end_src
* eat

#+begin_src emacs-lisp
(use-package eat
  :ensure t
  :defer t
  :init
  (defun my/eat-reset-key ()
    (when (boundp 'eat-emacs-mode-map)
      (define-key eat-emacs-mode-map (kbd "C-l") #'eat-reset)))
  :hook (eat-mode . my/eat-reset-key)
  :config
  (when (fboundp 'eat-global-mode)
    (eat-global-mode)
    (setq eat-kill-buffer-on-exit t)))
#+end_src
* projectile

#+begin_src emacs-lisp
(use-package projectile
  :ensure t
  :demand t
  :config
  (projectile-mode +1)
  (setq projectile-completion-system 'default
        projectile-enable-caching t
        projectile-indexing-method 'alien
        projectile-sort-order 'recentf
        projectile-require-project-root nil))
#+end_src
** consult-projectile

#+begin_src emacs-lisp
(use-package consult-projectile
  :ensure t
  :straight t
  :after (consult projectile)
  :defer t
  :config
  (setq consult-project-function #'projectile-project-root))
#+end_src
* pass

#+begin_src emacs-lisp
(use-package pass
  :ensure t
  :defer t)
#+end_src  
* keybindings
** disable frame

   #+begin_src emacs-lisp
   ;; (setq )
   #+end_src
   
** global leader (SPC) kill ring

#+begin_src emacs-lisp
(defun my/smart-find-file ()
  (interactive)
  (if (projectile-project-p)
      (projectile-find-file)
    (consult-buffer)))

(my-leader
  "sp" '(consult-ripgrep :wk "search project")
  "/" '(consult-line :wk "search buffer")
  "." '(find-file :wk "find file")
  "," '(bufler-switch-buffer :wk "switch buffer")
  "SPC" '(my/smart-find-file :wk "find file/buffer")
  ":" (lambda () (interactive) (execute-extended-command nil))

"d" '(:ignore t :wk "denote")
"dd" '(denote-menu-list-notes t :wk "List all notes")
"dg" '(denote-grep t :wk "Search")
"dn" '(denote t :wk "Create a new note")
"dr" '(denote-rename-file t :wk "Rename Note")

  "f" '(:ignore t :wk "files")
  "fd" '(dired :wk "dired")
  "fD" '(dired-jump :wk "dired jump")
  "fr" '(consult-recent-file :wk "recent files")
  "ff" '(find-file :wk "find file")
  "fs" '(save-buffer :wk "save file")

  "b" '(:ignore t :wk "buffers")
  "bb" '(consult-buffer :wk "switch buffer")
  "bi" '(ibuffer :wk "ibuffer")
  "bd" '(kill-current-buffer :wk "kill buffer")
  "bk" '(kill-current-buffer :wk "kill buffer")
  "bs" '(save-buffer :wk "save buffer")

  "p" '(:ignore t :wk "project")
  "pp" '(projectile-switch-project :wk "switch project")
  "pf" '(projectile-find-file :wk "find file")
  "ps" '(consult-ripgrep :wk "search")
  "pb" '(consult-projectile-buffer :wk "buffers")
  "pk" '(projectile-kill-buffers :wk "kill buffers")
  "pd" '(projectile-dired :wk "root dir")
  "pr" '(projectile-recentf :wk "recent files")
  "pa" '(projectile-add-known-project :wk "add project")
  "pc" '(projectile-compile-project :wk "compile")
  "pt" '(projectile-test-project :wk "test")
  "pi" '(projectile-invalidate-cache :wk "invalidate cache")

  "g" '(:ignore t :wk "git/goto")
  "gg" '(magit-status :wk "status")
  "gl" '(magit-log-current :wk "log")
  "gd" '(xref-find-definitions :wk "go to definition")  ; sowohl hier als auch unter code
  "gs" '(magit-status :wk "status")
  "gb" '(vc-annotate :wk "blame")

  "o" '(:ignore t :wk "open")
  "op" '(neotree-toggle :wk "neotree")
  "oP" '(dired-jump :wk "dired")
  "od" '(dirvish :wk "dirvish")

  "h" '(:ignore t :wk "help")
  "hm" '(describe-mode :wk "mode")
  "hf" '(describe-function :wk "function")
  "hv" '(describe-variable :wk "variable")
  "hk" '(describe-key :wk "key")

  "w" '(:ignore t :wk "windows")
  "wv" '(split-window-right :wk "split right")
  "ws" '(split-window-below :wk "split below")
  "wd" '(delete-window :wk "delete")
  "wo" '(delete-other-windows :wk "delete others")

  "c" '(:ignore t :wk "code")
  "ca" '(eglot-code-actions :wk "code actions")
  "cd" '(xref-find-definitions :wk "go to definition")  ; sowohl hier als auch unter g
  "cD" '(xref-find-references :wk "find references")
  "cr" '(eglot-rename :wk "lsp rename")
  "ch" '(eglot-help-at-point :wk "help at point")
  "cf" '(eglot-format :wk "format")
  "ci" '(eglot-find-implementation :wk "implementation")
  "ct" '(eglot-find-typeDefinition :wk "type definition")
  "cs" '(consult-eglot-symbols :wk "workspace symbols")
  "cS" '(eglot-shutdown :wk "shutdown lsp")
  "cR" '(eglot-reconnect :wk "restart lsp")

  "m" '(:ignore t :wk "mode")
  "mp" (list (lambda ()
               (interactive)
               (shell-command (concat "prettier --write "
                                    (shell-quote-argument (buffer-file-name))))
               (revert-buffer t t t))
             :wk "format prettier")

  "q" '(:ignore t :wk "quit")
  "qq" '(save-buffers-kill-terminal :wk "quit emacs")
  "qr" '(restart-emacs :wk "restart")

  "a" '(embark-act :wk "embark")
  "u" '(undo-tree-visualize :wk "undo tree")
  "P" '(consult-yank-from-kill-ring :wk "paste history"))
#+end_src
** local leader (,)

#+begin_src emacs-lisp
(my-local-leader
"a" '(org-agenda :wk "org agen")
  "t" '(eat :wk "terminal"))
#+end_src
** normal state

#+begin_src emacs-lisp
(general-def 'normal 'override
  "]d" 'flymake-goto-next-error
  "[d" 'flymake-goto-prev-error
  "]c" 'diff-hl-next-hunk
  "[c" 'diff-hl-previous-hunk
  "]b" 'switch-to-next-buffer
  "[b" 'switch-to-prev-buffer
  "]t" 'tab-next
  "[t" 'tab-previous
  "P" 'consult-yank-from-kill-ring
  "gcc" (lambda ()
          (interactive)
          (unless (use-region-p)
            (comment-or-uncomment-region
             (line-beginning-position)
             (line-end-position)))))

;; Global K binding für alle Modi mit eglot
#+end_src
** visual state

#+begin_src emacs-lisp
(general-def 'visual 'override
  "gc" (lambda ()
         (interactive)
         (when (use-region-p)
           (comment-or-uncomment-region
            (region-beginning)
            (region-end)))))
#+end_src
** avy

#+begin_src emacs-lisp
(general-def '(normal visual) 'override
  "s" (lambda ()
        (interactive)
        (let ((avy-all-windows t)
              (avy-background t)
              (scroll-margin 0)
              (maximum-scroll-margin 0))
          (call-interactively 'avy-goto-char-timer))))
#+end_src
** dirvish

#+begin_src emacs-lisp
(general-def 'normal dirvish-mode-map
  "?" 'dirvish-dispatch
  "q" 'dirvish-quit
  "b" 'dirvish-quick-access
  "f" 'dirvish-file-info-menu
  "p" 'dirvish-yank
  "S" 'dirvish-quicksort
  "F" 'dirvish-layout-toggle
  "z" 'dirvish-history-jump
  "gh" 'dirvish-subtree-up
  "gl" 'dirvish-subtree-toggle
  "h" 'dired-up-directory
  "l" 'dired-find-file
  "TAB" 'dirvish-subtree-toggle
  "[h" 'dirvish-history-go-backward
  "]h" 'dirvish-history-go-forward)

(general-def '(normal visual) dirvish-mode-map
  :prefix "y"
  "l" 'dirvish-copy-file-true-path
  "n" 'dirvish-copy-file-name
  "p" 'dirvish-copy-file-path
  "y" 'dired-do-copy)

(general-def 'normal dirvish-mode-map
  :prefix "s"
  "s" 'dirvish-symlink
  "S" 'dirvish-relative-symlink
  "h" 'dirvish-hardlink)
#+end_src

** org-mode

#+begin_src emacs-lisp
(my-local-leader
  :keymaps 'org-mode-map
  "h" '(consult-org-heading :wk "search headings"))
#+end_src
** minibuffer

#+begin_src emacs-lisp

(define-key minibuffer-local-map [escape] 'abort-recursive-edit)
(define-key minibuffer-local-ns-map [escape] 'abort-recursive-edit)
(define-key minibuffer-local-completion-map [escape] 'abort-recursive-edit)
(define-key minibuffer-local-must-match-map [escape] 'abort-recursive-edit)
(define-key minibuffer-local-isearch-map [escape] 'abort-recursive-edit)
#+end_src
** scroll

      #+begin_src emacs-lisp
   (global-set-key (kbd "C-=") 'text-scale-increase)
   (global-set-key (kbd "C--") 'text-scale-decrease)
   #+end_src
   
** provide init

   #+begin_src emacs-lisp
  (provide 'init)
   #+end_src