-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.el
1120 lines (1020 loc) · 39.6 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
;;; init.el --- -*- lexical-binding: t -*-
(setq gc-cons-threshold most-positive-fixnum ; 2^61 bytes
gc-cons-percentage 0.6)
(add-hook 'emacs-startup-hook
(lambda ()
(message "Emacs ready in %s with %d garbage collections."
(format "%.2f seconds"
(float-time
(time-subtract after-init-time before-init-time)))
gcs-done)))
(defvar file-name-handler-alist-original file-name-handler-alist)
(setq file-name-handler-alist nil)
(defvar better-gc-cons-threshold 33554432 ; 32mb
"The default value to use for `gc-cons-threshold'.
If you experience freezing, decrease this. If you experience stuttering, increase this.")
(add-hook 'emacs-startup-hook
(lambda ()
(setq gc-cons-threshold better-gc-cons-threshold)
(setq file-name-handler-alist file-name-handler-alist-original)
(makunbound 'file-name-handler-alist-original)))
(add-hook 'emacs-startup-hook
(lambda ()
(if (boundp 'after-focus-change-function)
(add-function :after after-focus-change-function
(lambda ()
(unless (frame-focus-state)
(garbage-collect))))
(add-hook 'after-focus-change-function 'garbage-collect))
(defun gc-minibuffer-setup-hook ()
(setq gc-cons-threshold (* better-gc-cons-threshold 2)))
(defun gc-minibuffer-exit-hook ()
(garbage-collect)
(setq gc-cons-threshold better-gc-cons-threshold))
(add-hook 'minibuffer-setup-hook #'gc-minibuffer-setup-hook)
(add-hook 'minibuffer-exit-hook #'gc-minibuffer-exit-hook)))
(defvar bootstrap-version)
(let ((bootstrap-file
(expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
(bootstrap-version 6))
(unless (file-exists-p bootstrap-file)
(with-current-buffer
(url-retrieve-synchronously
"https://raw.githubusercontent.com/radian-software/straight.el/develop/install.el"
'silent 'inhibit-cookies)
(goto-char (point-max))
(eval-print-last-sexp)))
(load bootstrap-file nil 'nomessage))
;; Install use-package
(straight-use-package 'use-package)
;; Configure use-package to use straight.el by default
(use-package straight
:config
(setq straight-use-package-by-default t))
(use-package bind-key)
(use-package diminish)
(use-package try)
(setq user-full-name "Simen Omholt-Jensen")
(setq user-mail-address "[email protected]")
(add-to-list 'default-frame-alist '(ns-transparent-titlebar . t)) ;; Fancy titlebar for MacOS
(add-to-list 'default-frame-alist '(ns-appearance . dark)) ;; Fancy titlebar for MacOS
(setq ns-use-proxy-icon nil) ;; Fancy titlebar for MacOS
(setq frame-title-format '(:eval (if (buffer-file-name) ;; Set frame title to *Buffer/File Name*
(abbreviate-file-name (buffer-file-name)) "%b")))
(set-language-environment "UTF-8") ;; Set enconding language
(set-default-coding-systems 'utf-8) ;; Set enconding language
(prefer-coding-system 'utf-8) ;; Set enconding language
(set-terminal-coding-system 'utf-8) ;; Set enconding language
(set-keyboard-coding-system 'utf-8) ;; Set enconding language
(global-display-line-numbers-mode) ;; Display line numbers
(dolist (mode '(org-mode-hook ;; Disable line numbers for some modes
term-mode-hook
vterm-mode-hook
jupyter-repl-mode-hook
eshell-mode-hook
pdf-view-mode-hook))
(add-hook mode (lambda () (display-line-numbers-mode 0))))
(setq-default read-process-output-max (* 1024 1024)) ;; Increase the amount of data which Emacs reads from the process
(setq-default fill-column 80) ;; Set fill column to 80 chars by default
(setq-default column-number-mode t) ;; Display column numbers
(setq-default inhibit-startup-screen t) ;; Don't show the startup message
(setq inhibit-startup-echo-area-message t) ;; Don't show the startup echo message
(setq-default initial-scratch-message nil) ;; Set initial scratch message to nil
(set-fringe-mode 10) ;; Give some breathing room
(set-default 'truncate-lines t) ;; default truncate lines
(setq debug-on-error nil) ;; Receive more information errors
(setq custom-file "~/.emacs.d/custom.el")
(ignore-errors (load custom-file)) ;; Load custom.el if it exists
(setq-default create-lockfiles nil) ;; Disable lock files
(setq-default backup-directory-alist '(("." . "/Users/simenojensen/.emacs.d/backups"))) ;; Save backup files
(setq-default indent-tabs-mode nil) ;; Don't use hard tabs
(setq echo-keystrokes 0.1) ;; Echo keystrokes fast
(fset 'yes-or-no-p 'y-or-n-p) ;; y-or-n instead of yes-or-no
(add-hook 'before-save-hook 'delete-trailing-whitespace) ;; Delete trailing whitespace on save
(setq require-final-newline t) ;; Add a newline at end of file on save
(global-auto-revert-mode t) ;; Automatically update buffers if a file content has changed on disk
(save-place-mode t) ;; Save position of the point in file
(global-hl-line-mode t) ;; Highlight the line with the point
(add-hook 'before-save-hook 'time-stamp) ;; Update timestamp of 8 first lines on save
(setq large-file-warning-threshold 100000000) ;; Warn when opening file larger than 100 MB
(desktop-save-mode 1) ;; save desktop
(setq history-delete-duplicates t) ;; delete duplicate history
(setq revert-without-query '(".*")) ;; do not ask when reverting buffer
(setq-default cursor-type '(bar . 4)) ;; use bar for cursor
(global-set-key (kbd "<escape>") 'keyboard-escape-quit) ;; Cancel on escape
;; Vertical Scroll
(setq scroll-step 1)
(setq scroll-margin 1)
(setq scroll-conservatively 101)
(setq scroll-up-aggressively 0.01)
(setq scroll-down-aggressively 0.01)
(setq auto-window-vscroll nil)
(setq fast-but-imprecise-scrolling nil)
(setq mouse-wheel-scroll-amount '(1 ((shift) . 1)))
(setq mouse-wheel-progressive-speed nil)
;; Horizontal Scroll
(setq hscroll-step 1)
(setq hscroll-margin 1)
(menu-bar-mode -1) ;; Disable menu bar
(tool-bar-mode -1) ;; Disable tool bar
(scroll-bar-mode -1) ;; Disable scroll bar
(blink-cursor-mode -1) ;; Disable blinking cursor
(setq-default ring-bell-function 'ignore) ;; Disable bell function
(setq-default confirm-kill-emacs nil) ;; Do not confirm when killing Emacs
(setq-default confirm-kill-processes nil) ;; do not confirm when killing processes before killing Emacs
(cond ((eq system-type 'darwin)
(customize-set-variable 'mac-command-modifier 'meta)
(customize-set-variable 'mac-right-command-modifier 'super)
(customize-set-variable 'mac-option-modifier 'alt)
(customize-set-variable 'mac-right-option-modifier 'hyper)
(bind-key "M-=" 'text-scale-increase)
(bind-key "M--" 'text-scale-decrease)
(bind-key "M-`" 'other-frame)
(use-package exec-path-from-shell
:config
(setq shell-file-name "/opt/homebrew/bin/zsh") ;; Let emacs know which shell to use.
(setq exec-path-from-shell-variables '("PATH" "MANPATH" "VIRTUAL_ENV" "PKG_CONFIG_PATH" "GOPATH"))
(setenv "PYTHONPATH" "/Applications/QGIS.app/Contents/Resources/python:/Applications/QGIS.app/Contents/Resources/python/plugins")
(if (string-equal system-type "darwin")
(exec-path-from-shell-initialize)))
)
((eq system-type 'windows-nt)
)
((eq system-type 'gnu/linux)
))
(use-package which-key
:diminish which-key-mode
:config
(setq which-key-idle-delay 0.5)
(setq which-key-frame-max-height 40)
(which-key-mode))
(bind-key "s-<left>" 'shrink-window-horizontally)
(bind-key "s-<right>" 'enlarge-window-horizontally)
(bind-key "s-<down>" 'shrink-window)
(bind-key "s-<up>" 'enlarge-window)
(unbind-key "C-v" global-map) ;; disable annoying scroll window
(bind-key "C-x C-l" 'toggle-truncate-lines)
(bind-key "M-p" 'backward-paragraph)
(bind-key "M-n" 'forward-paragraph)
(bind-key "M-g" 'goto-line)
(bind-key "C-x b" 'ibuffer-other-window)
(bind-key "C-x C-b" 'switch-to-buffer)
(unbind-key "C-x f" global-map)
(use-package crux
:bind
("C-a" . crux-move-beginning-of-line)
:config
(defalias 'rename-file-and-buffer #'crux-rename-file-and-buffer))
(use-package ivy
:diminish
:init
(use-package amx)
(use-package counsel :diminish :config (counsel-mode 1))
(use-package swiper)
(ivy-mode 1)
:bind
(("C-x C-f" . counsel-find-file)
("C-x f". counsel-fzf)
("C-h f" . counsel-describe-function)
("C-h v" . counsel-describe-variable)
("C-h l" . counsel-find-library)
("C-h i" . counsel-info-lookup-symbol)
("C-h u" . counsel-unicode-char)
("C-c k" . counsel-rg)
("C-x l" . counsel-locate)
("M-x" . counsel-M-x)
("M-v" . counsel-yank-pop)
("C-s" . swiper-isearch)
:map ivy-minibuffer-map
("A-<tab>" . ivy-mark) ;; Mark multiple candidates
("C-<return>" . ivy-call) ;; perform call
)
:config
(ivy-mode 1)
(setq ivy-height 20)
(setq ivy-initial-inputs-alist nil)
(setq ivy-display-style 'fancy)
(setq ivy-use-selectable-prompt t)
(setq counsel-switch-buffer-preview-virtual-buffers nil)
;; sort counsel-rg results
(setq ivy-sort-functions-alist
'((counsel-rg . ivy-sort-file-function-default)
(t . nil)))
;; (setq ivy-use-virtual-buffers t)
(setq ivy-count-format "(%d/%d) "))
(use-package helm)
(use-package undo-tree
:diminish undo-tree-mode
:init
(global-undo-tree-mode)
:config
(setq undo-tree-history-directory-alist '(("." . "~/.emacs.d/undo")))
(setq undo-tree-visualizer-diff t)
(setq undo-tree-visualizer-timestamps t))
(use-package dired
:straight nil
:bind
(("C-x C-j" . dired-jump)
("C-x j" . dired-jump-other-window))
:config
;; Always delete and copy recursively
(setq dired-recursive-deletes 'always)
(setq dired-recursive-copies 'always)
;; Auto refresh Dired, but be quiet about it
(setq global-auto-revert-non-file-buffers t)
(setq auto-revert-verbose nil)
;; Quickly copy/move file in Dired
(setq dired-dwim-target t)
;; Move files to trash when deleting
(setq delete-by-moving-to-trash t)
(setq trash-directory "~/.Trash")
;; Load the newest version of a file
(setq load-prefer-newer t)
;; Detect external file changes and auto refresh file
(setq auto-revert-use-notify nil)
(setq auto-revert-interval 3) ; Auto revert every 3 sec
;; Enable global auto-revert
(global-auto-revert-mode t)
;; sort directory first
(setq insert-directory-program "/opt/homebrew/bin/gls"
dired-use-ls-dired t)
(setq dired-listing-switches "-laXGh --group-directories-first")
;; Reuse same dired buffer, to prevent numerous buffers while navigating in dired
(put 'dired-find-alternate-file 'disabled nil)
:hook
(dired-mode . (lambda ()
(local-set-key (kbd "<mouse-2>") #'dired-find-alternate-file)
(local-set-key (kbd "RET") #'dired-find-alternate-file)
(local-set-key (kbd "^")
(lambda () (interactive) (find-alternate-file ".."))))))
(use-package ace-window
:bind
("C-x C-o" . ace-window)
("C-x o" . ace-window)
:init
(custom-set-faces
'(aw-leading-char-face
((t (:inherit fixed-pitch :height 4.0 :foreground "firebrick3"))))))
(winner-mode 1)
(use-package vterm
;; add functionality for counsel-yank-pop
:after counsel
:init
;; Counsel-yank-pop
(defun vterm-counsel-yank-pop-action (orig-fun &rest args)
(if (equal major-mode 'vterm-mode)
(let ((inhibit-read-only t)
(yank-undo-function (lambda (_start _end) (vterm-undo))))
(cl-letf (((symbol-function 'insert-for-yank)
(lambda (str) (vterm-send-string str t))))
(apply orig-fun args)))
(apply orig-fun args)))
(advice-add 'counsel-yank-pop-action :around #'vterm-counsel-yank-pop-action)
(setq vterm-max-scrollback 10000)
(setq vterm-always-compile-module t)
)
;; (use-package multi-vterm)
(use-package magit
:bind
("C-x g" . magit-status))
(use-package projectile
:diminish
:config
(define-key projectile-mode-map (kbd "s-p") 'projectile-command-map)
(setq projectile-completion-system 'ivy)
(projectile-mode +1))
(use-package evil-nerd-commenter
:bind
("C-;" . evilnc-comment-or-uncomment-lines))
(use-package flycheck
:diminish
:init
(global-flycheck-mode)
:hook
(prog-mode . flycheck-mode)
:config
(setq flycheck-checker-error-threshold 1000)
;; (setq-default flycheck-c/c++-clang-executable "/usr/bin/clangd")
;; (setq-default flycheck-clang-standard-library "libc++")
(setq-default flycheck-clang-language-standard "c++20")
(setq-default flycheck-cppcheck-standards '("c++20"))
(setq-default flycheck-clang-args "-std=c++20")
)
(use-package yasnippet
:bind
(:map yas-keymap
("M-j" . yas-next-field-or-maybe-expand)
("M-k" . yas-prev-field))
:config
(use-package yasnippet-snippets)
(yas-global-mode t)
)
(use-package smartparens
:init
(smartparens-global-mode 1)
:config
(setq smartparens-strict-mode t)
)
(use-package lsp-mode
:init
;; set prefix for lsp-command-keymap (few alternatives - "C-l", "C-c l")
(setq lsp-keymap-prefix "C-c l")
:hook (;; replace XXX-mode with concrete major-mode(e. g. python-mode)
(html-mode . lsp-deferred)
(json-mode . lsp-deferred)
(python-mode . lsp-deferred)
(c++-mode . lsp-deferred)
(go-mode . lsp-deferred)
(java-mode . lsp-deferred)
(sql-mode . lsp-deferred)
;; if you want which-key integration
(lsp-mode . lsp-enable-which-key-integration)
(lsp-mode . (lambda ()
(bind-key "M-;" 'lsp-rename lsp-mode-map))))
:commands lsp
:config
(setq lsp-idle-delay 0.2)
(setq lsp-log-io nil) ; if set to true can cause a performance hit
;; enable snippets
(setq lsp-enable-snippet t)
;; symbol highlighting
(setq lsp-enable-symbol-highlighting t)
;; lenses
(setq lsp-lens-enable nil)
;; headerline
(setq lsp-headerline-breadcrumb-enable t)
;; modeline
(setq lsp-modeline-code-actions-enable nil)
(setq lsp-modeline-diagnostics-enable t)
;; linter
(setq lsp-diagnostics-provider :auto) ;; prefer flycheck, fallback to flymake
;; eldoc
(setq lsp-eldoc-enable-hover nil)
(setq lsp-eldoc-render-all t)
;; signatures
(setq lsp-signature-auto-activate nil)
(setq lsp-signature-render-documentation nil)
;; disable semgrep
(setq lsp-disabled-clients '(semgrep-ls))
;; completion
(setq lsp-completion-provider :capf)
(setq lsp-completion-show-detail t)
(setq lsp-completion-show-kind t)
)
(use-package lsp-ui
:commands lsp-ui-mode
:bind
;; lsp-ui-peek
((:map lsp-ui-mode-map
([remap xref-find-definitions] . lsp-ui-peek-find-definitions)
([remap xref-find-references] . lsp-ui-peek-find-references)
("C-c d" . lsp-ui-doc-show)
))
:config
;; show docs
(setq lsp-ui-doc-enable t)
(setq lsp-ui-doc-show-with-cursor nil)
(setq lsp-ui-doc-show-with-mouse t)
;; sideline
(setq lsp-ui-sideline-enable t)
(setq lsp-ui-sideline-show-code-actions t)
(setq lsp-ui-sideline-show-hover nil)
(setq lsp-ui-sideline-show-diagnostics t)
(setq lsp-ui-sideline-diagnostic-max-line-length 100)
(setq lsp-ui-sideline-diagnostic-max-lines 5)
)
;; lsp-ui-doc
;; ("M-i" . lsp-ui-doc-focus-frame))
;; ("s-i" . my/toggle-lsp-ui-doc))
;; :preface
;; (defun my/toggle-lsp-ui-doc ()
;; (interactive)
;; (if lsp-ui-doc-mode
;; (lsp
;; (progn-ui-doc-mode -1)
;; (lsp-ui-doc--hide-frame))
;; (lsp-ui-doc-mode 1))))
(use-package company
:diminish company-mode
:hook
(after-init . global-company-mode)
:bind
((:map company-active-map
("C-n" . company-select-next)
("C-p" . company-select-previous))
(:map company-search-map
("C-n" . company-select-next)
("C-p" . company-select-previous)))
:config
(setq company-minimum-prefix-length 1)
(setq company-idle-delay 0.2)
(setq company-echo-delay 5)
;; (setq company-tooltip-idle-delay 0.0)
;; (setq company-tooltip-align-annotations t)
(setq company-require-match nil)
(setq company-show-numbers t)
(setq company-dabbrev-downcase nil) ;; case insensitive for dabbrev backend
(global-company-mode 1)
;; Don't use company in debugger mode
(setq company-global-modes '(not gud-mode)))
(use-package company-box
:diminish
:hook
(company-mode . company-box-mode)
:config
(setq company-box-doc-enable t)
(setq company-box-doc-delay 0.2)
)
(use-package format-all)
(use-package python
:hook
(python-mode . (lambda () ;; emulate python-shell-send-buffer
(setq indent-tabs-mode nil)
(display-fill-column-indicator-mode) ;; display column
))
:config
;; silence indentation guesses
(setq python-indent-guess-indent-offset-verbose nil))
(use-package lsp-pyright
:hook (python-mode . (lambda ()
(require 'lsp-pyright)
(lsp-deferred))))
(use-package conda
:hook
(python-mode . (lambda () (conda-env-activate "py3")))
:config
(setq conda-env-home-directory "/opt/homebrew/Caskroom/miniconda/base/")
(setq conda-anaconda-home "/opt/homebrew/Caskroom/miniconda/base/"))
(defun my/jupyter-load-file ()
"Send current buffer to jupyter kernel by default"
(interactive)
(jupyter-load-file (buffer-file-name)))
(use-package jupyter
:bind
(:map python-mode-map
("C-c C-p" . jupyter-run-repl))
:init
(setq jupyter-repl-allow-RET-when-busy t)
(setq jupyter-repl-echo-eval-p t)) ;; show plots
(use-package blacken
:hook
(python-mode . blacken-mode))
(use-package numpydoc
:config
(setq numpydoc-insert-examples-block nil)
(setq numpydoc-insert-return-without-typehint t)
)
(use-package py-isort
:after python
:hook (before-save . py-isort-before-save))
(use-package go-mode
:hook
(go-mode . (lambda()
(add-hook 'before-save-hook #'lsp-format-buffer t t)
(add-hook 'before-save-hook #'lsp-organize-imports t t))))
(use-package protobuf-mode
:mode "\\.proto\\'")
(defun my/c++-save-hook ()
(when (eq major-mode 'c++-mode)
(lsp-format-buffer)))
(add-hook 'before-save-hook #'my/c++-save-hook)
(use-package csv-mode
:mode "\\.[Cc][Ss][Vv]\\'")
(use-package graphql-mode
:mode "\\.graphql\\'"
:config
;; Optional: set indentation level to 2 spaces
(setq graphql-indent-level 2))
;; Tangle on config file
(defun my/tangle-emacs-config ()
"If the current file is this file, the code blocks are tangled"
(when (equal (buffer-file-name) (expand-file-name "~/.emacs.d/my-literate-emacs-configuration.org"))
(org-babel-tangle nil "~/.emacs.d/init.el")))
(use-package org
:straight (:type built-in)
:hook
(after-save . my/tangle-emacs-config)
(org-mode . (lambda ()
;; (flyspell-mode)
(display-fill-column-indicator-mode)
(auto-fill-mode)
))
:init
(use-package org-indent :straight (:type built-in))
:config
;; -------------------- Org Agenda --------------------
;; Org settings
(setq org-directory "~/Documents/Org") ;; Set default org directory
(setq org-default-notes-file (concat org-directory "/tasks.org")) ;; Set default org capture file
;; Org agenda
(setq org-todo-keywords
'((sequence "TODO" "|" "DONE" "CANCELED")))
(setq org-agenda-files '("~/Documents/Org/"))
(setq org-agenda-window-setup 'current-window)
;; org capture
(setq org-capture-templates
'(("a" "Assignment" entry
(file+headline "~/Documents/Org/Academic.org" "Assignments")
"* TODO %?\n")))
;; -------------------- Evaluation of Source Blocks --------------------
;; Do not confirm when evaluating code blocks
(setq org-confirm-babel-evaluate nil)
;; Run/highlight code using babel in org-mode
(org-babel-do-load-languages
'org-babel-load-languages
'((python . t)
(js . t)
(latex . t)
(jupyter . t)
(sql . t)
(shell . t)
(emacs-lisp . t)))
;; How to edit source code blocks: [plain, current-window, split-window-below, other-window, other-frame]
(setq org-src-window-setup 'current-window)
;; Edit source code blocks menu
(setq org-structure-template-alist
'(("a" . "export ascii\n")
("c" . "center\n")
("C" . "comment\n")
("e" . "src emacs-lisp\n")
("E" . "export")
("h" . "export html\n")
("l" . "src latex\n")
("q" . "quote\n")
("p" . "src python\n")
("j" . "src jupyter-python\n")
("s" . "src sql")
("v" . "verse\n")))
;; -------------------- Export reveal --------------------
(use-package htmlize)
;; -------------------- Various Behavior --------------------
;; Follow link when hitting return
(setq org-return-follows-link t)
;; -------------------- Latex Exports --------------------
;; auctex
(use-package tex
:straight auctex)
;; Remove logfiles
(setq org-latex-logfiles-extensions '(
;; Default settings
"aux" "bcf" "blg" "fdb_latexmk" "fls" "figlist" "idx" "log" "nav" "out" "ptc" "run.xml" "snm" "toc" "vrb" "xdv"
;; Added settings
"bbl" "lof" "lot" "tex" "glo" "ist" "glg" "gls" "acn" "acr" "alg" "loa"
))
(setq org-latex-remove-logfiles t)
;; Set default figure position
(setq org-latex-default-figure-position "H")
;; Set default caption position
(setq org-latex-caption-above nil) ;; '("table" "image")
;; Set default export to async
(setq org-export-in-background nil)
;; Remove default header exports
(setq org-export-with-title t
org-export-with-date t
org-export-with-author t
org-export-with-creator nil
org-export-with-toc t
)
;; add glossary and acronyms
(add-to-list 'org-export-before-parsing-hook 'org-ref-acronyms-before-parsing)
(add-to-list 'org-export-before-parsing-hook 'org-ref-glossary-before-parsing)
;; Latex compilation
;; (setq org-latex-pdf-process (list "latexmk -shell-escape -bibtex -f -pdf %f"))
(setq org-latex-pdf-process
'("pdflatex -interaction nonstopmode -output-directory %o %f"
"bibtex %b"
"makeglossaries %b"
"pdflatex -interaction nonstopmode -output-directory %o %f"
"pdflatex -interaction nonstopmode -output-directory %o %f"))
;; Latex classes
(setq org-latex-classes
'(("article"
"
\\documentclass[10pt]{article}
% Setup
\\usepackage[english]{babel}
\\usepackage[utf8]{inputenc}
\\usepackage{import}
\\usepackage[hidelinks]{hyperref}
\\usepackage{url}
\\hypersetup{colorlinks=true, allcolors=blue}
% Geometry
\\usepackage[a4paper, width=150mm, top=25mm, bottom=25mm]{geometry}
\\usepackage{parskip}
\\setlength{\\parindent}{0pt}
\\setlength{\\parskip}{\\baselineskip}
% Math
\\usepackage{amsmath}
\\usepackage{amssymb}
% Tables
\\usepackage{array}
\\usepackage{multirow}
\\usepackage{longtable}
% Color
\\usepackage{xcolor}
% Figures
\\usepackage{graphicx} % To show figures
\\usepackage{wrapfig} % Wrap text around figures
\\usepackage{subcaption}
\\usepackage{rotating}
% Others
\\usepackage{float}
\\usepackage{lastpage}
\\usepackage[normalem]{ulem}
\\usepackage{capt-of}
\\usepackage{csquotes}
\\usepackage{enumitem}
\\usepackage{ragged2e}
\\setlist{nosep} % or \setlist{noitemsep} to leave space around whole list
% TOC and Appendix
\\usepackage{appendix}
\\usepackage[nottoc]{tocbibind}
\\usepackage[acronyms, section]{glossaries}
\\makeglossaries
% Footers and Headers
\\usepackage{fancyhdr}
\\pagestyle{fancy}
\\fancyhf{}
\\fancyfoot[C]{\\thepage}
\\renewcommand{\\footrulewidth}{0.1pt}
% Bibliography
\\usepackage{natbib}
\\makeatletter
\\renewcommand{\\maketitle}{%
\\begingroup\\parindent0pt
\\Large{\\bfseries\\@title}\\newline
\\normalsize{\\bfseries\\@author}\\newline
\\normalsize{\\@date}\\vspace{-0.2cm}\\newline
\\noindent\\makebox[\\textwidth]{\\rule{\\textwidth}{0.4pt}}
\\endgroup\\@afterindentfalse\\@afterheading}
\\makeatother
[NO-DEFAULT-PACKAGES]
"
("\\section{%s}" . "\\section*{%s}")
("\\subsection{%s}" . "\\subsection*{%s}")
("\\subsubsection{%s}" . "\\subsubsection*{%s}")
("\\paragraph{%s}" . "\\paragraph*{%s}")
("\\subparagraph{%s}" . "\\subparagraph*{%s}"))
("report"
"
\\documentclass[10pt]{report}
% Setup
\\usepackage[english]{babel}
\\usepackage[utf8]{inputenc}
\\usepackage{import}
\\usepackage[hidelinks]{hyperref}
\\usepackage{url}
\\hypersetup{colorlinks=false}
% \\usepackage[none]{hyphenat}
% Geometry
\\usepackage[a4paper, width=150mm, top=25mm, bottom=25mm]{geometry}
\\usepackage{parskip}
\\setlength{\\parindent}{0pt}
\\setlength{\\parskip}{\\baselineskip}
% Math
\\usepackage{amsmath}
\\usepackage{amssymb}
\\usepackage[ruled, vlined]{algorithm2e}
\\usepackage{mathrsfs}
% Tables
\\usepackage{array}
\\usepackage{multirow}
\\usepackage{longtable}
\\usepackage{lscape}
% Color
\\usepackage{xcolor}
% Figures
\\usepackage{graphicx} % To show figures
\\usepackage{wrapfig} % Wrap text around figures
\\usepackage{caption}
\\usepackage{subcaption}
\\usepackage{rotating}
% others
\\usepackage{fixltx2e} % Required for \textsubscript
\\usepackage{float}
\\usepackage{lastpage}
\\usepackage[normalem]{ulem}
\\usepackage{capt-of}
\\usepackage{csquotes}
\\usepackage{enumitem}
\\usepackage{ragged2e}
\\usepackage{comment}
\\setlist{nosep} % or \setlist{noitemsep} to leave space around whole list
% TOC and Appendix
\\usepackage{appendix}
\\usepackage[nottoc]{tocbibind}
\\usepackage[acronyms, section]{glossaries}
\\makeglossaries
% Footers and Headers
\\usepackage{fancyhdr}
\\pagestyle{fancy}
\\fancyhf{}
\\fancyfoot[C]{\\thepage}
\\renewcommand{\\footrulewidth}{0.1pt}
% Bibliography
\\usepackage{natbib}
[NO-DEFAULT-PACKAGES]
"
("\\chapter{%s}" . "\\chapter*{%s}")
("\\section{%s}" . "\\section*{%s}")
("\\subsection{%s}" . "\\subsection*{%s}")
("\\subsubsection{%s}" . "\\subsubsection*{%s}"))
;; Book
("book" "\\documentclass[10pt]{book}"
("\\part{%s}" . "\\part*{%s}")
("\\chapter{%s}" . "\\chapter*{%s}")
("\\section{%s}" . "\\section*{%s}")
("\\subsection{%s}" . "\\subsection*{%s}")
("\\subsubsection{%s}" . "\\subsubsection*{%s}"))
;; Beamer
("beamer"
"
\\documentclass[presentation]{beamer}
\\usepackage{xcolor}
% Bibliography
\\usepackage{natbib}
% Math
\\usepackage{amsmath}
\\usepackage{amssymb}
\\usepackage[ruled, vlined]{algorithm2e}
\\usepackage{mathrsfs}
\\usepackage{listings}
\\lstset{frame=single,aboveskip=1em,
framesep=.5em,backgroundcolor=\\color{blue},
rulecolor=\\color{blue},framerule=1pt}
\\newcommand\\basicdefault[1]{\\scriptsize\\color{black}\\ttfamily#1}
\\lstset{basicstyle=\\basicdefault{\\spaceskip1em}}
\\lstset{literate=
{§}{{\\S}}1
{©}{{\\raisebox{.125ex}{\\copyright}\\enspace}}1
{«}{{\\guillemotleft}}1
{»}{{\\guillemotright}}1
{Á}{{\\'A}}1
{Ä}{{\\\"A}}1
{É}{{\\'E}}1
{Í}{{\\'I}}1
{Ó}{{\\'O}}1
{Ö}{{\\\"O}}1
{Ú}{{\\'U}}1
{Ü}{{\\\"U}}1
{ß}{{\\ss}}2
{à}{{\\`a}}1
{á}{{\\'a}}1
{ä}{{\\\"a}}1
{é}{{\\'e}}1
{í}{{\\'i}}1
{ó}{{\\'o}}1
{ö}{{\\\"o}}1
{ú}{{\\'u}}1
{ü}{{\\\"u}}1
{¹}{{\\textsuperscript1}}1
{²}{{\\textsuperscript2}}1
{³}{{\\textsuperscript3}}1
{ı}{{\\i}}1
{—}{{---}}1
{’}{{'}}1
{…}{{\\dots}}1
{⮠}{{$\\hookleftarrow$}}1
{␣}{{\\textvisiblespace}}1,
keywordstyle=\\color{green}\\bfseries,
identifierstyle=\\color{red},
commentstyle=\\color{gary}\\upshape,
stringstyle=\\color{blue}\\upshape,
emphstyle=\\color{brown}\\upshape,
showstringspaces=false,
columns=fullflexible,
keepspaces=true}
[DEFAULT-PACKAGES]
\\hypersetup{linkcolor=blue,urlcolor=blue,
citecolor=red,colorlinks=true}
\\AtBeginDocument{\\renewcommand{\\UrlFont}{\\ttfamily}}
[PACKAGES]
[EXTRA]
"
("\\section{%s}" . "\\section*{%s}")
("\\subsection{%s}" . "\\subsection*{%s}")
("\\subsubsection{%s}" . "\\subsubsection*{%s}"))
))
;; -------------------- Bibliography --------------------
(setq org-latex-prefer-user-labels t)
(use-package bibtex
:straight (:type built-in)
:init
(use-package ivy-bibtex)
(setq bibtex-completion-bibliography '("~/Documents/Org/Bibliography/Master.bib"))
(setq bibtex-completion-library-path nil)
(setq bibtex-completion-notes-path nil)
(setq bibtex-completion-pdf-field "file")
(setq bibtex-completion-pdf-open-function
(lambda (fpath)
(call-process "open" nil 0 nil fpath))))
(use-package org-ref
:bind
(:map bibtex-mode-map
("H-]" . org-ref-bibtex-hydra/body)
:map org-mode-map
("C-c ]" . org-ref-insert-link)
("s-]" . org-ref-insert-link-hydra/body))
:init
(use-package org-ref-ivy :straight (:type built-in))
(setq org-ref-insert-link-function 'org-ref-insert-link-hydra/body
org-ref-insert-cite-function 'org-ref-cite-insert-ivy
org-ref-insert-label-function 'org-ref-insert-label-link
org-ref-insert-ref-function 'org-ref-insert-ref-link))
;; -------------------- PDF --------------------
(use-package pdf-tools
:init
(use-package tablist)
:mode ("\\.pdf\\'" . pdf-view-mode)
:bind
(:map pdf-view-mode-map
("C-s" . isearch-forward))
:config
(pdf-loader-install)
(setq pdf-view-display-size 'fit-page)
)
(use-package pdf-view-restore
:after pdf-tools
:hook
(pdf-view-mode . pdf-view-restore-mode)
:config
(setq pdf-view-restore-filename "~/.emacs.d/.pdf-view-restore")
)
;; -------------------- Org Download --------------------
;; https://github.com/abo-abo/org-download
(use-package org-download
:config
(setq org-download-display-inline-images t))
;; -------------------- Beautifying Org Mode --------------------
;; Emphasis - disable strikethrough
(setq org-emphasis-alist '(("*" bold)
("/" italic)
("_" underline)
("=" org-verbatim verbatim)
("~" org-code verbatim)
("+" (:strike-through nil))))
;; Emphasis - hide markers
(setq org-hide-emphasis-markers t)
;; Org-Superstar - https://github.com/integral-dw/org-superstar-mode
(use-package org-superstar
:hook
(org-mode . (lambda () (org-superstar-mode 1)))
:config
(setq org-superstar-headline-bullets-list '("◉" "◈" "○" "▷"))
;; Do not cycle after bottom level
(setq org-superstar-cycle-headline-bullets nil)
)
;; Fonts and Section Title color
(let* ((variable-tuple
(cond ((x-list-fonts "ETBembo") '(:font "ETBembo"))
((x-list-fonts "Source Sans Pro") '(:font "Source Sans Pro"))
((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 a Sans Serif Font. Install Source Sans Pro."))))
(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 :forground "RoyalBlue1" :height 1.1))))
`(org-level-3 ((t (,@headline ,@variable-tuple :foreground "firebrick3" :height 1.25))))
`(org-level-2 ((t (,@headline ,@variable-tuple :foreground "green3" :height 1.5))))
`(org-level-1 ((t (,@headline ,@variable-tuple :foreground "DarkOrange2" :height 1.75))))
`(org-document-title ((t (,@headline ,@variable-tuple :height 2.0 :underline nil))))))
;; Indentation
(setq org-startup-indented nil)
;; prettify symbols
(setq org-pretty-entities nil)
;; images - set width
(setq org-startup-with-inline-images t
org-image-actual-width '(300))
)
(use-package markdown-mode
:commands (markdown-mode gfm-mode)
:mode (("README\\.md\\'" . gfm-mode)
("\\.md\\'" . markdown-mode)
("\\.markdown\\'" . markdown-mode))
:init
(setq markdown-command
(concat
"pandoc"
" --from=markdown --to=html"
" --standalone --mathjax --highlight-style=pygments"))
)
(use-package all-the-icons)
(use-package all-the-icons-ivy-rich
:config
(all-the-icons-ivy-rich-mode 1))
(use-package ivy-rich
:config
(ivy-rich-mode 1)
(setcdr (assq t ivy-format-functions-alist) #'ivy-format-function-line))
(use-package all-the-icons-dired
:diminish
:custom-face
(all-the-icons-dired-dir-face ((t (:foreground nil))))
:hook
(dired-mode . all-the-icons-dired-mode))