-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinit.el
executable file
·2010 lines (1768 loc) · 72.3 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
;; ======== TEMP BUGFIX FOR EMACS 28 MACRO CHANGE ========
(defmacro define-obsolete-variable-alias (obsolete-name current-name &optional when docstring)
"Make OBSOLETE-NAME a variable alias for CURRENT-NAME and mark it obsolete.
WHEN should be a string indicating when the variable was first
made obsolete, for example a date or a release number.
This macro evaluates all its parameters, and both OBSOLETE-NAME
and CURRENT-NAME should be symbols, so a typical usage would look like:
(define-obsolete-variable-alias 'foo-thing 'bar-thing \"27.1\")
This macro uses `defvaralias' and `make-obsolete-variable' (which see).
See the Info node `(elisp)Variable Aliases' for more details.
If CURRENT-NAME is a defcustom or a defvar (more generally, any variable
where OBSOLETE-NAME may be set, e.g. in an init file, before the
alias is defined), then the define-obsolete-variable-alias
statement should be evaluated before the defcustom, if user
customizations are to be respected. The simplest way to achieve
this is to place the alias statement before the defcustom (this
is not necessary for aliases that are autoloaded, or in files
dumped with Emacs). This is so that any user customizations are
applied before the defcustom tries to initialize the
variable (this is due to the way `defvaralias' works).
For the benefit of Customize, if OBSOLETE-NAME has
any of the following properties, they are copied to
CURRENT-NAME, if it does not already have them:
`saved-value', `saved-variable-comment'."
(declare (doc-string 4)
(advertised-calling-convention
(obsolete-name current-name when &optional docstring) "23.1"))
`(progn
(defvaralias ,obsolete-name ,current-name ,docstring)
(dolist (prop '(saved-value saved-variable-comment))
(and (get ,obsolete-name prop)
(null (get ,current-name prop))
(put ,current-name prop (get ,obsolete-name prop))))
(make-obsolete-variable ,obsolete-name ,current-name ,when)))
(defmacro define-obsolete-face-alias (obsolete-face current-face &optional when)
"Make OBSOLETE-FACE a face alias for CURRENT-FACE and mark it obsolete.
WHEN should be a string indicating when the face was first made
obsolete, for example a date or a release number."
`(progn (put ,obsolete-face 'face-alias ,current-face)
(put ,obsolete-face 'obsolete-face (or (purecopy ,when) t))))
(defmacro define-obsolete-function-alias (obsolete-name current-name &optional when docstring)
"Set OBSOLETE-NAME's function definition to CURRENT-NAME and mark it obsolete.
\(define-obsolete-function-alias \\='old-fun \\='new-fun \"22.1\" \"old-fun's doc.\")
is equivalent to the following two lines of code:
\(defalias \\='old-fun \\='new-fun \"old-fun's doc.\")
\(make-obsolete \\='old-fun \\='new-fun \"22.1\")
WHEN should be a string indicating when the function was first
made obsolete, for example a date or a release number.
See the docstrings of `defalias' and `make-obsolete' for more details."
(declare (doc-string 4))
`(progn (defalias ,obsolete-name ,current-name ,docstring)
(make-obsolete ,obsolete-name ,current-name ,when)))
;; ======== SANE DEFAULTS ========
(setq delete-old-versions -1 ) ; delete excess backup versions silently
(setq version-control t ) ; use version control
(setq vc-make-backup-files t ) ; make backups file even when in version controlled dir
(setq backup-directory-alist `(("." . "~/.emacs.d/backups")) ) ; which directory to put backups file
(setq vc-follow-symlinks t ) ; don't ask for confirmation when opening symlinked file
(setq auto-save-file-name-transforms '((".*" "~/.emacs.d/auto-save-list/" t))) ;; transform backups file name
(setq inhibit-startup-screen t) ;; inhibit useless and old-school startup screen
(setq ring-bell-function 'ignore) ;; silent bell when you make a mistake
(setq coding-system-for-read 'utf-8) ;; use utf-8 by default(setq coding-system-for-write 'utf-8 )
(setq sentence-end-double-space nil) ;; sentence SHOULD end with only a point.
(setq fill-column 80) ;; toggle wrapping text at the 80th character
(menu-bar-mode -1) ;; disable menu bar
(setq initial-scratch-message "Welcome to Emacs") ;; print a default message in the empty scratch buffer opened at startup
(setq user-full-name "Chris Matzenbach"
user-mail-address "[email protected]")
(global-linum-mode 1)
(scroll-bar-mode -1)
(tool-bar-mode -1)
(setq-default indent-tabs-mode nil) ;; use spaces instead of tabs
(setq-default tab-width 2)
;; avoid having to answer "yes" and "no" every time - change to "y" and "n"
(defalias 'yes-or-no-p 'y-or-n-p)
;; keep fringes clean
(setq-default indicate-empty-lines nil)
;; no more ugly line splitting
;;(setq-default truncate-lines t)
;; For MacOS - Add these to the PATH so that proper executables are found
(setenv "PATH" (concat (getenv "PATH") ":/usr/texbin"))
(setenv "PATH" (concat (getenv "PATH") ":/usr/bin"))
(setenv "PATH" (concat (getenv "PATH") ":/usr/local/bin"))
(setq exec-path (append exec-path '("/usr/texbin")))
(setq exec-path (append exec-path '("/usr/bin")))
(setq exec-path (append exec-path '("/usr/local/bin")))
;; ======== HISTORY ========
(setq savehist-file "~/.emacs.d/savehist")
(savehist-mode 1)
(setq history-length t)
(setq history-delete-duplicates t)
(setq savehist-save-minibuffer-history 1)
(setq savehist-additional-variables
'(kill-ring
search-ring
regexp-search-ring))
;; ======== PACKAGE SETUP/USE-PACKAGE ========
(require 'package)
(setq package-enable-at-startup nil)
(setq package-archives '(("melpa". "http://melpa.org/packages/")
("gnu" . "http://elpa.gnu.org/packages/")
("org" . "https://orgmode.org/elpa/")
;; melpa recommends not to use melpa-stable unless you have to
;; ("melpa-stable" . "https://stable.melpa.org/packages/")
))
(package-initialize)
;; bootstrap 'use-package'
(unless (package-installed-p 'use-package) ; unless it is already installed
(package-refresh-contents) ; update package archives
(package-install 'use-package)) ; install most recent version of use-package
(require 'use-package)
;; always download packages if not already installed
(setq use-package-always-ensure t)
;; TESTING enable imenu support for use-package
;; (setq use-package-enable-imenu-support t)
(unless (package-installed-p 'quelpa)
(with-temp-buffer
(url-insert-file-contents "https://raw.githubusercontent.com/quelpa/quelpa/master/quelpa.el")
(eval-buffer)
(quelpa-self-upgrade)))
(quelpa
'(quelpa-use-package
:fetcher git
:url "https://github.com/quelpa/quelpa-use-package.git"))
(require 'quelpa-use-package)
;; ======== LOCAL CONFIG FILES ========
(defconst user-config-dir "~/.emacs.d/config/")
(defun load-user-file (file)
(interactive "f")
"Load a file in current user's configuration directory"
(load-file (expand-file-name file user-config-dir)))
;; load custom config modules
(load-user-file "appearance.el")
;; load manually installed local packages
(add-to-list 'load-path "~/.emacs.d/local-packages/")
;; (add-to-list 'load-path "~/.emacs.d/config/")
(load "let-alist-1.0.5.el")
(load "highlight-escape-sequences.el")
(load "highlight-quoted.el")
;; (load "evil-evilified-state.el")
;; additional syntax highlighting
;; highlights elisp symbols
(use-package highlight-defined)
;; highlights numbers
(use-package highlight-numbers)
;; activate highlight-escape-sequences mode (locally installed package)
(hes-mode)
(add-hook 'prog-mode-hook 'highlight-numbers-mode)
;; ======== RANDOM/GENERAL PACKAGES ========
(use-package sudo-edit
:ensure t)
(use-package page-break-lines)
;; customized starting page dashboard
(use-package dashboard
:ensure t
:config
(dashboard-setup-startup-hook)
(setq dashboard-startup-banner 'logo)
(setq dashboard-center-content t)
(setq dashboard-projects-backend 'projectile)
(setq dashboard-items '((recents . 10)
(bookmarks . 5)
(projects . 8)
;; (agenda . 5)
;; (registers . 5)
))
(setq dashboard-set-heading-icons t)
(setq dashboard-set-file-icons t)
(setq dashboard-set-navigator t))
;; ======== COUNSEL/IVY/SWIPER ========
(use-package counsel
:diminish ivy-mode
:config
(ivy-mode 1)
(setq ivy-use-virtual-buffers t
ivy-count-format "%d/%d ")
(setq ivy-re-builders-alist
'((t . ivy--regex-ignore-order)))
:bind
("C-s" . swiper)
;; https://www.reddit.com/r/emacs/comments/6i8rmb/noob_change_ctrlnp_to_vimlike_binding_for_ivy_and/
(:map ivy-minibuffer-map
("C-h" . evil-delete-char) ; supposed to be (kbd "DEL")
("C-k" . ivy-previous-line)
("C-j" . ivy-next-line)
("C-l" . ivy-alt-done)))
(use-package ivy-hydra
:after ivy-mode)
;; ======== EVIL MODE ========
(use-package evil
:ensure t
:diminish evil-mode
:init
(setq evil-want-C-u-scroll t)
(setq evil-want-integration t)
(setq evil-want-keybinding nil)
(setq evil-undo-system 'undo-tree)
:config
(evil-mode 1))
;; evil-collection - WIP package to create evil keybindings for missing modes
(use-package evil-collection
:after evil
:ensure t
:config
(evil-collection-init))
;; load evil-evilified-state (from author of spacemacs)
;; (load-user-file "evil-evilified-state.el")
;; (require 'evil-evilified-state)
;; ;; use esc to exit minibuffer
;; (defun minibuffer-keyboard-quit ()
;; "Abort recursive edit.
;; In Delete Selection mode, if the mark is active, just deactivate it;
;; then it takes a second \\[keyboard-quit] to abort the minibuffer."
;; (interactive)
;; (if (and delete-selection-mode transient-mark-mode mark-active)
;; (setq deactivate-mark t)
;; (when (get-buffer "*Completions*") (delete-windows-on "*Completions*"))
;; (abort-recursive-edit)))
;; ;; make esc get me out of different situations
;; (define-key evil-normal-state-map [escape] 'keyboard-quit)
;; (define-key evil-visual-state-map [escape] 'keyboard-quit)
;; (define-key minibuffer-local-map [escape] 'minibuffer-keyboard-quit)
;; (define-key minibuffer-local-ns-map [escape] 'minibuffer-keyboard-quit)
;; (define-key minibuffer-local-completion-map [escape] 'minibuffer-keyboard-quit)
;; (define-key minibuffer-local-must-match-map [escape] 'minibuffer-keyboard-quit)
;; (define-key minibuffer-local-isearch-map [escape] 'minibuffer-keyboard-quit)
;(global-set-key [escape] 'evil-exit-emacs-state)
(require 'evil-collection-minibuffer)
;; set c-u to have vim-like behavior (scroll up half page)
(define-key evil-normal-state-map (kbd "C-u") 'evil-scroll-up)
(define-key evil-visual-state-map (kbd "C-u") 'evil-scroll-up)
;; (define-key evil-insert-state-map (kbd "C-u")
;; (lambda ()
;; (interactive)
;; (evil-delete (point-at-bol) (point))))
;; map fd to escape normal mode
(use-package key-chord
:ensure t
:config
(key-chord-mode 1)
(key-chord-define-global "fd" 'evil-normal-state))
(use-package evil-surround
:config
(global-evil-surround-mode))
;; or does this ^ need a t after it? global-evil-surround-mode t
;; ======== INDENTATION/BRACKET MANAGEMENT ========
;; evil-smartparens
(use-package smartparens)
(require 'smartparens-config)
(show-smartparens-global-mode +1)
(define-key smartparens-mode-map (kbd ")") #'sp-paredit-like-close-round)
(use-package evil-smartparens)
;; evil-cleverparens
(use-package evil-cleverparens)
;; make emacs recognize .editorconfig files
(use-package editorconfig
:config
(editorconfig-mode 1))
;; rainbow delimiters, a godsend for lisps and shitty es5 callback stacks from hell
(use-package rainbow-delimiters
:hook (prog-mode . rainbow-delimiters-mode))
;; ======== SUBLIMITY ========
(use-package sublimity)
;; smooth scrolling
(require 'sublimity-scroll)
(sublimity-mode 1)
;; ======== PERSPECTIVE ========
;; (use-package persp-mode)
;; (persp-mode)
;; ======== EYEBROWSE ========
(use-package eyebrowse
:init
(eyebrowse-mode))
;; ======== ACE-WINDOW ========
(use-package ace-window)
;; window hydra
(defhydra hydra-window ()
"
Movement^^ ^Split^ ^Switch^ ^Resize^
----------------------------------------------------------------
_h_ ← _v_ertical _b_uffer _q_ X←
_j_ ↓ _x_ horizontal _f_ind files _w_ X↓
_k_ ↑ _z_ undo _a_ce 1 _e_ X↑
_l_ → _Z_ reset _s_wap _r_ X→
_F_ollow _D_lt Other _S_ave max_i_mize
_SPC_ cancel _o_nly this _d_elete
"
("h" windmove-left )
("j" windmove-down )
("k" windmove-up )
("l" windmove-right )
("q" hydra-move-splitter-left)
("w" hydra-move-splitter-down)
("e" hydra-move-splitter-up)
("r" hydra-move-splitter-right)
("b" ivy-switch-buffer)
("f" counsel-find-files)
("F" follow-mode)
("a" (lambda ()
(interactive)
(ace-window 1)
(add-hook 'ace-window-end-once-hook
'hydra-window/body))
)
("v" (lambda ()
(interactive)
(split-window-right)
(windmove-right))
)
("x" (lambda ()
(interactive)
(split-window-below)
(windmove-down))
)
("s" (lambda ()
(interactive)
(ace-window 4)
(add-hook 'ace-window-end-once-hook
'hydra-window/body)))
("S" save-buffer)
("d" delete-window)
("D" (lambda ()
(interactive)
(ace-window 16)
(add-hook 'ace-window-end-once-hook
'hydra-window/body))
)
("o" delete-other-windows)
("i" ace-maximize-window)
("z" (progn
(winner-undo)
(setq this-command 'winner-undo))
)
("Z" winner-redo)
("SPC" nil)
)
;; ======== AVY ========
(use-package avy
:config
(avy-setup-default))
;; ======== WHICH-KEY && GENERAL ========
(use-package which-key :config (which-key-mode 1))
(setq which-key-idle-delay 0.3)
(use-package general)
(general-define-key
:states '(normal visual insert emacs)
:prefix "SPC"
:non-normal-prefix "C-SPC"
"SPC" 'counsel-M-x
"'" 'new-eshell
;"?" '(eshell- -goto-filedir-or-home :which-key "iterm - goto dir")
"TAB" 'switch-to-previous-buffer
"M-x" 'counsel-M-x ;; gives M-x command counsel features
";" 'comment-dwim ;; comment out lines
;; applications
"a" '(:ignore t :which-key "Applications")
"ad" 'dired
"am" 'hydra-macro/body
"ar" 'ranger
"ao" '(:ignore t :which-key "Org")
"aoa" 'org-agenda
"aob" 'org-switchb
"aoc" 'org-capture
"aol" 'org-store-link
"ar" 'start-restclient
"au" 'counsel-unicode-char
;; buffers
"b" '(:ignore t :which-key "Buffers")
"bb" 'ivy-switch-buffer
"bd" 'kill-this-buffer
"bD" 'kill-buffer-and-window
"bn" 'next-buffer
"bp" 'previous-buffer
;; elisp!
"e" '(:ignore t :which-key "Elisp")
"eb" 'eval-buffer
"er" 'eval-region
;; files
"f" '(:ignore t :which-key "Files")
"fD" 'delete-current-buffer-file
"ff" 'counsel-find-file
"fl" 'counsel-find-library
"fr" 'counsel-recentf
"fed" 'open-config-file
"feR" 'reload-config-file
"fr" 'rename-current-buffer-file
"fs" 'save-buffer
"fS" 'save-all-buffers
;; git
"g" '(:ignore t :which-key "Git")
"gs" 'magit-status
;; help
"h" '(:ignore t :which-key "Help")
"hc" 'helpful-command
"hf" 'helpful-callable
"hk" 'helpful-describe-key
"hm" 'helpful-macro
"hp" 'helpful-at-point
"hv" 'helpful-variable
;; ivy/counsel
"i" '(hydra-ivy/body :which-key "Ivy")
;; jump
"j" '(:ignore t :which-key "Jump")
"jc" 'avy-goto-char-timer
"jd" 'move-line-down
"jfb" 'beginning-of-defun
"jfe" 'end-of-defun
"ji" 'counsel-imenu
"jl" 'avy-goto-line
"jn" 'collapse-next-line
"jq" 'avy-goto-word-0
"ju" 'move-line-up
"jw" 'avy-goto-word-1
;; perspective
;; "l" '(:keymap persp-key-map :package persp-mode :which-key "Layout")
"l" '(:ignore t :which-key "Layout")
"l0" 'eyebrowse-switch-to-window-config-0
"l1" 'eyebrowse-switch-to-window-config-1
"l2" 'eyebrowse-switch-to-window-config-2
"l3" 'eyebrowse-switch-to-window-config-3
"l4" 'eyebrowse-switch-to-window-config-4
"l5" 'eyebrowse-switch-to-window-config-5
"l6" 'eyebrowse-switch-to-window-config-6
"l7" 'eyebrowse-switch-to-window-config-7
"l8" 'eyebrowse-switch-to-window-config-8
"l9" 'eyebrowse-switch-to-window-config-9
"m" 'hydra-by-major-mode
;; org
"o" '(:ignore t :which-key "Org")
"oa" 'org-agenda
"ob" 'org-switchb
"oc" 'org-capture
"ol" 'org-store-link
;; projectile
;; bind p to be the prefix for opening the map of projectile commands
"p" '(:keymap projectile-command-map :package projectile :which-key "Project")
;; search
"s" '(:ignore t :which-key "Search")
"sa" 'counsel-ag
"sg" 'counsel-git-grep
;; windows
"w" '(:ignore t :which-key "Windows")
"wa" 'hydra-window/body
"wd" 'evil-window-delete
"wh" 'evil-window-left
"wj" 'evil-window-down
"wk" 'evil-window-up
"wl" 'evil-window-right
"wr" 'rotate-windows
"w/" 'evil-window-vsplit
"w-" 'evil-window-split
)
;; ======== HYDRA ========
(use-package hydra
:defer t)
;; ======== COMPANY ========
(use-package company
:init
(add-hook 'prog-mode-hook 'global-company-mode)
:config
(setq company-tooltip-align-annotations t
company-minimum-prefix-length 2
company-idle-delay 0.0))
;; trigger company anytime in insert mode with C-l
(define-key evil-insert-state-map (kbd "C-l") #'company-complete)
;; recenter-top-bottom was originally mapped to C-l, change to C-;
(global-set-key (kbd "C-;") 'recenter-top-bottom)
;; use C-j and C-k to navigate through completion menu, C-l to complete
(with-eval-after-load 'company
(define-key company-active-map (kbd "M-n") nil)
(define-key company-active-map (kbd "M-p") nil)
(define-key company-active-map (kbd "C-j") #'company-select-next)
(define-key company-active-map (kbd "C-k") #'company-select-previous)
(define-key company-active-map (kbd "C-l") #'company-complete))
;; Company Box (pretty front-end with icons)
(use-package company-box
:hook (company-mode . company-box-mode))
;; (add-to-list 'load-path "~/.local/share/icons-in-terminal/icons-in-terminal.el")
;; (setq company-box-icons-unknown 'fa_question_circle)
;; (setq company-box-icons-elisp
;; '((fa_tag :face font-lock-function-name-face) ;; Function
;; (fa_cog :face font-lock-variable-name-face) ;; Variable
;; (fa_cube :face font-lock-constant-face) ;; Feature
;; (md_color_lens :face font-lock-doc-face))) ;; Face
;; (setq company-box-icons-yasnippet 'fa_bookmark)
;; (setq company-box-icons-lsp
;; '((1 . fa_text_height) ;; Text
;; (2 . (fa_tags :face font-lock-function-name-face)) ;; Method
;; (3 . (fa_tag :face font-lock-function-name-face)) ;; Function
;; (4 . (fa_tag :face font-lock-function-name-face)) ;; Constructor
;; (5 . (fa_cog :foreground "#FF9800")) ;; Field
;; (6 . (fa_cog :foreground "#FF9800")) ;; Variable
;; (7 . (fa_cube :foreground "#7C4DFF")) ;; Class
;; (8 . (fa_cube :foreground "#7C4DFF")) ;; Interface
;; (9 . (fa_cube :foreground "#7C4DFF")) ;; Module
;; (10 . (fa_cog :foreground "#FF9800")) ;; Property
;; (11 . md_settings_system_daydream) ;; Unit
;; (12 . (fa_cog :foreground "#FF9800")) ;; Value
;; (13 . (md_storage :face font-lock-type-face)) ;; Enum
;; (14 . (md_closed_caption :foreground "#009688")) ;; Keyword
;; (15 . md_closed_caption) ;; Snippet
;; (16 . (md_color_lens :face font-lock-doc-face)) ;; Color
;; (17 . fa_file_text_o) ;; File
;; (18 . md_refresh) ;; Reference
;; (19 . fa_folder_open) ;; Folder
;; (20 . (md_closed_caption :foreground "#009688")) ;; EnumMember
;; (21 . (fa_square :face font-lock-constant-face)) ;; Constant
;; (22 . (fa_cube :face font-lock-type-face)) ;; Struct
;; (23 . fa_calendar) ;; Event
;; (24 . fa_square_o) ;; Operator
;; (25 . fa_arrows)) ;; TypeParameter
;; )
;; Company Quickhelp
;; adds documentation pop-ups to company-mode
(use-package company-quickhelp)
(company-quickhelp-mode)
(eval-after-load 'company
'(define-key company-active-map (kbd "C-c h") #'company-quickhelp-manual-begin))
;; ======== YASNIPPET ========
(use-package yasnippet
:diminish yas-minor-mode)
(yas-global-mode 1)
;; variable used in helper function to embed yas suggestions in company completion window
(defvar company-mode/enable-yas t)
;; snippet sources
(use-package yasnippet-snippets)
;; BUG: no longer exists in package managers
;; (use-package php-auto-yasnippets)
(setq php-auto-yasnippet-php-program "~/.emacs.d/config/Create-PHP-YASnippet.php")
;; ======== FLYCHECK ========
(use-package flycheck
:defer t
:init (global-flycheck-mode))
(defun lunaryorn-use-js-executables-from-node-modules ()
"Set executables of JS checkers from local node modules."
(-when-let* ((file-name (buffer-file-name))
(root (locate-dominating-file file-name "node_modules"))
(module-directory (expand-file-name "node_modules" root)))
(pcase-dolist (`(,checker . ,module) '((javascript-jshint . "jshint")
(javascript-eslint . "eslint")
(javascript-jscs . "jscs")))
(let ((package-directory (expand-file-name module module-directory))
(executable-var (flycheck-checker-executable-variable checker)))
(when (file-directory-p package-directory)
(set (make-local-variable executable-var)
(expand-file-name (concat "bin/" module ".js")
package-directory)))))))
(defhydra 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")
("j" flycheck-next-error "Next")
("k" flycheck-previous-error "Previous")
("gg" flycheck-first-error "First")
("G" (progn (goto-char (point-max)) (flycheck-previous-error)) "Last")
("q" nil))
;; ======== ALL-THE-ICONS =========
(use-package all-the-icons)
;; fix for lag on windows when using all-the-icons
(when (string-equal system-type "windows-nt") (setq inhibit-compacting-font-caches t))
;(use-package spaceline)
;(require 'spaceline-config)
;(use-package spaceline-all-the-icons
; :after spaceline
; :config (spaceline-all-the-icons-theme))
;(setq spaceline-all-the-icons-separator-type 'arrow)
;; ======== DOOM MODELINE ========
(use-package doom-modeline
:ensure t
:init (doom-modeline-mode 1))
;; ======== PROJECTILE ========
(use-package projectile)
(use-package counsel-projectile
:config
(counsel-projectile-mode)
(setq projectile-enable-caching t)
;; overwrite default projectile functions with counsel-projectile alternatives
(define-key projectile-mode-map (kbd "C-c p b") 'counsel-projectile-switch-to-buffer)
(define-key projectile-mode-map (kbd "C-c p b") 'counsel-projectile-switch-to-buffer)
(define-key projectile-mode-map (kbd "C-c p d") 'counsel-projectile-find-dir)
;; currently overwriting projectile-find-file-in-directory (seems pointless)
(define-key projectile-mode-map (kbd "C-c p l") 'counsel-projectile)
(define-key projectile-mode-map (kbd "C-c p f") 'counsel-projectile-find-file)
(define-key projectile-mode-map (kbd "C-c p p") 'counsel-projectile-switch-project)
(define-key projectile-mode-map (kbd "C-c p s g") 'counsel-projectile-grep)
(define-key projectile-mode-map (kbd "C-c p s s") 'counsel-projectile-ag))
;; ======== LSP ========
(use-package lsp-mode
:ensure t
:defer t
;; :config
;; (require 'lsp-ui-imenu)
;; (add-hook 'lsp-after-open-hook 'lsp-ui-enable-imenu)
)
(use-package lsp-ui
:ensure t
:after lsp-mode
:hook (lsp-mode . lsp-ui-mode)
:commands lsp-ui-doc-hide
:bind (: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 u" . lsp-ui-imenu))
:init (setq lsp-ui-doc-enable t
lsp-ui-doc-use-webkit nil
lsp-ui-doc-header nil
lsp-ui-doc-delay 0.0
lsp-ui-doc-include-signature t
lsp-ui-doc-alignment 'frame
;; lsp-ui-doc-use-childframe nil
;; lsp-ui-doc-border (face-foreground 'default)
lsp-ui-peek-enable t
lsp-ui-peek-show-directory t
lsp-ui-sideline-update-mode 'line
lsp-ui-sideline-enable t
lsp-ui-sideline-show-code-actions t
lsp-ui-sideline-show-hover nil
lsp-ui-sideline-ignore-duplicate t)
:config
;; (lsp-ui-peek-jump-backward)
;; (lsp-ui-peek-jump-forward)
;; (add-to-list 'lsp-ui-doc-frame-parameters '(right-fringe . 8))
;; `C-g'to close doc
(advice-add #'keyboard-quit :before #'lsp-ui-doc-hide)
;; Reset `lsp-ui-doc-background' after loading theme
(add-hook 'after-load-theme-hook
(lambda ()
(setq lsp-ui-doc-border (face-foreground 'default))
(set-face-background 'lsp-ui-doc-background
(face-background 'tooltip))))
;; WORKAROUND Hide mode-line of the lsp-ui-imenu buffer
;; @see https://github.com/emacs-lsp/lsp-ui/issues/243
(defadvice lsp-ui-imenu (after hide-lsp-ui-imenu-mode-line activate)
(setq mode-line-format nil)))
;; ======== TREE-SITTER ========
;; (use-package tree-sitter
;; :hook (typescript-mode . tree-sitter-hl-mode)
;; :config
;; (setf (alist-get 'typescript-tsx-mode tree-sitter-major-mode-language-alist) 'tsx))
(use-package tree-sitter
:ensure t
:config
(global-tree-sitter-mode)
(add-hook 'tree-sitter-after-on-hook #'tree-sitter-hl-mode)
)
(use-package tree-sitter-langs
:ensure t
:after tree-sitter)
(with-eval-after-load 'tree-sitter-langs
(tree-sitter-require 'tsx)
(add-to-list 'tree-sitter-major-mode-language-alist '(typescript-mode . tsx))
(tree-sitter-require 'json)
(add-to-list 'tree-sitter-major-mode-language-alist '(bbjson-mode . json)))
;; ======== C-MODE ========
(add-hook 'c-mode-hook #'smartparens-mode)
(add-hook 'c-mode-hook #'evil-smartparens-mode)
(sp-local-pair 'c-mode "{" nil :post-handlers '((my-create-newline-and-enter-sexp "RET")))
;;;;;;;; cquery setup
;; options include irony, cquery, rtags, ggtags, and ycmd
(use-package cquery
:commands (lsp-cquery-enable)
:hook (c-mode-common . lsp-cquery-enable)
:custom
(cquery-executable "/Users/matzy/Development/cquery/BUILD/cquery")
(cquery-project-roots '("/Users/matzy/Projects/IupEmscripten/src" "/Users/matzy/Projects/IupEmscripten/include" "/Users/matzy/Projects/IupEmscripten/src/emscripten"))
;; (cquery-extra-init-params '(:index (:comments 2) :cacheFormat "msgpack"))
(cquery-extra-init-params '(:completion (:detailedLabel t) :extraClangArguments ("-I/Users/matzy/Projects/IupEmscripten/src" "-I/Users/matzy/Projects/IupEmscripten/include"))))
;; BUG: lsp-mode dropped company-lsp support
;; https://github.com/emacs-lsp/lsp-mode/pull/1983
;; (use-package company-lsp
;; :after (lsp-mode company-mode)
;; :custom (company-lsp-enable-recompletion t)
;; :config (add-to-list 'company-backends 'company-lsp))
(use-package ivy-xref
:after ivy
:custom (xref-show-xrefs-function #'ivy-xref-show-xrefs))
;; irony setup
;; (use-package irony
;; :init
;; (setq irony--compile-options
;; '(
;; "-I/Users/matzy/Projects/IupEmscripten/include"
;; "-I/Users/matzy/Projects/IupEmscripten/src")
;; )
;; :config
;; (use-package company-irony)
;; (use-package company-irony-c-headers)
;; (company-mode)
;; (eval-after-load 'company
;; '(add-to-list 'company-backends '(company-irony-c-headers company-irony)))
;; ;; (setq company-backends '(company-irony-c-headers company-irony company-dabbrev-code company-keywords company-yasnippet company-files company-dabbrev))
;; (setq company-backends (delete 'company-semantic company-backends))
;; )
;; (add-hook 'c++-mode-hook 'irony-mode)
;; (add-hook 'c-mode-hook 'irony-mode)
;; (add-hook 'objc-mode-hook 'irony-mode)
;; ;; replace the `completion-at-point' and `complete-symbol' bindings in
;; ;; irony-mode's buffers by irony-mode's function
;; (defun my-irony-mode-hook ()
;; (define-key irony-mode-map [remap completion-at-point]
;; 'irony-completion-at-point-async)
;; (define-key irony-mode-map [remap complete-symbol]
;; 'irony-completion-at-point-async))
;; (add-hook 'irony-mode-hook 'my-irony-mode-hook)
;; (add-hook 'irony-mode-hook 'irony-cdb-autosetup-compile-options)
;; (add-hook 'irony-mode-hook 'irony-eldoc)
;; ;; (add-hook 'c-mode-hook 'flycheck-mode)
;; (eval-after-load 'flycheck
;; '(add-hook 'flycheck-mode-hook #'flycheck-irony-setup))
;; auto-insert include guards in header files
;; autoinsert C/C++ header
(define-auto-insert
(cons "\\.\\([Hh]\\|hh\\|hpp\\)\\'" "My C/C++ header")
'(nil
(let* ((noext (substring buffer-file-name 0 (match-beginning 0)))
(nopath (file-name-nondirectory noext))
(ident (concat (upcase nopath) "_H_")))
(concat "#ifndef " ident "\n"
"#define " ident "\n\n\n"
"\n\n#endif // " ident "\n"))
))
(add-hook 'find-file-hook 'auto-insert)
;; (optional) adds CC special commands to `company-begin-commands' in order to
;; trigger completion at interesting places, such as after scope operator
;; std::|
;; (add-hook 'irony-mode-hook 'company-irony-setup-begin-commands)
;; Don't ask to reload TAGS if newer, just do it
;; (setq tags-revert-without-query 1)
(defhydra hydra-c (:color red
:hint nil)
"
_f_ flycheck
"
("f" hydra-flycheck/body :exit t)
)
;; (use-package cmake-ide
;; :config
;; (cmake-ide-setup)
;; )
;; (require 'cmake-ide)
;; (cmake-ide-setup)
;; ;; Set cmake-ide-flags-c++ to use C++11
;; (setq cmake-ide-cmake-opts "-DCMAKE_TOOLCHAIN_FILE=/Users/matzy/Development/emsdk_portable/emscripten/1.37.9/cmake/Modules/Platform/Emscripten.cmake -DCMAKE_BUILD_TYPE=Debug")
;; ;; (setq cmake-ide-flags-c (append '("-g4")))
;; (setq cmake-ide-build-dir "~/Projects/IupEmscripten/BUILD/emscripten")
;; ;; We want to be able to compile with a keyboard shortcut
;; (global-set-key (kbd "C-c m") 'cmake-ide-compile)
;; ======== JAVASCRIPT ========
(use-package js2-mode
:defer t
:init
(add-to-list 'auto-mode-alist '("\\.js\\'" . js2-mode))
(setq js2-include-node-externs t)
(setq js2-include-browser-externs t)
(setq js2-highlight-level 3)
:config
;; better imenu
(js2-imenu-extras-mode)
;; tern autocompletion
;; (use-package company-tern)
;; (add-to-list 'company-backends 'company-tern)
(add-hook 'js2-mode-hook (lambda ()
;; (tern-mode)
(company-mode)
(smartparens-mode)
(evil-smartparens-mode)
(flycheck-mode)))
;; (define-key tern-mode-keymap (kbd "M-.") nil)
;; (define-key tern-mode-keymap (kbd "M-,") nil)
;; js-mode (which js2 is based on) binds "M-." which conflicts with xref, so
;; unbind it.
(define-key js-mode-map (kbd "M-.") nil)
)
;; javascript/typescript lsp - not bad but doesn't provide much that tide doesnt
;; (use-package lsp-javascript-typescript
;; :init
;; (add-hook 'js2-mode-hook 'lsp-mode)
;; (add-hook 'js2-mode-hook 'company-mode)
;; (add-hook 'js2-mode-hook #'lsp-javascript-typescript-enable)
;; :config
;; (defun my-company-transformer (candidates)
;; (let ((completion-ignore-case t))
;; (all-completions (company-grab-symbol) candidates)))
;; (defun my-js-hook nil
;; (make-local-variable 'company-transformers)
;; (push 'my-company-transformer company-transformers))
;; (add-hook 'js2-mode-hook 'my-js-hook)
;; )
(use-package js2-refactor
:hook (js2-mode . js2-refactor-mode)
:config
(js2r-add-keybindings-with-prefix "C-c C-m"))
(use-package xref-js2
:defer t
:config
(define-key js2-mode-map (kbd "C-k") #'js2r-kill)
)
;; add-node-modules-path retrives binaries from node_modules for things like eslint
(use-package add-node-modules-path
:hook (js2-mode . add-node-modules-path))
;; setup mode hooks
(sp-local-pair 'js2-mode "{" nil :post-handlers '((my-create-newline-and-enter-sexp "RET")))
(add-hook 'js2-mode-hook (lambda ()
(add-hook 'xref-backend-functions #'xref-js2-xref-backend nil t)))
;; indium
(use-package indium
:defer t
:config
(add-to-list 'evil-emacs-state-modes 'indium-repl-mode))
;; skewer
;; (use-package skewer-mode
;; :defer t)
;; spacemacs skewer functions
;; (defun spacemacs/skewer-start-repl ()
;; "Attach a browser to Emacs and start a skewer REPL."
;; (interactive)
;; (run-skewer)
;; (skewer-repl))
;; (defun spacemacs/skewer-load-buffer-and-focus ()
;; "Execute whole buffer in browser and switch to REPL in insert state."
;; (interactive)
;; (skewer-load-buffer)
;; (skewer-repl)
;; (evil-insert-state))
;; (defun spacemacs/skewer-eval-defun-and-focus ()
;; "Execute function at point in browser and switch to REPL in insert state."
;; (interactive)
;; (skewer-eval-defun)
;; (skewer-repl)
;; (evil-insert-state))
;; (defun spacemacs/skewer-eval-region (beg end)
;; "Execute the region as JavaScript code in the attached browser."
;; (interactive "r")
;; (skewer-eval (buffer-substring beg end) #'skewer-post-minibuffer))
;; (defun spacemacs/skewer-eval-region-and-focus (beg end)
;; "Execute the region in browser and swith to REPL in insert state."
;; (interactive "r")
;; (spacemacs/skewer-eval-region beg end)
;; (skewer-repl)
;; (evil-insert-state))
;; js2-refactor hydra
(defhydra hydra-js2-refactor (:color blue :hint nil)
"
^Functions^ ^Variables^ ^Buffer^ ^sexp^ ^Debugging^
------------------------------------------------------------------------------------------------------------------------------
[_lp_] Localize Parameter [_ev_] Extract variable [_wi_] Wrap buffer in IIFE [_k_] js2 kill [_lt_] log this
[_ef_] Extract function [_iv_] Inline variable [_ig_] Inject global in IIFE [_ss_] split string [_dt_] debug this
[_ip_] Introduce parameter [_rv_] Rename variable [_ee_] Expand node at point [_sl_] forward slurp
[_em_] Extract method [_vt_] Var to this [_cc_] Contract node at point [_ba_] forward barf
[_ao_] Arguments to object [_sv_] Split var decl. [_uw_] unwrap
[_tf_] Toggle fun exp and decl [_ag_] Add var to globals
[_ta_] Toggle fun expr and => [_ti_] Ternary to if
[_z_] return [_q_] quit"
("ee" js2r-expand-node-at-point)
("cc" js2r-contract-node-at-point)
("ef" js2r-extract-function)
("em" js2r-extract-method)
("tf" js2r-toggle-function-expression-and-declaration)
("ta" js2r-toggle-arrow-function-and-expression)
("ip" js2r-introduce-parameter)
("lp" js2r-localize-parameter)
("wi" js2r-wrap-buffer-in-iife)
("ig" js2r-inject-global-in-iife)
("ag" js2r-add-to-globals-annotation)
("ev" js2r-extract-var)
("iv" js2r-inline-var)
("rv" js2r-rename-var)
("vt" js2r-var-to-this)
("ao" js2r-arguments-to-object)
("ti" js2r-ternary-to-if)
("sv" js2r-split-var-declaration)
("ss" js2r-split-string)
("uw" js2r-unwrap)
("lt" js2r-log-this)
("dt" js2r-debug-this)
("sl" js2r-forward-slurp)
("ba" js2r-forward-barf)