This repository has been archived by the owner on Mar 15, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 19
/
init.el
1801 lines (1607 loc) · 58.5 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 -*-
;;; Straight setup
(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)
;;; Use-package Setup
(straight-use-package 'use-package)
(use-package blackout
:straight (blackout :host github :repo "raxod502/blackout")
:demand t)
(use-package el-patch
:straight (:host github
:repo "raxod502/el-patch"
:branch "develop"))
(eval-when-compile
(require 'el-patch))
;;; EXWM setup
(add-to-list 'load-path (expand-file-name "elisp" user-emacs-directory))
(require 'emacsql-sqlite)
(require 'exwm)
(when (featurep 'exwm)
(require 'exwm-config))
;;; The Basics
(setq user-full-name "Jethro Kuan"
user-mail-address "[email protected]")
(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))))
(use-package autorevert
:straight nil
:blackout t
:hook
(focus-in . doom-auto-revert-buffers-h)
(after-save . doom-auto-revert-buffers-h)
:custom
(auto-revert-verbose t)
(auto-revert-use-notify nil)
(auto-revert-stop-on-user-input nil)
(revert-without-query '("."))
:config
(defun doom-visible-buffers (&optional buffer-list)
"Return a list of visible buffers (i.e. not buried)."
(if buffer-list
(cl-remove-if-not #'get-buffer-window buffer-list)
(delete-dups (mapcar #'window-buffer (window-list)))))
(defun doom-auto-revert-buffer-h ()
"Auto revert current buffer, if necessary."
(unless (or auto-revert-mode (active-minibuffer-window))
(auto-revert-handler)))
(defun doom-auto-revert-buffers-h ()
"Auto revert stale buffers in visible windows, if necessary."
(dolist (buf (doom-visible-buffers))
(with-current-buffer buf
(doom-auto-revert-buffer-h)))))
(setq custom-file (expand-file-name "custom.el" user-emacs-directory))
(defalias 'yes-or-no-p 'y-or-n-p)
(add-hook 'after-init-hook #'delete-selection-mode)
(setq-default word-wrap t
truncate-lines t
truncate-partial-width-windows nil)
(setq sentence-end-double-space t
delete-trailing-lines nil
require-final-newline t)
(setq-default tab-width 2
tab-always-indent t
indent-tabs-mode nil
fill-column 80)
(setq-default js-indent-level 2)
(setq auto-save-default nil
make-backup-files nil
create-lockfiles nil)
(setq browse-url-browser-function 'browse-url-xdg-open)
(add-hook 'after-save-hook 'executable-make-buffer-file-executable-if-script-p)
;;; Theming
(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
:config
(load-theme 'doom-tomorrow-night t)
(doom-themes-visual-bell-config)
(doom-themes-org-config))
(use-package doom-modeline
:hook (after-init . doom-modeline-mode)
:config
(setq doom-modeline-enable-word-count t)
(setq doom-modeline-buffer-encoding nil)
(setq doom-modeline-github t))
(setq show-paren-style 'parenthesis
show-paren-delay 0
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 isearch
:straight nil
:custom
(search-highlight t)
(search-whitespace-regexp ".*?")
(isearch-lax-whitespace t)
(isearch-regexp-lax-whitespace nil)
(isearch-lazy-highlight t)
(isearch-lazy-count t)
(lazy-count-prefix-format " (%s/%s) ")
(lazy-count-suffix-format nil)
(isearch-yank-on-move 'shift)
(isearch-allow-scroll 'unlimited))
(add-hook 'after-init-hook #'column-number-mode)
(use-package subword
:straight nil
:hook (prog-mode . subword-mode))
(use-package hl-todo
:config
(global-hl-todo-mode))
;;; Navigation
(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))
(use-package beacon
:blackout beacon-mode
:custom
(beacon-push-mark 10)
:config
(beacon-mode +1))
(use-package volatile-highlights
:blackout volatile-highlights-mode
:config
(volatile-highlights-mode +1))
(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))
;;; Mail (notmuch)
(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:inbox and tag:unread")
(:name "org-roam" :query "tag:inbox and tag:roam")
(:name "personal" :query "tag:inbox and tag:personal")
(:name "nushackers" :query "tag:inbox and tag:nushackers")
(:name "nus" :query "tag:inbox and tag:nus")
(:name "drafts" :query "tag:draft")))
:config
(defun jethro/org-capture-email ()
(interactive)
(org-capture nil "e")))
(use-package org-msg
;; Only for mu4e
:disabled t
:hook (message-mode . org-msg-mode)
:custom
(org-msg-options "html-postamble:nil H:5 num:nil ^:{} toc:nil")
(org-msg-greeting-name-limit 3)
(org-msg-greeting-fmt "\nHi *%s*,\n\n")
(org-msg-startup "hidestars indent inlineimages")
(org-msg-signature "\n\nRegards,\nJethro Kuan"))
;;; Dired
(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
:demand t
:bind (:map dired-mode-map
("/" . dired-narrow-fuzzy)))
;;; Utilities
(use-package crux
:bind (("C-c o" . crux-open-with)
("C-a" . crux-move-beginning-of-line)
("C-c D" . crux-delete-file-and-buffer)
("C-c r" . crux-rename-file-and-buffer)))
;;; Ivy
(use-package counsel
:demand t
: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)
("C-c s" . counsel-rg)
("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
(ivy-use-virtual-buffers t)
(enable-recursive-minibuffers t)
(ivy-display-style 'fancy)
(ivy-use-selectable-prompt t)
(ivy-re-builders-alist
'((t . ivy--regex-plus)))
:config
(ivy-mode +1))
(use-package ivy-rich
:init
(setq ivy-rich-display-transformers-list ; max column width sum = (ivy-poframe-width - 1)
'(ivy-switch-buffer
(:columns
((ivy-rich-candidate (:width 30)) ; return the candidate itself
(ivy-rich-switch-buffer-size (:width 7)) ; return the buffer size
(ivy-rich-switch-buffer-indicators (:width 4 :face error :align right)); return the buffer indicators
(ivy-rich-switch-buffer-major-mode (:width 12 :face warning)) ; return the major mode info
(ivy-rich-switch-buffer-project (:width 15 :face success)) ; return project name using `projectile'
(ivy-rich-switch-buffer-path (:width (lambda (x) (ivy-rich-switch-buffer-shorten-path x (ivy-rich-minibuffer-width 0.3)))))) ; return file path relative to project root or `default-directory' if project is nil
:predicate
(lambda (cand) (get-buffer cand)))
counsel-M-x
(:columns
((counsel-M-x-transformer (:width 35))
(ivy-rich-counsel-function-docstring (:width 34 :face font-lock-doc-face))))
counsel-describe-function
(:columns
((counsel-describe-function-transformer (:width 35))
(ivy-rich-counsel-function-docstring (:width 34 :face font-lock-doc-face))))
counsel-describe-variable
(:columns
((counsel-describe-variable-transformer (:width 35))
(ivy-rich-counsel-variable-docstring (:width 34 :face font-lock-doc-face))))))
:config
(ivy-rich-mode +1)
(setcdr (assq t ivy-format-functions-alist) #'ivy-format-function-line))
;;; Project Management
(use-package projectile
:custom
(projectile-use-git-grep t)
(projectile-create-missing-test-files t)
(projectile-completion-system 'ivy)
:config
(define-key projectile-mode-map (kbd "C-x p") 'projectile-command-map)
(projectile-mode +1))
(use-package wgrep
:commands
wgrep-change-to-wgrep-mode)
(use-package deadgrep
:if (executable-find "rg")
:bind* (("M-s" . deadgrep)))
(use-package ripgrep
:if (executable-find "rg"))
(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))
;;; Version Control
(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))
;;; Text Editing
(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
:blackout 'ws-butler-mode
:hook
(prog-mode . ws-butler-mode))
(use-package easy-kill
:bind*
(([remap kill-ring-save] . easy-kill)))
(use-package emojify
:defer 10
:custom
(emojify-emoji-styles '(unicode))
:bind (("C-c e" . emojify-insert-emoji))
:config
(global-emojify-mode +1))
(use-package whitespace
:straight nil
:blackout whitespace-mode
:hook (prog-mode . whitespace-mode)
:custom
(whitespace-line-column 80)
(whitespace-style '(face lines-tail)))
(use-package flyspell
:straight nil
:blackout flyspell-mode
:hook
(text-mode . flyspell-mode)
:custom
(flyspell-abbrev-p t)
(ispell-extra-args '("--encoding=utf-8" "--sug-mode=ultra")))
(use-package flyspell-correct-ivy
:bind
(:map flyspell-mode-map
(("C-;" . flyspell-correct-wrapper)))
:custom
(flyspell-correct-interface #'flyspell-correct-ivy))
(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)
;;; Writing
(use-package olivetti
:commands (olivetti-mode))
;;; Programming Utilities
(use-package highlight-indent-guides
:hook
(python-mode . highlight-indent-guides-mode)
(yaml-mode . highlight-indent-guides-mode)
:custom
(highlight-indent-guides-method 'character))
(use-package apheleia
:straight (apheleia :host github :repo "raxod502/apheleia")
:config
(apheleia-global-mode +1))
(use-package aggressive-indent
:blackout 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 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))
:custom
(sp-max-prefix-length 25)
(sp-max-pair-length 4)
:init
(smartparens-global-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"))))
(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))))))
(use-package bury-successful-compilation
:hook
(prog-mode . bury-successful-compilation))
(use-package direnv
:demand t
:if (executable-find "direnv")
:custom
(direnv-always-show-summary nil)
:config
(with-eval-after-load 'flycheck
(setq flycheck-executable-find
(lambda (cmd)
(add-hook 'post-command-hook #'direnv--maybe-update-environment)
(direnv-update-environment default-directory)
(executable-find cmd))))
(direnv-mode +1))
(use-package flycheck
:commands (flycheck-mode
flycheck-next-error
flycheck-previous-error)
:init
(dolist (where '((emacs-lisp-mode-hook . emacs-lisp-mode-map)))
(add-hook (car where)
`(lambda ()
(bind-key "M-n" #'flycheck-next-error ,(cdr where))
(bind-key "M-p" #'flycheck-previous-error ,(cdr where)))))
(when (executable-find "proselint")
(add-hook 'text-mode-hook 'flycheck-mode)))
(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))
(use-package yasnippet
:blackout ((yas-global-mode . t)
(yas-minor-mode . t))
:config
(add-to-list 'load-path (expand-file-name "snippets" user-emacs-directory))
(require 'yasnippet-snippets)
(yas-global-mode +1)
:custom
(yas-snippet-dirs (list (expand-file-name "snippets/snippets" user-emacs-directory))))
(use-package company
:blackout company-mode
:defines (company-dabbrev-ignore-case company-dabbrev-downcase)
:commands company-abort
:bind (("C-/" . company-complete)
:map company-active-map
(("<RET>" . nil)
("<tab>" . company-select-next)
("<backtab>" . company-select-previous)
("C-n" . company-select-next)
("C-p" . company-select-previous)
("M-n" . company-other-backend)))
:custom
(company-minimum-prefix-length 2)
(company-tooltip-limit 14)
(company-dabbrev-downcase nil)
(company-dabbrev-ignore-case nil)
(company-dabbrev-code-other-buffers t)
(company-tooltip-align-annotations t)
(company-require-match 'never)
(company-idle-delay 0.5)
(company-require-match nil)
(company-tooltip-align-annotations t)
(company-backends '(company-capf))
(company-frontends '(company-pseudo-tooltip-frontend
company-echo-metadata-frontend))
(company-global-modes '(not erc-mode message-mode help-mode gud-mode eshell-mode))
:config
(global-company-mode +1)
(dolist (where '((text-mode-hook . (company-dabbrev company-yasnippet company-ispell))
(prog-mode-hook . (company-capf company-yasnippet))
(conf-mode-hook . (company-capf company-dabbrev-code company-yasnippet))))
(add-hook (car where)
(lambda ()
(setq-local company-backends (cdr where))))))
(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 company-posframe
:after company
:hook (company-mode . company-posframe-mode))
(use-package dtrt-indent
:blackout 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)
:config
(add-hook 'lsp-mode-hook (lambda ()
(setq-local company-backends
(cons 'company-lsp company-backends)))))
(use-package dap-mode)
(use-package outshine
:hook
(emacs-lisp-mode . outshine-mode)
:straight (outshine :host github :repo "alphapapa/outshine"))
;;; Emacs Lisp
(use-package elisp-mode
:straight nil
:bind (:map emacs-lisp-mode-map
("C-c C-x" . ielm)
("C-c C-c" . eval-defun)
("C-c C-k" . eval-buffer)))
(use-package emacsql
:straight nil
:hook
(emacs-mode . emacsql-fix-vector-indentation)
:bind
(:map emacs-lisp-mode-map
(("C-c C-e" . emacsql-show-last-sql))))
(use-package helpful
:defines (counsel-describe-function-function
counsel-describe-variable-function)
:commands helpful--buffer
:bind (([remap describe-key] . helpful-key)
([remap describe-symbol] . helpful-symbol)
("C-c C-d" . helpful-at-point))
:init
(with-eval-after-load 'counsel
(setq counsel-describe-function-function #'helpful-callable
counsel-describe-variable-function #'helpful-variable))
(with-eval-after-load 'apropos
;; patch apropos buttons to call helpful instead of help
(dolist (fun-bt '(apropos-function apropos-macro apropos-command))
(button-type-put
fun-bt 'action
(lambda (button)
(helpful-callable (button-get button 'apropos-symbol)))))
(dolist (var-bt '(apropos-variable apropos-user-option))
(button-type-put
var-bt 'action
(lambda (button)
(helpful-variable (button-get button 'apropos-symbol)))))))
;;; Docker
(use-package docker
:commands docker-mode)
(use-package dockerfile-mode
:mode "Dockerfile\\'")
;;; C/C++
(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"))
;;; Fish
(use-package fish-mode
:mode ("\\.fish\\'" . fish-mode))
;;; Rust
(use-package rust-mode
:mode ("\\.rs\\'" . rust-mode))
(with-eval-after-load "python-mode"
(setq python-remove-cwd-from-path t))
;;; Web
(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
:blackout emmet-mode
:hook
(web-mode . emmet-mode)
(vue-mode . emmet-mode))
(use-package rainbow-mode
:blackout 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)))
;;; JSON
(use-package json-mode
:mode "\\.json\\'"
:hook
(json-mode . (lambda ()
(make-local-variable 'js-indent-level)
(setq js-indent-level 2))))
;;; Markdown
(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))
;;; Nix
(use-package nix-mode
:mode ("\\.nix\\'" . nix-mode))
(use-package nix-update
:commands nix-update-fetch)
;;; LaTeX
(defvar latex--company-backends nil)
(use-package tex
:straight nil
:mode ("\\.tex\\'" . LaTeX-mode)
:custom
(TeX-auto-save t) ; parse on save
(TeX-parse-self t) ; parse on load