-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.el
1080 lines (946 loc) · 41.8 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)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
;; Comment/uncomment this line to enable MELPA Stable if desired. See `package-archive-priorities`
;; and `package-pinned-packages`. Most users will not need or want to do this.
;;(add-to-list 'package-archives '("melpa-stable" . "https://stable.melpa.org/packages/") t)
(package-initialize)
;; since melpa version is breaking
(add-to-list 'package-pinned-packages
'(modus-themes . "3.0.0"))
;; Defaults
;; Start maximized
(add-to-list 'initial-frame-alist '(fullscreen . maximized))
(setq-default indent-tabs-mode nil)
(global-set-key (kbd "C-x C-b") 'ibuffer)
;; (global-set-key "\C-cy" '(lambda ()
;; (interactive)
;; (popup-menu 'yank-menu)))
(global-set-key "\C-cy" 'counsel-kill-ring)
(defun yank-pop-forwards (arg)
(interactive "p")
(yank-pop (- arg)))
(global-set-key "\M-Y" 'yank-pop-forwards)
(menu-bar-mode -1)
(tool-bar-mode -1)
(toggle-scroll-bar -1)
(column-number-mode +1)
(add-to-list 'load-path "~/.emacs.d/lisp/")
;; how to autoload this?
(require 'modeline-region)
(global-modeline-region-mode 1)
(autoload 'hide/show-comments-toggle "hide-comnt" "Hide/Show Comments" t)
;; (setq-default indent-tabs-mode nil)
;; (setq-default tab-width 4)
;; (setq indent-line-function 'insert-tab)
;; to add & configure
;; phpactor, dragstuff, zoom-all-windows
;; LSP
(setq lsp-keymap-prefix "C-c l")
(require 'lsp-mode) ;; avoid this require?
(with-eval-after-load 'lsp-mode
(add-hook 'lsp-mode-hook #'lsp-enable-which-key-integration))
(add-hook 'php-mode-hook #'lsp)
;; override phpactor config and set it as an add-on
(with-eval-after-load 'lsp-php
(add-to-list 'lsp-language-id-configuration
'(php-mode . "php"))
(lsp-register-client
(make-lsp-client :new-connection (lsp-stdio-connection
(lambda ()
(unless lsp-php-composer-dir
(setq lsp-php-composer-dir (lsp-php-get-composer-dir)))
(unless lsp-phpactor-path
(setq lsp-phpactor-path (or (executable-find "phpactor")
(f-join lsp-php-composer-dir "vendor/phpactor/phpactor/bin/phpactor"))))
(list lsp-phpactor-path "language-server")))
:major-modes '(php-mode)
:activation-fn (lsp-activate-on "php")
:add-on? t
:initialization-options (ht)
:server-id 'phpactor)))
(add-hook 'web-mode-hook #'lsp)
(add-hook 'css-mode-hook #'lsp)
;;(add-hook 'prog-mode-hook #'lsp)
(require 'lsp-pyright)
(add-hook 'python-mode-hook #'lsp) ; or lsp-deferred
;; Enable html-ls for twig files
(with-eval-after-load 'lsp-mode
(add-to-list 'lsp-language-id-configuration
'(".*\\.twig$" . "html")))
;; Enable html-ls for jinja files
(with-eval-after-load 'lsp-mode
(add-to-list 'lsp-language-id-configuration
'(".*\\.jinja$" . "html")))
;; Enable php ls (iph) for .php files any mode
(with-eval-after-load 'lsp-mode
(add-to-list 'lsp-language-id-configuration
'(".*\\.php$" . "php")))
;; Windsize & Windmove
;; with eval after load?
(windsize-default-keybindings)
(global-set-key (kbd "C-M-<up>") 'windmove-up)
(global-set-key (kbd "C-M-<left>") 'windmove-left)
(global-set-key (kbd "C-M-<down>") 'windmove-down)
(global-set-key (kbd "C-M-<right>") 'windmove-right)
;; Experimental
(global-set-key (kbd "C-M-p") 'windmove-up)
(global-set-key (kbd "C-M-b") 'windmove-left)
(global-set-key (kbd "C-M-n") 'windmove-down)
(global-set-key (kbd "C-M-f") 'windmove-right)
;; Alternative stuff
;; (global-set-key (kbd "C-x M-<up>") #'windmove-up)
;; (global-set-key (kbd "C-x M-<down>") #'windmove-down)
;; (global-set-key (kbd "C-x M-<left>") #'windmove-left)
;; (global-set-key (kbd "C-x M-<right>") #'windmove-right)
;; Ivy/Swiper/Counsel
(with-eval-after-load 'ivy
(setq ivy-re-builders-alist
'((t . ivy--regex-fuzzy)))
(setq ivy-use-virtual-buffers t)
(setq enable-recursive-minibuffers t)
;; enable this if you want `swiper' to use it
;; (setq search-default-mode #'char-fold-to-regexp)
(global-set-key (kbd "C-S-s") 'swiper-isearch)
(global-set-key (kbd "C-c C-r") 'ivy-resume)
(global-set-key (kbd "<f6>") 'ivy-resume)
(global-set-key (kbd "M-x") 'counsel-M-x)
(global-set-key (kbd "C-x C-f") 'counsel-find-file)
(global-set-key (kbd "<f1> f") 'counsel-describe-function)
(global-set-key (kbd "<f1> v") 'counsel-describe-variable)
(global-set-key (kbd "<f1> o") 'counsel-describe-symbol)
(global-set-key (kbd "<f1> l") 'counsel-find-library)
(global-set-key (kbd "<f2> i") 'counsel-info-lookup-symbol)
(global-set-key (kbd "<f2> u") 'counsel-unicode-char)
(global-set-key (kbd "C-c g") 'counsel-git)
(global-set-key (kbd "C-c j") 'counsel-git-grep)
(global-set-key (kbd "C-c k") 'counsel-ag)
(global-set-key (kbd "C-x l") 'counsel-locate)
(define-key minibuffer-local-map (kbd "C-r") 'counsel-minibuffer-history)
(define-key ivy-minibuffer-map (kbd "M-<tab>") 'ivy-rotate-preferred-builders))
;; (advice-add 'ivy-toggle-fuzzy :around
;; (lambda (orig-fun)
;; (let ((l (funcall orig-fun)))
;; (message "%s" ivy--regex-function))))
(defun ivy-curr-reb ()
(format "[%s] "
(or
(cdr
(assoc ivy--regex-function ivy-preferred-re-builders))
"fuzzy")))
;; Swiper-isearch with moving between lines with arrow keys
(defun swiper-isearch-next-line ()
(interactive)
(let ((shift 1))
(with-ivy-window
(let ((ln (line-number-at-pos (ivy-state-current ivy-last))))
(while (and (< (+ ivy--index shift) ivy--length)
(= ln (line-number-at-pos (nth (+ ivy--index shift) ivy--all-candidates))))
(cl-incf shift))))
(ivy-next-line shift)))
(defun swiper-isearch-prev-line ()
(interactive)
(let ((shift 1))
(with-ivy-window
(let ((ln (line-number-at-pos (ivy-state-current ivy-last))))
(while (and (>= (- ivy--index shift) 0)
(= ln (line-number-at-pos (nth (- ivy--index shift) ivy--all-candidates))))
(cl-incf shift))))
(ivy-previous-line shift)))
(with-eval-after-load 'swiper
(define-key swiper-isearch-map (kbd "<down>") #'swiper-isearch-next-line)
(define-key swiper-isearch-map (kbd "<up>") #'swiper-isearch-prev-line)
(define-key swiper-isearch-map (kbd "TAB") #'swiper-isearch-next-line)
(define-key swiper-isearch-map (kbd "S-TAB") #'swiper-isearch-prev-line)
(define-key swiper-isearch-map (kbd "S-SPC") nil))
;; Projectile
(with-eval-after-load 'projectile
(define-key projectile-mode-map (kbd "C-c p") 'projectile-command-map))
;; Custom Shortcuts
;; Multline
(global-set-key (kbd "C-c d") 'mc/mark-next-like-this-word)
(global-set-key (kbd "C->") 'mc/mark-next-word-like-this)
(global-set-key (kbd "C-<") 'mc/mark-previous-like-this)
(global-set-key (kbd "M-.") 'mc/mark-pop)
;; (global-set-key (kbd "C-S-c C-S-c") 'mc/edit-lines)
;; (global-set-key (kbd "C-S-w C-S-w") 'mc/mark-all-dwim)
;; (global-set-key (kbd "C-S-e C-S-e") 'mc/edit-ends-of-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))
;; Undo Tree
;; (defun undo-tree-split-side-by-side (original-function &rest args)
;; "Split undo-tree side-by-side"
;; (let ((split-height-threshold nil)
;; (split-width-threshold 0))
;; (apply original-function args)))
;; (advice-add 'undo-tree-visualize :around #'undo-tree-split-side-by-side)
;; Auto-Completion
(eval-after-load 'company
'(define-key company-active-map (kbd "C-c h") #'company-quickhelp-manual-begin))
;; Hooks
(add-hook 'magit-pre-refresh-hook 'diff-hl-magit-pre-refresh)
(add-hook 'magit-post-refresh-hook 'diff-hl-magit-post-refresh)
(with-eval-after-load 'magit-mode
(add-hook 'after-save-hook 'magit-after-save-refresh-status t))
(add-hook 'prog-mode-hook 'display-line-numbers-mode)
(add-hook 'prog-mode-hook 'display-fill-column-indicator-mode)
(add-hook 'prog-mode-hook 'electric-pair-local-mode)
(add-hook 'prog-mode-hook 'yas-minor-mode)
(add-hook 'prog-mode-hook 'company-mode)
(add-hook 'org-mode-hook 'yas-minor-mode)
;; https://emacs.stackexchange.com/questions/7321/turn-a-non-prog-mode-derived-major-mode-into-a-prog-mode-derived-major-mode
(add-hook 'yaml-mode-hook
(lambda () (run-hooks 'prog-mode-hook)))
(with-eval-after-load 'yasnippet
(yas-load-directory "~/.emacs.d/snippets"))
(with-eval-after-load 'magit
(define-key magit-hunk-section-map (kbd "C-o")
'magit-diff-visit-file-other-window)
(define-key magit-file-section-map (kbd "C-o")
'magit-diff-visit-file-other-window)
(magit-add-section-hook
'magit-status-sections-hook
'magit-insert-tracked-files
nil
'append))
;; (add-hook 'flyspell-mode-hook #'flyspell-buffer)
;; Disable pairing simple quote in elisp-mode
(add-hook 'emacs-lisp-mode-hook
(lambda ()
(setq-local electric-pair-pairs
(eval
(car
(get 'electric-pair-pairs 'standard-value))))
(setq-local electric-pair-text-pairs
(eval
(car
(get 'electric-pair-pairs 'standard-value))))))
(add-hook 'conf-mode-hook 'display-line-numbers-mode)
(add-hook 'after-init-hook (lambda () (message (concat "Startup time: " (emacs-init-time)))))
;; Set filter groups in ibuffer
(add-hook 'ibuffer-hook (lambda () (ibuffer-projectile-set-filter-groups)))
;; Mode & File Associations
;; Software Development
(add-to-list 'auto-mode-alist '("\\.html?\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.js[x]?\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.ts[x]?\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.twig\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.jinja\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.sql\\'" . sql-mode))
(add-to-list 'auto-mode-alist '("\\.restclient\\'" . restclient-mode))
(add-to-list 'auto-mode-alist '("\\.plantuml\\'" . plantuml-mode))
(add-to-list 'auto-mode-alist '("\\.puml\\'" . plantuml-mode))
(add-to-list 'auto-mode-alist '("\\.apib\\'" . apib-mode))
;; Other
(add-to-list 'auto-mode-alist '("\\.org$" . org-mode))
(add-to-list 'auto-mode-alist '("\\.ledger$" . ledger-mode))
;; Config/Data Files
(add-to-list 'auto-mode-alist '("\\.json\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.ya?ml\\'" . yaml-mode))
(add-to-list 'auto-mode-alist '("\\.env\\'" . conf-mode))
;; Things to probably move to other files
;; Enable mode-line-buffer-id states
(progn
(defun my-buffer-identification (fmt)
(list (propertize fmt
'face (if (let ((window (selected-window)))
(or (eq window (old-selected-window))
(and (minibuffer-window-active-p (minibuffer-window))
(with-selected-window (minibuffer-window)
(eq window (minibuffer-selected-window))))))
'mode-line-buffer-id-highlight
'mode-line-buffer-id)
'mouse-face 'mode-line-highlight
'local-map mode-line-buffer-identification-keymap)))
(setq-default mode-line-buffer-identification
'(:eval (my-buffer-identification " %12b "))))
;; Eval and Replace
;; From magnars
(defun eval-and-replace ()
"Replace the preceding sexp with its value."
(interactive)
(backward-kill-sexp)
(condition-case nil
(prin1 (eval (read (current-kill 0)))
(current-buffer))
(error (message "Invalid expression")
(insert (current-kill 0)))))
;; Regex Builder & Replace Bridge
;; https://karthinks.com/software/bridging-islands-in-emacs-1/
(defvar my/re-builder-positions nil
"Store point and region bounds before calling re-builder")
(advice-add 're-builder
:before
(defun my/re-builder-save-state (&rest _)
"Save into `my/re-builder-positions' the point and region
positions before calling `re-builder'."
(setq my/re-builder-positions
(cons (point)
(when (region-active-p)
(list (region-beginning)
(region-end)))))))
(defun reb-replace-regexp (&optional delimited)
"Run `query-replace-regexp' with the contents of re-builder. With
non-nil optional argument DELIMITED, only replace matches
surrounded by word boundaries."
(interactive "P")
(reb-update-regexp)
(let* ((re (reb-target-binding reb-regexp))
(replacement (query-replace-read-to
re
(concat "Query replace"
(if current-prefix-arg
(if (eq current-prefix-arg '-) " backward" " word")
"")
" regexp"
(if (with-selected-window reb-target-window
(region-active-p)) " in region" ""))
t))
(pnt (car my/re-builder-positions))
(beg (cadr my/re-builder-positions))
(end (caddr my/re-builder-positions)))
(with-selected-window reb-target-window
(goto-char pnt) ; replace with (goto-char (match-beginning 0)) if you want
; to control where in the buffer the replacement starts
; with re-builder
(setq my/re-builder-positions nil)
(reb-quit)
(query-replace-regexp re replacement delimited beg end))))
(with-eval-after-load 're-builder
(define-key reb-mode-map (kbd "RET") #'reb-replace-regexp)
(define-key reb-lisp-mode-map (kbd "RET") #'reb-replace-regexp))
(global-set-key (kbd "C-M-%") #'re-builder)
;; Custom Faces
(defface mode-line-buffer-id-highlight
'((t (:background "white" :foreground "black" :weight normal)))
"Face for mode-line-buffer-id buffer active"
:group 'basic-faces )
;; Customize
(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 success warning error])
'(ansi-color-names-vector
["gray35" "#ff8059" "#44bc44" "#d0bc00" "#2fafff" "#feacd0" "#00d3d0" "gray65"])
'(auto-save-file-name-transforms '((".*" "~/.emacs.d/backup/" t)))
'(awesome-tray-mode-line-active-color "#2fafff")
'(awesome-tray-mode-line-inactive-color "#323232")
'(backup-directory-alist '(("." . "~/.emacs.d/backup/")))
'(chart-face-color-list
'("#ef7969" "#4faa09" "#ffcf00" "#7090ff" "#e07fff" "#70d3f0" "#ffaab4" "#8fef00" "#f9ff00" "#9fc6ff" "#fad0ff" "#afefff"))
'(column-number-mode t)
'(company-dabbrev-downcase nil)
'(company-selection-wrap-around t)
'(current-language-environment "UTF-8")
'(custom-enabled-themes '(modus-operandi))
'(custom-safe-themes
'("71ac1434a07579da9b1ec1dd1a2b9cfa3182523d750678b68db6c25749fb6494" "3adebe6a07e999ecadabd1a12eb8becf0e036172cde1807b25b9a5919046339c" "1fab98300b100a19010734a14c4bf9b6712ffc8b9e1d7eca35f837adeeabf740" "53585ce64a33d02c31284cd7c2a624f379d232b27c4c56c6d822eff5d3ba7625" "7dc296b80df1b29bfc4062d1a66ee91efb462d6a7a934955e94e786394d80b71" "3199be8536de4a8300eaf9ce6d864a35aa802088c0925e944e2b74a574c68fd0" "3860a842e0bf585df9e5785e06d600a86e8b605e5cc0b74320dfe667bcbe816c" "ab04c00a7e48ad784b52f34aa6bfa1e80d0c3fcacc50e1189af3651013eb0d58" "04dd0236a367865e591927a3810f178e8d33c372ad5bfef48b5ce90d4b476481" "7356632cebc6a11a87bc5fcffaa49bae528026a78637acd03cae57c091afd9b9" "74a50f18c8c88eac44dc73d7a4c0bbe1f3e72ff5971aac38fcf354ddad0d4733" "aa72e5b41780bfff2ff55d0cc6fcd4b42153386088a4025fed606c1099c2d9b8" default))
'(diff-hl-flydiff-mode t)
'(dired-dwim-target t)
'(dired-listing-switches "-Falh --group-directories-first")
'(dired-mode-hook '(auto-revert-mode diff-hl-dired-mode))
'(ediff-split-window-function 'split-window-horizontally)
'(ediff-window-setup-function 'ediff-setup-windows-plain)
'(electric-pair-pairs '((34 . 34) (8216 . 8217) (8220 . 8221) (39 . 39)))
'(electric-pair-text-pairs '((34 . 34) (8216 . 8217) (8220 . 8221) (39 . 39)))
'(ement-notify-notification-predicates
'(ement-notify--event-mentions-session-user-p ement-notify--event-mentions-room-p))
'(ement-room-send-read-receipts nil)
'(ement-room-send-typing nil)
'(erc-autojoin-channels-alist '(("libera.chat" "#emacs")))
'(erc-server "irc.libera.chat")
'(erc-server-alist
'(("Libera" Libera "irc.libera.chat" 6667)
("Snoonet" Snoonet "irc.snoonet.org" 6667)))
'(erc-timestamp-format "[%H:%M:%S]")
'(erc-timestamp-format-right " [%H:%M:%S]")
'(eval-expression-print-length nil)
'(eval-expression-print-level nil)
'(explicit-shell-file-name "/bin/bash")
'(exwm-floating-border-color "#646464")
'(fci-rule-color "#5B6268")
'(flymake-error-bitmap '(flymake-double-exclamation-mark modus-themes-intense-red))
'(flymake-note-bitmap '(exclamation-mark modus-themes-intense-cyan))
'(flymake-warning-bitmap '(exclamation-mark modus-themes-intense-yellow))
'(global-diff-hl-mode t)
'(global-hl-line-mode t)
'(global-undo-tree-mode t)
'(global-whitespace-mode nil)
'(highlight-changes-colors nil)
'(highlight-changes-face-list '(success warning error bold bold-italic))
'(highlight-tail-colors
((("#101909" "#A8FF60" "green")
. 0)
(("#131319" "#C6C5FE" "brightcyan")
. 20)))
'(hl-todo-keyword-faces
'(("HOLD" . "#c0c530")
("TODO" . "#feacd0")
("NEXT" . "#b6a0ff")
("THEM" . "#f78fe7")
("PROG" . "#00d3d0")
("OKAY" . "#4ae2f0")
("DONT" . "#70b900")
("FAIL" . "#ff8059")
("BUG" . "#ff8059")
("DONE" . "#44bc44")
("NOTE" . "#d3b55f")
("KLUDGE" . "#d0bc00")
("HACK" . "#d0bc00")
("TEMP" . "#ffcccc")
("FIXME" . "#ff9077")
("XXX+" . "#ef8b50")
("REVIEW" . "#6ae4b9")
("DEPRECATED" . "#bfd9ff")))
'(ibuffer-deletion-face 'modus-themes-mark-del)
'(ibuffer-filter-group-name-face 'bold)
'(ibuffer-marked-face 'modus-themes-mark-sel)
'(ibuffer-title-face 'default)
'(indent-guide-char "│")
'(indent-guide-recursive t)
'(isearch-lazy-count t)
'(ispell-dictionary "pt_BR")
'(ispell-skip-html t)
'(ivy-mode t)
'(ivy-pre-prompt-function 'ivy-curr-reb)
'(ivy-preferred-re-builders
'((ivy--regex-plus . "regex")
(ivy--regex-ignore-order . "order")
(ivy--regex-fuzzy . "fuzzy")))
'(ivy-read-action-format-function 'ivy-read-action-format-columns)
'(ivy-rich-mode t)
'(ivy-use-selectable-prompt t)
'(ivy-virtual-abbreviate 'abbreviate)
'(jdee-db-active-breakpoint-face-colors (cons "#1B2229" "#96CBFE"))
'(jdee-db-requested-breakpoint-face-colors (cons "#1B2229" "#A8FF60"))
'(jdee-db-spec-breakpoint-face-colors (cons "#1B2229" "#3f444a"))
'(jinx-languages "pt_BR en_US")
'(keycast-mode-line-format "%1s%k%c%r")
'(keycast-mode-line-remove-tail-elements nil)
'(ledger-reports
'(("budget" "%(binary) -f %(ledger-file) --budget --monthly reg expenses")
("bal" "%(binary) -f %(ledger-file) bal")
("reg" "%(binary) -f %(ledger-file) reg")
("payee" "%(binary) -f %(ledger-file) reg @%(payee)")
("account" "%(binary) -f %(ledger-file) reg %(account)")))
'(lsp-disabled-clients '(eslint))
'(lsp-file-watch-threshold 10000)
'(magit-uniquify-buffer-names nil)
'(markdown-display-remote-images t)
'(mini-modeline-face-attr '(:background unspecified))
'(minimap-hide-fringes t)
'(minimap-mode t)
'(mlr-non-rectangle-style 'lines+words+chars)
'(modus-themes-org-blocks 'grayscale)
'(newsticker-automatically-mark-items-as-old nil)
'(newsticker-url-list
'(("Sacha Chua" "https://sachachua.com/blog/feed" nil nil nil)
("Irreal" "https://irreal.org/blog/?feed=rss2" nil nil nil)
("Karthinks" "https://karthinks.com/index.xml" nil nil nil)
("Manuel Uberti" "https://manueluberti.eu/feed.xml" nil nil nil)
("Planet Emacs" "https://planet.emacslife.com/atom.xml" nil nil nil)
("Karl Voit" "https://karl-voit.at/feeds/lazyblorg-all.atom_1.0.links-and-content.xml" nil nil nil)
("POURIA" "https://pouria.dev/rss.xml" nil nil nil)
("Prot" "https://protesilaos.com/master.xml" nil nil nil)
("Susam" "https://susam.net/maze/feed.xml" nil nil nil)))
'(objed-cursor-color "#ff6c60")
'(org-babel-load-languages '((emacs-lisp . t) (python . t) (js . t) (restclient . t)))
'(org-clock-sound "/usr/share/sounds/sound-icons/trumpet-12.wav")
'(org-crypt-disable-auto-save 'encrypt)
'(org-enforce-todo-dependencies t)
'(org-fontify-quote-and-verse-blocks t)
'(org-habit-graph-column 60)
'(org-image-actual-width nil)
'(org-log-into-drawer t)
'(org-modules
'(ol-bbdb ol-bibtex ol-docview ol-eww ol-gnus org-habit ol-info ol-irc ol-mhe ol-rmail ol-w3m))
'(org-src-block-faces 'nil)
'(org-src-lang-modes
'(("php" . php)
("C" . c)
("C++" . c++)
("asymptote" . asy)
("bash" . sh)
("beamer" . latex)
("calc" . fundamental)
("cpp" . c++)
("ditaa" . artist)
("dot" . fundamental)
("elisp" . emacs-lisp)
("ocaml" . tuareg)
("screen" . shell-script)
("shell" . sh)
("sqlite" . sql)
("plantuml" . plantuml)))
'(org-todo-keyword-faces
'(("IN-REVIEW" . org-macro)
("IN-PROGRESS" . org-sexp-date)))
'(package-selected-packages
'(ledger-mode exec-path-from-shell lsp-mode jinx cpf-tools yaml-mode lsp-treemacs writeroom-mode ob-restclient apib-mode restclient ox-gfm counsel-jq flycheck-plantuml plantuml-mode csv-mode feature-mode dockerfile-mode yasnippet ob-php git-link php-mode ivy-rich ibuffer-projectile highlight-indent-guides rainbow-delimiters lsp-pyright rg frameshot path-headerline-mode gif-screencast company-quickhelp keycast modus-themes tramp flycheck lsp-ui diff-hl multiple-cursors idle-highlight-mode company projectile counsel ivy web-mode windsize which-key uniquify-files undo-tree transpose-frame smex magit emmet-mode crux))
'(pdf-view-midnight-colors '("#ffffff" . "#100f10"))
'(php-mode-coding-style 'symfony2)
'(phpactor-executable "phpactor")
'(projectile-globally-ignored-directories
'("^\\.idea$" "^\\.vscode$" "^\\.ensime_cache$" "^\\.eunit$" "^\\.git$" "^\\.hg$" "^\\.fslckout$" "^_FOSSIL_$" "^\\.bzr$" "^_darcs$" "^\\.pijul$" "^\\.tox$" "^\\.svn$" "^\\.stack-work$" "^\\.ccls-cache$" "^\\.cache$" "^\\.clangd$" ".expo/web/cache/.*" "^\\.log" "^node_modules$"))
'(projectile-mode t nil (projectile))
'(reb-re-syntax 'string)
'(recentf-max-saved-items 100)
'(recentf-mode t)
'(rg-command-line-flags '("-C 5"))
'(rustic-ansi-faces
["#000000" "#ff6c60" "#A8FF60" "#FFFFB6" "#96CBFE" "#FF73FD" "#C6C5FE" "#f6f3e8"])
'(show-paren-mode t)
'(show-paren-when-point-in-periphery t)
'(show-paren-when-point-inside-paren t)
'(size-indication-mode t)
'(split-width-threshold 140)
'(sql-mysql-login-params '(user password server database port))
'(sql-port 3306)
'(tab-bar-close-button-show nil)
'(tab-bar-mode t)
'(tab-bar-new-button-show nil)
'(tab-bar-separator "" t)
'(tab-bar-tab-name-function 'tab-bar-tab-name-current-with-count)
'(text-mode-hook '(turn-on-flyspell text-mode-hook-identify))
'(tool-bar-mode nil)
'(truncate-lines t)
'(undo-limit 800000000)
'(undo-outer-limit 240000000)
'(undo-strong-limit 2400000)
'(undo-tree-enable-undo-in-region t)
'(undo-tree-history-directory-alist '(("." . "~/.emacs.d/backup")))
'(undo-tree-visualizer-diff t)
'(uniquify-buffer-name-style 'forward nil (uniquify))
'(vc-annotate-background nil)
'(vc-annotate-background-mode nil)
'(vc-annotate-color-map
'((20 . "#ff8059")
(40 . "#feacd0")
(60 . "#f78fe7")
(80 . "#ef8b50")
(100 . "#d0bc00")
(120 . "#c0c530")
(140 . "#f8dec0")
(160 . "#bfebe0")
(180 . "#44bc44")
(200 . "#70b900")
(220 . "#6ae4b9")
(240 . "#4ae2f0")
(260 . "#00d3d0")
(280 . "#c6eaff")
(300 . "#2fafff")
(320 . "#79a8ff")
(340 . "#00bcff")
(360 . "#b6a0ff")))
'(vc-annotate-very-old-color nil)
'(vc-make-backup-files t)
'(visible-bell t)
'(web-mode-enable-auto-indentation nil)
'(web-mode-enable-auto-pairing nil)
'(web-mode-enable-current-element-highlight t)
'(web-mode-enable-sql-detection t)
'(web-mode-script-padding 4)
'(web-mode-style-padding 4)
'(which-key-mode t)
'(whitespace-style
'(face trailing tabs spaces newline empty indentation space-after-tab space-before-tab space-mark tab-mark))
'(whitespace-trailing-regexp "\\([ ]+$\\|[^
] +[^
]\\|^[
]+$\\)")
'(widget-link-prefix "[")
'(widget-link-suffix "]")
'(widget-mouse-face '(highlight widget-button))
'(widget-push-button-prefix "[")
'(widget-push-button-suffix "]")
'(windmove-wrap-around t)
'(xterm-color-names
["black" "#ff8059" "#44bc44" "#d0bc00" "#2fafff" "#feacd0" "#00d3d0" "gray65"])
'(xterm-color-names-bright
["gray35" "#ef8b50" "#70b900" "#c0c530" "#79a8ff" "#f78fe7" "#4ae2f0" "white"]))
(custom-set-faces
;; custom-set-faces 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.
'(default ((t (:family "DejaVu Sans Mono" :foundry "PfEd" :slant normal :weight normal :height 120 :width normal))))
'(keycast-command ((t (:inherit bold :foreground "red"))))
'(keycast-key ((t (:background "red" :foreground "white" :box (:line-width 1 :color "dark gray")))))
'(mode-line ((t (:background "#000000" :foreground "#ffffff"))))
'(mode-line-buffer-id ((t (:inherit bold :background "gray20" :foreground "gray" :weight normal))))
'(mode-line-buffer-id-highlight ((t (:background "white" :foreground "black" :weight normal))))
'(mode-line-highlight ((t (:background "white" :foreground "black" :box nil))))
'(mode-line-id-inactive ((t (:background "gray10" :foreground "dim gray"))))
'(mode-line-inactive ((t (:background "black" :foreground "gray65" :box (:line-width 1 :color "gray40")))))
'(org-mode-line-clock ((t (:foreground "white"))))
'(tab-bar ((t (:inherit variable-pitch :background "black" :foreground "white"))))
'(tab-bar-tab ((t (:inherit modus-themes-tab-active :background "white" :foreground "black" :box (:line-width 2 :color "white")))))
'(tab-bar-tab-inactive ((t (:inherit modus-themes-tab-inactive :distant-foreground "gainsboro" :foreground "gray20" :box (:line-width 2 :color "gray25"))))))
;; Frame/window title
(setq frame-title-format
'((:eval (format "emacs-%d.%d@%s:%s" emacs-major-version emacs-minor-version system-type
(if (buffer-file-name) (abbreviate-file-name (buffer-file-name)) "%b")))))
;; Frameshot
(with-eval-after-load 'frameshot
(frameshot-setup
'((name . "emacs")
(output . "~/Downloads/"))))
;; Tab bar
;; Remove nth element of a list
;; (defun remove-nth-element (nth list)
;; (if (zerop nth) (cdr list)
;; (let ((last (nthcdr (1- nth) list)))
;; (setcdr last (cddr last))
;; list)))
;; Remove first tab separator
;; (advice-add 'tab-bar-make-keymap-1 :around
;; (lambda (orig-fun)
;; (remove-nth-element 2 (funcall orig-fun))))
;; Remove first tab separator (alternative)
(advice-add 'tab-bar-make-keymap-1 :around
(lambda (orig-fun)
(let ((l (funcall orig-fun)))
(delq (setcar (nthcdr 2 l) (cons nil nil)) l))))
;; Custom keybinds
(global-set-key (kbd "C-S-d") 'crux-duplicate-current-line-or-region)
(global-set-key (kbd "C-x t <right>") 'tab-next)
(global-set-key (kbd "C-x t <left>") 'tab-previous)
;; Aliases
(defalias 'counsel-kill-ring 'counsel-yank-pop)
;; Experimental stuff
;; Highlight parens when inside
(define-advice show-paren-function (:around (fn) fix)
"Highlight enclosing parens."
(cond ((looking-at-p "\\s(") (funcall fn))
(t (save-excursion
(ignore-errors (backward-up-list))
(funcall fn)))))
;; Custom keybindings
;;(define-key company-mode-map (kbd "<tab>") 'company-complete)
;; Disable suspend-frame keybind
(global-unset-key (kbd "C-z"))
;; Automatically wrap isearch
;; Prevents issue where you have to press backspace twice when
;; trying to remove the first character that fails a search
(define-key isearch-mode-map [remap isearch-delete-char] 'isearch-del-char)
(defadvice isearch-search (after isearch-no-fail activate)
(unless isearch-success
(ad-disable-advice 'isearch-search 'after 'isearch-no-fail)
(ad-activate 'isearch-search)
(isearch-repeat (if isearch-forward 'forward))
(ad-enable-advice 'isearch-search 'after 'isearch-no-fail)
(ad-activate 'isearch-search)))
;; Prevent spell checking tags/attributes
(defun web-mode-flyspell-verify ()
(let ((f (get-text-property (- (point) 1) 'face))
rlt)
(cond
((not (memq f '(web-mode-html-attr-value-face
web-mode-html-tag-face
web-mode-html-attr-name-face
web-mode-constant-face
web-mode-doctype-face
web-mode-keyword-face
web-mode-comment-face ;; focus on get html label right
web-mode-function-name-face
web-mode-variable-name-face
web-mode-css-property-name-face
web-mode-css-selector-face
web-mode-css-color-face
web-mode-type-face
web-mode-block-control-face
)
))
(setq rlt t))
((memq f '(web-mode-html-attr-value-face))
(save-excursion
(search-backward-regexp "=['\"]" (line-beginning-position) t)
(backward-char)
(setq rlt (string= (thing-at-point 'word) "value"))
))
(t t))
rlt
))
(put 'web-mode 'flyspell-mode-predicate 'web-mode-flyspell-verify)
;; (defun set-exec-path-from-shell-PATH ()
;; "Set up Emacs' `exec-path' and PATH environment variable to match
;; that used by the user's shell.
;; This is particularly useful under Mac OS X and macOS, where GUI
;; apps are not started from a shell."
;; (interactive)
;; (let ((path-from-shell (replace-regexp-in-string
;; "[ \t\n]*$" "" (shell-command-to-string
;; "$SHELL --login -c 'echo $PATH'"
;; ))))
;; (setenv "PATH" path-from-shell)
;; (setq exec-path (split-string path-from-shell path-separator))))
;; (set-exec-path-from-shell-PATH)
;; Org-mode src-block js fix
(with-eval-after-load 'org
(setq org-babel-js-function-wrapper
"process.stdout.write(require('util').inspect(function(){\n%s\n}(), { maxArrayLength: null, maxStringLength: null, breakLength: Infinity, compact: true }))"))
;; Disable Ctrl+tab and C-S-<arrow> org-mode
(with-eval-after-load 'org
(define-key org-mode-map (kbd "C-<tab>") nil)
(define-key org-mode-map (kbd "C-S-<up>") nil)
(define-key org-mode-map (kbd "C-S-<right>") nil)
(define-key org-mode-map (kbd "C-S-<down>") nil)
(define-key org-mode-map (kbd "C-S-<left>") nil))
;; Disable Ctrl+tab magit-status, process
(with-eval-after-load 'magit-status
(define-key magit-status-mode-map (kbd "C-<tab>") nil))
(with-eval-after-load 'magit-process
(define-key magit-process-mode-map (kbd "C-<tab>") nil))
;; Org-mode custom keybindings
(with-eval-after-load 'org-agenda (define-key org-agenda-mode-map (kbd "C-t") 'org-agenda-todo-yesterday))
;; PlantUML server fix (https://github.com/skuro/plantuml-mode/issues/146#issuecomment-1045289734)
(with-eval-after-load 'plantuml-mode
(defun hex-encode (str)
(string-join (mapcar (lambda (c) (format "%02x" c)) (string-as-unibyte str))))
(defun plantuml-server-encode-url (string)
"Encode the string STRING into a URL suitable for PlantUML server interactions."
(let* ((encoded-string (hex-encode string)))
(concat plantuml-server-url "/" plantuml-output-type "/~h" encoded-string))))
;; experimental templating handling
(defun templates/plantuml ()
(interactive)
(yas-expand-snippet (yas-lookup-snippet "PlantUML" 'plantuml-mode)))
(setq auto-insert-query nil)
(auto-insert-mode 1)
(add-hook 'find-file-hook 'auto-insert)
(setq auto-insert-alist nil) ;; remove this like to restore defaults
(add-to-list 'auto-insert-alist '(".*\\.plantuml$" . [templates/plantuml]))
;; utilities
(defun sort-words (reverse beg end)
"Sort words in region alphabetically, in REVERSE if negative.
Prefixed with negative \\[universal-argument], sorts in reverse.
The variable `sort-fold-case' determines whether alphabetic case
affects the sort order.
See `sort-regexp-fields'."
(interactive "*P\nr")
(sort-regexp-fields reverse "\\w+" "\\&" beg end))
(defun sort-symbols (reverse beg end)
"Sort symbols in region alphabetically, in REVERSE if negative.
See `sort-words'."
(interactive "*P\nr")
(sort-regexp-fields reverse "\\(\\sw\\|\\s_\\)+" "\\&" beg end))
(defun execute-last-line-as-shell-command (&optional arg)
"Excute last previous non-empty line as a shell command. Prefix to insert the output to the current buffer."
(interactive "P")
(shell-command
(save-excursion
(goto-char (line-beginning-position))
(beginning-of-line)
(while
(and
(not (bobp))
(string-blank-p
(buffer-substring-no-properties (line-beginning-position) (line-end-position))))
(forward-line -1))
(buffer-substring-no-properties (line-beginning-position) (line-end-position))) (when arg (current-buffer))))
(defun execute-region-as-shell-command (beg end &optional arg)
"Execute selected region as a shell command. Prefix to insert the output to the current buffer."
(interactive "r\nP")
(shell-command (buffer-substring beg end)
(when arg (current-buffer))))
(defun increase-default-face-height ()
"Increase default face height."
(interactive)
(set-face-attribute 'default nil :height (+ 20 (face-attribute 'default :height))))
(defun decrease-default-face-height ()
"Decrease the default face height."
(interactive)
(set-face-attribute 'default nil :height (- (face-attribute 'default :height) 20)))
(define-minor-mode sharing-screen-mode
"Sharing screen minor mode."
:lighter " ss"
:global
(if sharing-screen-mode
(funcall 'increase-default-face-height)
(funcall 'decrease-default-face-height)))
(defun scratch ()
"Create and switch to a temporary scratch buffer."
(interactive)
(switch-to-buffer (generate-new-buffer-name "*scratch*"))
(org-mode))
(defun bash ()
"Run ansi-term with bash shell."
(interactive)
(ansi-term "/bin/bash" default-directory)
(add-hook 'after-change-functions
(lambda (_ _ _) (rename-buffer (format "*term: %s*" default-directory) t)) nil t))
;; (defun rename-buffer-to-default-directory ()
;; (add-hook 'after-change-functions
;; (lambda (_ _ _) (rename-buffer (format "*term: %s*" default-directory) t)) nil t))
;; (add-hook 'term-mode-hook 'rename-buffer-to-default-directory)
(defun cleanup-whitespace-git-modified-files ()
"Cleanup whitespaces and empty lines of git modified files."
(interactive)
(mapcar (lambda (file)
(with-current-buffer (find-file file)
(save-excursion
(goto-char (point-min))
(replace-regexp "^\n$" "" nil (point-min) (point-max))
(delete-trailing-whitespace)
(goto-char (point-min))
(delete-blank-lines)
(save-buffer))))
(magit-modified-files)))
(defun generate-uuid (&optional arg)
"Generates a uuid using the uuidgen tool."
(interactive "P")
(shell-command "uuidgen" (when arg t)))
(defun json-stringify-region ()
(interactive)
(if (region-active-p)
(shell-command-on-region
(region-beginning) (region-end)
(format "node -e 'console.log(JSON.stringify(%s))'"
(buffer-substring (region-beginning) (region-end)))
(current-buffer) t) (message "No active region."))
)
(defun json-stringify-prettify-region (beg end)
(interactive "r")
(unless (region-active-p) (error "No active region."))
(replace-string
(buffer-substring-no-properties beg end)
(let ((output
(shell-command-to-string
(format "node -e 'console.log(JSON.stringify(%s))' " (buffer-substring beg end)))))
(let ((temp-buffer-string (with-temp-buffer
(insert output)
(json-pretty-print-buffer)
(buffer-string))))
temp-buffer-string)
) nil beg end)
)
;; (add-hook 'emacs-startup-hook #'global-jinx-mode)
(global-set-key (kbd "C-M-$") #'jinx-correct)
;; (keymap-global-set "C-M-$" #'jinx-correct)
;; (keymap-global-set "C-M-$" #'jinx-languages)
;; https://200ok.ch/posts/2020-08-22_setting_up_spell_checking_with_multiple_dictionaries.html
(with-eval-after-load "ispell"
;; Configure `LANG`, otherwise ispell.el cannot find a 'default
;; dictionary' even though multiple dictionaries will be configured
;; in next line.
;; (setenv "LANG" "en_US.UTF-8")
(setq ispell-program-name "hunspell")
(setq ispell-dictionary "pt_BR,en_GB,en_US")
;; ispell-set-spellchecker-params has to be called
;; before ispell-hunspell-add-multi-dic will work
(ispell-set-spellchecker-params)
(ispell-hunspell-add-multi-dic "pt_BR,en_GB,en_US"))
;; For saving words to the personal dictionary, don't infer it from
;; the locale, otherwise it would save to ~/.hunspell_de_DE.
;; (setq ispell-personal-dictionary "~/.hunspell_personal"))
(defun downcase-char (arg)
"Downcasify ARG chars starting from point. Point doesn't move."
(interactive "p")
(save-excursion
(downcase-region (point) (progn (forward-char arg) (point)))))
(defun downcase-initial (string)
"Downcase initial character of the string."
(and (stringp string) (not (string= "" string))
(concat (downcase (substring string 0 1)) (substring string 1))))
(defun downcase-initials (string)
"Upcase the initial of each word in the string."
(mapcar #'downcase-initial (split-string string "[^[:alpha:]]")))
(defun downcase-initials-region (beg end)
"Upcase the initial of each word in the region."
(interactive "r")
(let ((region (buffer-substring-no-properties beg end)))
(delete-region beg end)
(insert (downcase region))))
;; exec-path-sync
(when (memq window-system '(mac ns x))
(exec-path-from-shell-initialize))
;; html preview helpers
(defun browse-url-of-buffer-in-eww (&optional buffer)
"Use `eww' to `browse-url-of-buffer'."
(interactive)
(let ((browse-url-browser-function 'eww-browse-url))
(browse-url-of-buffer buffer)))
;;
(defun render-html-from-current-buffer ()
(interactive)
(shr-render-buffer (current-buffer)))
(defun render-html-replace-buffer ()
(interactive)
(eww-display-html 'utf-8 (buffer-name) nil (point-min) (current-buffer)))
(require 'org-crypt)
(org-crypt-use-before-save-magic)
(setq org-tags-exclude-from-inheritance (quote ("crypt")))
;; GPG key to use for encryption
;; Either the Key ID or set to nil to use symmetric encryption.
;; (setq org-crypt-key nil)