-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathdot_spacemacs
1204 lines (1072 loc) · 51.3 KB
/
dot_spacemacs
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
;; Configuration layers
;; --------------------
(defun dotspacemacs/layers ()
(setq-default
;; If non-nil then Spacelpa repository is the primary source to install
;; a locked version of packages. If nil then Spacemacs will install the lastest
;; version of packages from MELPA. (default nil)
dotspacemacs-use-spacelpa nil
dotspacemacs-auto-resume-layouts nil
dotspacemacs-delete-orphan-packages t
dotspacemacs-distribution 'spacemacs
;; If non-nil then Spacemacs will ask for confirmation before installing
;; a layer lazily. (default t)
dotspacemacs-ask-for-lazy-installation nil
dotspacemacs-configuration-layers
'(docker
github-copilot
(llm-client :variables
llm-client-enable-gptel t)
sql
(spacemacs-layouts
:variables
spacemacs-layouts-restrict-spc-tab t
persp-autokill-buffer-on-remove t)
terraform
;; (elfeed :variables
;; rmh-elfeed-org-files (list "~/notes/main-elfeed.org")
;; elfeed-enable-web-interface t
;; )
(clojure :variables
clojure-backend 'cider
clojure-enable-clj-refactor t
clojure-enable-linters 'clj-kondo
clojure-enable-fancify-symbols t
clojure-backend 'cider)
;; (rust :variables rust-format-on-save t)
(deft :variables deft-extensions '("org" "md" "txt"))
(ivy :variables
ivy-enable-advanced-buffer-information t
ivy-enable-icons nil)
nixos
helpful
;; semantic
neotree
;; csv
graphviz
;; (go :variables
;; go-backend 'lsp
;; ;; go-backend 'go-mode
;; go-format-before-save t
;; go-tab-width 4
;; )
(auto-completion :variables
company-minimum-prefix-length 1
company-idle-delay 0.8
company-quickhelp-delay 0.8
auto-completion-minimum-prefix-length 1
auto-completion-enable-help-tooltip t
auto-completion-return-key-behavior 'complete
auto-completion-private-snippets-directory nil
auto-completion-enable-snippets-in-popup t
auto-completion-tab-key-behavior 'cycle
auto-completion-complete-with-key-sequence-delay 0.1
:disabled-for org)
;; It slows down the navigation in the buffer
;; https://github.com/turnspike/spacemacs-spaceline
;; (spacemacs-spaceline :location local)
emacs-lisp
(git :variables
;; tell Magit to only automatically refresh the current Magit buffer,
;; but not the status buffer. If you do that, then the status buffer is only
;; refreshed automatically if it is the current buffer.
;; https://magit.vc/manual/magit/Performance.html#Performance
magit-diff-highlight-indentation nil
magit-diff-highlight-trailing nil
magit-diff-highlight-hunk-body nil
magit-diff-refine-hunk nil
magit-refresh-status-buffer t
;; start with cursor on head section
magit-status-initial-section nil
;; to see only 2-panes in the diff-window instead of 3
magit-ediff-dwim-show-on-hunks t
;; to see the diff by words not whole lines
magit-diff-refine-hunk nil
)
;; gtags
html
(lsp :variables
;; https://emacs-lsp.github.io/lsp-mode/tutorials/how-to-turn-off/
lsp-headerline-breadcrumb-enable t
lsp-enable-file-watchers nil
lsp-enable-symbol-highlighting t
lsp-ui-doc-enable t
lsp-navigation 'peek
lsp-modeline-code-actions-enable t
lsp-modeline-diagnostics-enable nil
lsp-modeline-code-actions-segments t
lsp-use-lsp-ui t
lsp-lens-enable t
lsp-auto-guess-root t
lsp-log-io nil
lsp-restart 'auto-restart
lsp-keep-workspace-alive t
lsp-enable-on-type-formatting nil
lsp-signature-auto-activate nil
lsp-signature-render-documentation nil
lsp-eldoc-hook nil
lsp-semantic-tokens-enable nil
lsp-enable-folding nil
lsp-disabled-clients '(semgrep-ls)
;; (https://github.com/emacs-lsp/lsp-pyright/issues/69#issuecomment-1432999642)
read-process-output-max (* 1024 1024) ;; 1MB
lsp-idle-delay 1.5
)
(markdown :variables
markdown-live-preview-engine 'vmd)
;; (dart :variables
;; dart-backend 'lsp
;; lsp-enable-on-type-formatting t
;; lsp-dart-sdk-dir (expand-file-name "~/proj/flutter/bin/cache/dart-sdk/")
;; )
;; nginx
(org :variables
;; Select headings up 10 level as candiates for org-refile command. It applies to all the headings in the same file.
org-refile-targets '((nil :maxlevel . 10))
org-download-method 'attach
org-download-timestamp t
org-enable-bootstrap-support t
org-startup-indented t
org-hide-emphasis-markers t
org-cycle-separator-lines -2
org-fontify-whole-heading-lines t
org-blank-before-new-entry '(
(heading . nil)
(plain-list-item . nil))
org-export-babel-evaluate nil
org-src-preserve-indentation t
org-log-done (quote time)
org-log-into-drawer t
org-log-state-notes-insert-after-drawers nil
org-hide-emphasis-markers t
;; Syntax highlighting in #+BEGIN_SRC blocks
org-src-fontify-natively t
;; Don't prompt before running code in org
org-confirm-babel-evaluate nil
org-capture-templates
'(("t" "Todo" entry (file+headline "~/gsync-docs/today.org" "Tasks")
"* TODO %?\n %i\n %a")
("w" "Work Journal" entry (file+datetree "~/Documents/work.org")
"* %?\nEntered on %U\n %i\n %a")
("j" "Journal" entry (file+datetree "~/gsync-docs/today.org")
"* %?\nEntered on %U\n %i\n %a"))
)
;; ocaml
(osx :variables
mac-system-move-file-to-trash-use-finder nil)
;; dap
(python :variables
lsp-python-ms-python-executable "python3"
python-interpreter "python3"
python-shell-interpreter "python3"
;; no need to guess identation
python-indent-guess-indent-offset t
python-guess-indent nil
python-backend 'anaconda
;; python-lsp-server 'pyright
lsp-pyright-multi-root nil
python-fill-docstring-style 'pep-257-nn
python-fill-column 88
python-test-runner 'pytest
python-format-on-save t
python-formatter 'black
python-auto-set-local-pyvenv-virtualenv 'on-project-switch
python-indent-offset 4
lsp-enable-snippet t
lsp-prefer-flymake nil
)
(shell :variables
shell-default-height 48
shell-default-position 'bottom
shell-default-term-shell "bash"
;; shell-default-shell 'vterm
)
(spell-checking :variables
spell-checking-enable-auto-dictionary nil
enable-flyspell-auto-completion nil
spell-checking-enable-by-default nil
;; ispell-program-name "aspell"
;; ispell-dictionary "british"
)
restclient
react
(typescript :variables
typescript-linter 'tslint
typescript-fmt-tool 'prettier
typescript-fmt-on-save t
;; typescript-backend 'tide
typescript-backend 'lsp
)
(java :variables java-backend 'lsp
lsp-enable-indentation t
lsp-java-import-maven-enabled t
lsp-java-maven-download-sources t
lsp-java-boot-lens-mode t
lsp-java-vmargs
(list "-Xms1000m"
"-noverify"
"--enable-preview"
"-Dlog.protocol=true"
"-Dlog.level=DEBUG"
"-Xmx4G"
"-XX:+UnlockExperimentalVMOptions"
"-XX:+UseZGC"
"-XX:+UseStringDeduplication"
"-XX:AdaptiveSizePolicyWeight=90"
"-Dsun.zip.disableMemoryMapping=true"
(format "-javaagent:%s/.gradle/caches/modules-2/files-2.1/org.projectlombok/lombok/1.18.22//9c08ea24c6eb714e2d6170e8122c069a0ba9aacf/lombok-1.18.22.jar" (expand-file-name "~"))
;; (format "-Xbootclasspath/a:%s/.gradle/caches/modules-2/files-2.1/org.projectlombok/lombok/1.18.24/13a394eed5c4f9efb2a6d956e2086f1d81e857d9/lombok-1.18.24.jar" (expand-file-name "~"))
)
)
(javascript :variables
javascript-backend 'tide
javascript-lsp-linter nil
javascript-fmt-tool 'prettier
javascript-repl 'nodejs)
;; (version-control :variables
;; ;; diff-hl is slow
;; ;; version-control-diff-tool 'diff-hl
;; git-magit-status-fullscreen t)
yaml
)
;; Defines the behaviour of Spacemacs when installing packages.
;; Possible values are `used-only', `used-but-keep-unused' and `all'.
;; `used-only' installs only explicitly used packages and uninstall any
;; unused packages as well as their unused dependencies.
;; `used-but-keep-unused' installs only the used packages but won't uninstall
;; them if they become unused. `all' installs *all* packages supported by
;; Spacemacs and never uninstall them. (default is `used-only')
dotspacemacs-install-packages 'used-but-keep-unused
dotspacemacs-additional-packages `(
multi-web-mode
atomic-chrome
dumber-jump
highlight-indent-guides
edit-server
nerd-icons
org-ai
reformatter
direnv
blacken
igist
ef-themes
;; to fix the editor issue when commiting
;; git-commit
;; call all-the-icons-install-fonts to install the fonts on the system
;; all-the-icons
poetry
;; protobuf-mode
;; eval-sexp-fu
virtualenvwrapper
ob-restclient
ob-graphql
;; allows to not block on org source-block
;; execution
ob-async
reverso
;; writegood-mode requires configuration
powerthesaurus
;; run tests in TS and TSX
jest-test-mode
;; access clipboard in OSX
pbcopy
;; (robot-framework :location (recipe
;; :fetcher github
;; :repo "dalanicolai/robot-framework-layer"))
)
dotspacemacs-excluded-packages `(
json-navigator
;; ;; use highlight-indent-guides instead
;; highlight-indentation
;; inspector
;; importmagic
;; auto-highlight-symbol
;; org-plus-contrib
;; evil-search-highlight-persist
;; eval-sexp-fu
;; info+
;; ;; smooth-scrolling
;; rainbow-delimiters
;; ;; not needed functionality
;; pip-requirements
;; pippel
;; ;; I don't really need them
;; define-word
;; fancy-battery
;; ;; git-gutter
;; git-gutter+
;; git-gutter-fringe
;; git-gutter-fringe+
;; ;; https://github.com/syl20bnr/spacemacs/issues/9124
;; ;; it's not possible to change the compile buffer position
;; ;; and it works perfect now with pytest compilation window
;; window-purpose
;; ;; not using it
;; forge
)
) ;; setq
)
(defun dotspacemacs/init ()
"Initialization function.
This function is called at the very startup of Spacemacs initialization
before layers configuration."
(setq-default
spacemacs-theme-comment-italic t
spacemacs-theme-keyword-italic t
dotspacemacs-folding-method 'origami
dotspacemacs-mode-line-theme 'doom
dotspacemacs-mode-line-unicode-symbols t
dotspacemacs-highlight-delimiters 'nil
display-line-numbers-width 3
dotspacemacs-line-numbers '(
:relative nil
:visual t
:enabled-for-modes python-mode typescript-mode markdown-mode org-mode typescript-tsx-mode
:size-limit-kb 1000)
;; True if the home buffer should respond to resize events. (default t)
dotspacemacs-startup-buffer-responsive t
;; exec-path-from-shell-arguments '("-l")
dotspacemacs-elpa-https t
dotspacemacs-elpa-timeout 5
;; If non nil then spacemacs will check for updates at startup
;; when the current branch is not `develop'. (default t)
dotspacemacs-check-for-update nil
dotspacemacs-editing-style 'vim
;; If non nil output loading progress in `*Messages*' buffer. (default nil)
dotspacemacs-verbose-loading nil
dotspacemacs-themes (if (display-graphic-p) '(modus-operandi-tinted spacemacs-light) '(modus-operandi-tinted ef-reverie leuven wheatgrass tango))
;; If non nil the cursor color matches the state color.
dotspacemacs-colorize-cursor-according-to-state t
;; Location where to auto-save files. Possible values are `original' to
;; auto-save the file in-place, `cache' to auto-save the file to another
;; file stored in the cache directory and `nil' to disable auto-saving.
;; (default 'cache)
dotspacemacs-auto-save-file-location 'cache
;; Maximum number of rollback slots to keep in the cache. (default 5)
dotspacemacs-max-rollback-slots 5
;; Size (in MB) above which spacemacs will prompt to open the large file
;; literally to avoid performance issues. Opening a file literally means that
;; no major mode or minor modes are active. (default is 1)
dotspacemacs-large-file-size 1
;; dotspacemacs-default-font '("Go Mono" :size 14)
;; dotspacemacs-default-font '("Inconsolata" :size 16)
;; dotspacemacs-default-font '("Cascadia Code Light" :size 12)
;; dotspacemacs-default-font '("Monaco" :size 12)
dotspacemacs-leader-key ","
dotspacemacs-emacs-leader-key "M-m"
dotspacemacs-major-mode-leader-key "SPC"
dotspacemacs-major-mode-emacs-leader-key "C-M-m"
dotspacemacs-command-key ":"
dotspacemacs-remap-Y-to-y$ t
dotspacemacs-use-ido nil
history-delete-duplicates t
;; Which-key delay in seconds. The which-key buffer is the popup listing
;; the commands bound to the current keystroke sequence. (default 0.4)
dotspacemacs-which-key-delay 0.4
;; If non-nil `spacemacs/toggle-fullscreen' will not use native fullscreen.
;; Use to disable fullscreen animations in OSX. (default nil)
dotspacemacs-fullscreen-use-non-native nil
;; If non-nil smooth scrolling (native-scrolling) is enabled. Smooth
;; scrolling overrides the default behavior of Emacs which recenters point
;; when it reaches the top or bottom of the screen. (default t)
dotspacemacs-smooth-scrolling t
truncate-lines -1
dotspacemacs-search-tools '("rg" "ag" "grep")
;; Format specification for setting the frame title.
;; %a - the `abbreviated-file-name', or `buffer-name'
;; %t - `projectile-project-name'
;; %I - `invocation-name'
;; %S - `system-name'
;; %U - contents of $USER
;; %b - buffer name
;; %f - visited file name
;; %F - frame name
;; %s - process status
;; %p - percent of buffer above top of window, or Top, Bot or All
;; %P - percent of buffer above bottom of window, perhaps plus Top, or Bot or All
;; %m - mode name
;; %n - Narrow if appropriate
;; %z - mnemonics of buffer, terminal, and keyboard coding systems
;; %Z - like %z, but including the end-of-line format
;; (default "%I@%S")
dotspacemacs-frame-title-format "%b @ %t"
))
(defun dotspacemacs/user-init ()
;; just in case if custom theme is added
(add-to-list 'custom-theme-load-path "~/.emacs.d/private/local/")
(setq-default
spell-checking-enable-by-default nil
;; Increase minimum severity level for displaying the warning buffer.
;; It's an alternative way to supress warnings buffer to disabling warnings and errors from
;; asynchronous native compilation.
;; native-comp-async-report-warnings-errors nil
;; See https://www.reddit.com/r/emacs/comments/l42oep/suppress_nativecomp_warnings_buffer/
warning-minimum-level :error
;; Increase space between the lines
line-spacing 7
;; Miscellaneous
require-final-newline t
x-select-enable-clipboard t
undo-tree-auto-save-history nil
;; Backups
backup-directory-alist `((".*" . ,temporary-file-directory))
auto-save-file-name-transforms `((".*" ,temporary-file-directory t))
backup-by-copying nil
delete-old-versions t
kept-new-versions 6
kept-old-versions 2
make-backup-files nil
;; Evil
evil-shift-round nil
evil-want-C-i-jump nil
;; do not put replaced text in clipboard
evil-kill-on-visual-paste nil
;; Whitespace mode
whitespace-style '(face tabs tab-mark newline-mark)
whitespace-display-mappings
'((newline-mark 10 [172 10])
(tab-mark 9 [9655 9]))
;; Wait 0.5seconds before automatically highlitghting
ahs-idle-interval 0.5
;; Avy
avy-all-windows 'all-frames
;; Flycheck
flycheck-check-syntax-automatically '(save mode-enabled)
;; simple mode line
mode-line-format (list
;; %p percent of buffer above top of window
"%p > "
;; position line:column
"%l:%c > "
;; buffer name
"[ %b ] "
;; name of major mode
"%m| "
;; buffer size - auto-scaled
"size %I |"
"%-"
)
))
(defun dotspacemacs/user-config ()
"Configuration function.
This function is called at the very end of Spacemacs initialization after
layers configuration."
;; ;; function from pbcopy package to manage clipboard when running in Terminal
;; (if (and (spacemacs/system-is-mac) (not (display-graphic-p)))
;; (turn-on-pbcopy))
(setq editorconfig-exclude-modes '(org-mode))
(setq show-paren-style 'expression)
;; configure denote
(setq
denote-directory (expand-file-name "~/notes")
denote-known-keywords '("emacs" "denote" "testing")
)
;; Ghost text
(setq atomic-chrome-url-major-mode-alist
'(("github\\.com" . gfm-mode)
("hackerrank\\.com" . python-mode)
("leetcode\\.com" . python-mode)
("redmine" . textile-mode)))
;; org-ai
(setq org-ai-default-chat-model "gpt-4o-mini")
(let* ((variable-tuple (cond ((x-list-fonts "Monaco") '(:font "Monaco"))
((x-list-fonts "Lucida Grande") '(:font "Lucida Grande"))
((x-list-fonts "Verdana") '(:font "Verdana"))
((x-family-fonts "Sans Serif") '(:family "Sans Serif"))
(nil (warn "Cannot find Monaco. Install Monaco."))))
(base-font-color (face-foreground 'default nil 'default))
(headline `(:inherit default :weight bold :foreground ,base-font-color)))
(custom-theme-set-faces 'user
`(org-level-8 ((t (,@headline ,@variable-tuple))))
`(org-level-7 ((t (,@headline ,@variable-tuple))))
`(org-level-6 ((t (,@headline ,@variable-tuple))))
`(org-level-5 ((t (,@headline ,@variable-tuple))))
`(org-level-4 ((t (,@headline ,@variable-tuple :height 1.1))))
`(org-level-3 ((t (,@headline ,@variable-tuple :height 1.25))))
`(org-level-2 ((t (,@headline ,@variable-tuple :height 1.5))))
`(org-level-1 ((t (,@headline ,@variable-tuple :height 1.75))))
`(org-document-title ((t (,@headline ,@variable-tuple :height 2.0 :underline nil))))))
(custom-theme-set-faces
'user
'(org-block ((t (:inherit fixed-pitch))))
'(org-code ((t (:inherit (shadow fixed-pitch)))))
'(org-document-info ((t (:foreground "dark orange"))))
'(org-document-info-keyword ((t (:inherit (shadow fixed-pitch)))))
'(org-indent ((t (:inherit (org-hide fixed-pitch)))))
'(org-link ((t (:foreground "royal blue" :underline t))))
'(org-meta-line ((t (:inherit (font-lock-comment-face fixed-pitch)))))
'(org-property-value ((t (:inherit fixed-pitch))) t)
'(org-special-keyword ((t (:inherit (font-lock-comment-face fixed-pitch)))))
'(org-table ((t (:inherit fixed-pitch :foreground "#83a598"))))
'(org-tag ((t (:inherit (shadow fixed-pitch) :weight bold :height 0.8))))
'(org-verbatim ((t (:inherit (shadow fixed-pitch))))))
;; --------- copilot
;; accept completion from copilot and fallback to company
(with-eval-after-load 'company
;; disable inline previews
(delq 'company-preview-if-just-one-frontend company-frontends))
(with-eval-after-load 'copilot
(define-key copilot-completion-map (kbd "<tab>") 'copilot-accept-completion)
(define-key copilot-completion-map (kbd "TAB") 'copilot-accept-completion)
(define-key copilot-completion-map (kbd "C-TAB") 'copilot-accept-completion-by-word)
(define-key copilot-completion-map (kbd "C-<tab>") 'copilot-accept-completion-by-word))
;; (add-hook 'prog-mode-hook 'copilot-mode)
(direnv-mode)
(config-visuals)
;; scrolling configuration
(setq
scroll-conservatively 1000
maximum-scroll-margin 0.5
scroll-margin 10
truncate-partial-width-windows nil
)
;; https://github.com/emacsorphanage/popwin
(push '(compilation-mode :noselect t :position bottom) popwin:special-display-config)
(setq use-dialog-box nil)
(setq sp/deft/dir-list '("~/notes"))
(setq deft-directory "~/notes")
;; pytest
;; (add-to-list 'pytest-project-root-files "pyproject.toml")
;; (add-to-list 'spacemacs-default-jump-handlers 'dumb-jump-go)
;; (add-hook 'xref-backend-functions #'dumb-jump-xref-activate)
(add-hook 'xref-backend-functions #'dumber-jump-xref-activate)
;; hugo
;; note: tailing slash is important
(setq easy-hugo-basedir "~/proj/signalpillar.github.io/")
(setq easy-hugo-url "https://signalpillar.github.io")
(setq easy-hugo-postdir "content/posts")
;; for any theme I wan to be able to see the borders of the windows.
(set-frame-parameter (selected-frame) 'internal-border-width 15)
;; [[https://github.com/gboncoffee/emacs][gboncoffee/emacs: My Emacs configuration]]
(set-frame-parameter (selected-frame) 'alpha-background 90)
(add-to-list 'default-frame-alist '(alpha-background . 90))
(fset 'evil-visual-update-x-selection 'ignore)
;; ui
;; https://news.ycombinator.com/item?id=17172524
(add-to-list 'default-frame-alist '(ns-transparent-titlebar . t))
(add-to-list 'default-frame-alist '(ns-appearance . light))
;; Neotree
(with-eval-after-load 'neotree
(add-to-list 'neo-hidden-regexp-list "TAGS$")
(add-to-list 'neo-hidden-regexp-list "__pycache__")
)
;; Enable custom neotree theme
(require 'nerd-icons)
(setq nerd-icons-font-family "JetBrainsMono Nerd Font")
(setq neo-theme 'nerd-icons)
(evil-leader/set-key "of" 'neotree-find)
(defun jao-toggle-selective-display ()
(interactive)
(set-selective-display (if selective-display nil 1)))
(global-set-key [f3] 'jao-toggle-selective-display)
(global-set-key [f4] 'sp/tox/activate-current-project-tox-env)
(global-set-key [f5] 'sp/org-insert-clipboard-image)
(global-set-key [f6] 'sp/insert-fortune-cookie)
(global-set-key [f2] 'sp/org/add-note-to-last-clocked)
;; candidate for ,a(pplication)s(end)r(egion)
;; C-r C-r doesn't work in org-mode
(spacemacs/set-leader-keys "xsr" 'tws-region-to-process)
(defun os-open (path &optional link)
"Open the path with OS specific command"
(shell-command (format "open %s" path)))
;; (add-to-list 'org-file-apps '("\\.jpeg\\'" . os-open))
;; measured in bytes
;; https://www.reddit.com/r/emacs/comments/yzb77m/an_easy_trick_i_found_to_improve_emacs_startup/
;; (defun config:defer-gc ()
;; (setq gc-cons-threshold most-positive-fixnum))
;; (defun config:-do-restore-gc ()
;; (setq gc-cons-threshold 16777216))
;; (defun config:restore-gc ()
;; (run-at-time 1 nil #'config:-do-restore-gc))
(add-hook 'minibuffer-setup #'config:defer-gc)
(add-hook 'minibuffer-exit #'config:restore-gc)
;; tmpdir --------
(defconst emacs-tmp-dir (expand-file-name (format "emacs%d" (user-uid)) temporary-file-directory))
(setq backup-directory-alist
`((".*" . ,emacs-tmp-dir)))
(setq auto-save-file-name-transforms
`((".*" ,emacs-tmp-dir t)))
(setq auto-save-list-file-prefix
emacs-tmp-dir)
;; tmpdir --------
(setq-default
powerline-default-separator 'alternate
guide-key/popup-window-position :right
)
(set-fill-column 100)
(global-set-key (kbd "C-=") 'zoom-frm-in)
(global-set-key (kbd "C--") 'zoom-frm-out)
(setq clojure-enable-fancify-symbols t)
;; disable additional bindings so they aren't bound when the package loads
;; https://github.com/emacs-evil/evil-cleverparens/issues/58#issuecomment-717412151
(setq evil-cleverparens-use-additional-bindings nil)
(setq flycheck-display-errors-function 'flycheck-display-error-messages-unless-error-list)
;; lisp
(add-hook 'clojure-mode 'electric-pair-mode)
(add-hook 'clojure-mode 'rainbow-delimiters-mode)
;; (spacemacs/toggle-evil-safe-lisp-structural-editing-on-register-hooks)
;; Miscellaneous
(add-hook 'text-mode-hook 'auto-fill-mode)
(add-hook 'makefile-mode-hook 'whitespace-mode)
;; (add-hook 'python-mode-hook 'flycheck-mode)
(add-hook 'python-mode-hook 'flyspell-prog-mode)
(add-hook 'python-mode-hook 'electric-pair-mode)
(add-hook 'python-mode-hook 'auto-fill-mode)
(add-hook 'python-mode-hook 'blacken-mode)
(add-hook 'python-mode-hook #'(lambda () (modify-syntax-entry ?_ "w")))
(add-hook 'live-py-mode-hook (lambda ()
(progn
(setq-default live-py-version (executable-find "python"))
(live-py-update-all))))
;; [A trick to speed up projectile-find-file in a large monorepo - Emacs TIL](https://emacstil.com/til/2022/10/01/a-trick-to-speed-up-projectilefindfile-in-a-large-monorepo/)
(setq projectile-indexing-method 'alien)
(setq projectile-enable-caching t)
(setq
;; For example, project-find-file uses 'project-files which uses
;; substring completion by default. Set to nil to make sure it's using
;; flx.
completion-category-defaults nil
completion-category-overrides nil
)
;; .envrc files are setting now PYTHONPATH
;; (advice-add 'pyenv-mode-set
;; :after
;; (lambda (_) (setenv "PYTHONPATH" (format "%s/src" (projectile-project-root))))
;; )
;; Org attachment ID & path
;; [Org ID, Org Attach & Better Folder Names · The Art of Not Asking Why](https://helpdeskheadesk.net/2022-03-13/)
(setq org-id-method 'ts)
(setq org-attach-id-to-path-function-list
'(org-attach-id-ts-folder-format
org-attach-id-uuid-folder-format))
;; Org-babel
;; https://stackoverflow.com/questions/22888785/is-it-possible-to-get-org-mode-to-show-breadcrumbs-in-agenda-todo-list
;; https://blog.ryuslash.org/archives/2012/12/19/orgagendaprefixformat
(setq org-agenda-prefix-format '((agenda . "%-25:(sp/org/agenda/partial-breadcrumb) |")
(todo . " %i %-12:c")
(tags . " %i %-12:c")
(search . " %i %-12:c")))
(org-babel-do-load-languages
'org-babel-load-languages
'(
(async . t)
(plantuml . t)
(clojure . t)
(awk . t)
(dot . t)
(emacs-lisp . t)
(restclient . t)
(graphql . t)
(gnuplot . t)
(makefile . t)
(ocaml . t)
(js . t)
(org . t)
(perl . t)
(python . t)
(shell . t)
(sql . t)
(sqlite . t)))
;; Open only task sub-tree on org-agdenda-goto from agenda
;; https://emacs.stackexchange.com/questions/17797/how-to-narrow-to-subtree-in-org-agenda-follow-mode
(advice-add 'org-agenda-goto :after
(lambda (&rest args)
(org-narrow-to-subtree)))
;; Disable smartparens highlighting
(with-eval-after-load 'smartparens
(show-smartparens-global-mode -1))
;; https://gist.github.com/ftrain/8443721
;; enable visual feedback on selections
(setq transient-mark-mode t)
;; default to better frame titles
(setq frame-title-format
(concat "%b - emacs@" (system-name)))
;; default to unified diffs
(setq diff-switches "-u")
;; plantuml
(setq org-plantuml-jar-path (expand-file-name "~/bin/plantuml.jar"))
;; use the built-in emacs prompt for passphrase when using gpg
(setf epa-pinentry-mode 'loopback)
;; setup jest (test tool)
(dolist (major-mode '(typescript-mode js2-mode typescript-tsx-mode))
(spacemacs/set-leader-keys-for-major-mode major-mode
"tp" 'jest-test-run-all-tests
"ta" 'jest-test-rerun-test
"tn" 'jest-test-run
"tt" 'jest-test-run-at-point)
(spacemacs/declare-prefix-for-mode major-mode "mt" "test"))
(add-to-list 'auto-mode-alist '("\\.tsx\\'" . typescript-tsx-mode))
(setq open-junk-file-format "~/.tmp/%Y/%m/%d-%H%M%S.")
;; Add vale to the flycheck checkers
(flycheck-define-checker vale
"A checker for prose"
:command ("vale" "--output" "line"
source)
:standard-input nil
:error-patterns
((error line-start (file-name) ":" line ":" column ":" (id (one-or-more (not (any ":")))) ":" (message) line-end))
:modes (markdown-mode org-mode text-mode)
)
(add-to-list 'flycheck-checkers 'vale 'append)
)
;; [Send region to shell in another buffer - Emacs Stack Exchange](https://emacs.stackexchange.com/questions/37887/send-region-to-shell-in-another-buffer)
(defun tws-region-to-process (arg beg end)
"Send the current region to a process buffer.
The first time it's called, will prompt for the buffer to
send to. Subsequent calls send to the same buffer, unless a
prefix argument is used (C-u), or the buffer no longer has an
active process."
(interactive "P\nr")
(if (or arg ;; user asks for selection
(not (boundp 'tws-process-target)) ;; target not set
;; or target is not set to an active process:
(not (process-live-p (get-buffer-process
tws-process-target))))
(setq-local tws-process-target
(completing-read
"Process: "
(seq-map (lambda (el) (buffer-name (process-buffer el)))
(process-list)))))
;; [Emacs Shell mode: how to send region to shell? - Stack Overflow](https://stackoverflow.com/questions/6286579/emacs-shell-mode-how-to-send-region-to-shell)
;; (with-current-buffer tws-process-target
;; (goto-char (process-mark proc))
;; (insert command)
;; (move-marker (process-mark proc) (point))
;; )
(message "target %s beg %s end %s" tws-process-target beg end)
(process-send-string tws-process-target (format "%s\n"(buffer-substring beg end)))
)
(defun sp/auth-info-host-user (host)
"Find user for the host"
(plist-get (car (auth-source-search :max 1 :host host :require '(:user))) :user))
(defun sp/auth-info-host-password (host)
"Find password for the host"
(auth-info-password (car (auth-source-search :max 1 :host host :require '(:secret)))))
(defun sp/workflows/mark-git-branch-as-done (main-branch)
;; depends on magit
(interactive (list (read-string "Main branch: " "main")))
(let ((branch-to-delete (magit-get-current-branch)))
(magit-branch-checkout main-branch)
(call-interactively 'magit-branch-delete branch-to-delete)
(call-interactively 'magit-pull))
)
(defun config-visuals ()
;; https://stackoverflow.com/questions/7251784/how-do-i-adjust-the-left-margin-in-emacs-nox
(add-hook 'window-configuration-change-hook
(lambda ()
(set-window-margins nil 2 2)))
(spacemacs/toggle-highlight-current-line-globally-off)
(add-hook 'semantic-mode-hook 'sp/fight-stickyfunc)
;; [DarthFennec/highlight-indent-guides: Emacs minor mode to highlight indentation](https://github.com/DarthFennec/highlight-indent-guides)
;; (add-hook 'prog-mode-hook 'highlight-indent-guides-mode)
(setq-default highlight-indent-guides-method 'column)
;; (unless (display-graphic-p)
;; (set-background-color "ivory"))
)
;; copied from https://github.com/adamseyfarth/dotfiles/blob/70cd5f7d6961097926142af1e8c6c33b20eedfa2/spacemacs/.spacemacs#L344
(defun sp/fight-stickyfunc ()
"Do whatever it takes to disable semantic-stickyfunc-mode"
(with-eval-after-load 'semantic
(setq-default semantic-default-submodes
(remove 'global-semantic-stickyfunc-mode
semantic-default-submodes))
(spacemacs/toggle-semantic-stickyfunc-globally-off)))
(defun sp/deft/pick-dir ()
"Select directories from a list"
(interactive)
(setq deft-directory
(ido-completing-read "Select directory: " sp/deft/dir-list))
(deft-refresh))
(defun sp/path/parent-dir (dir)
(file-name-directory (directory-file-name dir)))
(defun sp/tox/find-tox-dirs-in-project (project-root-dir)
(defun -find-toxenv-bin-dirs (root)
(projectile-files-via-ext-command
root
(format "find %s -type d -name 'bin' -path '*/.tox/*/bin' -print0" root)))
(-map (lambda (file) (sp/path/parent-dir (sp/path/parent-dir file)))
(-find-toxenv-bin-dirs project-root-dir)))
(defun sp/tox/activate-tox-env-lsp ()
(interactive)
(call-interactively 'sp/tox/activate-current-project-tox-env)
(call-interactively 'lsp-workspace-restart)
)
(defun sp/poetry/activate-env-lsp ()
(interactive)
(call-interactively 'poetry-venv-workon)
(let ((python-exe (format "%s/bin/python" (poetry-get-virtualenv))))
;; (pytest.el) 'pytest-global-name', default value is py.test and it's used like
;; executable in compilation mode. That approach doesn't when pytest is
;; not installed globally and we need to use one from the virtual
;; environment.
;; We set this custom variable to run pytest with the venv python
;; interpreter.
(message "Activated python - %s" python-exe)
(setq lsp-pyright-venv-path (poetry-get-virtualenv))
(message "LPS pyright venv path: %s" lsp-pyright-venv-path)
(setq pytest-global-name (format "%s --module -m pytest" python-exe))
(pythonic-activate python-exe)
(setq lsp-python-ms-python-executable python-exe)
;; support for python.el.gz
(setq python-shell-process-environment
(list
(format "PATH=%s" (mapconcat
'identity
(reverse
(cons (getenv "PATH")
(list (format "%s/bin" lsp-pyright-venv-path))))
":"))
(format "VIRTUAL_ENV=%s" lsp-pyright-venv-path)))
(message "python shell process env: %s" python-shell-process-environment)
(call-interactively 'lsp-workspace-restart)
)
)
(defun sp/python/activate-current-project-venv ()
(interactive)
(progn
(call-interactively 'pyvenv-activate)
(message "Activated %s" python-shell-virtualenv-root)
(venv-set-location (file-name-directory (directory-file-name python-shell-virtualenv-root)))
(venv-workon)
(let ((python-exe (format "%s/bin/python3" python-shell-virtualenv-root)))
(message python-exe)
;; (pytest.el) 'pytest-global-name', default value is py.test and it's used like
;; executable in compilation mode. That approach doesn't when pytest is
;; not installed globally and we need to use one from the virtual
;; environment.
;; We set this custom variable to run pytest with the venv python
;; interpreter.
(setq pytest-global-name (format "%s -m pytest" python-exe))
(pythonic-activate python-exe)
(setq lsp-python-ms-python-executable python-exe)
)
(add-to-list 'python-shell-extra-pythonpaths (projectile-project-root))
(add-to-list 'python-shell-extra-pythonpaths (format "%s/src" (projectile-project-root)))
(lsp-restart-workspace)
)
)
(defun sp/tox/activate-current-project-tox-env ()
(interactive)
(let* (
(venv-dirs (sp/tox/find-tox-dirs-in-project (projectile-project-root)))
(venv-dirs-length (length venv-dirs)))
(progn
(venv-set-location
(if (> venv-dirs-length 1)
(helm-comp-read "Choose tox directory to workon" venv-dirs)
(if (= venv-dirs-length 0)
(error "The project doesn't have created tox virtual environments.")
(car venv-dirs))))
(venv-workon)
(let ((python-exe (format "%s/%s/bin/python3" venv-location venv-current-name)))
;; (pytest.el) 'pytest-global-name', default value is py.test and it's used like
;; executable in compilation mode. That approach doesn't when pytest is
;; not installed globally and we need to use one from the virtual
;; environment.
;; We set this custom variable to run pytest with the venv python
;; interpreter.
(setq pytest-global-name (format "%s -m pytest" python-exe))
(pythonic-activate python-exe)
(setq lsp-python-ms-python-executable python-exe)
)
(add-to-list 'python-shell-extra-pythonpaths (projectile-project-root))
(add-to-list 'python-shell-extra-pythonpaths (format "%s/src" (projectile-project-root))))))
(defun sp/org-insert-clipboard-image ()
(interactive)
;; Insert image from clipboard in the org-mode headline.
;; use org-id.el to get or craete ID property.