-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.el
1237 lines (1080 loc) · 36.3 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 --- Init File -*- lexical-binding: t -*-
;;; Commentary:
;; This is my personal programming-focused Emacs configuration file.
;;
;;; Code:
;; Use `straight.el' instead of the built-in `package.el' for downloading external
;; packages. As we are completely replacing `package.el' we need to download
;; `straight.el' without using it. We first create a bootstrap file that will
;; contain the install script and is installed the very first time we launch
;; Emacs.
(defvar bootstrap-version)
(let ((bootstrap-file
(expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
(bootstrap-version 6))
(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 'use-package)
(setq straight-use-package-by-default nil)
;; Load private information
;;(load-file (concat user-emacs-directory "secret.el"))
;; The package `diminish' introduces the `:diminish' keyword which can be used
;; together with `use-package' to hide minor modes from the modeline. This
;; allows the modeline to be kept minimal and show only required modes.
;;
;; https://github.com/emacsmirror/diminish
(use-package diminish
:straight t)
(use-package gcmh
:straight t
:config
(gcmh-mode 1)
:diminish)
;; The package `no-littering' ensures that the `user-emacs-directory' location
;; is kept "clean" by moving the various different files that get created into
;; specific directories. It is important to note that this package must be
;; installed and activated before other Emacs packages are initialised.
;;
;; https://github.com/emacscollective/no-littering
(use-package no-littering
:straight t
:init
(setq no-littering-etc-directory (expand-file-name "tmp/config/" user-emacs-directory)
no-littering-var-directory (expand-file-name "tmp/data/" user-emacs-directory)))
(use-package emacs
:init
(setq create-lockfiles nil
history-length 1000
history-delete-duplicates t
use-dialog-box nil
ring-bell-function 'ignore
frame-resize-pixelwise t ; For seperate frames (C-x 5 2)
echo-keystrokes 0.02
use-short-answers t
frame-title-format '("" (:eval (if (buffer-file-name)
(abbreviate-file-name (buffer-file-name))
"%b")))
enable-recursive-minibuffers t
initial-scratch-message nil
inhibit-startup-echo-area-message user-login-name
inhibit-startup-screen t
;;inhibit-splash-screen t
;;inhibit-startup-message t
tab-always-indent 'complete
delete-by-moving-to-trash t
user-full-name "Zakariya Oulhadj"
user-mail-address "[email protected]"
;; scroll-conservatively most-positive-fixnum
sentence-end-double-space nil
)
(setq-default tab-width 8
fill-column 80)
;; Disable bindings for suspending Emacs in graphical mode since it's super
;; annoying.
(when (display-graphic-p)
(global-unset-key (kbd "C-z"))
(global-unset-key (kbd "C-x C-z")))
(tool-bar-mode -1)
(scroll-bar-mode -1)
(blink-cursor-mode -1)
(menu-bar-mode -1)
(add-to-list 'default-frame-alist '(fullscreen . maximized))
;; (toggle-frame-maximized) ; @todo: Does not work for emacsclient
:config
(put 'narrow-to-region 'disabled nil)
:bind
("C-x k" . kill-this-buffer)
;; :hook
;; (after-init . (lambda ()
;; (message "Emacs loaded in %s seconds with %d garbage collections"
;; (emacs-init-time) gcs-done)))
)
(defun custom/load-config ()
"Load my Emacs init.el configuration file."
(interactive)
(find-file (concat user-emacs-directory "init.el")))
;;(global-set-key (kbd "C-c c") 'custom/load-config)
;; ========== [Core] ==========
(use-package use-package-core
:init
(setq use-package-verbose t))
(use-package comp
:init
(setq native-comp-async-report-warnings-errors 'silent))
(use-package custom
:init
(setq custom-safe-themes t))
;; ========== [User Interface] ==========
(defun prev-window ()
(interactive)
(other-window -1))
(use-package window
:init
(setq switch-to-buffer-obey-display-actions nil)
:config
(global-set-key (kbd "C-x o") 'other-window)
:bind
("C-," . prev-window)
("C-." . other-window)
("C-1" . delete-other-windows)
("C-2" . split-window-below)
("C-3" . split-window-right)
("C-0" . delete-window)
;; These bindings make it easier dealing with windows in `god-mode'.
;; @TODO: Only enable these bindings when god-mode is active.
("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)
)
(use-package frame
:config
(toggle-frame-maximized)
;;(toggle-frame-fullscreen)
)
(use-package display-fill-column-indicator
:config
(set-face-attribute 'fill-column-indicator nil :foreground "grey14")
;; :hook
;; (prog-mode . display-fill-column-indicator-mode)
)
(use-package fringe
:config
(fringe-mode nil))
(use-package hl-line
:config
(global-hl-line-mode 0))
(use-package face-remap
:config
(setq text-scale-mode-step 1.2))
;; @TODO: Move this into eglot configuration
(use-package cc-vars
:init
(setq c-default-style "k&r"
c-basic-offset 4))
(use-package subword
:config
(global-subword-mode 1))
(use-package compile
:init
(setq compilation-scroll-output nil
compilation-ask-about-save nil)
;; Make the compilation window automatically disappear - from enberg on #emacs
;; (setq compilation-finish-functions
;; (lambda (buf str)
;; (if (null (string-match ".*exited abnormally.*" str))
;; ;;no errors, make the compilation window go away in a few seconds
;; (progn
;; (run-at-time
;; "1 sec" nil 'delete-windows-on
;; (get-buffer-create "*compilation*"))
;; (message "No Compilation Errors!")))))
:bind
("<f5>" . recompile)
("C-c c" . recompile))
(use-package comint
:init
(setq comint-input-ignoredups t
comint-process-echoes t))
(use-package whitespace
:hook
(before-save . whitespace-cleanup))
(use-package calendar
:init
(setq calendar-date-style "european"
calendar-week-start-day 1))
(use-package vc-hooks
:init
(setq vc-follow-symlinks t))
(use-package files
:init
(setq large-file-warning-threshold 100000000 ; warn when opening files bigger than 100MB
make-backup-files nil
require-final-newline t
delete-old-versions t
confirm-kill-emacs 'y-or-n-p))
(use-package delsel
:config
(delete-selection-mode t))
(use-package saveplace
:init
(setq save-place-limit 500)
:config
(save-place-mode 1))
(use-package savehist
:init
(setq savehist-additional-variables
'(search-ring regexp-search-ring)
savehist-autosave-interval 60)
:config
(savehist-mode +1))
(use-package desktop
:disabled ;; todo: messes up the previously loaded theme.
:init
(setq
;; @TODO: For some reason dirname is not set?
desktop-dirname (expand-file-name "tmp/data/desktop/" user-emacs-directory)
desktop-load-locked-desktop t
desktop-auto-save-timeout 30)
:config
(desktop-save-mode 1))
;; (use-package pixel-scroll
;; :config
;; ;; @TODO: Disabled for now because it feels laggy.
;; (pixel-scroll-precision-mode 0))
(use-package autorevert
:init
(setq global-auto-revert-non-file-buffers t)
:config
(global-auto-revert-mode t))
(use-package simple
:init
(setq read-extended-command-predicate #'command-completion-default-include-p ; hide commands (M-x) that are not supported in the current mode)
column-number-mode t
next-line-add-newlines t
kill-do-not-save-duplicates t)
(setq-default indent-tabs-mode nil)
:config
(visual-line-mode -1)
(size-indication-mode -1)
(set-default 'truncate-lines t))
(use-package time
:init
(setq display-time-24hr-format t)
:config
(display-time-mode -1)
:custom
(display-time-default-load-average nil))
(use-package display-line-numbers
:init
(setq display-line-numbers-type 'visual)
;;:hook
;;(prog-mode . display-line-numbers-mode)
;;(org-mode . display-line-numbers-mode)
)
(use-package which-func
:hook
(prog-mode . which-function-mode))
(use-package elec-pair
:config
(electric-pair-mode 1))
(use-package paren
:init
(setq show-paren-delay 0.0)
:config
(show-paren-mode 1))
(use-package recentf
:init
(setq recentf-max-saved-items 500
recentf-max-menu-items 15
;; disable recentf-cleanup on emacs start, because it can cause
;; problems with remote files (prelude)
recentf-auto-cleanup 'never)
:config
(recentf-mode 1)
:custom
;; exclude all of files in the no-littering directories from recentf.
(add-to-list 'recentf-exclude
(recentf-expand-file-name no-littering-var-directory))
(add-to-list 'recentf-exclude
(recentf-expand-file-name no-littering-etc-directory)))
(use-package windmove
:config
(windmove-default-keybindings))
;; todo: only enable if aspell is installed
;; maybe we can use :ensure-system-package
(use-package flyspell
:disabled ;; @TODO: C-, conflicts with prev-window
:init
(setq ispell-program-name "aspell"
ispell-extra-args '("--sug-mode=ultra"))
:hook
(prog-mode . flyspell-prog-mode))
(use-package isearch
:config
(setq isearch-wrap-pause t
isearch-lazy-count t
isearch-allow-scroll 'unlimited)
:bind (:map isearch-mode-map
("<backspace>" . isearch-del-char)))
(use-package dired
:init
(setq dired-kill-when-opening-new-dired-buffer t
dired-hide-details-hide-symlink-targets nil
dired-dwim-target t)
;; @TODO: on macOS --group-directories-first is not supported.
;; See: https://github.com/d12frosted/homebrew-emacs-plus/issues/383#issuecomment-899157143
(setq-default dired-listing-switches "-l --all --no-group --human-readable --group-directories-first --time-style=long-iso")
:config
(define-key dired-mode-map [mouse-2] 'dired-mouse-find-file)
;; :hook
;; (dired-mode . dired-hide-details-mode)
)
(use-package org
:init
(setq org-agenda-files '("~/Documents/org/agenda.org")
org-startup-indented nil
org-time-stamp-custom-formats '("<%d/%m/%y %a>" . "<%d/%m/%y %a %h:%m>")
org-display-custom-times t
org-return-follows-link t
org-hide-emphasis-markers t)
:hook
(org-mode . turn-on-auto-fill))
(use-package org-clock
:init
(setq org-clock-persist 'history
org-clock-idle-time 15)
:config
(org-clock-persistence-insinuate))
;; (use-package gnus
;; :init
;; (setq gnus-select-method '(nntp "news.gmane.io")
;; gnus-thread-hide-subtree t
;; gnus-newsgroup-maximum-articles 50
;; gnus-secondary-select-methods '((nntp "news.tilde.club"))))
;; The `treesit' package performs fast syntax parsing for languages and allows
;; for other packages to make use of the better context aware functionality.
;;
;; https://github.com/tree-sitter/tree-sitter
(use-package treesit
:init
(setq treesit-language-source-alist
'((c "https://github.com/tree-sitter/tree-sitter-c")
(cpp "https://github.com/tree-sitter/tree-sitter-cpp")
(rust "https://github.com/tree-sitter/tree-sitter-rust")
(python "https://github.com/tree-sitter/tree-sitter-python")))
;; Even when tree sitter is installed and the language grammer is configured,
;; emacs will not enable it. this is because we must enable the special "ts"
;; modes. so here we remap the default modes to tree-sitter specific modes.
(setq major-mode-remap-alist
'((c-mode . c-ts-mode)
(c++-mode . c++-ts-mode)
(c-or-c++-mode . c-or-c++-ts-mode)
(python-mode . python-ts-mode))))
;; @TODO: Requires c/c++ language server
(use-package c-ts-mode
:requires treesit
:init
(setq c-ts-mode-indent-offset 4
c-ts-mode-indent-style 'k&r))
;; (const :tag "Documentation on hover" :hoverProvider)
;; (const :tag "Code completion" :completionProvider)
;; (const :tag "Function signature help" :signatureHelpProvider)
;; (const :tag "Go to definition" :definitionProvider)
;; (const :tag "Go to type definition" :typeDefinitionProvider)
;; (const :tag "Go to implementation" :implementationProvider)
;; (const :tag "Go to declaration" :declarationProvider)
;; (const :tag "Find references" :referencesProvider)
;; (const :tag "Highlight symbols automatically" :documentHighlightProvider)
;; (const :tag "List symbols in buffer" :documentSymbolProvider)
;; (const :tag "List symbols in workspace" :workspaceSymbolProvider)
;; (const :tag "Execute code actions" :codeActionProvider)
;; (const :tag "Code lens" :codeLensProvider)
;; (const :tag "Format buffer" :documentFormattingProvider)
;; (const :tag "Format portion of buffer" :documentRangeFormattingProvider)
;; (const :tag "On-type formatting" :documentOnTypeFormattingProvider)
;; (const :tag "Rename symbol" :renameProvider)
;; (const :tag "Highlight links in document" :documentLinkProvider)
;; (const :tag "Decorate color references" :colorProvider)
;; (const :tag "Fold regions of buffer" :foldingRangeProvider)
;; (const :tag "Execute custom commands" :executeCommandProvider)
;; (const :tag "Inlay hints" :inlayHintProvider)
(use-package eglot
:init
(setq eglot-ignored-server-capabilities '(:documentHighlightProvider
:inlayHintProvider)
eglot-autoshutdown t
eglot-events-buffer-size 0)
:config
(add-hook 'eglot-managed-mode-hook (lambda () (eldoc-mode -1)))
(add-to-list 'eglot-server-programs
'((c-ts-mode c++-ts-mode c-mode c++-mode)
. ("clangd"
"-j=8"
;; "--log=error"
"--malloc-trim"
"--background-index"
;; "--clang-tidy"
"--completion-style=detailed"
"--pch-storage=memory"
"--header-insertion=never"
"--header-insertion-decorators=0")))
:custom
(setq-default eglot-inlay-hints-mode -1)
(eldoc-echo-area-use-multiline-p nil)
:bind (:map eglot-mode-map
("C-c C-d" . eldoc)
("C-c C-r" . eglot-rename))
:hook
(python-ts-mode . eglot-ensure))
;;:hook
;;(add-hook 'eglot-managed-mode-hook (lambda () (eglot-inlay-hints-mode -1)))
;; (use-package tab-bar
;; :init
;; (setq
;; tab-bar-show t
;; tab-bar-new-tab-to 'rightmost
;; ;;tab-bar-new-tab-choice "*dashboard*"
;; )
;; :config
;; (tab-bar-mode 0))
(use-package erc
:disabled
:init
(setq erc-server "irc.libera.chat"
erc-nick "zoulhadj" ; Change this!
erc-user-full-name "Zakariya Oulhadj" ; And this!
erc-track-shorten-start 8
erc-autojoin-channels-alist '(("irc.libera.chat" "#linux" "#emacs"))
erc-kill-buffer-on-part t
erc-auto-query 'bury))
(use-package tramp
:config (setq tramp-default-method "ssh"))
;; /////////////////////////////////////////////////////////////////////////////
(use-package keyfreq
:disabled
:straight t
:config
(keyfreq-mode 1)
(keyfreq-autosave-mode 1))
(use-package undo-tree
:straight t
:init
(setq undo-tree-history-directory-alist
`((".*" . ,temporary-file-directory)))
:config
(global-undo-tree-mode)
:diminish)
(use-package ultra-scroll
:straight (ultra-scroll :type git :host github :repo "jdtsmith/ultra-scroll")
:init
(setq scroll-conservatively 101 ; important!
scroll-margin 0)
:config
(ultra-scroll-mode 1))
;; Note that rust-analyzer is needed for eglot and can be obtained through
;; rustup.
(use-package rust-mode
:straight t
:init
(setq rust-mode-treesitter-derive t)
:config
;;(add-to-list 'major-mode-remap-alist '(rust-mode . rust-ts-mode))
:hook
(rust-mode . eglot-ensure))
(use-package zig-mode
:straight t)
;; Adds support for the Lua programming language.
;;
;; https://github.com/immerrr/lua-mode
(use-package lua-mode
:straight t)
;; ;;(add-hook 'help-fns-describe-function-functions #'shortdoc-help-fns-examples-function)
;; (global-unset-key [mouse-2])
;; (make-directory (expand-file-name "tmp/auto-saves/" user-emacs-directory) t)
;; (setq backup-directory-alist `(("." . ,(expand-file-name "tmp/backups/" user-emacs-directory)))
;; auto-save-list-file-prefix (expand-file-name "tmp/auto-saves/sessions/" user-emacs-directory)
;; auto-save-file-name-transforms `((".*" ,(expand-file-name "tmp/auto-saves/" user-emacs-directory) t))
;; custom-file (no-littering-expand-etc-file-name "custom.el"))
;; Adds additional functionality to the default dired mode
;;
;; https://github.com/emacsmirror/dired-plus/tree/master
;; (use-package dired+
;; :straight t)
;; The package `which-key' displays a popup window showing all the possible key
;; combinations for the current action. This allows a user to not forget
;; specific commands.
;;
;; https://github.com/justbur/emacs-which-key
(use-package which-key
:straight t
:init
(setq which-key-show-early-on-C-h nil
which-key-idle-delay 1.0
which-key-idle-secondary-delay nil)
:config
(which-key-enable-god-mode-support)
(which-key-setup-side-window-bottom)
(which-key-mode)
:diminish)
;; (defun my-god-mode-update-cursor-type ()
;; (setq cursor-type (if (or god-local-mode buffer-read-only) 'box 'bar)))
(use-package god-mode
:disabled
:straight t
;; :init
;; (setq god-exempt-major-modes nil
;; god-exempt-predicates nil)
:config
(god-mode)
:bind
("<left-control>" . #'god-local-mode)
(:map god-local-mode-map
("." . repeat)
("i" . god-local-mode)
("[" . backward-paragraph)
("]" . forward-paragraph))
;; :hook
;; (god-mode-enabled . my-god-mode-update-cursor-type)
;; (god-mode-disabled . my-god-mode-update-cursor-type)
)
(use-package evil
:disabled
:straight t
:config
(evil-mode 1))
(use-package evil-escape
:disabled
:straight t
:config
(evil-escape-mode)
(setq-default evil-escape-key-sequence "jk"
evil-escape-delay 0.1)
)
(use-package avy
:straight t
:init
(setq avy-timeout-seconds 0.40)
:config
(global-set-key (kbd "M-j") 'avy-goto-char-timer))
;; ;; The package `exec-path-from-shell' ensures all environment variables are
;; ;; present within Emacs. By default, Emacs only uses a small subset of
;; ;; variables. However, this package works by copying all enviornment variables
;; ;; from the system into Emacs so that all commands are accessible.
;; ;; todo: Take a closer look how this package behaves on Windows since its not
;; ;; Unix based.
;; ;;
;; ;; https://github.com/purcell/exec-path-from-shell
;; (use-package exec-path-from-shell
;; :straight t
;; :config
;; (exec-path-from-shell-initialize))
;; Provides a dashboard/home screen when starting Emacs that lists projects,
;; recent files and more.
;;
;; https://github.com/emacs-dashboard/emacs-dashboard
(use-package dashboard
:straight t
:init
(setq dashboard-banner-logo-title "Welcome to Emacs!"
dashboard-footer-messages '("")
dashboard-startup-banner 2
dashboard-center-content nil
dashboard-show-shortcuts t
dashboard-set-navigator t
dashboard-projects-backend 'project-el
dashboard-items '((recents . 5)
(bookmarks . 5)
(projects . 5)
(agenda . 5))
dashboard-week-agenda t
)
;; dashboard-filter-agenda-entry 'dashboard-no-filter-agenda
:config
(dashboard-setup-startup-hook))
(use-package dumb-jump
:straight t
:init
(setq xref-show-definitions-function #'xref-show-definitions-completing-read)
(add-hook 'xref-backend-functions #'dumb-jump-xref-activate))
;; The package `flycheck' shows syntactic highlighting in code that displays
;; logs, warnings and errors.
;;
;; https://github.com/flycheck/flycheck
(use-package flycheck
:disabled
:straight t
:init (global-flycheck-mode)
:diminish)
;; The package `vertico' provides vertical interactive completion similar to
;; `smex' or the built-in package `ido'.
;;
;; https://github.com/minad/vertico
(use-package vertico
:straight t
:init
(setq vertico-cycle t
vertico-resize nil
vertico-count 10
vertico-multiform-commands '((consult-imenu buffer indexed))
vertico-multiform-categories '((file grid)
(consult-grep buffer)))
:config
(vertico-mode)
(vertico-multiform-mode))
;; Adds a small description to each item within the minibuffer completion list.
;;
;; https://github.com/minad/marginalia
(use-package marginalia
:straight t
:after vertico
:config
(marginalia-mode)
:custom
(marginalia-annotators '(marginalia-annotators-heavy marginalia-annotators-light nil)))
;; The package `corfu' display a window for autocomplete candidates when writing
;; text. It is a simpler alternative to the highly popular `company'
;; package. This is because it uses the Emacs buit-in completion system.
;;
;; https://github.com/minad/corfu
(use-package corfu
:straight t
:init
(setq corfu-cycle t
corfu-auto t
corfu-auto-delay 0.2 ; Should not use lower values as this can cause issues
corfu-separator ?\s
corfu-quit-at-boundary 'separator
corfu-quit-no-match t
corfu-preview-current nil
corfu-preselect 'valid
corfu-on-exact-match 'insert
corfu-scroll-margin 1)
:config
(global-corfu-mode)
:bind
(:map corfu-map
("RET" . nil)))
(use-package company
:disabled
:straight t
:diminish
:config
(setq company-global-modes '(not text-mode term-mode markdown-mode gfm-mode)
company-selection-wrap-around t
company-show-numbers nil
company-tooltip-align-annotations t
company-idle-delay 0.0
company-require-match nil
company-minimum-prefix-length 2)
:bind
(:map company-active-map
("C-n" . company-select-next)
("C-p" . company-select-previous)
("<tab>" . company-complete-selection))
:hook (prog-mode . company-mode))
;; This package changes how completion candidates are displayed within a
;; completion window such as `corfu' or `company'.
;;
;; https://github.com/oantolin/orderless
(use-package orderless
:straight t
:init
(setq completion-styles '(orderless partial-completion basic)
completion-category-defaults nil
completion-category-overrides nil))
(use-package embark
:disabled
:straight t)
;; Provides search and navigation commands
;;
;; https://github.com/minad/consult
(use-package consult
:straight t
:init
(setq register-preview-delay 0.5
register-preview-function #'consult-register-format)
(advice-add #'register-preview :override #'consult-register-window)
;; Use Consult to select xref locations with preview
(setq xref-show-xrefs-function #'consult-xref
xref-show-definitions-function #'consult-xref)
:config
(consult-customize
consult-theme :preview-key '(:debounce 0.2 any)
consult-ripgrep consult-git-grep consult-grep
consult-bookmark consult-recent-file consult-xref
consult--source-bookmark consult--source-file-register
consult--source-recent-file consult--source-project-recent-file
;; :preview-key "M-."
:preview-key '(:debounce 0.4 any))
(setq consult-narrow-key "<")
;; Hide buffers that start with a * and only shown them if SPC is pressed
(add-to-list 'consult-buffer-filter "^\\*")
:bind (("C-c M-x" . consult-mode-command)
("C-c h" . consult-history)
("C-c k" . consult-kmacro)
("C-c m" . consult-man)
("C-c i" . consult-info)
([remap Info-search] . consult-info)
;; C-x bindings in `ctl-x-map'
("C-x M-:" . consult-complex-command) ;; orig. repeat-complex-command
("C-x b" . consult-buffer) ;; orig. switch-to-buffer
("C-x 4 b" . consult-buffer-other-window) ;; orig. switch-to-buffer-other-window
("C-x 5 b" . consult-buffer-other-frame) ;; orig. switch-to-buffer-other-frame
("C-x p b" . consult-project-buffer) ;; orig. project-switch-to-buffer
;; Other custom bindings
("M-y" . consult-yank-pop) ;; orig. yank-pop
;; M-g bindings in `goto-map'
("M-g e" . consult-compile-error)
("M-g f" . consult-flycheck) ;; Alternative: consult-flycheck
("M-g g" . consult-goto-line) ;; orig. goto-line
("M-g M-g" . consult-goto-line) ;; orig. goto-line
("M-g o" . consult-outline) ;; Alternative: consult-org-heading
("M-g m" . consult-mark)
("M-g k" . consult-global-mark)
("M-g i" . consult-imenu)
("M-g I" . consult-imenu-multi)
("M-g t" . consult-theme)
;; M-s bindings in `search-map'
("M-s d" . consult-find)
("M-s D" . consult-locate)
;("M-s g" . consult-grep)
("M-s G" . consult-git-grep)
("M-s r" . consult-ripgrep)
("M-s l" . consult-line)
("M-s L" . consult-line-multi)
("M-s k" . consult-keep-lines)
("M-s u" . consult-focus-lines)
;; Isearch integration
("M-s e" . consult-isearch-history)
:map isearch-mode-map
("M-e" . consult-isearch-history) ;; orig. isearch-edit-string
("M-s e" . consult-isearch-history) ;; orig. isearch-edit-string
("M-s l" . consult-line) ;; needed by consult-line to detect isearch
("M-s L" . consult-line-multi) ;; needed by consult-line to detect isearch
;; Minibuffer history
:map minibuffer-local-map
("M-s" . consult-history) ;; orig. next-matching-history-element
("M-r" . consult-history)) ;; orig. previous-matching-history-element
:hook (completion-list-mode . consult-preview-at-point-mode))
;; Consult users will also want the embark-consult package.
;;
;;
(use-package embark-consult
:straight t
:requires (embark consult)
:hook
(embark-collect-mode . consult-preview-at-point-mode))
(use-package consult-flycheck
:disabled
:requires (consult flycheck)
:after (consult flycheck)
:straight t)
;; A Git client that can be used within Emacs.
;;
;; https://github.com/magit/magit
(use-package magit
:straight t
:config
(magit-auto-revert-mode 1)
:bind
("C-c g" . magit-status)
("C-c f" . magit-file-dispatch))
;; Adds colors to matching brackets based on level
;;
;; https://github.com/Fanael/rainbow-delimiters
(use-package rainbow-delimiters
:disabled
:straight t
:hook
(prog-mode . rainbow-delimiters-mode))
;; The package `lsp-mode' is a front-end to LSP which stands for Language Server
;; Protocol and allows for language parsing, debugging and navigation.
;;
;; https://github.com/emacs-lsp/lsp-mode
(use-package lsp-mode
:disabled
:straight t
:init
(setq lsp-keymap-prefix "C-c l"
lsp-headerline-breadcrumb-enable nil
lsp-enable-symbol-highlighting nil
lsp-enable-on-type-formatting nil
lsp-enable-links nil
lsp-idle-delay 0.1
lsp-warn-no-matched-clients nil
lsp-signature-render-documentation nil)
(defun custom/lsp-mode-setup-completion ()
(setf (alist-get 'styles (alist-get 'lsp-capf completion-category-defaults))
'(orderless))) ;; Configure flex
:custom
(lsp-completion-provider :none)
:hook
(prog-mode . lsp-deferred)
(lsp-mode . lsp-enable-which-key-integration)
(lsp-completion-mode . custom/lsp-mode-setup-completion)
:commands
(lsp lsp-deferred))
;; Allows for lines or regions to be moved.
;;
;; https://github.com/rejeep/drag-stuff.el
(use-package drag-stuff
:straight t
:config
(drag-stuff-global-mode 1)
;;(drag-stuff-define-keys)
:bind
("M-P" . drag-stuff-up)
("M-N" . drag-stuff-down)
:diminish)
;; ;; Adds icon support. Once the package is installed, the actual icons need to be
;; ;; installed manually which can be done using the command `all-the-icons-install-fonts'.
;; ;;
;; ;; https://github.com/iyefrat/all-the-icons.el
;; (use-package all-the-icons
;; :straight t
;; :if (display-graphic-p))
(use-package ef-themes
:straight t)
(use-package doom-themes
:straight t
:init
(setq doom-themes-enable-bold t ; if nil, bold is universally disabled
doom-themes-enable-italic t) ; if nil, italics is universally disabled
:config
(doom-themes-neotree-config)
(doom-themes-org-config)
(load-theme 'doom-gruvbox))
(use-package modus-themes
:straight t
)
(use-package gruber-darker-theme
:disabled
:straight t
:config
(load-theme 'gruber-darker)
)
(use-package naysayer-theme
:disabled
:straight t
:config
(load-theme 'naysayer t)
)
;; Keeps the cursor in centered within a buffer.
;;
;; https://github.com/emacsmirror/centered-cursor-mode
(use-package centered-cursor-mode
:disabled
:straight t
:config
(global-centered-cursor-mode))
(use-package centered-window
:disabled
:straight t
:init
(setq cwm-centered-window-width 120)
:hook
(prog-mode . centered-window-mode))
(use-package dimmer
:disabled
:straight t
:config
(setq dimmer-fraction 0.3
dimmer-adjustment-mode :foreground
dimmer-use-colorspace :rgb)