-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.el
1501 lines (1275 loc) · 50.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
(require 'package)
(customize-set-variable 'package-archives
`(("melpa" . "https://melpa.org/packages/")
,@package-archives))
(customize-set-variable 'package-enable-at-startup nil)
(package-initialize)
(unless (package-installed-p 'use-package)
(package-refresh-contents)
(package-install 'use-package))
(eval-when-compile
(require 'use-package))
(use-package diminish
:ensure t)
(setq warning-minimum-level :error)
(use-package solarized-theme
:disabled
:ensure t
:custom
(solarized-use-variable-pitch nil)
(solarized-high-contrast-mode-line t)
(solarized-use-less-bold nil)
(solarized-use-more-italic t)
(solarized-emphasize-indicators t)
(solarized-scale-org-headlines nil)
(solarized-height-minus-1 1.0)
(solarized-height-plus-1 1.0)
(solarized-height-plus-2 1.0)
(solarized-height-plus-3 1.0)
(solarized-height-plus-4 1.0)
:custom-face
(org-block ((t :background nil :extend t)))
(org-block-begin-line ((t (:underline "#c2bdb2" :foreground "#c2bdb2"))))
(org-block-end-line ((t (:overline nil :underline nil :foreground "#c2bdb2"))))
(org-checkbox ((t :box nil)))
(magit-diff-added ((t (:background "#f1ead8" :foreground "#1b5e20"))))
;; (magit-diff-changed ((t (:background "#f1ead8" :foreground nil))))
(magit-diff-removed ((t (:background "#f1ead8" :foreground "#b0554c"))))
;; (magit-section-highlight ((t (:background nil :foreground "#f1ead8"))))
(magit-diff-added-highlight ((t (:background "#efeac7" :foreground "#1b5e20"))))
;; ;; (magit-diff-changed-highlight ((t (:background "#f1ead8" :foreground "blue"))))
(magit-diff-removed-highlight ((t (:background "#fedfc5" :foreground "#8e433d"))))
(diff-refine-added ((t (:background nil :foreground "#00cd00"))))
(diff-refine-changed ((t (:background nil :foreground "#0000ff"))))
(diff-refine-removed ((t (:background nil :foreground "#ff0009"))))
:config
(load-theme 'solarized-light t))
(setq treesit-language-source-alist
'((bash "https://github.com/tree-sitter/tree-sitter-bash")
(css "https://github.com/tree-sitter/tree-sitter-css")
(elisp "https://github.com/Wilfred/tree-sitter-elisp")
(go "https://github.com/tree-sitter/tree-sitter-go")
(html "https://github.com/tree-sitter/tree-sitter-html")
(javascript "https://github.com/tree-sitter/tree-sitter-javascript" "master" "src")
(tsx "https://github.com/tree-sitter/tree-sitter-typescript" "master" "tsx/src")
(typescript "https://github.com/tree-sitter/tree-sitter-typescript" "master" "typescript/src")
(json "https://github.com/tree-sitter/tree-sitter-json")
(make "https://github.com/alemuller/tree-sitter-make")
(markdown "https://github.com/ikatyang/tree-sitter-markdown")
(python "https://github.com/tree-sitter/tree-sitter-python")
(toml "https://github.com/tree-sitter/tree-sitter-toml")
(yaml "https://github.com/ikatyang/tree-sitter-yaml")
(prisma "https://github.com/victorhqc/tree-sitter-prisma")))
(use-package zenburn-theme
:ensure t
:config
(setq zenburn-override-colors-alist
'(("zenburn-fg-2" . "#6D6D6D")
("zenburn-fg-1" . "#878787")
("zenburn-fg-05" . "#A2A2A2")
("zenburn-fg" . "#BDBDBD")
("zenburn-fg+1" . "#D7D7D7")
("zenburn-fg+2" . "#F2F2F2")
("zenburn-bg-2" . "#1f1f1f")
("zenburn-bg-1" . "#252525")
("zenburn-bg-08" . "#2b2b2b")
("zenburn-bg-05" . "#313131")
("zenburn-bg" . "#383838")
("zenburn-bg+05" . "#3e3e3e")
("zenburn-bg+1" . "#414141")
("zenburn-bg+2" . "#4c4c4c")
("zenburn-bg+3" . "#575757")
))
(load-theme 'zenburn t)
(let ((custom--inhibit-theme-enable nil))
(zenburn-with-color-variables
(custom-theme-set-faces
'zenburn
`(cursor ((t (:foreground ,zenburn-fg :background ,zenburn-fg))))
`(fringe ((t (:foreground ,zenburn-fg :background ,zenburn-bg))))
;; display-line-numbers
`(line-number ((t (:foreground ,zenburn-bg+3 :background ,zenburn-bg :bold nil :slant italic :box nil))))
`(line-number-current-line ((t (:inherit line-number :foreground ,zenburn-yellow-2 ))))
;; magit
`(magit-diff-added ((t (:background unspecified :foreground ,zenburn-green))))
`(magit-diff-changed ((t (:background unspecified :foreground ,zenburn-yellow-1))))
`(magit-diff-removed ((t (:background unspecified :foreground ,zenburn-red-2))))
`(magit-diff-added-highlight ((t (:background ,zenburn-bg+05 :foreground ,zenburn-green))))
`(magit-diff-changed-highlight ((t (:background ,zenburn-bg+05 :foreground ,zenburn-yellow-1))))
`(magit-diff-removed-highlight ((t (:background ,zenburn-bg+05 :foreground ,zenburn-red-2))))
;; diff
`(diff-refine-added ((t (:background unspecified :foreground ,zenburn-green+4))))
`(diff-refine-changed ((t (:background unspecified :foreground ,zenburn-yellow))))
`(diff-refine-removed ((t (:background unspecified :foreground ,zenburn-red+1))))
;; ediff
`(ediff-current-diff-A ((t (:foreground ,zenburn-red-4 :background ,zenburn-bg+05))))
`(ediff-current-diff-Ancestor ((t (:foreground ,zenburn-red-4 :background ,zenburn-bg+05))))
`(ediff-current-diff-B ((t (:foreground ,zenburn-green-2 :background ,zenburn-bg+05))))
`(ediff-current-diff-C ((t (:foreground ,zenburn-blue-5 :background ,zenburn-bg+05))))
`(ediff-even-diff-A ((t (:background ,zenburn-bg-05))))
`(ediff-even-diff-Ancestor ((t (:background ,zenburn-bg-05))))
`(ediff-even-diff-B ((t (:background ,zenburn-bg-05))))
`(ediff-even-diff-C ((t (:background ,zenburn-bg-05))))
`(ediff-fine-diff-A ((t (:foreground ,zenburn-red-2 :background nil :weight bold))))
`(ediff-fine-diff-Ancestor ((t (:foreground ,zenburn-red-2 :background nil weight bold))))
`(ediff-fine-diff-B ((t (:foreground ,zenburn-green :background nil :weight bold))))
`(ediff-fine-diff-C ((t (:foreground ,zenburn-blue-3 :background nil :weight bold ))))
`(ediff-odd-diff-A ((t (:background ,zenburn-bg-05))))
`(ediff-odd-diff-Ancestor ((t (:background ,zenburn-bg-05))))
`(ediff-odd-diff-B ((t (:background ,zenburn-bg-05))))
`(ediff-odd-diff-C ((t (:background ,zenburn-bg-05))))
`(font-lock-comment-face ((t (:foreground ,zenburn-fg-2))))
`(font-lock-comment-delimiter-face ((t (:foreground ,zenburn-fg-2))))
`(font-lock-doc-face ((t (:foreground ,zenburn-green-1))))
`(ledger-font-xact-highlight-face ((t (:background ,zenburn-bg+05))))
;; org mode
`(org-checkbox ((t (:foreground ,zenburn-fg+1 :weight bold))))
`(org-link ((t (:foreground ,zenburn-yellow-2 :underline nil :bold t))))))))
(use-package spaceline
:ensure t
:config
(use-package spaceline-config
:config
(spaceline-define-segment version-control
"Show vc-mode in downcase"
(when vc-mode
(powerline-raw
(s-trim (concat (downcase vc-mode)
(when (buffer-file-name)
(pcase (vc-state (buffer-file-name))
(`up-to-date " ")
(`edited " Mod")
(`added " Add")
(`unregistered " ??")
(`removed " Del")
(`needs-merge " Con")
(`needs-update " Upd")
(`ignored " Ign")
(_ " Unk"))))))))
(spaceline-define-segment workspace-number
"Show windows config number always when use eyebrowse"
(when (bound-and-true-p eyebrowse-mode)
(let* ((wsc (length (eyebrowse--get 'window-configs)))
(num (eyebrowse--get 'current-slot))
(tag (when num (nth 2 (assoc num (eyebrowse--get 'window-configs)))))
(str (if (and tag (< 0 (length tag)))
(format "%d:%s" num tag)
(when num (int-to-string num)))))
(setq str (format "%s/%d" str wsc))
(propertize str 'face 'bold))))
(spaceline-compile)
(spaceline-spacemacs-theme)))
(use-package vertico
:ensure t
:custom
(setq vertico-count 10)
(vertico-resize nil)
(vertico-cycle nil) ;; Enable cycling for `vertico-next/previous'
:init
(vertico-mode))
;; Persist history over Emacs restarts. Vertico sorts by history position.
(use-package savehist
:init
(savehist-mode))
(use-package marginalia
:ensure t
:after vertico
:bind (:map minibuffer-local-map
("M-A" . marginalia-cycle))
;; :custom
;; (marginalia-annotators '(marginalia-annotators-heavy marginalia-annotators-light nil))
:init
(marginalia-mode))
(use-package orderless
:ensure t
:custom
(completion-styles '(orderless basic))
(completion-category-defaults nil)
(completion-category-overrides '((file (styles partial-completion)))))
(use-package consult
:ensure t
;; Replace bindings. Lazily loaded by `use-package'.
:bind (;; C-c bindings in `mode-specific-map'
("C-s" . consult-line)
("C-x 4 b" . consult-buffer-other-window)
("C-y" . yank)
("M-y" . consult-yank-from-kill-ring)
("M-g f" . consult-flycheck)
("M-g e" . consult-compile-error)
("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 r b" . consult-bookmark) ;; orig. bookmark-jump
)
;; ("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 t b" . consult-buffer-other-tab) ;; orig. switch-to-buffer-other-tab
;; ("C-x r b" . consult-bookmark) ;; orig. bookmark-jump
;; ("C-x p b" . consult-project-buffer) ;; orig. project-switch-to-buffer
;; ;; Custom M-# bindings for fast register access
;; ("M-#" . consult-register-load)
;; ("M-'" . consult-register-store) ;; orig. abbrev-prefix-mark (unrelated)
;; ("C-M-#" . consult-register)
;; ;; 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-flymake) ;; 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-s bindings in `search-map'
;; ("M-s d" . consult-find) ;; Alternative: consult-fd
;; ("M-s c" . 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
;; Enable automatic preview at point in the *Completions* buffer. This is
;; relevant when you use the default completion UI.
:hook (completion-list-mode . consult-preview-at-point-mode)
;; The :init configuration is always executed (Not lazy)
:init
;; Optionally configure the register formatting. This improves the register
;; preview for `consult-register', `consult-register-load',
;; `consult-register-store' and the Emacs built-ins.
(setq register-preview-delay 0.5
register-preview-function #'consult-register-format)
;; Optionally tweak the register preview window.
;; This adds thin lines, sorting and hides the mode line of the window.
(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)
;; Configure other variables and modes in the :config section,
;; after lazily loading the package.
:config
;; Optionally configure preview. The default value
;; is 'any, such that any key triggers the preview.
;; (setq consult-preview-key 'any)
;; (setq consult-preview-key "M-.")
;; (setq consult-preview-key '("S-<down>" "S-<up>"))
;; For some commands and buffer sources it is useful to configure the
;; :preview-key on a per-command basis using the `consult-customize' macro.
(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))
;; Optionally configure the narrowing key.
;; Both < and C-+ work reasonably well.
(setq consult-narrow-key "<") ;; "C-+"
(autoload 'projectile-project-root "projectile")
(setq consult-project-function
(lambda (_) (projectile-project-root))))
;; Disable the damn thing by making it disposable.
(setq custom-file "~/.emacs.d/custom.el")
(load custom-file)
(setq default-input-method "latin-prefix")
(setq vc-follow-symlinks t)
;; If there enough blanks before/after the point then treat
;; them as a "word"
(define-key global-map (kbd "C-<backspace>")
(lambda (args)
"First delete blanks before point if there is at least two blanks"
(interactive "p")
(if (looking-back "[ \t]\\{2,\\}" nil t)
(replace-match "" nil nil)
(delete-region (point) (progn (forward-word (- args)) (point))))))
(define-key global-map (kbd "M-d")
(lambda (args)
"First delete blanks after point if there is at least three blanks"
(interactive "p")
(if (looking-at "[ \t]\\{3,\\}")
(replace-match "" nil nil)
(delete-region (point) (progn (forward-word args) (point))))))
(use-package move-text
:ensure t
:bind
(("C-M-s-<up>" . move-text-up)
("C-M-s-<down>" . move-text-down)))
;; fix focus
(use-package frame
:init
;; in gnome, stealing focus doesn't work correctly
(add-hook 'after-make-frame-functions
(lambda (frame) (interactive) (select-frame-set-input-focus frame))))
;; flashing when yanking
(use-package simple
:after flash-region
:config
(setq-default indent-tabs-mode nil)
(advice-add 'yank
:around
(lambda (origfn &rest args)
"flashing after yanked text"
(let ((beg (point)))
(apply origfn args)
(flash-region beg (point) 'highlight 0.1))))
(defun ma/kill-line-or-region (beg end &optional region)
"Kill line if no region is active"
(interactive (list (mark) (point)))
(if mark-active
(kill-region beg end region)
(let (beg end empty-line (cc (current-column)))
(save-excursion
(beginning-of-line)
(if (= (progn (skip-chars-forward " \t") (point))
(progn (end-of-line) (point)))
(setq empty-line t)))
(if empty-line
(progn
(beginning-of-line)
(kill-line)
(move-to-column cc))
(progn
(back-to-indentation)
(setq beg (point))
(end-of-line)
(skip-syntax-backward " ")
(setq end (point))
(kill-region beg end region))))))
(define-key global-map (kbd "C-w") 'ma/kill-line-or-region))
(use-package misc-defuns
:load-path "./defuns/"
:init
(global-set-key (kbd "C-o") #'ma/open-line-and-indent)
(global-set-key (kbd "<C-return>") #'ma/open-line-below)
(global-set-key (kbd "<C-S-return>") #'ma/open-line-above)
(global-set-key (kbd "<M-backspace>") #'ma/kill-line)
(global-set-key (kbd "C-c e") #'ma/eval-and-replace)
(global-set-key (kbd "C-c j") #'ma/join-line)
(global-set-key (kbd "C-c J") (lambda () (interactive) (ma/join-line t)))
(global-set-key (kbd "M-w") #'ma/kill-ring-save-line-or-region)
(global-set-key (kbd "C-c C-SPC") #'ma/jump-to-mark-skip-same-line))
(use-package flash-region
:ensure t)
(use-package hl-todo
:ensure t
:init (global-hl-todo-mode)
:config
(setq hl-todo-activate-in-modes '(prog-mode)))
;; notify when emacs is ready
;; I run emacs in server mode set a systemd units
(use-package notifications
:init
(add-hook 'after-init-hook #'(lambda ()
(notifications-notify
:title "Emacs"
:body "I am ready to hack!"
:urgency 'low))))
(delete-selection-mode)
(use-package recentf
:config
(run-at-time nil (* 10 60) (lambda () (let ((inhibit-message t)) (recentf-save-list))))
(setq recentf-max-saved-items 100
recentf-max-menu-items 15
;; disable recentf-cleanup on Emacs start, because it can cause
;; problems with remote files
recentf-auto-cleanup 'never)
(setq recentf-exclude
'("/\\.emacs\\.d/\\(elpa/\\|backups/\\)"
".gitignore"))
(recentf-mode +1))
;; save backups
(setq
backup-directory-alist '(("." . "~/.emacs.d/backups"))
delete-old-versions -1
version-control t
vc-make-backup-files t
auto-save-file-name-transforms '((".*" "~/.emacs.d/auto-save-list/" t)))
(use-package exec-path-from-shell
:ensure t
:config
(dolist (var '("GOPATH" "PYTHONUSERBASE" "NVM_DIR"))
(add-to-list 'exec-path-from-shell-variables var))
(exec-path-from-shell-initialize)
(add-to-list 'exec-path "~/.local/bin/")
(add-to-list 'exec-path "/home/marcelo/.nvm/versions/node/v22.7.0/bin")
(add-to-list 'exec-path (concat (getenv "PYTHONUSERBASE") "/bin")))
(use-package ethan-wspace
:ensure t
:diminish ethan-wspace-mode
:init
(setq mode-require-final-newline nil)
(add-hook 'org-mode #'ethan-wspace-mode)
(add-hook 'org-src-mode-hook #'ethan-wspace-clean-all)
(add-hook 'prog-mode-hook #'ethan-wspace-mode)
(add-hook 'markdown-mode-hook #'ethan-wspace-mode)
(add-hook 'LaTeX-mode-hook #'ethan-wspace-mode)
(add-hook 'yaml-mode-hook #'ethan-wspace-mode)
(add-hook 'see-mode-hook #'ethan-wspace-mode)
(add-hook 'ledger-mode-hook #'ethan-wspace-mode)
(add-hook 'yaml-mode-hook #'ethan-wspace-mode))
(use-package expand-region
:ensure t
:after hydra
:commands hydra-er/body
:custom
(expand-region-fast-keys-enabled nil)
:init
(defhydra hydra-er nil
"Expand region hydra"
("e" er/expand-region)
("d" er/contract-region :bind nil))
(hydra-set-property 'hydra-er :verbosity 0)
(defun ma/expand-region ()
(interactive)
(er/expand-region 1)
(hydra-er/body))
(global-set-key (kbd "C-*") 'ma/expand-region))
(use-package hydra
:ensure t)
(use-package smartparens
:ensure t
:diminish smartparens-mode
:hook (prog-mode text-mode markdown-mode) ;; add `smartparens-mode` to these hooks
:config
;; load default config
(require 'smartparens-config))
(use-package smooth-scroll
:ensure t
:diminish smooth-scroll-mode
:bind (("M-p" . scroll-down-1)
("M-n" . scroll-up-1)))
(use-package uniquify
:custom
(uniquify-buffer-name-style 'reverse)
(uniquify-separator " • ")
(uniquify-after-kill-buffer-p t)
(uniquify-ignore-buffers-re "^\\*"))
(use-package yasnippet
:ensure t
:diminish yas-minor-mode
:hook
((tsx-ts-mode go-mode python-mode emacs-lisp-mode web-mode) . yas-minor-mode)
:custom
(yas-triggers-in-field t)
:config
(add-to-list 'yas-snippet-dirs "~/.emacs.d/snippets/")
(yas-reload-all)
;; (add-hook 'go-mode-hook 'yas-minor-mode)
;; (add-hook 'python-mode-hook 'yas-minor-mode)
;; (add-hook 'emacs-lisp-mode-hook 'yas-minor-mode)
;; (add-hook 'tsx-ts-mode-hook 'yas-minor-mode)
;; (add-hook 'web-mode-hook 'yas-minor-mode)
)
(use-package saveplace
:custom
(save-place-file "~/.emacs.d/saveplace")
:init
(save-place-mode))
(use-package markdown-mode
:ensure t
:mode (("\\.md\\'" . markdown-mode)
("\\.markdown\\'" . markdown-mode))
:custom
(markdown-fontify-code-blocks-natively t))
(use-package edit-indirect
:after markdown
:ensure t)
(use-package projectile
:ensure t
:bind-keymap ("C-," . projectile-command-map)
:bind (
:map projectile-command-map
;; ("s a" . counsel-projectile-ag)
("," . projectile-switch-project))
:custom
;; (projectile-completion-system 'ivy)
(projectile-indexing-method 'hybrid)
(projectile-sort-order 'modification-time)
(projectile-switch-project-action (lambda () (projectile-dired) (projectile-commander)))
;; (projectile-mode-line-function (lambda () (format "proj: %s" (projectile-project-name))))
(projectile-project-search-path '("~/lab"))
(projectile-find-dir-includes-top-level t)
:config
;; projectile slows down tramp-mode
;; https://www.reddit.com/r/emacs/comments/320cvb/projectile_slows_tramp_mode_to_a_crawl_is_there_a/
(defadvice projectile-project-root (around ignore-remote first activate)
(unless (file-remote-p default-directory) ad-do-it))
(add-to-list 'projectile-other-file-alist '("tsx" . ("sass" "scss" "css")))
(add-to-list 'projectile-other-file-alist '("scss" . ("tsx" "ts")))
(add-to-list 'projectile-other-file-alist '("sass" . ("tsx" "ts")))
(add-to-list 'projectile-other-file-alist '("css" . ("tsx" "ts")))
(projectile-global-mode))
(use-package ispell
:custom
(ispell-program-name "hunspell")
(ispell-dictionary "es_CL,en_US")
:config
(ispell-set-spellchecker-params)
(ispell-hunspell-add-multi-dic "es_CL,en_US"))
(use-package flyspell
:diminish
:bind (:map flyspell-mode-map
("C-," . nil)
("C-." . nil)
("C-c $" . nil))
:hook
(org-mode . flyspell-mode)
(markdown-mode . flyspell-mode)
(prog-mode . flyspell-prog-mode)
(yaml-mode . flyspell-prog-mode)
:config
(add-hook 'prog-mode-hook (lambda () (setq flyspell-persistent-highlight nil)))
(add-hook 'yaml-mode-hook (lambda () (setq flyspell-persistent-highlight nil)))
(add-hook 'python-mode-hook (lambda () (setq flyspell-persistent-highlight nil)))
(add-hook 'jtsx-tsx-mode-hook (lambda () (setq flyspell-persistent-highlight nil)))
(add-hook 'jtsx-jsx-mode-hook (lambda () (setq flyspell-persistent-highlight nil)))
)
(use-package flyspell-correct
:ensure t
:bind (:map flyspell-mode-map ("C-c c" . flyspell-correct-wrapper)))
(use-package flyspell-correct-popup
:ensure t
:custom
(flyspell-correct-interface #'flyspell-correct-popup))
(use-package magit
:ensure t
:bind (("C-c g" . magit-status)
("C-c d" . ma/magit-diff-buffer-file))
:custom
(magit-save-repository-buffers 'dontask)
(magit-display-buffer-function 'magit-display-buffer-same-window-except-diff-v1)
(magit-section-visibility-indicator nil)
(magit-diff-adjust-tab-width tab-width)
(magit-diff-refine-hunk 'all)
(magit-copy-revision-abbreviated t)
(magit-section-initial-visibility-alist '((untracked . hide)
(unstaged . show)
(staged . show)
(stashes . hide)
(recent . show)))
:hook
(git-commit-mode . git-commit-turn-on-flyspell)
:preface
(defun ma/display-buffer-same-windows (buffer)
(display-buffer buffer '(display-buffer-same-window)))
(defun ma/magit-diff-buffer-file ()
(interactive)
(let ((magit-display-buffer-function #'ma/display-buffer-same-windows))
(magit-diff-buffer-file)))
:config
(global-git-commit-mode)
(magit-add-section-hook 'magit-status-sections-hook
'magit-insert-unpushed-to-upstream
'magit-insert-unpushed-to-upstream-or-recent
'replace)
(magit-add-section-hook 'magit-status-sections-hook
'magit-insert-recent-commits
'magit-insert-unpushed-to-upstream
'append))
(use-package forge
:ensure t
:after magit)
(use-package git-modes
:ensure t)
(use-package git-timemachine
:ensure t)
(use-package window
:after hydra
:init
(defhydra hydra-window (global-map "C-x")
"Some hydra for windows related command"
("<left>" previous-buffer)
("<right>" next-buffer))
:config
:bind (("s-x" . delete-window)
("s-c" . delete-other-windows)))
(use-package windmove
:custom
(windmove-create-window t)
:bind (("s-f" . (lambda () (interactive) (windmove-right)))
("s-F" . ma/show-current-after-move-to-right)
("s-s" . (lambda () (interactive) (windmove-left)))
("s-S" . ma/show-current-after-move-to-left)
("s-e" . (lambda () (interactive) (windmove-up)))
("s-E" . ma/show-current-after-move-to-up)
("s-d" . (lambda () (interactive) (windmove-down)))
("s-D" . ma/show-current-after-move-to-down)
("s-b" . balance-windows))
:config
(defun ma/show-current-after-move-to (dir)
(let ( (buff (window-buffer)))
(windmove-do-window-select dir nil)
(switch-to-buffer buff)))
(defun ma/show-current-after-move-to-left ()
(interactive)
(ma/show-current-after-move-to 'left))
(defun ma/show-current-after-move-to-right ()
(interactive)
(ma/show-current-after-move-to 'right))
(defun ma/show-current-after-move-to-up ()
(interactive)
(ma/show-current-after-move-to 'up))
(defun ma/show-current-after-move-to-down ()
(interactive)
(ma/show-current-after-move-to 'down)))
(use-package emmet-mode
:ensure t
:diminish
:hook (web-mode tsx-ts-mode typescript-ts-mode))
(use-package web-mode
:ensure t
:bind (:map web-mode-map ("C-=" . web-mode-mark-and-expand))
:mode
(("\\.html?\\'" . web-mode))
:custom
(web-mode-enable-current-element-highlight t)
(web-mode-enable-element-content-fontification t)
(web-mode-enable-element-tag-fontification t)
(web-mode-markup-indent-offset 2))
(use-package json-mode
:ensure t
:init
(add-hook 'json-mode-hook
(lambda ()
(make-local-variable 'js-indent-level)
(setq js-indent-level 2)))
:mode (("\\.geojson\\'" . json-mode)
("\\.json\\'" . json-mode)))
(use-package company
;; TODO: try corfu
:ensure t
;; :after lsp-mode
:diminish company-mode
:bind (:map company-mode-map
("C-M-s-c" . company-complete)
:map company-active-map
("C-n" . company-select-next)
("C-p" . company-select-previous))
:hook ((emacs-lisp-mode . company-mode)
(web-mode . company-mode)
(css-mode . company-mode)
(c++-mode . company-mode)
(cider-repl-mode . company-mode)
(cider-mode . company-mode)
(sh-mode . company-mode)
(typescript-mode . company-mode)
(inferior-ess-mode . company-mode)
(jtsx-jsx-mode . company-mode)
(org-mode . company-mode))
:custom
(company-idle-delay nil)
(company-tooltip-idle-delay 0)
(company-minimum-prefix-length 3)
(company-show-numbers 'left)
(company-dabbrev-downcase nil)
(company-selection-wrap-around t)
:config
(setq company-backends '(company-capf))
;; (add-to-list 'company-backend 'company-ispell)
)
(use-package company-box
:ensure t
:diminish company-box-mode
:custom
(company-box-doc-enable nil)
(company-box-doc-delay 0)
:hook (company-mode . company-box-mode))
(use-package autorevert
:delight auto-revert-mode
:hook ((dired-mode) . auto-revert-mode)
:custom
(auto-revert-verbose nil))
(use-package dired-x
:custom
(dired-omit-verbose nil)
(dired-omit-files "^\\.")
:init
(add-hook 'dired-mode-hook
(lambda ()
(dired-omit-mode)
(diminish 'dired-omit-mode))))
(use-package dired
:bind (:map dired-mode-map
("k" . ma/dired-kill-or-up-subdir))
:custom
(dired-dwim-target t)
(wdired-allow-to-change-permissions t)
(dired-listing-switches "-AGFlhv --group-directories-first --time-style=long-iso")
:init
(defun ma/dired-kill-or-up-subdir ()
"Kill current subtree but if it's top level so call
`dired-up-directory'"
(interactive)
(let ((in-header (dired-get-subdir))
(cur-dir (dired-current-directory)))
(if (equal cur-dir (expand-file-name default-directory))
(dired-up-directory)
(progn
(when (not in-header)
(call-interactively 'dired-prev-subdir)
(setq dir (dired-get-subdir)))
(dired-do-kill-lines '(4))
(dired-goto-file dir))))))
(use-package dired-narrow
:ensure t
:bind (:map dired-mode-map
("/" . dired-narrow)))
(use-package all-the-icons
;; after install run the command (all-the-icons-install-fonts)
:ensure t
:defer t
:diminish)
(use-package all-the-icons-dired
:ensure t
:diminish
:custom
(all-the-icons-dired-monochrome nil)
:hook
(dired-mode . all-the-icons-dired-mode)
:init
(defface all-the-icons-dired-dir-face
'((((background dark)) :foreground "#BDBDBD"))
"Face for the directory icon"
:group 'all-the-icons-faces)
:config
(add-to-list 'all-the-icons-extension-icon-alist
'("go" all-the-icons-alltheicon "go" :height 1.0 :face all-the-icons-blue)))
(use-package deft
:ensure t
:bind ([f2] . ma/deft-in-new-frame)
:custom
(deft-directory "~/syncthing/org/deft")
(deft-extensions '("org" "md" "markdown" "txt" "text"))
:config
(defun ma/deft-in-new-frame (&optional arg)
"Launch deft in a new frame"
(interactive "P")
(if (not arg)
(deft)
(select-frame (make-frame-command))
(deft))))
(use-package rainbow-mode
:ensure t)
(use-package google-translate
:ensure t
:bind ("C-c t" . google-translate-smooth-translate)
:init
(use-package google-translate-smooth-ui)
(setq google-translate-translation-directions-alist '(("en" . "es") ("es" . "en")))
(defun google-translate--search-tkk () "Search TKK." (list 430675 2721866130)))
(use-package multiple-cursors
:ensure t
:bind (("C->" . mc/mark-next-like-this)
("C-<" . mc/mark-previous-like-this)
("C-c C->" . mc/mark-next-like-this-word))
:init
(global-unset-key (kbd "C-<down-mouse-1>")))
(use-package yaml-mode
:ensure t
:mode (("\\.yml\\'" . yaml-mode)
("\\.yaml\\'" . yaml-mode)))
(use-package toml-mode
:ensure t
:mode ("\\.toml\\'" "/Pipfile\\'"))
(use-package subword
:diminish
:hook ((prog-mode) . subword-mode))
(use-package go-mode
:ensure t
:bind (:map go-mode-map
("C-=" . (lambda () (interactive) (insert ":="))))
:init
(setq gofmt-command "goimports")
(add-hook 'go-mode-hook
(lambda ()
(add-hook 'before-save-hook 'gofmt-before-save))))
(use-package pyvenv
:ensure t
:config
(require 'pyvenv)
(defun pyvenv-autoload ()
(interactive)
"auto activate venv directory if exists"
(f-traverse-upwards (lambda (path)
(let ((venv-path (f-expand "venv" path)))
(when (f-exists? venv-path)
(pyvenv-activate venv-path))))))
;; (add-hook 'python-mode-hook 'pyvenv-autoload)
(pyvenv-mode 1))
(use-package python
:bind (:map python-mode-map
("<backtab>" . nil)
("C-c C-n" . ma/python-eval-current-line))
:custom
(python-eldoc-get-doc nil)
(python-indent-offset 4)
(python-shell-interpreter "ipython")
;; (python-shell-interpreter-args "--simple-prompt -i")
:config
(defun ma/python-eval-current-line (&optional keep)
(interactive "P")
(let ((beg (line-beginning-position))
(end (line-end-position)))
(python-shell-send-region beg end nil t)
(unless keep
(forward-line))))
(defun ma/python-newline-advice (orig-fun &rest args)
"A better newline for python-mode.
this advice understand if point is currently at indentation
level, so when press RET, indentation level is keeps. If point is not
at indentation level the behavior is the same as if press RET
which call (newline) command"
(let ((levels (python-indent-calculate-levels))
(cur (current-column)))