forked from jethrokuan/.emacs.d
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.el
1511 lines (1327 loc) · 48.9 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
;;;; -*- lexical-binding: t -*-
(setq straight-repository-branch "develop")
(defvar bootstrap-version)
(let ((bootstrap-file
(expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
(bootstrap-version 5))
(unless (file-exists-p bootstrap-file)
(with-current-buffer
(url-retrieve-synchronously
"https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el"
'silent 'inhibit-cookies)
(goto-char (point-max))
(eval-print-last-sexp)))
(load bootstrap-file nil 'nomessage))
(setq straight-use-package-by-default t)
(straight-use-package 'use-package)
(straight-use-package 'diminish)
(add-to-list 'load-path (expand-file-name "elisp" user-emacs-directory))
(when (featurep 'exwm)
(require 'exwm-config))
(use-package use-package-company
:straight (use-package-company :host github :repo "akirak/use-package-company"))
(setq user-full-name "Jethro Kuan"
user-mail-address "jethrokuan95@gmail.com")
(defun jethro/phone-p ()
(and (equal (system-name) "localhost")
(not (equal user-login-name "jethro"))))
(use-package exec-path-from-shell
:config
(exec-path-from-shell-initialize))
(setq ad-redefinition-action 'accept)
(use-package no-littering
:config
(require 'recentf)
(add-to-list 'recentf-exclude no-littering-var-directory)
(add-to-list 'recentf-exclude no-littering-etc-directory)
:config
(setq auto-save-file-name-transforms
`((".*" ,(no-littering-expand-var-file-name "auto-save/") t))))
(setq gc-cons-threshold 50000000)
(setq large-file-warning-threshold 100000000)
(use-package autorevert
:straight nil
:diminish t
:hook
(dired-mode . auto-revert-mode)
:config
(global-auto-revert-mode +1)
:custom
(auto-revert-verbose nil))
(setq custom-file (expand-file-name "custom.el" user-emacs-directory))
(defalias 'yes-or-no-p 'y-or-n-p)
(delete-selection-mode 1)
(setq sentence-end-double-space nil)
(setq-default tab-width 2)
(setq-default js-indent-level 2)
(setq-default indent-tabs-mode nil)
(setq-default truncate-lines t)
(defun jethro/truncate-lines-hook ()
(setq truncate-lines nil))
(add-hook 'text-mode-hook 'jethro/truncate-lines-hook)
;; For when Emacs is started in GUI mode:
(setq create-lockfiles nil)
(setq browse-url-browser-function 'browse-url-xdg-open)
(use-package goto-addr
:hook ((compilation-mode . goto-address-mode)
(prog-mode . goto-address-prog-mode)
(eshell-mode . goto-address-mode)
(shell-mode . goto-address-mode))
:bind (:map goto-address-highlight-keymap
("<RET>" . goto-address-at-point)
("M-<RET>" . newline))
:commands (goto-address-prog-mode
goto-address-mode))
(bind-key "C-z" 'bury-buffer)
(bind-key "C-S-s" 'isearch-forward-symbol-at-point)
(add-hook 'after-save-hook 'executable-make-buffer-file-executable-if-script-p)
(use-package notmuch
:preface (setq-default notmuch-command (executable-find "notmuch"))
:if (executable-find "notmuch")
:bind (("<f2>" . notmuch)
:map notmuch-search-mode-map
("t" . jethro/notmuch-toggle-read)
("r" . notmuch-search-reply-to-thread)
("R" . notmuch-search-reply-to-thread-sender)
:map notmuch-show-mode-map
("l" . jethro/notmuch-show-jump-to-latest)
("<tab>" . org-next-link)
("<backtab>". org-previous-link)
("C-<return>" . browse-url-at-point)
:map notmuch-show-mode-map
("C" . jethro/org-capture-email))
:config
(defun jethro/notmuch-toggle-read ()
"toggle read status of message"
(interactive)
(if (member "unread" (notmuch-search-get-tags))
(notmuch-search-tag (list "-unread"))
(notmuch-search-tag (list "+unread"))))
(defun jethro/notmuch-show-jump-to-latest ()
"Jump to the message in the current thread with the latest
timestamp."
(interactive)
(let ((timestamp 0)
latest)
(notmuch-show-mapc
(lambda () (let ((ts (notmuch-show-get-prop :timestamp)))
(when (> ts timestamp)
(setq timestamp ts
latest (point))))))
(if latest
(goto-char latest)
(error "Cannot find latest message."))))
:custom
(message-auto-save-directory "~/.mail/drafts/")
(message-send-mail-function 'message-send-mail-with-sendmail)
(sendmail-program (executable-find "msmtp"))
;; We need this to ensure msmtp picks up the correct email account
(message-sendmail-envelope-from 'header)
(mail-envelope-from 'header)
(mail-specify-envelope-from t)
(message-sendmail-f-is-evil nil)
(message-kill-buffer-on-exit t)
(notmuch-always-prompt-for-sender t)
(notmuch-archive-tags '("-inbox" "-unread"))
(notmuch-crypto-process-mime t)
(notmuch-hello-sections '(notmuch-hello-insert-saved-searches))
(notmuch-labeler-hide-known-labels t)
(notmuch-search-oldest-first nil)
(notmuch-archive-tags '("-inbox" "-unread"))
(notmuch-message-headers '("To" "Cc" "Subject" "Bcc"))
(notmuch-saved-searches '((:name "unread" :query "tag:unread")
(:name "to-me" :query "tag:to-me")
(:name "sent" :query "tag:sent")
(:name "personal" :query "tag:personal")
(:name "nushackers" :query "tag:nushackers")
(:name "nus" :query "tag:nus")
(:name "drafts" :query "tag:draft")))
:config
(defun jethro/org-capture-email ()
(interactive)
(org-capture nil "e")))
(setq default-frame-alist '((font . "Iosevka-14")))
(when (fboundp 'tooltip-mode)
(tooltip-mode -1))
(when (fboundp 'tool-bar-mode)
(tool-bar-mode -1))
(when (fboundp 'menu-bar-mode)
(menu-bar-mode -1))
(when (fboundp 'scroll-bar-mode)
(scroll-bar-mode -1))
(setq inhibit-splash-screen t)
(setq inhibit-startup-message t)
(use-package doom-themes
:init
(load-theme 'doom-challenger-deep t))
(use-package doom-modeline
:hook (after-init . doom-modeline-mode))
(use-package rainbow-delimiters
:hook
(prog-mode . rainbow-delimiters-mode)
:config
(rainbow-delimiters-mode +1))
(use-package zoom
:commands zoom-mode
:custom
(zoom-size '(0.618 . 0.618)))
(setq show-paren-style 'paren
show-paren-delay 0.03
show-paren-highlight-openparen t
show-paren-when-point-inside-paren nil
show-paren-when-point-in-periphery t)
(show-paren-mode 1)
(blink-cursor-mode 0)
(use-package hl-todo
:config
(global-hl-todo-mode))
(use-package counsel
:diminish ivy-mode
:bind
(("C-c C-r" . ivy-resume)
("M-x" . counsel-M-x)
("C-c i" . counsel-imenu)
("C-x b" . ivy-switch-buffer)
("C-x B" . ivy-switch-buffer-other-window)
("C-x k" . kill-buffer)
("C-x C-f" . counsel-find-file)
("C-x l" . counsel-locate)
("C-c j" . counsel-git)
("M-y" . counsel-yank-pop)
:map help-map
("f" . counsel-describe-function)
("v" . counsel-describe-variable)
("l" . counsel-info-lookup-symbol)
:map ivy-minibuffer-map
("C-o" . ivy-occur)
("<return>" . ivy-alt-done)
("M-<return>" . ivy-immediate-done)
:map read-expression-map
("C-r" . counsel-minibuffer-history))
:custom
(counsel-find-file-at-point t)
(ivy-use-virtual-buffers t)
(ivy-display-style 'fancy)
(ivy-use-selectable-prompt t)
(ivy-re-builders-alist
'((t . ivy--regex-plus)))
:config
(ivy-set-actions
t
'(("I" insert "insert")))
(ivy-set-occur 'ivy-switch-buffer 'ivy-switch-buffer-occur)
(ivy-mode +1))
(use-package anzu
:defer 3
:config
(global-anzu-mode +1))
(use-package emojify
:defer 10
:custom
(emojify-emoji-styles '(unicode))
:bind (("C-c e" . emojify-insert-emoji))
:config
(global-emojify-mode +1))
(use-package projectile
:custom
(projectile-use-git-grep t)
(projectile-create-missing-test-files t)
(projectile-completion-system 'ivy)
(projectile-switch-project-action #'projectile-commander)
:config
(define-key projectile-mode-map (kbd "C-x p") 'projectile-command-map)
(projectile-mode +1)
(def-projectile-commander-method ?S
"Run a search in the project"
(counsel-projectile-rg))
(def-projectile-commander-method ?s
"Open a *eshell* buffer for the project."
(projectile-run-eshell))
(def-projectile-commander-method ?d
"Open project root in dired."
(projectile-dired))
(def-projectile-commander-method ?g
"Show magit status."
(magit-status)))
(use-package counsel-projectile
:after ivy projectile
:config
(counsel-projectile-mode))
(use-package wgrep
:commands
wgrep-change-to-wgrep-mode
ivy-wgrep-change-to-wgrep-mode)
(use-package deadgrep
:if (executable-find "rg")
:bind* (("M-s" . deadgrep)))
(use-package hydra
:config
(defhydra jethro/hydra-zoom ()
"zoom"
("i" text-scale-increase "in")
("o" text-scale-decrease "out"))
(bind-key "C-c h z" 'jethro/hydra-zoom/body))
(use-package whitespace
:straight nil
:diminish whitespace-mode
:hook (prog-mode . whitespace-mode)
:custom
(whitespace-line-column 80)
(whitespace-style '(face lines-tail)))
(use-package minions
:config
(minions-mode +1))
(use-package beacon
:diminish beacon-mode
:custom
(beacon-push-mark 10)
:config
(beacon-mode +1))
(use-package volatile-highlights
:diminish volatile-highlights-mode
:config
(volatile-highlights-mode +1))
(use-package diff-hl
:hook
(dired-mode . diff-hl-dired-mode)
:init
(defconst jethro/diff-hl-mode-hooks '(emacs-lisp-mode-hook
conf-space-mode-hook ;.tmux.conf
markdown-mode-hook
css-mode-hook
web-mode-hook
sh-mode-hook
python-mode-hook
yaml-mode-hook ;tmuxp yaml configs
c-mode-hook)
"List of hooks of major modes in which diff-hl-mode should be enabled.")
(dolist (hook jethro/diff-hl-mode-hooks)
(add-hook hook #'diff-hl-flydiff-mode)))
(use-package diff-hl-hydra
:straight nil
:after hydra
:no-require t
:config
(defhydra jethro/hydra-diff-hl (:color red)
"diff-hl"
("=" diff-hl-diff-goto-hunk "goto hunk")
("<RET>" diff-hl-diff-goto-hunk "goto hunk")
("u" diff-hl-revert-hunk "revert hunk")
("[" diff-hl-previous-hunk "prev hunk")
("p" diff-hl-previous-hunk "prev hunk")
("]" diff-hl-next-hunk "next hunk")
("n" diff-hl-next-hunk "next hunk")
("q" nil "cancel"))
(bind-key "C-c h v" #'jethro/hydra-diff-hl/body))
(use-package crux
:bind (("C-c o" . crux-open-with)
("C-c D" . crux-delete-file-and-buffer)
("C-a" . crux-move-beginning-of-line)
("M-o" . crux-smart-open-line)
("C-c r" . crux-rename-file-and-buffer)
("M-D" . crux-duplicate-and-comment-current-line-or-region)
("s-o" . crux-smart-open-line-above)))
(let ((gls (executable-find "gls")))
(when gls
(setq insert-directory-program gls)))
(setq dired-listing-switches "-aBhl --group-directories-first")
(setq dired-dwim-target t)
(setq dired-recursive-copies (quote always))
(setq dired-recursive-deletes (quote top))
(use-package wdired
:commands wdired-mode wdired-change-to-wdired-mode
:custom
(wdired-allow-to-change-permissions t))
(use-package dired-narrow
:bind (:map dired-mode-map
("/" . dired-narrow-fuzzy)))
(use-package easy-kill
:bind*
(([remap kill-ring-save] . easy-kill)))
(use-package aggressive-indent
:diminish aggressive-indent-mode
:config
(global-aggressive-indent-mode +1)
:custom
(aggressive-indent-excluded-modes
'(bibtex-mode
cider-repl-mode
c-mode
c++-mode
coffee-mode
comint-mode
conf-mode
Custom-mode
diff-mode
doc-view-mode
dos-mode
erc-mode
jabber-chat-mode
haml-mode
intero-mode
haskell-mode
interative-haskell-mode
haskell-interactive-mode
image-mode
makefile-mode
makefile-gmake-mode
minibuffer-inactive-mode
nix-mode
netcmd-mode
python-mode
sass-mode
slim-mode
special-mode
shell-mode
snippet-mode
eshell-mode
tabulated-list-mode
term-mode
TeX-output-mode
text-mode
yaml-mode
scala-mode)))
(use-package multiple-cursors
:bind (("C-M-c" . mc/edit-lines)
("C->" . mc/mark-next-like-this)
("C-<" . mc/mark-previous-like-this)
("C-c C-<" . mc/mark-all-like-this)))
(use-package expand-region
:bind (("C-=" . er/expand-region)))
(use-package smartparens
:bind (:map smartparens-mode-map
("C-M-f" . sp-forward-sexp)
("C-M-b" . sp-backward-sexp)
("C-M-u" . sp-backward-up-sexp)
("C-M-d" . sp-down-sexp)
("C-M-p" . sp-backward-down-sexp)
("C-M-n" . sp-up-sexp)
("C-M-s" . sp-splice-sexp)
("C-M-<up>" . sp-splice-sexp-killing-backward)
("C-M-<down>" . sp-splice-sexp-killing-forward)
("C-M-r" . sp-splice-sexp-killing-around)
("C-)" . sp-forward-slurp-sexp)
("C-<right>" . sp-forward-slurp-sexp)
("C-}" . sp-forward-barf-sexp)
("C-<left>" . sp-forward-barf-sexp)
("C-(" . sp-backward-slurp-sexp)
("C-M-<left>" . sp-backward-slurp-sexp)
("C-{" . sp-backward-barf-sexp)
("C-M-<right>" . sp-backward-barf-sexp)
("M-S" . sp-split-sexp))
:init
(smartparens-global-strict-mode +1)
:config
(require 'smartparens-config)
;; Org-mode config
(sp-with-modes 'org-mode
(sp-local-pair "'" nil :unless '(sp-point-after-word-p))
(sp-local-pair "*" "*" :actions '(insert wrap) :unless '(sp-point-after-word-p sp-point-at-bol-p) :wrap "C-*" :skip-match 'sp--org-skip-asterisk)
(sp-local-pair "_" "_" :unless '(sp-point-after-word-p))
(sp-local-pair "/" "/" :unless '(sp-point-after-word-p) :post-handlers '(("[d1]" "SPC")))
(sp-local-pair "~" "~" :unless '(sp-point-after-word-p) :post-handlers '(("[d1]" "SPC")))
(sp-local-pair "=" "=" :unless '(sp-point-after-word-p) :post-handlers '(("[d1]" "SPC")))
(sp-local-pair "«" "»"))
(defun sp--org-skip-asterisk (ms mb me)
(or (and (= (line-beginning-position) mb)
(eq 32 (char-after (1+ mb))))
(and (= (1+ (line-beginning-position)) me)
(eq 32 (char-after me))))))
(autoload 'zap-up-to-char "misc"
"Kill up to, but not including ARGth occurrence of CHAR.
\(fn arg char)"
'interactive)
(bind-key "M-z" 'zap-up-to-char)
(use-package ws-butler
:diminish 'ws-butler-mode
:hook
(prog-mode . ws-butler-mode))
(use-package vc
:bind (("C-x v =" . jethro/vc-diff)
("C-x v H" . vc-region-history)) ; New command in emacs 25.x
:config
(defun jethro/vc-diff (no-whitespace)
"Call `vc-diff' as usual if buffer is not modified.
If the buffer is modified (yet to be saved), call `diff-buffer-with-file'.
If NO-WHITESPACE is non-nil, ignore all white space when doing diff."
(interactive "P")
(let* ((no-ws-switch '("-w"))
(vc-git-diff-switches (if no-whitespace
no-ws-switch
vc-git-diff-switches))
(vc-diff-switches (if no-whitespace
no-ws-switch
vc-diff-switches))
(diff-switches (if no-whitespace
no-ws-switch
diff-switches))
;; Set `current-prefix-arg' to nil so that the HISTORIC arg
;; of `vc-diff' stays nil.
current-prefix-arg)
(if (buffer-modified-p)
(diff-buffer-with-file (current-buffer))
(call-interactively #'vc-diff)))))
(use-package smerge-mode
:bind (("C-c h s" . jethro/hydra-smerge/body))
:init
(defun jethro/enable-smerge-maybe ()
"Auto-enable `smerge-mode' when merge conflict is detected."
(save-excursion
(goto-char (point-min))
(when (re-search-forward "^<<<<<<< " nil :noerror)
(smerge-mode 1))))
(add-hook 'find-file-hook #'jethro/enable-smerge-maybe :append)
:config
(defhydra jethro/hydra-smerge (:color pink
:hint nil
:pre (smerge-mode 1)
;; Disable `smerge-mode' when quitting hydra if
;; no merge conflicts remain.
:post (smerge-auto-leave))
"
^Move^ ^Keep^ ^Diff^ ^Other^
^^-----------^^-------------------^^---------------------^^-------
_n_ext _b_ase _<_: upper/base _C_ombine
_p_rev _u_pper _=_: upper/lower _r_esolve
^^ _l_ower _>_: base/lower _k_ill current
^^ _a_ll _R_efine
^^ _RET_: current _E_diff
"
("n" smerge-next)
("p" smerge-prev)
("b" smerge-keep-base)
("u" smerge-keep-upper)
("l" smerge-keep-lower)
("a" smerge-keep-all)
("RET" smerge-keep-current)
("\C-m" smerge-keep-current)
("<" smerge-diff-base-upper)
("=" smerge-diff-upper-lower)
(">" smerge-diff-base-lower)
("R" smerge-refine)
("E" smerge-ediff)
("C" smerge-combine-with-next)
("r" smerge-resolve)
("k" smerge-kill-current)
("q" nil "cancel" :color blue)))
(use-package magit
:straight (magit :type git
:files ("lisp/magit*.el" "lisp/git*.el"
"Documentation/magit.texi" "Documentation/AUTHORS.md"
"COPYING" (:exclude "lisp/magit-popup.el"))
:host github :repo "magit/magit")
:bind (("s-g" . magit-status)
("C-c g" . magit-status)
("s-G" . magit-blame-addition)
("C-c G" . magit-blame-addition))
:hook
(magit-mode . hl-line-mode)
:custom
(magit-auto-revert-mode nil)
(magit-log-arguments '("-n100" "--graph" "--decorate"))
:config
(transient-append-suffix 'magit-log "a"
'("w" "Wip" magit-wip-log-current))
(magit-define-popup-switch 'magit-log-popup
?m "Omit merge commits" "--no-merges")
(transient-append-suffix 'magit-log "-A"
'("-m" "Omit merge commits" "--no-merges")))
(use-package git-link
:commands
(git-link git-link-commit git-link-homepage)
:custom
(git-link-use-commit t))
(use-package bury-successful-compilation
:hook
(prog-mode . bury-successful-compilation))
(use-package direnv
:if (executable-find "direnv")
:custom
(direnv-always-show-summary nil)
:config
(direnv-mode +1))
(use-package flycheck
:config
(global-flycheck-mode +1)
(setq-default flycheck-check-syntax-automatically '(save
idle-change
mode-enabled))
;; Temporary workaround: Direnv needs to load PATH before flycheck looks
;; for linters
(setq flycheck-executable-find
(lambda (cmd)
(direnv-update-environment default-directory)
(executable-find cmd))))
(use-package flycheck-hydra
:straight nil
:no-require t
:after flycheck hydra
:config
(defhydra jethro/hydra-flycheck
(:pre (progn (setq hydra-lv t) (flycheck-list-errors))
:post (progn (setq hydra-lv nil) (quit-windows-on "*Flycheck errors*"))
:hint nil)
"Errors"
("f" flycheck-error-list-set-filter "Filter")
("n" flycheck-next-error "Next")
("p" flycheck-previous-error "Previous")
("<" flycheck-first-error "First")
(">" (progn (goto-char (point-max)) (flycheck-previous-error)) "Last")
("q" nil))
(bind-key "C-c h f" #'jethro/hydra-flycheck/body))
(use-package flycheck-pos-tip
:after flycheck
:hook
(flycheck-mode . flycheck-pos-tip-mode))
(flycheck-add-mode 'proselint 'org-mode)
(use-package yasnippet
:diminish yas-global-mode yas-minor-mode
:config
(yas-global-mode +1)
:custom
(yas-snippet-dirs (list (expand-file-name "snippets/snippets" user-emacs-directory))))
(use-package company
:diminish company-mode
:defines (company-dabbrev-ignore-case company-dabbrev-downcase)
:commands company-abort
:bind (("M-/" . company-complete)
("C-/" . company-yasnippet)
:map company-active-map
("M-n" . nil)
("M-p" . nil)
("C-n" . company-select-next)
("C-p" . company-select-previous))
:custom
(company-dabbrev-downcase nil)
(company-idle-delay 0.5)
(company-require-match nil)
(company-minimum-prefix-length 2)
(company-tooltip-align-annotations t)
:init
(global-company-mode +1))
(use-package company-quickhelp
:after company
:bind (:map company-active-map
("M-h" . company-quickhelp-manual-begin))
:hook
(company-mode . company-quickhelp-mode))
(use-package flyspell
:straight nil
:diminish flyspell-mode
:hook
(text-mode . flyspell-mode)
:custom
(flyspell-abbrev-p t)
(ispell-program-name "aspell")
(ispell-dictionary "en_GB"))
(add-hook 'text-mode-hook 'auto-fill-mode)
(add-hook 'message-mode-hook (lambda ()
(auto-fill-mode -1)))
(diminish 'auto-fill-mode)
(defun endless/fill-or-unfill ()
"Like `fill-paragraph', but unfill if used twice."
(interactive)
(let ((fill-column
(if (eq last-command 'endless/fill-or-unfill)
(progn (setq this-command nil)
(point-max))
fill-column)))
(call-interactively #'fill-paragraph)))
(global-set-key [remap fill-paragraph]
#'endless/fill-or-unfill)
(use-package dtrt-indent
:diminish t
:config
(dtrt-indent-mode +1))
(use-package lsp-mode
:commands lsp
:hook
(lsp-after-open-hook . lsp-enable-imenu)
(python-mode . lsp)
(c++-mode . lsp)
(c-mode . lsp)
:custom
(lsp-message-project-root-warning t))
(use-package lsp-ui
:after lsp-mode
:hook
(lsp-mode . lsp-ui-mode)
:config
(define-key lsp-ui-mode-map [remap xref-find-definitions] #'lsp-ui-peek-find-definitions)
(define-key lsp-ui-mode-map [remap xref-find-references] #'lsp-ui-peek-find-references))
(use-package company-lsp
:after (company lsp)
:company lsp-mode)
(use-package dap-mode)
(bind-key "C-c C-k" 'eval-buffer emacs-lisp-mode-map)
(use-package docker
:commands docker-mode)
(use-package dockerfile-mode
:mode "Dockerfile\\'")
(use-package cc-mode
:ensure nil
:mode
("\\.c\\'" . c-mode)
("\\.cpp\\'" . c++-mode)
("\\.h\\'" . c++-mode)
("\\.hpp\\'" . c++-mode))
(add-hook 'c++-mode-hook
(lambda ()
(unless (file-exists-p "Makefile")
(set (make-local-variable 'compile-command)
(let ((file (file-name-nondirectory buffer-file-name)))
(format "g++ -Wall -s -pedantic-errors %s -o %s --std=c++14"
file
(file-name-sans-extension file)))))))
(use-package ccls
:after lsp-mode
:custom
(ccls-executable "ccls"))
(use-package fish-mode
:mode ("\\.fish\\'" . fish-mode))
(use-package rust-mode
:mode ("\\.rs\\'" . rust-mode))
(eval-after-load "python-mode"
(lambda ()
(setq python-remove-cwd-from-path t)))
(use-package py-isort
:commands
(py-isort-buffer py-isort-region))
(use-package blacken
:hook
(python-mode . blacken-mode))
(use-package pytest
:bind (:map python-mode-map
("C-c a" . pytest-all)
("C-c m" . pytest-module)
("C-c ." . pytest-one)
("C-c d" . pytest-directory)
("C-c p a" . pytest-pdb-all)
("C-c p m" . pytest-pdb-module)
("C-c p ." . pytest-pdb-one)))
(use-package highlight-indent-guides
:hook
(python-mode . highlight-indent-guides-mode)
:custom
(highlight-indent-guides-method 'character))
(use-package web-mode
:mode (("\\.html\\'" . web-mode)
("\\.html\\.erb\\'" . web-mode)
("\\.mustache\\'" . web-mode)
("\\.jinja\\'" . web-mode)
("\\.njk\\'" . web-mode)
("\\.php\\'" . web-mode)
("\\.js[x]?\\'" . web-mode))
:custom
(web-mode-enable-css-colorization t)
(web-mode-content-types-alist
'(("jsx" . "\\.js[x]?\\'")))
:config
(setq-default css-indent-offset 2
web-mode-markup-indent-offset 2
web-mode-css-indent-offset 2
web-mode-code-indent-offset 2
web-mode-attr-indent-offset 2))
(use-package emmet-mode
:diminish emmet-mode
:hook
(web-mode . emmet-mode)
(vue-mode . emmet-mode))
(use-package rainbow-mode
:diminish rainbow-mode
:hook
(css-mode . rainbow-mode)
(scss-mode . rainbow-mode))
(use-package js2-mode
:hook
(web-mode-hook . js2-minor-mode)
:config
(setq-default flycheck-disabled-checkers
(append flycheck-disabled-checkers
'(javascript-jshint)))
:custom
(js-switch-indent-offset 2))
(use-package indium
:after js2-mode
:bind (:map js2-mode-map
("C-c C-l" . indium-eval-buffer))
:hook
((js2-mode . indium-interaction-mode)))
(use-package prettier-js
:hook
(js2-minor-mode . prettier-js-mode))
(use-package json-mode
:mode "\\.json\\'"
:hook
(json-mode . (lambda ()
(make-local-variable 'js-indent-level)
(setq js-indent-level 2))))
(use-package markdown-mode
:mode ("\\.md\\'" . markdown-mode)
:commands (markdown-mode gfm-mode)
:custom
(markdown-fontify-code-blocks-natively t)
(markdown-command "multimarkdown --snippet --smart --notes")
(markdown-enable-wiki-links t)
(markdown-indent-on-enter 'indent-and-new-item)
(markdown-asymmetric-header t)
(markdown-live-preview-delete-export 'delete-on-destroy))
(use-package nix-mode
:mode ("\\.nix\\'" . nix-mode))
(use-package nix-update
:commands nix-update-fetch)
(use-package auctex
:mode ("\\.tex\\'" . latex-mode)
:custom
(TeX-auto-save t)
(TeX-parse-self t)
(TeX-syntactic-comment t)
;; Synctex Support
(TeX-source-correlate-start-server nil)
;; Don't insert line-break at inline math
(LaTeX-fill-break-at-separators nil)
(TeX-view-program-list '(("zathura" "zathura --page=%(outpage) %o")))
(TeX-view-program-selection '((output-pdf "zathura")))
:config
(setq-default TeX-engine 'luatex)
(add-hook 'LaTeX-mode-hook
(lambda ()
(company-mode)
(setq TeX-PDF-mode t)
(setq TeX-source-correlate-method 'synctex)
(setq TeX-source-correlate-start-server t)))
(add-hook 'LaTeX-mode-hook 'LaTeX-math-mode)
(add-hook 'LaTeX-mode-hook 'TeX-source-correlate-mode)
(add-hook 'LaTeX-mode-hook 'TeX-PDF-mode))
(use-package company-auctex
:after auctex company-mode)
(use-package yaml-mode
:mode ("\\.yaml\\'" . yaml-mode))
(use-package ess)
(straight-use-package 'org-plus-contrib)
(use-package org
:mode ("\\.org\\'" . org-mode)
:bind
(("C-c l" . org-store-link)
("C-c a" . org-agenda)
("C-c b" . org-iswitchb)
("C-c c" . org-capture))
:bind
(:map org-mode-map
("M-n" . outline-next-visible-heading)
("M-p" . outline-previous-visible-heading))
:custom
(org-src-window-setup 'current-window)
(org-return-follows-link t)
(org-agenda-diary-file "~/.org/diary.org")
(org-babel-load-languages
'((emacs-lisp . t)
(python . t)
(dot . t)))
(org-confirm-babel-evaluate nil)
(org-use-speed-commands t)
(org-catch-invisible-edits 'show)
(org-preview-latex-image-directory "/tmp/ltximg/")
:custom-face
(variable-pitch ((t (:family "iA Writer Duospace" :height 0.9))))
(org-document-title ((t (:weight bold :height 1.5))))
(org-done ((t (:strike-through t :weight bold))))
(org-headline-done ((t (:strike-through t))))
(org-level-1 ((t (:height 1.3 :weight bold))))
(org-level-2 ((t (:height 1.2 :weight bold))))
(org-level-3 ((t (:height 1.1 :weight bold))))
(org-image-actual-width (/ (display-pixel-width) 2))
:custom
(org-structure-template-alist '(("a" . "export ascii")
("c" . "center")
("C" . "comment")
("e" . "example")
("E" . "export")
("h" . "export html")
("l" . "export latex")
("q" . "quote")
("s" . "src")
("v" . "verse")
("el" . "src emacs-lisp")
("d" . "definition")
("t" . "theorem")))
:config
(require 'org-habit)
(require 'org-tempo)
(require 'ol-notmuch))
(require 'org)
(add-hook 'org-mode-hook
'(lambda ()
(setq line-spacing 0.2) ;; Add more line padding for readability
(variable-pitch-mode 1) ;; All fonts with variable pitch.
(mapc
(lambda (face) ;; Other fonts with fixed-pitch.
(set-face-attribute face nil :inherit 'fixed-pitch))
(list 'org-code
'org-link
'org-block
'org-table
'org-verbatim
'org-block-begin-line
'org-block-end-line
'org-meta-line
'org-document-info-keyword))))
(setq org-startup-indented nil
org-hide-leading-stars nil
org-hide-emphasis-markers nil
org-pretty-entities nil