-
Notifications
You must be signed in to change notification settings - Fork 1
/
init.el
4478 lines (3962 loc) · 160 KB
/
init.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
;;; init.el --- Emacs init -*- lexical-binding: t -*-
;;
;; Copyright (c) 2022 mattiasdrp and contributors.
;; Author: mattiasdrp
;; Maintainer: mattiasdrp <https://github.com/mattiasdrp>
;; Created: 17 august 2022
;; Version: 1.0
;; Licence: MIT
;; Keywords: emacs, init, convenience, configuration
;; URL: https://github.com/mattiasdrp/pokemacs
;;; Commentary:
;; This file IS NOT intended to be edited! It was generated by init.org.
;; If you want to change it, edit init.org then M-x org-babel-tangle
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Code:
(defvar elpaca-installer-version 0.8)
(defvar elpaca-directory (expand-file-name "elpaca/" user-emacs-directory))
(defvar elpaca-builds-directory (expand-file-name "builds/" elpaca-directory))
(defvar elpaca-repos-directory (expand-file-name "repos/" elpaca-directory))
(defvar elpaca-order '(elpaca :repo "https://github.com/progfolio/elpaca.git"
:ref nil :depth 1
:files (:defaults "elpaca-test.el" (:exclude "extensions"))
:build (:not elpaca--activate-package)))
(let* ((repo (expand-file-name "elpaca/" elpaca-repos-directory))
(build (expand-file-name "elpaca/" elpaca-builds-directory))
(order (cdr elpaca-order))
(default-directory repo))
(add-to-list 'load-path (if (file-exists-p build) build repo))
(unless (file-exists-p repo)
(make-directory repo t)
(when (< emacs-major-version 28) (require 'subr-x))
(condition-case-unless-debug err
(if-let* ((buffer (pop-to-buffer-same-window "*elpaca-bootstrap*"))
((zerop (apply #'call-process `("git" nil ,buffer t "clone"
,@(when-let* ((depth (plist-get order :depth)))
(list (format "--depth=%d" depth) "--no-single-branch"))
,(plist-get order :repo) ,repo))))
((zerop (call-process "git" nil buffer t "checkout"
(or (plist-get order :ref) "--"))))
(emacs (concat invocation-directory invocation-name))
((zerop (call-process emacs nil buffer nil "-Q" "-L" "." "--batch"
"--eval" "(byte-recompile-directory \".\" 0 'force)")))
((require 'elpaca))
((elpaca-generate-autoloads "elpaca" repo)))
(progn (message "%s" (buffer-string)) (kill-buffer buffer))
(error "%s" (with-current-buffer buffer (buffer-string))))
((error) (warn "%s" err) (delete-directory repo 'recursive))))
(unless (require 'elpaca-autoloads nil t)
(require 'elpaca)
(elpaca-generate-autoloads "elpaca" repo)
(load "./elpaca-autoloads")))
(add-hook 'after-init-hook #'elpaca-process-queues)
(elpaca `(,@elpaca-order))
;; Install use-package support
(elpaca bind-key)
(elpaca elpaca-use-package
;; Enable :ensure use-package keyword.
(elpaca-use-package-mode)
;; Assume :ensure t unless otherwise specified.
(setq elpaca-use-package-by-default t))
(use-package system-packages
:ensure t
:config (message "`system-packages' loaded"))
(use-package use-package-ensure-system-package
:after (system-packages)
:ensure nil
:config (message "`use-package-ensure-system-package' loaded"))
(elpaca-wait)
(eval-and-compile
(setq
use-package-verbose t
use-package-expand-minimally t
use-package-compute-statistics t
use-package-always-defer t
use-package-enable-imenu-support t))
(setq byte-compile-warnings '(cl-functions))
;; Miscellaneous Packages
(defgroup pokemacs nil
"Customisation group for pokemacs"
:group 'emacs
:tag "Pokemacs customisation")
(defgroup pokemacs-packages nil
"Pokemacs packages options."
:group 'pokemacs
:tag "Packages")
(defcustom use-dashboard nil
"If non-nil, uses the dashboard packages.
This package greets you with a nice startup screen"
:group 'pokemacs-packages
:type 'boolean
:tag " Dashboard")
(defcustom use-eaf nil
"If non-nil, uses the Emacs application framework."
:group 'pokemacs-packages
:type 'boolean
:tag " Emacs Application Framework")
(defcustom use-gcal nil
"If non-nil, uses the org-gcal package.
This package is used to link google calendars to org agendas.
This is way too emacsy for most people"
:group 'pokemacs-packages
:type 'boolean
:tag " Org Google Calendar")
(defcustom use-god nil
"If non-nil, uses the god (mode) packages.
Similar to Vim's separation of command/insert modes"
:group 'pokemacs-packages
:type 'boolean
:tag " God Mode")
(defcustom use-magit-todos nil
"If non-nil, show todos in the current project in magit buffer.
If your project contains a lot of todos you may want to disable this package."
:group 'pokemacs-packages
:type 'boolean
:tag " Magit todos")
(defcustom use-mu4e nil
"If non-nil, use mu4e and smtpmail.
Reading your emails in emacs, what else?"
:group 'pokemacs-packages
:type 'boolean
:tag " Mu4e")
(defcustom use-org-agenda-startup nil
"Start the org agenda at startup.
If you don't live the org life you don't need it.
But you don't live the org life.
That's on you."
:group 'pokemacs-packages
:type 'boolean
:tag " Org Agenda")
(defcustom use-org-roam nil
"If non-nil, uses Org roam.
The Zettelkasten method.
In emacs.
With org-mode."
:group 'pokemacs-packages
:type 'boolean
:tag " Zettelkasten/Org Roam")
(defcustom use-pandoc nil
"If non-nil, uses the pandoc packages.
You know, for markdown. Because you don't use org-mode."
:group 'pokemacs-packages
:type 'boolean
:tag " Pandoc")
(defcustom use-posframe nil
"If non-nil, uses the vertico-posframe packages.
Instead of displaying candidate menus in the minibuffer display them in a fancy posframe."
:group 'pokemacs-packages
:type 'boolean
:tag " Posframe")
(defcustom use-treemacs nil
"If non-nil, uses the treemacs packages.
Some people want vscode in their emacs. Don't gate-keep, give them their big tree."
:group 'pokemacs-packages
:type 'boolean
:tag " Treemacs")
(defcustom use-window-purpose nil
"If non-nil, uses the window-purpose package.
Give windows a 'purpose' to prevent them from being populated by buffers that don't have the same purpose."
:group 'pokemacs-packages
:type 'boolean
:tag " Window Purpose")
;; Custom values
(defgroup pokemacs-values nil
"Pokemacs values options."
:group 'pokemacs
:tag "Values")
(defcustom pokemacs-repeat-timeout 0.5
"Time before repeat-mode exits."
:group 'pokemacs-values
:type 'integer
:tag "Repeat")
;; Themes
(defgroup pokemacs-appearance nil
"Pokemacs appearance options."
:group 'pokemacs
:tag "Appearance")
(defcustom pokemacs-mono-font "Fira Code"
"Default mono font."
:group 'pokemacs-appearance
:type 'string
:tag " Mono Font")
(defcustom pokemacs-variable-font "Iosevka Aile"
"Default variable font."
:group 'pokemacs-appearance
:type 'string
:tag " Variable Font")
(defcustom tuple-mono-font `(:font ,pokemacs-mono-font)
"List of possible mono fonts (the first available one will be used).
`pokemacs-mono-font' is the first checked font"
:group 'pokemacs-appearance
:type 'list
:tag " Mono Fonts")
(defcustom tuple-variable-font `(:font ,pokemacs-variable-font)
"List of possible mono fonts (the first available one will be used).
`pokemacs-variable-font' is the first checked font"
:group 'pokemacs-appearance
:type 'list
:tag " Variable Fonts")
(defcustom pokemacs-dark-theme-p t
"Dark or light theme."
:group 'pokemacs-appearance
:type 'boolean
:tag " Dark/Light")
(defcustom pokemacs-dark-theme 'doom-solarized-dark
"Dark theme to load."
:group 'pokemacs-appearance
:type 'symbol
:tag " Dark Theme")
(defcustom pokemacs-light-theme 'doom-solarized-light
"Light theme to load."
:group 'pokemacs-appearance
:type 'symbol
:tag " Light Theme")
(defcustom use-all-the-icons nil
"Use all-the-icons (when t) or nerd-icons (when nil).
nerd-icons is a better choice and I plan to stop using all-the-icons completely."
:group 'pokemacs-appearance
:type 'boolean
:tag " Icons")
(defcustom use-header-line nil
"Use the header-line as the mode-line."
:group 'pokemacs-appearance
:type 'boolean
:tag "〜 Header-line")
(defcustom use-maximize nil
"If non-nil, maximize Emacs at startup."
:group 'pokemacs-appearance
:type 'boolean
:tag " Maximize")
(defcustom use-rainbow nil
"If non-nil, don't be @thriim.
Rainbowify parentheses and other things."
:group 'pokemacs-appearance
:type 'boolean
:tag " Rainbows")
(defcustom use-solaire t
"If non-nil, uses the solaire package.
Distinguishes between \"real\" buffers and \"unreal\" ones by giving the latter a darker background."
:group 'pokemacs-appearance
:type 'boolean
:tag " Solaire")
(defcustom use-visual-fill nil
"If non-nil, fill the frame when there's only one."
:group 'pokemacs-appearance
:type 'boolean
:tag " Visual Fill")
;; Dictionaries
(defgroup pokemacs-dictionaries nil
"Pokemacs dictionaries options."
:group 'pokemacs
:tag "Dictionaries")
(defcustom pokemacs-dict "en-GB"
"Dictionary language.
Specify the chosen language used by spell checking tools in pokemacs."
:group 'pokemacs-dictionaries
:type '(choice (const :tag "en-GB" "en-GB")
(const :tag "en-US" "en-US")
(const :tag "fr" "fr")
(const :tag "No dict" nil)
(string :tag "Other"))
:tag " Dictionary")
(setq user-init-file (or load-file-name (buffer-file-name)))
(setq user-emacs-directory (file-name-directory user-init-file))
(setq custom-file (expand-file-name "custom.el" user-emacs-directory))
(load custom-file 'noerror)
(defun pokemacs-get-current-theme ()
(if pokemacs-dark-theme-p
pokemacs-dark-theme
pokemacs-light-theme))
(setq reface-list nil)
(defun fill-reface-list (face)
;; saved-face is nil if the face hasn't been customized
(message "reface %S is %S" face (get face 'saved-face))
(unless (get face 'saved-face)
(add-to-list 'reface-list face)))
(fill-reface-list 'show-paren-match)
(fill-reface-list 'show-paren-mismatch)
(defun reface-p (face)
(member face reface-list))
(defun pokemacs--reface (&rest _)
(custom-set-faces
`(org-block ((t :background ,(doom-darken (doom-color 'bg) 0.15))) t)
`(org-block-begin-line ((t)) t)
`(org-block-end-line ((t :foreground unspecified :background unspecified))))
(when (reface-p 'show-paren-match)
(message "reface show paren match")
(custom-set-faces
`(show-paren-match
((t (:inherit region :background ,(doom-color 'base3)
:weight unspecified :foreground unspecified))))))
(when (reface-p 'show-paren-mismatch)
(custom-set-faces
`(show-paren-mismatch
((t (:foreground unspecified :weight unspecified
:background ,(doom-color 'warning))))))))
(defun pokemacs-load-theme ()
(load-theme (pokemacs-get-current-theme) t)
(pokemacs--reface))
(advice-add #'consult-theme :after #'pokemacs--reface)
(defun pokemacs-toggle-dark-light-theme ()
(interactive)
(setq pokemacs-dark-theme-p (not pokemacs-dark-theme-p))
(pokemacs-load-theme))
(use-package doom-themes
:demand t
:config
;; Enable flashing mode-line on errors
(doom-themes-visual-bell-config)
;; Enable custom neotree theme (all-the-icons must be installed!)
;; (doom-themes-neotree-config)
;; or for treemacs users
(setq doom-themes-treemacs-theme "doom-colors") ; use the colorful treemacs theme
(doom-themes-treemacs-config)
;; Corrects (and improves) org-mode's native fontification.
(doom-themes-org-config)
(pokemacs-load-theme)
(message "`doom-themes' loaded"))
(elpaca-wait)
(when use-maximize
(set-frame-parameter (selected-frame) 'fullscreen 'maximized)
(add-to-list 'default-frame-alist '(fullscreen . maximized)))
(defvar better-gc-cons-threshold (* 128 1024 1024)) ; 128mb
(add-hook 'emacs-startup-hook
(lambda ()
(setq file-name-handler-alist file-name-handler-alist-original)
(makunbound 'file-name-handler-alist-original)))
(setq gc-cons-threshold better-gc-cons-threshold)
(setq gc-cons-percentage 0.1)
(setq garbage-collection-messages nil)
(defun update-to-load-path (folder)
"Update FOLDER and its subdirectories to `load-path'."
(let ((base folder))
(unless (member base load-path)
(add-to-list 'load-path base))
(dolist (f (directory-files base))
(let ((name (concat base "/" f)))
(when (and (file-directory-p name)
(not (equal f ".."))
(not (equal f ".")))
(unless (member base load-path)
(add-to-list 'load-path name)))))))
(update-to-load-path (expand-file-name "lisp" user-emacs-directory))
(setq frame-title-format '(buffer-file-name "%b (%f)" "%b"))
(fset 'yes-or-no-p 'y-or-n-p)
(setq-default
;; Save backup files in a .backup directory
backup-directory-alist `(("." . ,(expand-file-name ".backup" user-emacs-directory)))
backup-by-copying t
delete-old-versions t
kept-new-versions 6
kept-old-versions 2
version-control t
desktop-save-mode 1
delete-by-moving-to-trash t)
(setq-default
;; Briefly move cursor to the matching open-paren
;; even if it is not visible in the window.
blink-matching-paren 'jump-offscreen
;; Show matching parenthesis even for comments
blink-matching-paren-dont-ignore-comments t
;; Show matching parentheses even when on screen
blink-matching-paren-on-screen t
;; Show column with line in the modeline
column-number-mode t
;; Full comments per line
comment-style 'indent
;; Always kill compilation process before starting another
compilation-always-kill t
;; Save all buffers before compiling
compilation-ask-about-save nil
;; TODO: Not exactly sure what this does
compilation-context-lines t
;; TODO: Not exactly sure what this does
compilation-error-screen-columns t
;; Scroll to the first error in the compilation buffer
compilation-scroll-output 'first-error
;; Number of lines in a compilation window
compilation-window-height 12
;; Ask before killing emacs
confirm-kill-emacs 'y-or-n-p
;; Don't lock files, I know what I'm doing
create-lockfiles nil
;; If two dired are opened with two different locations
;; copy command will copy from one to the other
dired-dwim-target t
;; Show Keystrokes in Progress Instantly
echo-keystrokes 0.1
;; Turn font lock mode for all modes that allow it
;; TODO: Specify a list when we'll start using tree-sitter
font-lock-global-modes t
;; Never insert tabs when indenting (default is now to always use space)
indent-tabs-mode nil
;; I know emacs, I really don't need the startup-screen
inhibit-startup-screen t
;; Don't put anything in the scratch buffer
initial-scratch-message nil
;; Move point by visual lines
line-move-visual t
;; Highlight the location of the next-error in the source buffer
next-error-highlight t
;; Highlight the locus indefinitely until some other locus replaces it.
next-error-highlight-no-select t
;; Add a newline automatically at the end of the file upon save.
require-final-newline t
;; Turn Off Cursor Alarms
ring-bell-function 'ignore
;; Use the clipboard too when cutting and pasting
select-enable-clipboard t
;; TODO: Not sure why I'm using it
sentence-end-double-space nil
;; I don't need scroll bars
scroll-bar-mode nil
tab-width 2
;; Long lines will span on a continuation line (makes the whole line visible)
truncate-lines nil
;; Save undos even when closing emacs
undo-tree-auto-save-history t
;; yes or no replace by y or n everywhere
use-short-answers t
vc-follow-symlinks t
;; Flash the screen
visible-bell nil)
(use-package server
:demand t
:ensure nil
:config
(unless (server-running-p) (server-start))
(message "`server' loaded"))
;; Allows to repeat just one key to allow shorter key sequences
(use-package repeat
:ensure nil
:init (repeat-mode t)
:config
(setopt repeat-exit-timeout nil)
(defun pokemacs-set-repeat-exit-timeout (list)
(dolist (command list)
(put command 'repeat-exit-timeout pokemacs-repeat-timeout))))
(global-prettify-symbols-mode t)
(prettify-symbols-mode)
(setq prettify-symbols-unprettify-at-point 1)
(global-auto-revert-mode t)
(auto-revert-mode t)
(show-paren-mode 1)
;; (global-display-line-numbers-mode t)
(setq save-place-forget-unreadable-files t)
(save-place-mode 1)
(delete-selection-mode t)
(when (fboundp 'global-so-long-mode)
(global-so-long-mode))
(unless (version< emacs-version "29")
(pixel-scroll-precision-mode t))
(add-to-list 'auto-mode-alist '("\\.in\\'" . text-mode))
(add-to-list 'auto-mode-alist '("\\.out\\'" . text-mode))
(add-to-list 'auto-mode-alist '("\\.args\\'" . text-mode))
(add-hook 'before-save-hook 'delete-trailing-whitespace)
(use-package auto-package-update
:custom
(auto-package-update-show-preview t)
(auto-package-update-prompt-before-update t)
(auto-package-update-delete-old-version t)
:config (message "`auto-package-update' loaded"))
(use-package no-littering
:demand t
:config (message "`no-littering' loaded"))
(elpaca-wait)
(auto-save-visited-mode 1)
(setq auto-save-default t)
(setq auto-save-timeout 60)
(setq auto-save-interval 200)
(require 'cl-lib)
(require 'package)
(require 'pokemacs-functions)
(defconst pokemacs-sys/win32
(eq system-type 'windows-nt)
"Are we running on a WinTel system?")
(defconst pokemacs-sys/linux
(eq system-type 'gnu/linux)
"Are we running on a GNU/Linux system?")
(defconst pokemacs-sys/mac
(eq system-type 'darwin)
"Are we running on a Mac system?")
(defvar pokemacs-fd-binary
(cl-find-if #'executable-find (list "fdfind" "fd"))
"The filename of the `fd' executable. On some distros it's 'fdfind' (ubuntu,
debian, and derivatives). On most it's 'fd'.")
(use-package gcmh
:demand t
:custom
(gcmh-idle-delay 'auto) ; default is 15s
(gcmh-auto-idle-delay-factor 10)
(gcmh-high-cons-threshold (* 16 1024 1024)) ; 16mb
:config (gcmh-mode 1))
(use-package esup
:config
(setq esup-depth 0)
(message "`esup' loaded"))
(use-package prescient
:init (setq prescient-persist-mode 1)
:config (message "`prescient' loaded"))
(use-package savehist
:ensure nil
:init
(savehist-mode t)
;; Remember recently opened files
(recentf-mode t)
:custom
(history-delete-duplicates t)
:config
;; Persist 'compile' history
(add-to-list 'savehist-additional-variables 'compile-history)
(add-to-list 'recentf-exclude no-littering-var-directory)
(add-to-list 'recentf-exclude no-littering-etc-directory)
(message "`savehist' loaded"))
(defun pokemacs-wsl-specific-function ()
"Change some values if running on WSL"
(when (getenv "WSLENV")
(message "setting wsl env")
(eshell-command "xmodmap -e 'keycode 191 = space'")
(let ((cmd-exe "/mnt/c/Windows/System32/cmd.exe")
(cmd-args '("/c" "start")))
(when (file-exists-p cmd-exe)
(setq browse-url-generic-program cmd-exe
browse-url-generic-args cmd-args
browse-url-browser-function 'browse-url-generic
search-web-default-browser 'browse-url-generic)))))
(add-hook 'after-init-hook #'pokemacs-wsl-specific-function)
(unless pokemacs-sys/win32
(set-selection-coding-system 'utf-8)
(prefer-coding-system 'utf-8)
(set-language-environment "UTF-8")
(set-default-coding-systems 'utf-8)
(set-terminal-coding-system 'utf-8)
(set-keyboard-coding-system 'utf-8)
(setq locale-coding-system 'utf-8))
(use-package all-the-icons
:if (display-graphic-p)
:demand t
:config
(when use-all-the-icons
(set-fontset-font t '(#xe3d0 . #xe909) "Material Icons")
(set-fontset-font t '(#xe3d0 . #xe3d9) "Material Icons"))
(message "`all-the-icons' loaded"))
(when use-all-the-icons
(use-package all-the-icons-dired
:if (display-graphic-p)
:hook (dired-mode . all-the-icons-dired-mode)
:config
(message "`all-the-icons-dired' loaded")))
(when use-all-the-icons
(use-package all-the-icons-completion
:if (display-graphic-p)
:init (all-the-icons-completion-mode)
:after (marginalia all-the-icons)
:hook (marginalia-mode . all-the-icons-completion-marginalia-setup)
:config
(message "`all-the-icons-completion' loaded")))
(unless use-all-the-icons
(use-package nerd-icons
:demand t
:config
(set-fontset-font t '(#x25d0 . #xf10d7) "Symbols Nerd Font Mono")
(set-fontset-font t '(#xe3d0 . #xe3d9) "Material Icons")
(message "`nerd-icons' loaded")))
(unless use-all-the-icons
(use-package nerd-icons-dired
:hook (dired-mode . nerd-icons-dired-mode)
:config (message "`nerd-icons-dired' loaded")))
(unless use-all-the-icons
(use-package nerd-icons-completion
:after (marginalia nerd-icons)
:hook (marginalia-mode . nerd-icons-completion-marginalia-setup)
:config
(nerd-icons-completion-mode)
(message "`nerd-icons-completion' loaded")))
(use-package nerd-icons-corfu
:demand t
:after (nerd-icons corfu)
:config
(add-to-list 'corfu-margin-formatters #'nerd-icons-corfu-formatter)
;; Optionally:
;; (setq nerd-icons-corfu-mapping
;; '((array :style "cod" :icon "symbol_array" :face font-lock-type-face)
;; (boolean :style "cod" :icon "symbol_boolean" :face font-lock-builtin-face)
;; ;; ...
;; (t :style "cod" :icon "code" :face font-lock-warning-face)))
;; Remember to add an entry for `t', the library uses that as default.
)
(use-package ligature
:demand t
:config
;; Enable the "www" ligature in every possible major mode
(ligature-set-ligatures 't '("www"))
;; Enable traditional ligature support in eww-mode, if the
;; `variable-pitch' face supports it
(ligature-set-ligatures 'eww-mode '("ff" "fi" "ffi"))
;; Enable all Fira Code ligatures in programming modes
(ligature-set-ligatures
'prog-mode '(
"www" "**" "***" "**/" "*>" "*/" "\\\\" "\\\\\\" "{-" "::"
":::" ":=" "!!" "!=" "!==" "-}" "----" "-->" "->" "->>"
"-<" "-<<" "-~" "#{" "#[" "##" "###" "####" "#(" "#?" "#_"
"#_(" ".-" ".=""..<""?=" "??" ";;" "/*" "/**"
;; "..""..."
"/=" "/==" "/>" "//" "///" "&&" "||" "||=" "|=" "|>" "^=" "$>"
"++" "+++" "+>" "=:=" "==" "===" "==>" "=>" "=>>" "<="
"=<<" "=/=" ">-" ">=" ">=>" ">>" ">>-" ">>=" ">>>" "<*"
"<*>" "<|" "<|>" "<$" "<$>" "<!--" "<-" "<--" "<->" "<+"
"<+>" "<=" "<==" "<=>" "<=<" "<>" "<<" "<<-" "<<=" "<<<"
"<~" "<~~" "</" "</>" "~@" "~-" "~>" "~~" "~~>" "%%" "[|" "|]"))
;; Enables ligature checks globally in all buffers. You can also do it
;; per mode with `ligature-mode'.
(global-ligature-mode t)
(message "`ligature' loaded"))
(use-package ansi-color
:ensure nil
:hook (shell-mode . ansi-color-for-comint-mode-on)
:config (message "`ansi-color' loaded"))
(use-package xterm-color
:config
(setq compilation-environment '("TERM=xterm-256color"))
(defun my/advice-compilation-filter (f proc string)
(funcall f proc (xterm-color-filter string)))
(advice-add 'compilation-filter :around #'my/advice-compilation-filter))
(use-package kurecolor
:config (message "`kurecolor' loaded"))
(use-package emojify
:hook (after-init . global-emojify-mode)
:config (message "`emojify' loaded"))
(use-package general
:demand t
:init
(if (display-graphic-p)
(general-unbind "C-z"))
(general-unbind
"C-o"
"C-f"
"C-x C-z"
"M-z"
"M-m"
"M-l"
"M-h"
"M-/"
"M-l"
"M-f")
(general-define-key
[remap kill-buffer] 'kill-current-buffer
[remap ispell-word] 'jinx-correct
;; Prefixed by C
"C-x C-1" 'delete-other-windows
"C-x C-2" 'split-window-below
"C-x C-3" 'split-window-right
"C-x C-0" 'delete-window
"C-x &" 'delete-other-windows
"C-x é" 'split-window-below
"C-x \"" 'split-window-right
"C-x à" 'delete-window
"C-x C-l" 'toggle-truncate-lines
"C-=" 'text-scale-increase
"C-+" 'text-scale-increase
"C--" 'text-scale-decrease
"C-c b" 'describe-personal-keybindings
;; Create new line contextualised by the previous one
;; (will add a comment if in comment mode for example)
"C-<return>" 'default-indent-new-line
;; emacs autocompletion (not like company)
"C-<tab>" 'dabbrev-expand
"C-n" 'next-error
"C-p" 'previous-error
"C-x C-o" 'ace-window
;; rotate buffers and window arrangements
"C-c r w" 'rotate-window
"C-c r l" 'rotate-layout
;; Prefixed by M
"M-u" 'upcase-dwim
"M-J" (lambda () (interactive) (pokemacs-resize-window t 5))
"M-L" (lambda () (interactive) (pokemacs-resize-window t -5))
"M-I" (lambda () (interactive) (pokemacs-resize-window nil 5))
"M-K" (lambda () (interactive) (pokemacs-resize-window nil -5))
;; Custom comment overwriting comment-dwim key binding
"M-;" 'pokemacs-comment-eclipse
"M-p" 'backward-paragraph
"M-<f1>" 'kill-current-buffer
"M-Q" 'unfill-paragraph
"M-+" 'hs-toggle-hiding
"M-*" 'hs-show-all
;; Function keys
[f3] 'next-match
[(shift f3)] 'prev-match
[f4] 'goto-line
[f7] 'next-error
[f8] 'normal-mode)
(general-define-key
:prefix "M-z"
;; Setup shorcuts for window resize width and height
"w" 'pokemacs-resize-window-width
"h" 'pokemacs-resize-window-height)
(general-define-key
:prefix "M-h"
"d" '(hydra-dates/body :which-key "Date Utils")
"f" '(hydra-flycheck/body :which-key "Flycheck")
"g" '(hydra-smerge/body :which-key "Git/Smerge")
"w" '(hydra-window/body :which-key "Window")
"t" '(pokemacs-toggles/body :which-key "Toggles"))
(general-def minibuffer-local-map
"C-<tab>" 'dabbrev-expand)
:config (message "`general' loaded"))
(elpaca-wait)
(use-package which-key
:init (which-key-mode)
:custom
(which-key-separator " ")
(which-key-prefix-prefix "+")
:config
(which-key-add-major-mode-key-based-replacements 'markdown-mode
"C-c TAB" "markdown/images"
"C-c C-a" "markdown/links"
"C-c C-c" "markdown/process"
"C-c C-s" "markdown/style"
"C-c C-t" "markdown/header"
"C-c C-x" "markdown/structure"
"C-c m" "markdown/personal")
(which-key-add-major-mode-key-based-replacements 'web-mode
"C-c C-a" "web/attributes"
"C-c C-b" "web/blocks"
"C-c C-d" "web/dom"
"C-c C-e" "web/element"
"C-c C-t" "web/tags")
(which-key-setup-side-window-bottom)
(setq which-key-sort-order 'which-key-key-order-alpha
which-key-side-window-max-width 0.33
which-key-show-early-on-C-h t
which-key-idle-delay 0.1)
(message "`which-key' loaded"))
(use-package hydra
:demand t
:custom
(hydra-default-hint nil)
(hydra-look-for-remap t)
:init
(defun pokemacs-date-iso ()
"Insert the current date, ISO format, eg. 2016-12-09."
(interactive)
(insert (format-time-string "%F")))
(defun pokemacs-date-iso-with-time ()
"Insert the current date, ISO format with time, eg. 2016-12-09T14:34:54+0100."
(interactive)
(insert (format-time-string "%FT%T%z")))
(defun pokemacs-date-long ()
"Insert the current date, long format, eg. December 09, 2016."
(interactive)
(insert (format-time-string "%d %B %Y")))
(defun pokemacs-date-long-with-time ()
"Insert the current date, long format, eg. December 09, 2016 - 14:34."
(interactive)
(insert (capitalize (format-time-string "%d %B %Y - %H:%M"))))
(defun pokemacs-date-short ()
"Insert the current date, short format, eg. 2016.12.09."
(interactive)
(insert (format-time-string "%Y.%m.%d")))
(defun pokemacs-date-short-with-time ()
"Insert the current date, short format with time, eg. 2016.12.09 14:34"
(interactive)
(insert (format-time-string "%Y.%m.%d %H:%M")))
:config
(message "`hydra' loaded"))
(elpaca-wait)
;; NOTE: hydra and posframe are required
(when use-posframe
(use-package hydra-posframe
:ensure (:type git :host github :repo "Ladicle/hydra-posframe")
:hook (after-init . hydra-posframe-mode)))
(use-package major-mode-hydra
:ensure t
:demand t
:general
("M-h h" '(major-mode-hydra :which-key "Major mode"))
("M-h m" '(pokemacs-major-mode-hydra-custom :which-key "Custom mode"))
:custom
(major-mode-hydra-invisible-quit-key "q")
:config
(defun pokemacs-major-mode-hydra-custom (mode)
(interactive
(list
(intern
(completing-read
"Describe custom theme: "
(mapcar #'symbol-name
(buffer-local-value 'local-minor-modes (current-buffer)))))))
(major-mode-hydra-dispatch mode))
(defun major-mode-hydra-dispatch (mode)
"Summon the hydra for given MODE (if there is one)."
(let ((orig-mode mode))
(catch 'done
(while mode
(let ((hydra (major-mode-hydra--body-name-for mode)))
(when (fboundp hydra)
(call-interactively hydra)
(throw 'done t)))
(setq mode (or (get mode 'derived-mode-parent) 'root-mode))))))
(setq major-mode-hydra-title-generator
'(lambda (mode)
(let ((icon (all-the-icons-icon-for-mode mode :v-adjust 0.05)))
(if (stringp icon)
(s-concat "\n"
(s-repeat 7 " ")
icon
" "
(s-capitalize (symbol-name mode))
" commands")
(s-concat "\n"
(s-repeat 10 " ")
(s-capitalize (symbol-name mode))
" commands"))))))
(elpaca-wait)
(use-package pretty-hydra
:ensure nil
:config
(pretty-hydra-define
hydra-dates (:color teal :title "Dates" :quit-key "q")
("Insert"
(("d" pokemacs-date-short "short")
("i" pokemacs-date-iso "iso")
("l" pokemacs-date-long "long"))
"Insert with time"
(("D" pokemacs-date-short-with-time "short")
("I" pokemacs-date-iso-with-time "iso")
("L" pokemacs-date-long-with-time "long")))))
(use-package keycast
:commands keycast-mode
:config
(define-minor-mode keycast-mode