-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconfig.el
1660 lines (1459 loc) · 57.5 KB
/
config.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
(when init-file-debug
(require 'benchmark-init)
(add-hook 'doom-first-input-hook #'benchmark-init/deactivate))
(setq warning-minimum-level :emergency)
(setq read-process-output-max (* 1024 1024))
(setq-default left-margin-width 1 right-margin-width 2) ; Define new widths.
(ignore-errors
(load! "~/.doom.d/private.el"))
(setq user-full-name "darkawower"
user-mail-address "[email protected]")
(when (eq system-type 'darwin)
(setq browse-url-firefox-program "/Applications/Brave Browser.app/Contents/MacOS/Brave Browser")
(setq browse-url-generic-program "/Applications/Brave Browser.app/Contents/MacOS/Brave Browser"
browse-url-browser-function 'browse-url-generic))
(setq-default indent-tabs-mode nil)
(setq-default tab-width 2)
(setq +m-color-main "#61AFEF"
+m-color-secondary "red")
(use-package! modus-themes
:defer t)
(setq doom-theme 'doom-moonlight)
(setq fancy-splash-image "/Users/darkawower/.doom.d/icons/I-am-doom.png")
(progn
(set-frame-parameter (selected-frame) 'alpha '(100 . 100))
(add-to-list 'default-frame-alist '(alpha . (100 . 100))))
(use-package! auto-dark
:defer 5
:config
(setq auto-dark--dark-theme 'doom-moonlight)
(setq auto-dark--light-theme 'pinky-winky))
(setq display-line-numbers-type nil)
(setq display-line-numbers nil)
(set-frame-font "JetBrainsMono Nerd Font 15" nil t)
(custom-set-faces
`(font-lock-comment-face ((t (:font "ChalkBoard SE" :italic t :height 1.0))))
`(font-lock-string-face ((t (:italic t :height 1.0)))))
(defconst jetbrains-ligature-mode--ligatures
'("-->" "//" "/**" "/*" "*/" "<!--" ":=" "->>" "<<-" "->" "<-"
"<=>" "==" "!=" "<=" ">=" "=:=" "!==" "&&" "||" "..." ".."
"|||" "///" "&&&" "===" "++" "--" "=>" "|>" "<|" "||>" "<||"
"|||>" "<|||" ">>" "<<" "::=" "|]" "[|" "{|" "|}"
"[<" ">]" ":?>" ":?" "/=" "[||]" "!!" "?:" "?." "::"
"+++" "??" "###" "##" ":::" "####" ".?" "?=" "=!=" "<|>"
"<:" ":<" ":>" ">:" "<>" "***" ";;" "/==" ".=" ".-" "__"
"=/=" "<-<" "<<<" ">>>" "<=<" "<<=" "<==" "<==>" "==>" "=>>"
">=>" ">>=" ">>-" ">-" "<~>" "-<" "-<<" "=<<" "---" "<-|"
"<=|" "/\\" "\\/" "|=>" "|~>" "<~~" "<~" "~~" "~~>" "~>"
"<$>" "<$" "$>" "<+>" "<+" "+>" "<*>" "<*" "*>" "</>" "</" "/>"
"<->" "..<" "~=" "~-" "-~" "~@" "^=" "-|" "_|_" "|-" "||-"
"|=" "||=" "#{" "#[" "]#" "#(" "#?" "#_" "#_(" "#:" "#!" "#="
"&="))
(sort jetbrains-ligature-mode--ligatures (lambda (x y) (> (length x) (length y))))
(dolist (pat jetbrains-ligature-mode--ligatures)
(set-char-table-range composition-function-table
(aref pat 0)
(nconc (char-table-range composition-function-table (aref pat 0))
(list (vector (regexp-quote pat)
0
'compose-gstring-for-graphic)))))
(defun correct-my-fringe (&optional ignore)
(unless (eq fringe-mode '16)
(fringe-mode '16)))
(add-hook 'after-init-hook #'correct-my-fringe)
(add-hook 'buffer-list-update-hook #'correct-my-fringe)
(setq evil-normal-state-cursor '(box "#41a7fc")
evil-insert-state-cursor '(bar "#00AEE8")
evil-visual-state-cursor '(hollow "#c75ae8"))
(use-package! nyan-mode
:after doom-modeline
:init
(nyan-mode))
(progn
(set-frame-parameter (selected-frame) 'alpha '(90 . 90))
(add-to-list 'default-frame-alist '(alpha . (90 . 90))))
(use-package! rainbow-mode
:hook (((css-mode scss-mode org-mode typescript-mode js-mode emacs-lisp-mode). rainbow-mode))
:defer 5)
(use-package! doom-modeline
:defer t
:config
(setq doom-modeline-buffer-file-name-style 'file-name))
(defun my-add-additional-space-when-not-exist (_)
"Add additional sapce if previous char is not space!"
(unless (eq (char-before) ? )
(insert " ")))
(advice-add 'org-insert-link :before 'my-add-additional-space-when-not-exist)
(defun format-org-mode-block ()
"Format org mode code block"
(interactive "p")
(org-edit-special)
(format-all-ensure-formatter)
(format-all-buffer)
(org-edit-src-exit))
(defun my-switch-to-xwidget-buffer (&optional a b)
"Switch to xwidget buffer."
(interactive)
(switch-to-first-matching-buffer "xwidget webkit"))
(defun my-toggle-default-browser ()
"Toggle default browser for preview"
(interactive)
(if (eq browse-url-browser-function #'browse-url-default-browser)
(progn (setq browse-url-browser-function #'xwidget-webkit-browse-url)
(advice-add 'browse-url :after #'my-switch-to-xwidget-buffer))
(progn
(setq browse-url-browser-function #'browse-url-default-browser)
(advice-remove 'browse-url #'my-switch-to-xwidget-buffer))))
(defun switch-to-first-matching-buffer (regex)
(switch-to-buffer (car (remove-if-not (apply-partially #'string-match-p regex)
(mapcar #'buffer-name (buffer-list))))))
(defun +select-window-by-name (regexp)
"Selects the window with buffer NAME"
(select-window
(car (seq-filter
(lambda (window)
(string-match-p regexp (buffer-name (window-buffer window))))
(window-list-1 nil 0 t)))))
(defun my-remove-cr (&optional begin end)
"Remove line prefixes ending with carriage-return.
BEGIN END specifies region, otherwise works on entire buffer."
(save-excursion
(goto-char (or begin (point-min)))
(while (re-search-forward "^.*\033\\[2K\033\\[1G" end t)
(replace-match ""))))
(defun toggle-maximize-buffer () "Maximize buffer"
(interactive)
(if (= 1 (length (window-list)))
(jump-to-register '_)
(progn
(window-configuration-to-register '_)
(delete-other-windows))))
(defun xah-copy-to-register-1 ()
"Copy current line or text selection to register 1.
See also: `xah-paste-from-register-1', `copy-to-register'.
;;;; Register copy past
URL `http://xahlee.info/emacs/emacs/elisp_copy-paste_register_1.html'
Version 2017-01-23"
(interactive)
(let ($p1 $p2)
(if (region-active-p)
(progn (setq $p1 (region-beginning))
(setq $p2 (region-end)))
(progn (setq $p1 (line-beginning-position))
(setq $p2 (l(defun xah-paste-from-register-1 ()
"Paste text from register 1.
See also: `xah-copy-to-register-1', `insert-register'.
URL `http://xahlee.info/emacs/emacs/elisp_copy-paste_register_1.html'
Version 2015-12-08"
(interactive)
(when (use-region-p)
(delete-region (region-beginning) (region-end)))
(insert-register ?1 t))ine-end-position))))
(copy-to-register ?1 $p1 $p2)
(message "Copied to register 1: 「%s」." (buffer-substring-no-properties $p1 $p2))))
(defun xah-paste-from-register-1 ()
"Paste text from register 1.
See also: `xah-copy-to-register-1', `insert-register'.
URL `http://xahlee.info/emacs/emacs/elisp_copy-paste_register_1.html'
Version 2015-12-08"
(interactive)
(when (use-region-p)
(delete-region (region-beginning) (region-end)))
(insert-register ?1 t))
(defun my-open-kitty-right-here ()
"Open or switch kitty to root directory of current project."
(interactive)
(let* ((cmd (concat "open -a kitty.app --args \"cd\" " default-directory)))
(shell-command cmd)))
(defun my-copy-pwd ()
"Copy PWD command to clipboard"
(interactive)
(when (buffer-file-name)
(kill-new (replace-regexp-in-string " " "\\\\\ " (file-name-directory (buffer-file-name))))))
(defun my-copy-file-name ()
"Copy file name command to clipboard"
(interactive)
(when (buffer-file-name)
(kill-new (file-name-nondirectory (buffer-file-name)))))
(defun my-copy-full-path ()
"Copy full path till file to clipboard"
(interactive)
(when (buffer-file-name)
(kill-new (replace-regexp-in-string " " "\\\\\ " (buffer-file-name)))))
(defun my-vterm-change-current-directory-to-active-buffer-pwd ()
"Just exec CD to pwd of active buffer."
(interactive)
(when-let* ((file-name (buffer-file-name))
(file-dir (file-name-directory file-name))
(file-dir (replace-regexp-in-string " " "\\\\\ " file-dir)))
(message "FILE: %s" file-dir)
(save-window-excursion
(switch-to-first-matching-buffer "vterm")
(vterm-send-C-c)
(vterm-send-string (concat "cd " file-dir))
(vterm-send-return)
)
(evil-window-down 1)))
(defun my-forge-browse-buffer-file ()
(interactive)
(browse-url
(let
((rev (cond ((and (boundp git-timemachine-mode) git-timemachine-mode) (git-timemachine-kill-revision))
((and (boundp magit-gitflow-mode) magit-gitflow-mode) (magit-copy-buffer-revision))
(t "master")))
(repo (forge-get-repository 'stub))
(file (magit-file-relative-name buffer-file-name))
(highlight
(if
(use-region-p)
(let ((l1 (line-number-at-pos (region-beginning)))
(l2 (line-number-at-pos (- (region-end) 1))))
(format "#L%d-L%d" l1 l2))
""
)))
(message "rev: %s" rev)
(if (not file)
(if-let ((path (forge--split-remote-url (forge--get-remote))))
(message "https://%s/%s/%s/commit/%s" (nth 0 path) (nth 1 path) (nth 2 path) rev)
(user-error "Cannot browse non-forge remote %s" (forge--get-remote)))
(forge--format repo "https://%h/%o/%n/blob/%r/%f%L"
`((?r . ,rev) (?f . ,file) (?L . ,highlight)))))))
(setq my-transparency-disabled-p t)
(defun my-toggle-transparency ()
"Toggle transparency"
(interactive)
(let* ((not-transparent-p (and (boundp 'my-transparency-disabled-p) my-transparency-disabled-p))
(alpha (if not-transparent-p 100 95)))
(setq my-transparency-disabled-p (not not-transparent-p))
(message "%s" alpha)
(progn
(set-frame-parameter (selected-frame) 'alpha `(,alpha . ,alpha))
(add-to-list 'default-frame-alist `(alpha . (,alpha . ,alpha))))))
(defun my-insert-todo-by-current-git-branch ()
"Insert todo for current git branch."
(interactive)
(let* ((branch-name (magit-get-current-branch))
(vw (string-match "\\(?1:[A-Za-z0-9]+\/\\)\\(?2:VW-[0-9]+\\)" branch-name))
(task-number (match-string 2 branch-name))
(todo-msg (or task-number branch-name)))
(insert (format "TODO: %s " todo-msg))
(comment-line 1)
;; (forward-line 1)
(previous-line)
(end-of-line)
(indent-according-to-mode)
(evil-insert 1)))
(defun my-run-sass-auto-fix ()
"Run sass auto fix if cli tool exist"
(interactive)
(save-window-excursion
(let ((default-directory (file-name-directory buffer-file-name)))
(async-shell-command "sass-lint-auto-fix")
;; (revert-buffer-no-confirm)
(message "SASS FORMATTED"))))
(use-package! explain-pause-mode
:defer t)
(use-package! dirvish
:init
(dirvish-override-dired-mode)
:custom
;; Go back home? Just press `bh'
(dirvish-bookmark-entries
'(("h" "~/" "Home")
("d" "~/Downloads/" "Downloads")))
;; (dirvish-header-line-format '(:left (path) :right (free-space)))
(dirvish-mode-line-format ; it's ok to place string inside
'(:left (sort file-time " " file-size symlink) :right (omit yank index)))
;; Don't worry, Dirvish is still performant even you enable all these attributes
(dirvish-attributes '(all-the-icons file-size collapse subtree-state vc-state git-msg))
;; Maybe the icons are too big to your eyes
(dirvish-all-the-icons-height 0.8)
;; In case you want the details at startup like `dired'
;; (dirvish-hide-details nil)
:config
;; (dirvish-peek-mode)
(setq dired-kill-when-opening-new-dired-buffer t)
(setq dirvish-reuse-session t)
;; Dired options are respected except a few exceptions, see *In relation to Dired* section above
(setq dired-dwim-target t)
(setq delete-by-moving-to-trash t)
(setq dirvish-default-layout '(1 0.3 0.7))
;; Enable mouse drag-and-drop files to other applications
(setq dired-mouse-drag-files t) ; added in Emacs 29
(setq mouse-drag-and-drop-region-cross-program t) ; added in Emacs 29
(setq dired-listing-switches
"-l --almost-all --human-readable --time-style=long-iso --group-directories-first --no-group")
(setq dirvish-attributes '(vc-state subtree-state collapse git-msg file-size))
(advice-add #'+dired/quit-all :after (lambda () (interactive) (dirvish-kill (dirvish-prop :dv))))
:bind
;; Bind `dirvish|dirvish-side|dirvish-dwim' as you see fit
(("C-c f" . dirvish-fd)
:map dired-mode-map ; Dirvish respects all the keybindings in this map
("h" . dired-up-directory)
("j" . dired-next-line)
("k" . dired-previous-line)
("l" . dired-find-file)
("i" . wdired-change-to-wdired-mode)
("." . dired-omit-mode)
("b" . dirvish-bookmark-jump)
("f" . dirvish-file-info-menu)
("y" . dirvish-yank-menu)
("N" . dirvish-narrow)
("^" . dirvish-history-last)
("s" . dirvish-quicksort) ; remapped `dired-sort-toggle-or-edit'
("?" . dirvish-dispatch) ; remapped `dired-summary'
("TAB" . dirvish-subtree-toggle)
("SPC" . dirvish-history-jump)
("M-n" . dirvish-history-go-forward)
("M-p" . dirvish-history-go-backward)
("M-l" . dirvish-ls-switches-menu)
("M-m" . dirvish-mark-menu)
("M-f" . dirvish-toggle-fullscreen)
("M-s" . dirvish-setup-menu)
("M-e" . dirvish-emerge-menu)
("M-j" . dirvish-fd-jump)))
(use-package! treemacs
:defer t
:bind (:map treemacs-mode-map
("@" . evil-execute-macro))
:custom-face
(font-lock-doc-face ((t (:inherit nil))))
(doom-themes-treemacs-file-face ((t (:inherit font-lock-doc-face :slant italic))))
(doom-themes-treemacs-root-face ((t (:inherit nil :slant italic))))
(treemacs-root-face ((t (:inherit variable-pitch :slant italic))))
:custom
(treemacs-width 45)
:config
(setq doom-themes-treemacs-theme "doom-colors") ; use "doom-colors" for less minimal icon theme
(doom-themes-treemacs-config)
(doom-themes-org-config))
(use-package! bm
:defer t
:custom-face
(bm-face ((t (:foreground ,+m-color-secondary))))
:bind (("C-M-n" . bm-next)
("C-M-p" . bm-previous)
("s-b" . bm-toggle)))
(use-package! bookmark
:defer t
:config
(setq bookmark-save-flag 1)
(setq bookmark-default-file "~/.doom.d/bookmarks"))
(use-package! vterm-toggle
:defer t
:bind (:map evil-normal-state-map
("SPC t ]" . vterm-toggle-forward)
("SPC t [" . vterm-toggle-backward)
("SPC t n" . (lambda () (interactive)
(let ((current-buffer-name (buffer-name)))
(vterm-toggle--new)
(delete-window)
(display-buffer current-buffer-name)
(vterm-toggle-forward))))
("SPC t x" . (lambda (args) (interactive "P")
(when (string-match "vterm" (buffer-name))
(let ((kill-buffer-query-functions nil))
(kill-this-buffer)
(+vterm/toggle args)))))
("SPC o h" . (lambda () (interactive)
(+vterm/toggle t)))
("SPC t h" . vterm-toggle-hide)
("SPC t k" . my-open-kitty-right-here))
:config
(setq vterm-kill-buffer-on-exit nil)
(setq vterm-toggle-scope 'project))
(use-package! hl-todo
:defer 2
:config
(setq hl-todo-keyword-faces
'(("TODO" . "#E5C07B")
("FIXME" . "#E06C75")
("DEBUG" . "#C678DD")
("REFACTOR" . "#C678DD")
("GOTCHA" . "#FF4500")
("NOTE" . "#98C379")
("QUESTION" . "#98C379")
("STUB" . "#61AFEF")))
(global-hl-todo-mode 1))
(use-package! secret-mode
:defer t)
(use-package! outline-minor-faces
:after outline
:config (add-hook 'outline-minor-mode-hook
'outline-minor-faces-add-font-lock-keywords))
(use-package! hydra
:defer t)
(global-set-key (kbd "C-S-k") 'shrink-window)
(global-set-key (kbd "s-y") 'yas-expand)
(global-set-key (kbd "<C-S-up>") 'shrink-window)
(global-set-key (kbd "C-S-j") 'enlarge-window)
(global-set-key (kbd "<C-S-down>") 'enlarge-window)
(global-set-key (kbd "C-S-l") 'enlarge-window-horizontally)
(global-set-key (kbd "C-S-h") 'shrink-window-horizontally)
(global-set-key (kbd "C-c l") 'smerge-keep-lower)
(global-set-key (kbd "C-c u") 'smerge-keep-upper)
(global-set-key (kbd "C-c a") 'smerge-keep-all)
(global-set-key (kbd "C-c j") 'smerge-next)
(global-set-key (kbd "C-c k") 'smerge-prev)
(global-set-key (kbd "s-e") 'emmet-expand-line)
(global-set-key (kbd "C-s") 'save-buffer)
(define-key evil-normal-state-map (kbd "SPC w w") 'ace-window)
(use-package! reverse-im
:defer 5
:config
(reverse-im-activate "russian-computer"))
(use-package! evil-leader
:after evil
:bind (:map evil-normal-state-map
("f" . avy-goto-word-1)
("SPC n r f" . org-roam-node-find)
("SPC t a" . treemacs-add-project-to-workspace)
("SPC g t" . git-timemachine)
;; Compilation
("SPC c v" . (lambda ()
(interactive)
(compilation-display-error)
(+select-window-by-name "*compilation.*")))
;; CUSTOM
("SPC t i" . my-insert-todo-by-current-git-branch)
;; Org mode
("SPC d t" . org-time-stamp-inactive)
("SPC d T" . org-time-stamp)
("SPC r p" . +python/open-ipython-repl)
("SPC r n" . nodejs-repl)
("SPC t t" . ivy-magit-todos)
("SPC v t t" . my-toggle-transparency)
;; TODO: add check might be roam buffer already opened?
("SPC r u" . (lambda () (interactive)
(org-roam-ui-open)
(run-at-time "0.3 sec" nil (lambda () (org-roam-ui-sync-theme) (my-switch-to-xwidget-buffer)))))
("SPC j" . ace-window)
("SPC w f" . ace-window)
("s-Y" . xah-paste-from-register-1)
("s-p" . yank-from-kill-ring)
("s-r" . (lambda () (interactive) (set-mark-command nil) (evil-avy-goto-char)))
("SPC y k" . yank-from-kill-ring)
("s-." . ace-window)
;; Git
("SPC g o f" . my-forge-browse-buffer-file)
:map evil-insert-state-map
("s-Y" . xah-copy-to-register-1)
("s-P" . xah-paste-from-register-1)
("s-p" . yank-from-kill-ring)
("s-." . ace-window)
:map evil-visual-state-map
("s-Y" . xah-copy-to-register-1)
("s-P" . xah-paste-from-register-1)
("s-." . ace-window)
("SPC r r" . query-replace))
:init
(global-evil-leader-mode)
:config
(setq-default evil-kill-on-visual-paste nil)
(evil-leader/set-key
;; "f" 'evil-find-char
"f" 'avy-goto-char
"b" 'my-switch-to-xwidget-buffer
"x" 'my-ecmascript-formatter
"k" 'save-buffer-without-dtw
"w" 'avy-goto-word-0
"]" 'flycheck-next-error
"[" 'flycheck-previous-error
"d" 'dap-debug
"\\" 'ace-window
"o" 'org-mode
"q" 'kill-current-buffer
"v" 'vterm
"`" 'vterm-toggle-cd
"i" 'git-messenger:popup-message
"t" 'google-translate-smooth-translate
"T" 'google-translate-query-translate
"a" 'counsel-org-agenda-headlines
"c" 'dired-create-empty-file
"p" '+format/buffer
"s" 'publish-org-blog
"g" 'ace-window
;; Evil
"=" 'evil-record-macro
"-" 'evil-execute-macro
"0" 'my-toggle-default-browser
;; "=" 'kmacro-start-macro-or-insert-counter
;; Lsp
"h" 'lsp-ui-doc-show
"e" 'lsp-treemacs-errors-list
"l" 'lsp-execute-code-action
"r" 'treemacs-select-window
"m" 'toggle-maximize-buffer
"y" 'yas-expand))
(use-package! evil-matchit
:defer t)
(evilmi-load-plugin-rules '(ng2-html-mode) '(html))
(global-evil-matchit-mode 1)
(use-package! avy
:defer t
:bind (:map evil-normal-state-map
("SPC k l" . avy-kill-whole-line)
("SPC k r" . avy-kill-region))
:custom
(avy-single-candidate-jump t)
(avy-keys '(?w ?e ?r ?t ?y ?u ?i ?o ?p ?a ?s ?d ?f ?g ?h ?j ?k ?l ?z ?x ?c ?v ?b ?n ?m)))
(use-package! vertico
:defer t
:bind (:map vertico-map
("C-d" . (lambda ()
(interactive)
(kill-whole-line)
(insert "~/")))
("C-o" . (lambda ()
(interactive)
(embark-act)))
("C-r" . (lambda ()
(interactive)
(kill-whole-line)
(insert "/")))
("s-<return>" . vertico-exit-input)))
(use-package! wakatime-mode
:defer 3
:config
(global-wakatime-mode))
(use-package! wakatime-ui
:load-path "~/.doom.d/"
:defer 4
:custom
;; (wakatim-ui-schedule-url "https://wakatime.com/share/@darkawower/bb8cf0d7-3554-4297-ac4d-01f8a155073c.svg")
(wakatim-ui-schedule-url "https://wakatime.com/share/@darkawower/af1bfb85-2c8b-44e4-9873-c4a91b512e8d.png")
:config
(wakatime-ui-mode))
(defun my-set-spellfu-faces ()
"Set faces for correct spell-fu working"
(interactive)
(setq spell-fu-faces-include '(tree-sitter-hl-face:comment
tree-sitter-hl-face:doc
tree-sitter-hl-face:string
tree-sitter-hl-face:function
tree-sitter-hl-face:variable
tree-sitter-hl-face:type
tree-sitter-hl-face:method
tree-sitter-hl-face:function.method
tree-sitter-hl-face:function.special
tree-sitter-hl-face:attribute
font-lock-comment-face
font-lock-doc-face
font-lock-string-face
lsp-face-highlight-textual
default))
(setq spell-fu-faces-exclude (append spell-fu-faces-exclude
'(diredfl-file-name))))
(use-package! spell-fu
:bind (:map evil-normal-state-map
("z g" . spell-fu-word-add))
:defer 2
:config
(setq ispell-program-name "aspell")
(setq spell-fu-directory "~/.doom.d/dictionary")
(setq ispell-program-name "aspell"
;; ;; Notice the lack of "--run-together"
ispell-extra-args '("--sug-mode=ultra" "--lang=en_US" "--run-together" "--run-together-limit=56"))
(setq spell-fu-ignore-modes '(dired-mode vterm-mode elfeed-search-mode))
(add-hook 'spell-fu-mode-hook
(lambda ()
(spell-fu-dictionary-add (spell-fu-get-ispell-dictionary "en"))
(spell-fu-dictionary-add (spell-fu-get-ispell-dictionary "ru"))
(spell-fu-dictionary-add
(spell-fu-get-personal-dictionary "en-personal" "/Users/darkawower/.doom.d/dictionary/.pws"))
(spell-fu-dictionary-add
(spell-fu-get-personal-dictionary "ru-personal" "/Users/darkawower/.doom.d/dictionary/ru.pws"))))
;; Camel case support
(setq-default spell-fu-word-regexp
(rx
(or
;; lowercase
(seq
(one-or-more lower)
(opt
(any "'’")
(one-or-more lower)
word-end))
;; capitalized
(seq
upper
(zero-or-more lower)
(opt
(any "'’")
(one-or-more lower)
word-end))
;; uppercase
(seq
(one-or-more upper)
(opt
(any "'’")
(one-or-more upper)
word-end)))))
(defun cs/spell-fu-check-range (pos-beg pos-end)
(let (case-fold-search)
(spell-fu-check-range-default pos-beg pos-end)))
(setq-default spell-fu-check-range #'cs/spell-fu-check-range)
(global-spell-fu-mode)
(my-set-spellfu-faces))
(use-package! lsp-grammarly
:defer t)
;; :hook (text-mode . (lambda ()
;; (require 'lsp-grammarly)
;; (lsp-deferred))))
(use-package! google-translate
:defer 10
:bind
(:map google-translate-minibuffer-keymap
("C-k" . google-translate-next-translation-direction)
("C-n" . google-translate-next-translation-direction)
("C-l" . google-translate-next-translation-direction))
:config
(require 'google-translate-smooth-ui)
(setq google-translate-backend-method 'curl)
(setq google-translate-pop-up-buffer-set-focus t)
(setq google-translate-translation-directions-alist
'(("en" . "ru") ("ru" . "en") ))
(defun google-translate--search-tkk () "Search TKK." (list 430675 2721866130)))
(use-package! flycheck
:defer 2
:bind (:map evil-normal-state-map
("SPC f ]" . flycheck-next-error)
("SPC f [" . flycheck-previous-error)
("SPC e l" . flycheck-list-errors)))
(use-package! format-all
:defer t
;; :hook ((js2-mode typescript-mode ng2-html-mode ng2-ts-mode go-mode) . format-all-mode)
:hook ((json-mode go-mode dart-mode) . format-all-mode)
:config
(add-to-list '+format-on-save-enabled-modes 'typescript-mode t)
(add-to-list '+format-on-save-enabled-modes 'ng2-mode t)
(add-to-list '+format-on-save-enabled-modes 'js2-mode t))
(use-package! prettier
:defer 5
:hook ((typescript-tsx-mode typescript-mode js2-mode json-mode ng2-mode ng2-html-mode html-mode) . prettier-mode)
;; :config
;; ;; This should prevent reset of encoding
;; (defun custom-prettier ()
;; (interactive)
;; (when (member major-mode '(js2-mode typescript-mode typescript-tsx-mode ng2-html-mode vue-mode web-mode ng2-ts-mode))
;; (prettier-prettify)))
;; (add-hook 'before-save-hook #'custom-prettier t)
;; :hook ((js2-mode typescript-mode ng2-html-mode vue-mode web-mode) . prettier-mode)
)
(use-package! turbo-log
:defer t
:bind (("C-s-l" . turbo-log-print)
("C-s-i" . turbo-log-print-immediately)
("C-s-h" . turbo-log-comment-all-logs)
("C-s-s" . turbo-log-uncomment-all-logs)
("C-s-x" . turbo-log-delete-all-logs)
("C-s-[" . turbo-log-paste-as-logger )
("C-s-]" . turbo-log-paste-as-logger-immediately))
:custom
(turbo-log-allow-insert-without-tree-sitter-p t)
;; (turbo-log-payload-format-template "")
;; (turbo-log-payload-format-template "\x1b[35m%s: ")
(turbo-log-payload-format-template "%s: ")
:config
(turbo-log-configure
:modes (typescript-mode js2-mode web-mode ng2-ts-mode js-mode)
:strategy merge
:post-insert-hooks (prettier-prettify lsp)
:msg-format-template "'🦄: %s'"))
(use-package! auto-rename-tag
:defer t
:hook ((html-mode ng2-html-mode-hook vue-mode web-mode) . auto-rename-tag-mode)
:config
(auto-rename-tag-mode 1))
(use-package! string-inflection
:defer t
:bind ("C-s-c" . string-inflection-all-cycle))
(use-package! quicktype
:defer t
:bind (("C-x j v" . quicktype-json-to-type)
("C-x j p" . quicktype-paste-json-as-type)
("C-x j q" . quicktype)))
(use-package! lsp
:hook ((clojure-mode
scss-mode
go-mode
css-mode
js-mode
typescript-mode
vue-mode
web-mode
ng2-html-mode
ng2-ts-mode
python-mode
dart-mode
typescript-tsx-mode) . lsp-deferred)
:bind (:map evil-normal-state-map
("SPC f n" . flycheck-next-error)
("g i" . lsp-goto-implementation)
("SPC l a" . lsp-execute-code-action)
("SPC l r" . lsp-find-references)
("SPC l w" . lsp-restart-workspace)
("SPC r l" . lsp))
:custom
(lsp-headerline-breadcrumb-enable nil)
(lsp-idle-delay 0.3)
(lsp-enable-on-type-formatting nil)
(lsp-eldoc-render-all nil)
(lsp-prefer-flymake nil)
(lsp-modeline-diagnostics-scope :workspace)
(lsp-clients-typescript-server-args '("--stdio" "--tsserver-log-file" "/dev/stderr"))
(lsp-yaml-schemas '((kubernetes . ["/auth-reader.yaml", "/deployment.yaml"])))
;; Disable bottom help info
(lsp-signature-render-documentation nil)
(lsp-signature-auto-activate nil)
;; (lsp-use-plists t)
(lsp-enable-file-watchers nil)
(lsp-file-watch-threshold 5000)
:config
(setq lsp-javascript-display-return-type-hints t)
(setq lsp-json-schemas
`[
(:fileMatch ["ng-openapi-gen.json"] :url "https://raw.githubusercontent.com/cyclosproject/ng-openapi-gen/master/ng-openapi-gen-schema.json")
(:fileMatch ["package.json"] :url "http://json-schema.org/draft-07/schema")
])
(set-face-attribute 'lsp-face-highlight-read nil :background "#61AFEF")
;; Flycheck patch checkers
(require 'flycheck)
(require 'lsp-diagnostics)
(lsp-diagnostics-flycheck-enable)
;; Golang
(defun lsp-go-install-save-hooks ()
(flycheck-add-next-checker 'lsp '(warning . go-gofmt) 'append)
(flycheck-add-next-checker 'lsp '(warning . go-golint))
(flycheck-add-next-checker 'lsp '(warning . go-errcheck))
(flycheck-add-next-checker 'lsp '(warning . go-staticcheck))
(add-hook 'before-save-hook #'lsp-format-buffer t t)
(add-hook 'before-save-hook #'lsp-organize-imports t t))
(add-hook 'go-mode-hook #'lsp-go-install-save-hooks)
(setq lsp-idle-delay 0.5
lsp-enable-symbol-highlighting t
lsp-enable-snippet nil ;; Not supported by company capf, which is the recommended company backend
lsp-pyls-plugins-flake8-enabled nil)
(setq lsp-disabled-clients '(html html-ls))
(add-to-list 'lsp-file-watch-ignored "[/\\\\]\\venv\\'")
(add-to-list 'lsp-file-watch-ignored "[/\\\\]\\pyenv\\'")
(add-to-list 'lsp-file-watch-ignored "[/\\\\]\\.cache\\'")
(set-face-attribute 'lsp-face-highlight-textual nil :background "#c0caf5")
(setq lsp-eldoc-hook nil))
(use-package! lsp-dart
:defer t
:hook (dart-mode . (lambda () (interactive)
(add-hook 'after-save-hook
(lambda ()
;; (flutter-run-or-hot-reload)
(flutter-hot-restart)
(message "flutter restarted")
)
t t)))
:custom
(lsp-dart-dap-flutter-hot-reload-on-save t)
:config
(defun lsp-dart-flutter-widget-guide--add-overlay-to (buffer line col string)
"Add to BUFFER at LINE and COL a STRING overlay."
(save-excursion
(goto-char (point-min))
(forward-line line)
(move-to-column col)
(when (string= lsp-dart-flutter-widget-guide-space (string (following-char)))
(let ((ov (make-overlay (point) (1+ (point)) buffer)))
(overlay-put ov 'category 'lsp-dart-flutter-widget-guide)
(overlay-put ov 'display (propertize string
'face 'custom-comment-tag)))))))
(use-package! lsp-yaml
:defer t
:hook (yaml-mode . lsp-mode))
(use-package! lsp-ui
:after lsp-mode
:hook (lsp-mode . lsp-ui-mode)
:config
(setq lsp-ui-sideline-diagnostic-max-line-length 100
lsp-ui-sideline-diagnostic-max-lines 8
lsp-ui-doc-delay 2
lsp-ui-doc-position 'top
lsp-ui-doc-show-with-mouse nil
lsp-ui-doc-border +m-color-main))
(use-package! tree-sitter-langs)
(use-package! tree-sitter
:after (tree-sitter-langs spell-fu)
:hook ((go-mode typescript-mode css-mode typescript-tsx-mode html-mode scss-mode ng2-mode js-mode python-mode rust-mode ng2-ts-mode ng2-html-mode) . tree-sitter-hl-mode)
:init
(setq tsc-dyn-get-from nil)
:config
(setq tsc-dyn-get-from '(:github))
(setq tsc-dyn-get-from nil)
(advice-add 'tree-sitter-hl-mode :before 'my-set-spellfu-faces)
(push '(ng2-html-mode . html) tree-sitter-major-mode-language-alist)
(push '(ng2-ts-mode . typescript) tree-sitter-major-mode-language-alist)
(push '(scss-mode . css) tree-sitter-major-mode-language-alist)
(push '(scss-mode . typescript) tree-sitter-major-mode-language-alist)
(tree-sitter-require 'tsx)
(add-to-list 'tree-sitter-major-mode-language-alist '(typescript-tsx-mode . tsx)))
(use-package! tree-edit
:defer t)
(use-package! evil-tree-edit
:after tree-edit)
(use-package! tree-edit
:defer t)
(use-package! evil-tree-edit
:after tree-edit)
(use-package ts-docstr
:after tree-sitter
:config
(setq ts-docstr-key-support t)
(setq ts-docstr-ask-on-enable t))
(defun compile-eslint--find-filename ()
"Find the filename for current error."
(save-match-data
(save-excursion
(when (re-search-backward (rx bol (group "/" (+ any)) eol))
(list (match-string 1))))))
;; (use-package! compile
;; :defer t
;; :config
(after! compile
(setq compilation-scroll-output t)
(setq compilation-error-regexp-alist '())
(setq compilation-error-regexp-alist-alist '())
;; eslint https://github.com/Fuco1/compile-eslint/blob/master/compile-eslint.el
(when (not compilation-error-regexp-alist-alist)
(setq compilation-error-regexp-alist-alist '()))
(let ((form `(eslint
,(rx-to-string
'(and (group (group (+ digit)) ":" (group (+ digit)))
(+ " ") (or "error" "warning")))
compile-eslint--find-filename
2 3 2 1)))
(if (assq 'eslint compilation-error-regexp-alist-alist)
(setf (cdr (assq 'eslint compilation-error-regexp-alist-alist)) (cdr form))
(push form compilation-error-regexp-alist-alist)))
(push 'eslint compilation-error-regexp-alist)
(add-to-list 'compilation-error-regexp-alist '("^[[:blank:]]*\\([/_-\\.[:alnum:]]+\\):\\([[:digit:]]+\\):\\([[:digit:]]+\\) - error.*$" 1 2 3))
;; React
(add-to-list 'compilation-error-regexp-alist '("[[:blank:]]*\\([/_\\.[:alnum:]-]+\\):\\([[:digit:]]+\\):\\([[:digit:]]+\\) - error.*$" 1 2 3))
;; Angular
(add-to-list 'compilation-error-regexp-alist '("^Error: \\([_[:alnum:]-/.]*\\):\\([0-9]+\\):\\([0-9]+\\)" 1 2 3)))
(use-package! company
:defer t
:bind (:map evil-insert-state-map ("C-'" . company-yasnippet)
:map company-active-map
("<escape>" . (lambda () (interactive)
(company-cancel)
(evil-normal-state))))
:config
(setq company-idle-delay 0.2)
(setq company-quick-access-modifier 'super)
(setq company-show-quick-access t)
(setq company-minimum-prefix-length 1)
(setq company-dabbrev-char-regexp "[A-z:-]")
(custom-set-variables
'(company-quick-access-keys '("1" "2" "3" "4" "5" "6" "7" "8" "9" "0"))
'(company-quick-access-modifier 'super)))
(use-package! copilot
:defer 5
:bind
("s-]" . copilot-next-completion)
("s-[" . copilot-previous-completion)
("s-l" . copilot-accept-completion)
("s-j" . copilot-complete)
("s-;" . copilot-accept-completion-by-word)
;; :custom
;; (copilot-idle-delay 0.5)
:config
(setq copilot--previous-point nil)
(setq copilot--previous-window-width nil)
(copilot-diagnose)
(defun copilot--preserve-positions ()
(setq copilot--previous-point (point))
(setq copilot--previous-window-width (blamer--real-window-width)))
(defun copilot--positions-changed-p ()
(or (not (equal (point) copilot--previous-point))
(not (equal (window-width) copilot--previous-window-width))))
(defun copilot--rerender ()
(when-let ((copilot--changed (copilot--positions-changed-p)))
(copilot-clear-overlay)
(copilot--preserve-positions)
(blamer--clear-overlay)
(when (evil-insert-state-p) (copilot-complete))))