-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.el
1047 lines (891 loc) · 25.7 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
;; Disable magic file name
(defconst my-saved-file-name-handler-alist file-name-handler-alist)
(setq file-name-handler-alist nil)
(require 'package)
(setq package-archives
'(("melpa" . "http://melpa.org/packages/")
("melpa-stable" . "http://stable.melpa.org/packages/")
("gnu" . "http://elpa.gnu.org/packages/")))
(package-initialize)
;; warning level
(setq warning-minimum-level :emergency)
;; Native compile
(setq package-native-compile t)
(use-package auto-async-byte-compile
:ensure t
:init
(add-hook 'emacs-lisp-mode-hook 'enable-auto-async-byte-compile-mode))
(use-package exec-path-from-shell
:ensure t
:init
(exec-path-from-shell-initialize))
;;;;; Encoding ;;;;;
(set-language-environment 'utf-8)
(set-file-name-coding-system 'utf-8)
(set-terminal-coding-system 'utf-8)
(prefer-coding-system 'utf-8)
;;;;; Environment ;;;;;
(setq auto-save-default nil
create-lockfiles nil
delete-auto-save-files t
make-backup-files nil
;; suppress bell
ring-bell-function 'ignore
;; default directory
default-directory "~/"
command-line-default-directory "~/"
inhibit-startup-message t
;; always insert a newline at the end
require-final-newline t
kill-whole-line t
max-specpdl-size 10000
;; Increase the amount of data which Emacs reads from the process: 1mb
read-process-output-max (* 1024 1024))
(setopt use-short-answers t)
(setq-default cursor-type 'bar)
(savehist-mode 1)
(save-place-mode 1)
;; expand region
(use-package expand-region
:ensure t
:defer t
:bind (("C-=" . er/expand-region)))
(use-package which-key
:ensure nil
:diminish which-key-mode
:hook (after-init . which-key-mode)
:config
(setq which-key-popup-type 'minibuffer))
;; window manager
(use-package ace-window
:ensure t
:config
(global-set-key (kbd "C-x o") 'ace-window))
;; presentation
(use-package presentation
:ensure t
:defer t)
;; smart move
(use-package mwim
:ensure t
:bind
(("C-a" . mwim-beginning-of-code-or-line)
("C-e" . mwim-end-of-code-or-line)))
;; comment-dwim
(use-package comment-dwim-2
:ensure t
:config
(global-set-key (kbd "M-;") 'comment-dwim-2))
;; multiple-cursors
(use-package multiple-cursors
:ensure t
:config
(global-set-key (kbd "C-S-c C-S-c") 'mc/edit-lines)
(global-set-key (kbd "C->") 'mc/mark-next-like-this)
(global-set-key (kbd "C-<") 'mc/mark-previous-like-this)
(global-set-key (kbd "C-c C-<") 'mc/mark-all-like-this))
(use-package goggles
:ensure t
:diminish
:defer t
:hook ((prog-mode text-mode) . goggles-mode)
:custom
(goggles-pulse-delay 0.03)
(goggles-pulse-iteration 3)
:config
(setq-default goggles-pulse t)
:custom-face
(goggles-added ((t (:background "#50fa7b"))))
(goggles-changed ((t (:background "#f1fa8c"))))
(goggles-removed ((t (:background "#ff79c6")))))
(use-package autorevert
:ensure nil
:diminish
:hook (after-init . global-auto-revert-mode))
(use-package delsel
:ensure nil
:hook (after-init . delete-selection-mode))
(use-package hungry-delete
:ensure t
:defer t
:diminish
:hook (prog-mode . global-hungry-delete-mode))
(use-package disable-mouse
:ensure t
:defer t
:diminish disable-mouse-mode
:init
(setq disable-mouse-wheel-events nil)
:hook (emacs-startup . global-disable-mouse-mode))
;; highlight keyword
(use-package hl-todo
:ensure t
:defer t
:hook (prog-mode . hl-todo-mode)
:config
(setq hl-todo-keyword-faces
'(("TODO" . "#cc9393")
("FIXME" . "#cc9393")
("DEBUG" . "#A020F0"))))
;; hightlight symbol
(use-package highlight-symbol
:ensure t
:defer t
:hook
((prog-mode . highlight-symbol-mode)
(prog-mode . highlight-symbol-nav-mode))
:config
(setq highlight-symbol-idle-delay 0.5))
;;;;; nerd-icon ;;;;;
;; Nerd font is required
(use-package nerd-icons
:ensure t
:defer t
:custom
(nerd-icons-font-family "MesloLGL Nerd Font Mono"))
;;;;; Dashboard ;;;;;
(use-package dashboard
:ensure t
:defer t
:hook
(after-init . dashboard-setup-startup-hook)
:custom
(dashboard-display-icons-p t)
(dashboard-icon-type 'nerd-icons)
(dashboard-set-init-info t)
(dashboard-set-heading-icons t)
(dashboard-set-file-icons t))
;;;;; Dired related packages;;;;;
(use-package dired+
:ensure t
:vc (:url "https://github.com/emacsmirror/dired-plus.git" :rev :newest)
:after dired
:init
(setq diredp-hide-details-initially-flag nil
diredp-hide-details-propagate-flag nil)
:config
(diredp-toggle-find-file-reuse-dir 1))
(use-package dired-subtree
:ensure t
:after dired
:config
(bind-keys :map dired-mode-map
("i" . dired-subtree-insert)
(";" . dired-subtree-remove)
("C-, C-p" . dired-subtree-up)
("C-, C-n" . dired-subtree-down)))
;;;;; Dimmer ;;;;;
(use-package dimmer
:ensure t
:custom
(dimmer-fraction 0.3)
(dimmer-watch-frame-focus-events nil)
(dimmer-buffer-exclusion-regexps
'("^\\*Minibuf-[0-9]+\\*" "^.\\*which-key\\*$"
"^*Messages*" "*LV*" "transient"))
:config
(dimmer-configure-magit)
(dimmer-configure-posframe)
(dimmer-configure-which-key)
(dimmer-mode t)
;; make it compatible with corfu
;; https://github.com/gonewest818/dimmer.el/issues/62
(defun advise-dimmer-config-change-handler ()
"Advise to only force process if no predicate is truthy."
(let ((ignore (cl-some (lambda (f) (and (fboundp f) (funcall f)))
dimmer-prevent-dimming-predicates)))
(unless ignore
(when (fboundp 'dimmer-process-all)
(dimmer-process-all t)))))
(defun corfu-frame-p ()
"Check if the buffer is a corfu frame buffer."
(string-match-p "\\` \\*corfu" (buffer-name)))
(defun dimmer-configure-corfu ()
(add-to-list
'dimmer-prevent-dimming-predicates
#'corfu-frame-p))
(advice-add
'dimmer-config-change-handler
:override 'advise-dimmer-config-change-handler)
(dimmer-configure-corfu))
;;;;; Undo Tree ;;;;;
(use-package undo-tree
:ensure t
:defer t
:hook (prog-mode . global-undo-tree-mode)
:diminish undo-tree-mode
:config
(setq undo-tree-auto-save-history nil))
;;;;; treemacs ;;;;;
(use-package treemacs
:ensure t
:defer t
:bind
(:map global-map
("C-q" . treemacs))
:custom
(treemacs-follow-after-init t)
(treemacs-expand-after-init t)
(treemacs-display-in-side-window t)
(treemacs-position 'left)
(treemacs-show-hidden-files t)
(treemacs-hide-dot-git-directory t)
(treemacs-filewatch-mode t)
(treemacs-follow-mode t)
(treemacs-indentation 2)
(treemacs-event-guide-mode t)
:hook
(treemacs-mode . treemacs-project-follow-mode))
;;;;; tab bar ;;;;;
(tab-bar-mode 1)
;;(global-tab-line-mode)
;;;;; Spell checking ;;;;;
(setq-default ispell-program-name "aspell")
(with-eval-after-load "ispell"
(add-to-list 'ispell-skip-region-alist '("[^\000-\377]+")))
(use-package flyspell
:ensure t
:defer t
:hook
(prog-mode . flyspell-mode)
:diminish flyspell-mode
:config
(define-key flyspell-mode-map (kbd "C-;") nil)
(add-hook 'prog-mode-hook
'(lambda ()
(flyspell-prog-mode))))
;; modus theme
(setq modus-themes-bold-constructs t
modus-themes-italic-constructs t
modus-themes-mixed-fonts t
modus-themes-fringes 'nil
modus-themes-region '(bg-only no-extend)
modus-themes-subtle-line-numbers t
modus-themes-syntax '(faint alt-syntax green-strings)
modus-themes-paren-match 'intense
modus-themes-hl-line 'accented
modus-themes-variable-pitch-ui t
modus-themes-prompts '(bold background)
modus-themes-mode-line '(moody))
(load-theme 'modus-vivendi)
;; modeline
(use-package moody
:ensure t
:config
(setq x-underline-at-descent-line t)
(moody-replace-mode-line-buffer-identification)
(moody-replace-vc-mode)
(moody-replace-mode-line-front-space)
(moody-replace-eldoc-minibuffer-message-function))
(use-package minions
:ensure t
:diminish minions-mode
:config
(minions-mode 1)
(setq minions-mode-line-lighter "[+]"))
;;;;; yasnippet ;;;;;
(use-package yasnippet
:ensure t
:defer t
:hook
(prog-mode . yas-minor-mode)
:bind
(("C-c y n" . yas-new-snippet)
("C-c y v" . yas-visit-snippet-file)
("C-c y i" . yas-insert-snippet))
:config
(yas-reload-all)
(setq yas-snippet-dirs
'("~/.emacs.d/snippets")))
;;;;; tree-sitter ;;;;;
(use-package tree-sitter
:ensure t
:defer t
:hook
(prog-mode . tree-sitter-mode)
:config
(use-package tree-sitter-langs
:ensure t)
(add-hook 'tree-sitter-after-on-hook #'tree-sitter-hl-mode))
;;;;; lsp-mode ;;;;;
(use-package lsp-mode
:ensure t
:defer t
:commands lsp
:hook
((rust-mode . (lsp lsp-inlay-hints-mode))
(go-mode . (lsp lsp-inlay-hints-mode))
(c++-mode . lsp))
:custom
;; cc-mode does not work well when following two settings are enabled.
(lsp-enable-on-type-formatting nil)
(lsp-enable-indentation nil)
(lsp-diagnostics-provider :flymake)
(lsp-headerline-breadcrumb-icons-enable t)
(lsp-enable-snippet t)
(lsp-auto-guess-root t)
(lsp-idle-delay 0.3)
(lsp-log-io nil)
(lsp-modeline-code-actions-enable nil)
(lsp-completion-provider :none)
(lsp-eldoc-render-all t)
:bind
(:map lsp-mode-map
("C-c C-l" . lsp-execute-code-action)
("C-c r" . lsp-rename))
:config
(add-hook 'c++-mode-hook '(lambda() (add-hook 'before-save-hook 'lsp-format-buffer t t))))
(use-package lsp-ui
:ensure t
:defer t
:hook (lsp-mode-hook . lsp-ui-mode)
:custom
;; doc
(lsp-ui-doc-enable nil)
;; sideline
(lsp-ui-sideline-enable t)
(lsp-ui-sideline-show-diagnostics nil)
(lsp-ui-sideline-ignore-duplicate t)
(lsp-ui-sideline-show-hover nil)
:init
(defun toggle-lsp-ui-sideline ()
(interactive)
(if lsp-ui-sideline-show-hover
(progn
(setq lsp-ui-sideline-show-hover nil
lsp-ui-sideline-show-code-actions nil
lsp-ui-sideline-show-diagnostics nil)
(message "sideline-hover disabled"))
(progn
(setq lsp-ui-sideline-show-hover t
lsp-ui-sideline-show-code-actions t
lsp-ui-sideline-show-diagnostics t)
(message "sideline-hover enabled"))))
(defun toggle-lsp-ui-imenu ()
(interactive)
(let ((imenu-buffer (get-buffer lsp-ui-imenu-buffer-name)))
(if imenu-buffer
(progn
(lsp-ui-imenu-buffer-mode -1)
(kill-buffer lsp-ui-imenu-buffer-name)
(message "lsp-ui-imenu disabled"))
(progn
(lsp-ui-imenu)
(message "lsp-ui-imenu enabled")))))
:bind
(:map lsp-mode-map
("C-c C-i" . lsp-ui-peek-find-implementation)
("M-." . lsp-ui-peek-find-definitions)
("M-?" . lsp-ui-peek-find-references)
("C-c i" . toggle-lsp-ui-imenu)
("C-c C-s" . toggle-lsp-ui-sideline)))
(use-package lsp-treemacs
:ensure t
:after lsp-mode)
;;;;; dap ;;;;;
(use-package dap-mode
:ensure t
:after lsp-mode)
;;;;; Org mode ;;;;;
(add-to-list 'auto-mode-alist '("\\.org\\'" . org-mode))
(global-set-key (kbd "C-c a") 'org-agenda)
(use-package toc-org
:ensure t
:init
(add-hook 'org-mode-hook 'toc-org-mode)
)
;;;;; Project Root ;;;;;
(use-package projectile
:ensure t
:diminish projectile-mode)
(defun my-projectile-project-find-function (dir)
(let ((root (projectile-project-root dir)))
(and root (cons 'transient root))))
(projectile-mode t)
(with-eval-after-load 'project
(add-to-list 'project-find-functions 'my-projectile-project-find-function))
;;;;; Coding Style ;;;;;
;; minimap
(use-package minimap
:ensure t
:defer t
:commands
(minimap-buffer-name minimap-create-window minimap-kill)
:diminish
:custom
(minimap-major-modes '(prog-mode))
(minimap-minimum-width 15)
(minimap-window-location 'right)
:bind
(("C-c C-m" . minimap-mode)))
;; Code folding
(use-package origami
:ensure t
:defer t
:diminish
:hook (prog-mode . global-origami-mode)
:bind
(("C-c o o" . origami-open-node)
("C-c o c" . origami-close-node)))
;; line number
(global-display-line-numbers-mode)
;; indentation
(use-package aggressive-indent
:ensure t
:defer t
:hook (prog-mode . global-aggressive-indent-mode))
(use-package highlight-indent-guides
:ensure t
:defer t
:hook
((prog-mode yaml-mode) . highlight-indent-guides-mode)
:custom
(highlight-indent-guides-method 'character)
(highlight-indent-guides-auto-enabled nil)
:custom-face
(highlight-indent-guides-character-face ((t (:foreground "dimgray")))))
(column-number-mode t)
(electric-pair-mode 1)
(show-paren-mode 1)
(defvar show-paren-delay 0)
(which-function-mode t)
(setq-default tab-width 4)
;; parenthesis color
(use-package rainbow-delimiters
:ensure t
:config
(add-hook 'prog-mode-hook 'rainbow-delimiters-mode)
(use-package cl-lib
:ensure t)
(use-package color
:ensure t
:config
(defun rainbow-delimiters-using-stronger-colors ()
(interactive)
(cl-loop
for index from 1 to rainbow-delimiters-max-face-count
do
(let ((face (intern (format "rainbow-delimiters-depth-%d-face" index))))
(cl-callf color-saturate-name (face-foreground face) 30)))))
(add-hook 'emacs-startup-hook 'rainbow-delimiters-using-stronger-colors))
;; Cursor
(use-package beacon
:ensure t
:custom
(beacon-color "orange")
:config
(beacon-mode 1))
;;;;; Key Bindings ;;;;;
(global-set-key (kbd "C-c <left>") 'windmove-left)
(global-set-key (kbd "C-c <right>") 'windmove-right)
(global-set-key (kbd "C-c <up>") 'windmove-up)
(global-set-key (kbd "C-c <down>") 'windmove-down)
(defun copy-line (arg)
"Copy lines (as many as prefix argument) in the kill ring.
Ease of use features:
- Move to start of next line.
- Appends the copy on sequential calls.
- Use newline as last char even on the last line of the buffer.
- If region is active, copy its lines."
(interactive "p")
(let ((beg (line-beginning-position))
(end (line-end-position arg)))
(when mark-active
(if (> (point) (mark))
(setq beg (save-excursion (goto-char (mark)) (line-beginning-position)))
(setq end (save-excursion (goto-char (mark)) (line-end-position)))))
(if (eq last-command 'copy-line)
(kill-append (buffer-substring beg end) (< end beg))
(kill-ring-save beg end)))
(beginning-of-line (or (and arg (1+ arg)) 2))
(if (and arg (not (= 1 arg))) (message "%d lines copied" arg)))
(global-set-key (kbd "C-c C-n") 'rename-file-and-buffer)
(global-set-key (kbd "M-k") 'copy-line)
;;;;; Watch Python3 ;;;;;
(setq python-shell-interpreter "python3")
;;;;; corfu ;;;;;
(use-package corfu
:ensure t
:custom
(corfu-cycle t)
(corfu-auto t)
(corfu-quit-at-boundary nil)
(corfu-scroll-margin 5)
(corfu-echo-documentation t)
(corfu-quit-no-match t)
:bind
(:map corfu-map
("TAB" . corfu-insert)
([tab] . corfu-insert)
("C-n" . corfu-next)
("C-p" . corfu-previous))
:init
(global-corfu-mode))
(use-package corfu-popupinfo
:after corfu
:ensure nil
:init
(corfu-popupinfo-mode)
:config
(setq corfu-popupinfo-delay 0.1))
(use-package corfu-quick
:after corfu
:ensure nil
:bind
(:map corfu-map
("C-;" . corfu-quick-complete)))
;;;;; cape ;;;;;
(use-package company
:ensure t)
(use-package cape
:ensure t
:config
(defun my/lsp-capf ()
(setq-local completion-at-point-functions
(list (cape-capf-super
#'lsp-completion-at-point
(cape-company-to-capf #'company-yasnippet)))))
(add-hook 'lsp-completion-mode-hook #'my/lsp-capf))
;;;;; kind-icon ;;;;;
(use-package kind-icon
:ensure t
:after corfu
:custom
(kind-icon-default-face 'corfu-default)
:config
(add-to-list 'corfu-margin-formatters #'kind-icon-margin-formatter))
;;;;; vertico ;;;;;
(use-package vertico
:ensure t
:init
(vertico-mode)
:config
(setq vertico-count 20
vertico-resize t
vertico-cycle t))
(use-package vertico-directory
:after vertico
:ensure nil
:bind (:map vertico-map
("C-l" . vertico-directory-up)))
(use-package vertico-quick
:after vertico
:ensure nil
:bind (:map vertico-map
("C-;" . vertico-quick-jump)
("C-'" . vertico-quick-exit)))
;;;;; Consult ;;;;;
(use-package consult
:ensure t
:bind
(("M-y" . consult-yank-from-kill-ring)
("C-s" . consult-line)
("C-c s" . consult-line-multi)
("C-x b" . consult-buffer)
("C-c b" . consult-buffer-other-window)
("C-c l" . consult-goto-line)
("C-c f" . consult-find)
("C-c !" . consult-flymake))
:config
(use-package affe
:ensure t))
(defun consult-ripgrep-symbol-at-point ()
(interactive)
(consult-ripgrep nil (thing-at-point 'symbol)))
(defun my-consult-ripgrep (use-symbol)
(interactive "p")
(cond ((eq use-symbol 1)
(call-interactively 'consult-ripgrep))
((eq use-symbol 4)
(call-interactively 'consult-ripgrep-symbol-at-point))))
(global-set-key (kbd "C-c g") 'my-consult-ripgrep)
;;;;; orderless ;;;;;
(use-package orderless
:ensure t
:custom
(completion-styles '(orderless basic))
(completion-category-overrides '((file (styles basic partial-completion)))))
;;;;; marginalia ;;;;;
(use-package marginalia
:ensure t
:init
(marginalia-mode))
;;;;; avy ;;;;;
(use-package avy
:ensure t
:config
(global-set-key (kbd "C-;") 'avy-goto-char-timer))
;;;;; git ;;;;;
;; magit
(use-package magit
:ensure t
:bind
(("M-g" . magit-status)))
;; git-gutter
(use-package git-gutter
:ensure t
:defer t
:hook (prog-mode . global-git-gutter-mode)
:custom
(git-gutter:modified-sign "~")
(git-gutter:added-sign "+")
(git-gutter:deleted-sign "-")
:custom-face
(git-gutter:modified ((t (:background "#f1fa8c"))))
(git-gutter:added ((t (:background "#50fa7b"))))
(git-gutter:deleted ((t (:background "#ff79c6")))))
;; blamer
(use-package blamer
:ensure t
:defer t
:custom
(blamer-idle-time 0.3)
(blamer-min-offset 40)
(blamer-pretty-time-p t)
(blamer-author-formatter "✎ %s ")
(blamer-datetime-formatter "[%s] ")
(blamer-commit-formatter "● %s")
(blamer-type 'visual))
;; smerge
(use-package smerge-mode
:diminish)
;;;;; flymake ;;;;;
(use-package flymake-diagnostic-at-point
:ensure t
:after flymake
:config
(add-hook 'flymake-mode-hook #'flymake-diagnostic-at-point-mode))
;;;; vterm ;;;;;
(use-package vterm
:ensure t
:defer t
:init
(defun open-shell-sub (new)
(split-window-below)
(enlarge-window 12)
(other-window 1)
(let ((term) (res))
(if (or new (null (setq term (dolist (buf (buffer-list) res)
(if (string-match "*terminal<[0-9]+>*" (buffer-name buf))
(setq res buf))))))
(vterm)
(switch-to-buffer term))))
(defun open-shell-sub-right (new)
(split-window-right)
(enlarge-window-horizontally 40)
(other-window 1)
(let ((term) (res))
(if (or new (null (setq term (dolist (buf (buffer-list) res)
(if (string-match "*terminal<[0-9]+>*" (buffer-name buf))
(setq res buf))))))
(vterm)
(switch-to-buffer term))))
(defun open-shell ()
(interactive)
(open-shell-sub t))
(defun open-shell-r ()
(interactive)
(open-shell-sub-right t))
(defun vterm-consult-yank-from-kill-ring-action (orig-fun &rest args)
(if (equal major-mode 'vterm-mode)
(let ((inhibit-read-only t)
(yank-undo-function (lambda (_start _end) (vterm-undo))))
(cl-letf (((symbol-function 'insert-for-yank)
(lambda (str) (vterm-send-string str t))))
(apply orig-fun args)))
(apply orig-fun args)))
:bind
(("C-c m" . open-shell)
("C-c n" . open-shell-r))
:config
(setq vterm-always-compile-module t)
(advice-add #'consult-yank-from-kill-ring :around #'vterm-consult-yank-from-kill-ring-action))
;; (use-package multi-vterm
;; :ensure t)
;;;;; golang ;;;;;
(use-package go-mode
:ensure t
:defer t
:mode ("\\.go$" . go-mode)
:init
(defun my/golangci-lint ()
(interactive)
(with-output-to-temp-buffer "*golangci-lint*"
(call-process-shell-command
(concat "cd " (vc-root-dir) "; golangci-lint run --color always") nil
"*golangci-lint*" t)
(pop-to-buffer "*golangci-lint*")
(ansi-color-apply-on-region 1 (buffer-size))))
(defun lsp-go-install-save-hooks ()
(add-hook 'before-save-hook #'lsp-format-buffer t t)
(add-hook 'before-save-hook #'lsp-organize-imports t t))
:config
(lsp-register-custom-settings
'(("gopls.hints"
((assignVariableTypes . t)
(compositeLiteralFields . t)
(compositeLiteralTypes . t)
(constantValues . t)
(functionTypeParameters . t)
(parameterNames . t)
(rangeVariableTypes . t)))
("gopls.completeUnimported" t t)
("gopls.staticcheck" t t))
(add-hook 'go-mode-hook #'lsp-go-install-save-hooks)))
(use-package gotest
:after go-mode
:ensure t
:bind (:map go-mode-map
("C-c x" . go-run)
("C-c t c" . go-test-current-test)
("C-c t f" . go-test-current-file)
("C-c t a" . go-test-current-project))
:config
(setq go-test-args "-v -count=1"))
;;;;; rust ;;;;;
(use-package rust-mode
:ensure t
:defer t
:mode ("\\.rs$" . rust-mode)
:bind
(:map rust-mode-map
("C-c t c" . lsp-rust-analyzer-related-tests))
:custom
(lsp-inlay-hint-enable t)
(lsp-rust-analyzer-display-chaining-hints t)
(lsp-rust-analyzer-display-closure-return-type-hints t)
(lsp-rust-analyzer-display-chaining-hints t)
(lsp-rust-analyzer-rustc-source "discover")
(lsp-rust-analyzer-linked-projects
["./Cargo.toml", "clippy_dev/Cargo.toml", "lintcheck/Cargo.toml"])
:config
(setq rust-format-on-save t))
(use-package cargo
:ensure t
:defer t
:hook (rust-mode . cargo-minor-mode))
;;;;; lisp ;;;;;
(setq inferior-lisp-program "clisp")
(add-to-list 'load-path (expand-file-name "~/.emacs.d/slime"))
(use-package slime
:defer t
:ensure t
:config
(slime-setup '(slime-repl slime-fancy slime-banner)))
;;;;; lua ;;;;;
(use-package lua-mode
:defer t
:ensure t
:config
(add-to-list 'auto-mode-alist '("\\.lua$" . lua-mode))
(add-to-list 'interpreter-mode-alist '("lua" . lua-mode)))
;;;;; web ;;;;;
(use-package web-mode
:ensure t
:defer t
:mode ("\\.html?\\'" . web-mode)
:config
(add-to-list 'auto-mode-alist '("\\.astro\\$" . web-mode))
(setq web-mode-enable-current-element-highlight t
web-mode-enable-current-column-highlight t
web-mode-enable-auto-pairing t))
;;;;; terraform ;;;;;
(use-package terraform-mode
:ensure t
:defer t
:mode ("\\.tf$" . terraform-mode)
:hook (terraform-mode . terraform-format-on-save-mode)
:custom
(terraform-indent-level 4))
;;;;; yaml ;;;;;
(use-package yaml-mode
:ensure t
:defer t
:config
(add-to-list 'auto-mode-alist '("\\.yml\\'" . yaml-mode))
(add-to-list 'auto-mode-alist '("\\.yaml\\'" . yaml-mode)))
;;;;; shell ;;;;;
;; (add-hook 'after-save-hook
;; 'executable-make-buffer-file-executable-if-script-p)
;;;;; markdown ;;;;;
(use-package markdown-mode
:ensure t
:defer t
:mode ("\\.md\\'" . gfm-mode)
:custom
(markdown-fontify-code-blocks-natively t)
(markdown-header-scaling t)
(markdown-indent-on-enter 'indent-and-new-item))
;;;;; Docker ;;;;;
(use-package docker
:ensure t
:defer t
:bind (("C-c C-d" . docker)))
(use-package dockerfile-mode
:ensure t
:defer t
:config
(add-to-list 'auto-mode-alist '("Dockerfile\\'" . dockerfile-mode))
;; https://github.com/spotify/dockerfile-mode/issues/47
;; https://github.com/spotify/dockerfile-mode/commit/9f4381178aa03212cd3400c60c0f48ff306a0994#r30968900
:hook (dockerfile-mode . (lambda () (setq-local indent-line-function nil))))
(use-package docker-compose-mode
:ensure t
:defer t)
;;;;; Custom Functions ;;;;;
;;;;; color ;;;;;
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(ansi-color-faces-vector
[default bold shadow italic underline bold bold-italic bold])
'(ansi-color-names-vector
(vector "#000000" "#d54e53" "#b9ca4a" "#e7c547" "#7aa6da" "#c397d8"