-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathinit.el
4494 lines (3829 loc) · 147 KB
/
init.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
;;; init.el --- Emacs configuration of Aaron Culich -*- lexical-binding: t; -*-
;;
;; Copyright (c) 2016 Aaron Culich <[email protected]>
;; Copyright (c) 2012-2016 Sebastian Wiesner <[email protected]>
;; Copyright (c) 2016 WellonsChristopher <[email protected]>
;;
;; Author: Aaron Culich <[email protected]>
;; URL: https://gihub.com/aculich/.emacs.d
;; Keywords: convenience
;; This file is not part of GNU Emacs.
;; This program is free software; you can redistribute it and/or modify it under
;; the terms of the GNU General Public License as published by the Free Software
;; Foundation; either version 3 of the License, or (at your option) any later
;; version.
;; This program is distributed in the hope that it will be useful, but WITHOUT
;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
;; FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
;; details.
;; You should have received a copy of the GNU General Public License along with
;; GNU Emacs; see the file COPYING. If not, write to the Free Software
;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
;; USA.
;;; Commentary:
;; Emacs configuration of Aaron Culich
;;
;; Based heavily on (e.g. forked directly from) Sebastian Wiesner's awesome
;; Emacs setup: https://github.com/lunaryorn/.emacs.d
;;
;; With many awesome additions taken from Christopher Wellons's configs:
;; https://github.com/skeeto/.emacs.d
;;; Code:
;;; Debugging
(setq message-log-max 10000)
;;;; Paths
(prefer-coding-system 'utf-8-unix)
(set-language-environment "UTF-8")
(setq iso-transl-char-map nil) ; http://emacs.stackexchange.com/a/17524/2138
(defvar user-setup-directory (expand-file-name "setup" user-emacs-directory))
(defvar user-setup-builtins-directory (expand-file-name "setup/builtins" user-emacs-directory))
(defvar local-dev-package-directory (expand-file-name "packages" user-emacs-directory))
(defvar user-data-directory (expand-file-name "" user-emacs-directory))
(defvar user-cache-directory (expand-file-name ".cache" user-emacs-directory))
(defvar user-bin-directory (expand-file-name "bin" "~"))
(setq custom-file (expand-file-name "settings.el" user-emacs-directory))
(make-directory user-cache-directory t)
;;; Package management
;; Please don't load outdated byte code
(setq load-prefer-newer t)
;;;; test -e ~/.cask || ln -s $(dirname $(brew list cask | grep cask.el | head -1)) ~/.cask
; (require 'cask "~/.cask/cask.el")
; (ignore-errors (cask-initialize))
(require 'package)
(setq package-enable-at-startup nil)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/"))
(package-initialize)
;; Bootstrap `use-package'
(unless (package-installed-p 'use-package)
(package-refresh-contents)
(package-install 'use-package))
;;; Requires
(eval-when-compile
(require 'use-package)
(setq use-package-verbose t))
(use-package benchmark-init
:ensure t)
(require 'diminish) ;; if you use :diminish
(require 'bind-key)
(require 'subr-x)
(require 'time-date)
;;; Initialization
(when (version< emacs-version "25")
(warn "This configuration needs Emacs trunk, but this is %s!" emacs-version))
;; And disable the site default settings
(setq inhibit-default-init t)
(defun lunaryorn-snapshot-version-p (version)
"Whether VERSION is an Emacs snapshot version."
(pcase-let ((`(,_ ,_ ,build) (version-to-list version)))
;; Snapshots with build numbers > 90 are pretests which come from proper
;; release tarballs and don't need to be rebuild weekly
(and (>= build 50) (<= build 90))))
(when (lunaryorn-snapshot-version-p emacs-version)
;; When on a snapshot version, warn if the build is older than a week to
;; ensure that we stay up to date.
(run-with-idle-timer
2 nil
(lambda ()
(let ((time-since-build (time-subtract (current-time) emacs-build-time)))
(when (> (time-to-number-of-days time-since-build) 7)
(lwarn 'emacs :warning "Your Emacs build is more than a week old!"))))))
;;; Environment fixup
(use-package exec-path-from-shell
:ensure t
:if (and (eq system-type 'darwin) (display-graphic-p))
:config
(progn
(when (string-match-p "/zsh$" (getenv "SHELL"))
;; Use a non-interactive login shell. A login shell, because my
;; environment variables are mostly set in `.zprofile'.
(setq exec-path-from-shell-arguments '("-l")))
;; Import additional environment variables beyond just $PATH
(dolist (var '("PYTHONPATH" ; Python modules
"INFOPATH" ; Info directories
"JAVA_OPTS" ; Options for java processes
"SBT_OPTS" ; Options for SBT
"RUST_SRC_PATH" ; Rust sources, for racer
"CARGO_HOME" ; Cargo home, for racer
"EMAIL" ; My personal email
"GPG_TTY"
"GPG_AGENT_INFO"
"SSH_AUTH_SOCK"
"SSH_AGENT_PID"
))
(add-to-list 'exec-path-from-shell-variables var))
;; Initialize Emacs' environment from the shell
(exec-path-from-shell-initialize)
;; Tell Emacs about my email address
;; FIXME: bug triggered in tramp-loaddefs.el:543 if user-mail-address is nil
;; /Applications/Emacs.app/Contents/Resources/lisp/net/
;; report upstream in two places:
;; https://github.com/lunaryorn/.emacs.d/
;; upstream emacs source: tramp-loaddefs.el:543
(setq user-mail-address (or (getenv "EMAIL") "[email protected]"))
;; Re-initialize the `Info-directory-list' from $INFOPATH. Since package.el
;; already initializes info, we need to explicitly add the $INFOPATH
;; directories to `Info-directory-list'. We reverse the list of info paths
;; to prepend them in proper order subsequently
(with-eval-after-load 'info
(dolist (dir (nreverse (parse-colon-path (getenv "INFOPATH"))))
(when dir
(add-to-list 'Info-directory-list dir))))))
;;; Customization
(defconst lunaryorn-custom-file (locate-user-emacs-file "custom.el")
"File used to store settings from Customization UI.")
(use-package cus-edit
:defer t
:config
(setq custom-file lunaryorn-custom-file
custom-buffer-done-kill nil ; Kill when existing
custom-buffer-verbose-help nil ; Remove redundant help text
;; Show me the real variable name
custom-unlispify-tag-names nil
custom-unlispify-menu-entries nil)
:init (load lunaryorn-custom-file 'no-error 'no-message))
;;; OS X support
(use-package ns-win ; OS X window support
:defer t
:if (eq system-type 'darwin)
:config
(setq ns-pop-up-frames nil ; Don't pop up new frames from the
; workspace
mac-option-modifier 'meta ; Option is simply the natural Meta
mac-command-modifier 'meta ; But command is a lot easier to hit
mac-right-command-modifier 'left
mac-right-option-modifier 'none ; Keep right option for accented input
;; Just in case we ever need these keys
mac-function-modifier 'hyper))
(use-package lunaryorn-osx ; Personal OS X tools
:if (eq system-type 'darwin)
:load-path "lisp/"
:defer t)
(use-package osx-trash ; Trash support for OS X
:if (eq system-type 'darwin)
:ensure t
:init (osx-trash-setup))
;;; Fonts
;; We use these fonts:
;;
;; - Monoid (http://larsenwork.com/monoid/) as default
;; - XITS Math (https://github.com/khaledhosny/xits-math) as fallback for math
;;
;; Source Code Pro (https://github.com/adobe-fonts/source-code-pro) is a good
;; monospace font, too. An alternative is Consolas. Another great monospace
;; font is and Pragmata Pro (http://www.fsd.it/fonts/pragmatapro.htm,
;; proprietary, around 200$).
;;
;; Currently this setup only works for OS X, as we rely on Apple's Emoji and
;; Symbol fonts.
;;
;; TODO: Find Emoji and symbol fonts for Linux and Windows
;; TODO: need a better fallback option if these custom fonts are not available
(set-face-attribute 'default nil
:family "Source Code Pro" :height 110)
(set-face-attribute 'variable-pitch nil
:family "Fira Sans" :height 120 :weight 'regular)
;; Font setup
(defun lunaryorn-configure-fonts (frame)
"Set up fonts for FRAME.
Set the default font, and configure various overrides for
symbols, emojis, greek letters, as well as fall backs for."
;; Additional fonts for special characters and fallbacks
;; Test range: 🐷 ❤ ⊄ ∫ 𝛼 α 🜚 Ⓚ
(dolist (script '(symbol mathematical))
(set-fontset-font t script (font-spec :family "XITS Math")
frame 'prepend))
;; Define a font set stack for symbols, greek and math characters
(dolist (script '(symbol greek mathematical))
(set-fontset-font t script (font-spec :family "Arial Unicode MS")
frame 'prepend)
(set-fontset-font t script (font-spec :family "Menlo")
frame 'prepend)
(set-fontset-font t script (font-spec :family "DejaVu Sans Mono")
frame 'prepend))
(when (eq system-type 'darwin)
;; Colored Emoji on OS X, prefer over everything else!
(set-fontset-font t nil (font-spec :family "Apple Color Emoji")
frame 'prepend))
;; Fallbacks for math and generic symbols
(set-fontset-font t nil (font-spec :family "Apple Symbols")
frame 'append))
(when-let (frame (selected-frame))
(lunaryorn-configure-fonts frame))
(add-hook 'after-make-frame-functions #'lunaryorn-configure-fonts)
(use-package face-remap ; Face remapping
:bind (("C-c w z" . text-scale-adjust)))
;;; User interface
;; Get rid of tool bar, menu bar and scroll bars. On OS X we preserve the menu
;; bar, since the top menu bar is always visible anyway, and we'd just empty it
;; which is rather pointless.
(when (fboundp 'tool-bar-mode)
(tool-bar-mode -1))
(when (and (not (eq system-type 'darwin)) (fboundp 'menu-bar-mode))
(menu-bar-mode -1))
(when (fboundp 'scroll-bar-mode)
(scroll-bar-mode -1))
;; No blinking and beeping, no startup screen, no scratch message and short
;; Yes/No questions.
(blink-cursor-mode -1)
(setq ring-bell-function #'ignore
inhibit-startup-screen t
initial-scratch-message "Hello there!\n")
(fset 'yes-or-no-p #'y-or-n-p)
;; Opt out from the startup message in the echo area by simply disabling this
;; ridiculously bizarre thing entirely.
(fset 'display-startup-echo-area-message #'ignore)
;; Insert my logo into scratch <3
(add-hook 'after-init-hook
(lambda ()
(with-current-buffer "*scratch*"
(goto-char (point-min))
(insert-image (create-image (locate-user-emacs-file "logo.png"))
"logo")
(insert "\n"))))
(use-package flatland-black-theme
:ensure t
:init
(progn
(load-theme 'flatland-black :no-confirm)
(setf frame-background-mode 'dark)
(global-hl-line-mode 1)))
(use-package dakrone-theme
:disabled t
:ensure t
:init
(progn
(load-theme 'atom-dark :no-confirm)
(setf frame-background-mode 'dark)
(global-hl-line-mode 1)))
(use-package atom-dark-theme
:disabled t
:ensure t
:init
(progn
(load-theme 'atom-dark :no-confirm)
(setf frame-background-mode 'dark)
(global-hl-line-mode 1)))
(use-package cyberpunk-theme
:disabled t
:ensure t
:init
(progn
(load-theme 'cyberpunk :no-confirm)
(setf frame-background-mode 'dark)
(global-hl-line-mode 1)))
(use-package color-theme-sanityinc-tomorrow
:disabled t
:ensure t
:init
(progn
(load-theme 'sanityinc-tomorrow-black :no-confirm)
;; (load-theme 'sanityinc-tomorrow-blue :no-confirm)
;; (load-theme 'sanityinc-tomorrow-night :no-confirm)
(setf frame-background-mode 'dark)
(global-hl-line-mode 1)
(custom-set-faces
'(cursor ((t :background "#eebb28")))
'(diff-added ((t :foreground "green" :underline nil)))
'(diff-removed ((t :foreground "red" :underline nil)))
'(highlight ((t :background "black" :underline nil)))
'(magit-item-highlight ((t :background "black")))
'(hl-line ((t :background "gray10"))))))
(use-package solarized ; My colour theme
:disabled t
:ensure solarized-theme
:config
;; Disable variable pitch fonts in Solarized theme
(setq solarized-use-variable-pitch nil
;; Prefer italics over bold
solarized-use-less-bold t
solarized-use-more-italic t
solarized-distinct-doc-face t ; Emphasize docstrings
;; I find different font sizes irritating.
solarized-height-minus-1 1.0
solarized-height-plus-1 1.0
solarized-height-plus-2 1.0
solarized-height-plus-3 1.0
solarized-height-plus-4 1.0)
(load-theme 'solarized-dark 'no-confirm))
(bind-key "C-c t v" #'variable-pitch-mode)
(use-package page-break-lines ; Turn page breaks into lines
:ensure t
:init (global-page-break-lines-mode)
:diminish page-break-lines-mode)
(use-package beacon ; Highlight cursor position in buffer
:ensure t
:init (beacon-mode 1)
:diminish beacon-mode)
(use-package stripe-buffer ; Add stripes to a buffer
:disabled t
:ensure t
:init (add-hook 'dired-mode-hook #'stripe-buffer-mode))
;;; Keys and key bindings
;; Our key bindings are solely in the user space C-c <letter>. The list of
;; which-key prefixes documents the meaning of specific key prefixes, such as
;; C-c f for file commands. C-c m is special in that it always holds commands
;; that are only for the current major mode. The mode-specific which-key
;; prefixes document the individual bindings for major modes under C-c m.
;;
;; We may also bind F5 to F9. Since we can't document these in code, the
;; following list shows their abstract meanings:
;;
;; * F5: Compile
;; * F6: n/a
;; * F7: n/a
;; * F8: n/a
;; * F9: n/a
;;
;; All of these keys have default global bindings, but major and minor modes may
;; override them if there's a better command for the specific purpose available.
;;
;; Note that the notation for the function keys is <f5>, i.e. the lowercase name
;; surrounded by angle brackets.
(use-package which-key ; Show help popups for prefix keys
:ensure t
:init (which-key-mode)
:config
(setq which-key-idle-delay 0.4
which-key-sort-order 'which-key-prefix-then-key-order
;; Let's go unicode :)
which-key-key-replacement-alist
'(("<\\([[:alnum:]-]+\\)>" . "\\1")
("up" . "↑")
("right" . "→")
("down" . "↓")
("left" . "←")
("DEL" . "⌫")
("deletechar" . "⌦")
("RET" . "⏎"))
which-key-description-replacement-alist
'(("Prefix Command" . "prefix")
;; Lambdas
("\\`\\?\\?\\'" . "λ")
;; Prettify hydra entry points
("/body\\'" . "|=")
;; Drop/shorten package prefixes
("\\`lunaryorn-" . "")
("projectile-" . "proj-")
("helm-" . "h-")
("magit-" . "ma-")))
(which-key-declare-prefixes
;; Prefixes for global prefixes and minor modes
"C-c @" "outline"
"C-c !" "flycheck"
"C-c 8" "typo"
"C-c 8 -" "typo/dashes"
"C-c 8 <" "typo/left-brackets"
"C-c 8 >" "typo/right-brackets"
;; Prefixes for my personal bindings
"C-c a" "applications"
"C-c b" "buffers"
"C-c c" "compile-and-comments"
"C-c e" "errors"
"C-c f" "files"
"C-c f v" "variables"
"C-c g" "git"
"C-c g g" "github/gist"
"C-c h" "helm/help"
"C-c i" "insert"
"C-c i l" "licenses"
"C-c j" "jump"
"C-c l" "language/spelling"
"C-c m" "major mode"
"C-c o" "cursors"
"C-c p" "projects"
"C-c p s" "projects/search"
"C-c p x" "projects/execute"
"C-c p 4" "projects/other-window"
"C-c s" "search"
"C-c t" "toggle"
"C-c w" "windows/frames"
"C-c x" "text")
;; Prefixes for major modes
(which-key-declare-prefixes-for-mode 'markdown-mode
"C-c TAB" "markdown/images"
"C-c C-a" "markdown/links"
"C-c C-c" "markdown/process"
"C-c C-s" "markdown/style"
"C-c C-t" "markdown/header"
"C-c C-x" "markdown/structure"
"C-c m" "markdown/personal")
(which-key-declare-prefixes-for-mode 'emacs-lisp-mode
"C-c m" "elisp/personal"
"C-c m e" "eval")
(which-key-declare-prefixes-for-mode 'js2-mode
"C-c m" "js/personal"
"C-c m r" "refactor")
(which-key-declare-prefixes-for-mode 'scala-mode
"C-c C-b" "ensime/build"
"C-c C-d" "ensime/debug"
"C-c C-r" "ensime/refactor"
"C-c C-v" "ensime/misc"
"C-c m" "scala/personal"
"C-c m b" "scala/build")
(which-key-declare-prefixes-for-mode 'haskell-mode
"C-c m" "haskell/personal"
"C-c m i" "haskell/imports")
(which-key-declare-prefixes-for-mode 'rust-mode
"C-c C-c" "rust/cargo")
(which-key-declare-prefixes-for-mode 'web-mode
"C-c C-a" "web/attributes"
"C-c C-b" "web/blocks"
"C-c C-d" "web/dom"
"C-c C-e" "web/element"
"C-c C-t" "web/tags")
:diminish which-key-mode)
(use-package hydra ; Bindings that stick
:ensure t)
(use-package helm-descbinds ; Describe key bindings with Helm
:ensure t
:bind ("C-h C-b" . describe-bindings)
:init (helm-descbinds-mode))
(use-package help
:config
(defun describe-key-copy-as-kill (&optional key insert untranslated)
(kill-new (format "%s" (key-binding key))))
(advice-add 'describe-key-briefly :after #'describe-key-copy-as-kill))
;; Package manager and init file
(use-package paradox ; Better package menu
:ensure t
:bind (("C-c a p" . paradox-list-packages)
("C-c a P" . package-list-packages-no-fetch))
:config
(setq paradox-execute-asynchronously nil ; No async update, please
paradox-spinner-type 'moon ; Fancy spinner
;; Show all possible counts
paradox-display-download-count t
paradox-display-star-count t
;; Don't star automatically
paradox-automatically-star nil
;; Hide download button, and wiki packages
paradox-use-homepage-buttons nil ; Can type v instead
paradox-hide-wiki-packages t))
(use-package bug-hunter ; Search init file for bugs
:ensure t)
;;; The mode line
(line-number-mode)
(column-number-mode)
(use-package fancy-battery ; Fancy battery info for mode line
:ensure t
:defer t
:init (fancy-battery-mode))
(use-package anzu ; Position/matches count for isearch
:ensure t
:bind
(([remap query-replace] . anzu-query-replace)
([remap query-replace-regexp] . anzu-query-replace-regexp)
:map isearch-mode-map
([remap isearch-query-replace] . anzu-isearch-query-replace)
([remap isearch-query-replace-regexp] . anzu-isearch-query-replace-regexp))
:init (global-anzu-mode)
:config (setq anzu-cons-mode-line-p nil)
:diminish anzu-mode)
(use-package which-func ; Current function name
:init (which-function-mode)
:config
(setq which-func-unknown "⊥" ; The default is really boring…
which-func-format
`((:propertize (" ➤ " which-func-current)
local-map ,which-func-keymap
face which-func
mouse-face mode-line-highlight
help-echo "mouse-1: go to beginning\n\
mouse-2: toggle rest visibility\n\
mouse-3: go to end"))))
(use-package spaceline-config ; A beautiful mode line
:ensure spaceline
:config
(spaceline-helm-mode) ; Enable a special Helm mode line
(spaceline-compile
'lunaryorn
;; Left side of the mode line (all the important stuff)
'(((buffer-modified buffer-size input-method) :face highlight-face)
anzu
'(buffer-id remote-host buffer-encoding-abbrev)
((point-position line-column buffer-position selection-info)
:separator " | ")
major-mode
process
(flycheck-error flycheck-warning flycheck-info)
(python-pyvenv :fallback python-pyenv)
((which-function projectile-root) :separator " @ ")
((minor-modes :separator spaceline-minor-modes-separator) :when active)
nyan-cat)
;; Right segment (the unimportant stuff)
'((version-control :when active)
battery))
;; FIXME: create a new issue at https://github.com/lunaryorn/.emacs.d/
;; (setq-default mode-line-format '("%e" (:eval (spaceline-ml-lunaryorn))))
)
;; Because you know you need it: http://youtu.be/QH2-TGUlwu4
;; Because you know you can't get enough: http://youtu.be/wZZ7oFKsKzY
(use-package nyan-mode ; NYAN CATS!!!
:ensure t
:init (nyan-mode))
(use-package powerline ; The work-horse of Spaceline
:ensure t
:after spaceline-config
:config (setq powerline-height (truncate (* 1.0 (frame-char-height)))
powerline-default-separator 'utf-8))
;;; Minibuffer and Helm
(setq history-length 1000 ; Store more history
use-dialog-box nil ; Never use dialogs for minibuffer input
)
(use-package savehist ; Save minibuffer history
:init (savehist-mode t)
:config (setq savehist-save-minibuffer-history t
savehist-autosave-interval 180))
(use-package helm ; Powerful minibuffer input framework
:ensure t
:bind (("A-C-o" . helm-resume)
("C-x C-f" . helm-find-files)
("A-f" . helm-find)
("C-h SPC" . helm-all-mark-rings))
:init
;; FIXME: these are experimental convenience keybindings used by aculich that
;; may not be more generally useful nor wanted. Revisit these in the future.
(bind-keys
:map helm-map
("C-w" . backward-kill-word)
("M-w" . helm-yank-text-at-point)
("C-z" . helm-select-action)
("C-i" . helm-execute-persistent-action)
("C-j" . helm-maybe-exit-minibuffer)
("C-<return>" . helm-execute-persistent-action))
(bind-keys
:prefix-map help-helm-map
:prefix "C-c h"
("a" . helm-apropos)
("b" . helm-buffers-list)
("c" . helm-colors)
("e" . helm-register)
("f" . helm-find-files)
("g" . helm-git-grep)
("i" . helm-semantic-or-imenu)
("k" . helm-man-woman)
("m" . helm-all-mark-rings)
("o" . helm-occur)
("O" . helm-multi-occur)
("p" . helm-list-emacs-process)
("r" . helm-regexp)
("l" . helm-resume)
("R" . helm-resume)
("t" . helm-top)
("y" . helm-show-kill-ring)
("/" . helm-find))
(helm-mode 1)
(with-eval-after-load 'helm-config
(warn "`helm-config' loaded! Get rid of it ASAP!"))
:config
;; Split inside selected window with Helm
(setq helm-split-window-in-side-p t)
;; FIXME: still experimenting with the right combination of settings
;; here. Suggestions welcome.
(setq
helm-always-two-windows nil
helm-truncate-lines t
helm-full-frame nil
helm-split-window-default-side 'left
helm-reuse-last-window-split-state t
helm-split-window-in-side-p nil
helm-ff-file-name-history-use-recentf t
helm-ff-search-library-in-sexp t
;; helm-buffers-fuzzy-matching t
;; helm-man-or-woman-function 'woman
;; helm-quick-update t
)
:diminish helm-mode)
(use-package helm-command ; Command execution with Helm
:ensure helm
:defer t
:bind (([remap execute-extended-command] . helm-M-x)))
;;; Buffer, Windows and Frames
(setq frame-resize-pixelwise t ; Resize by pixels
frame-title-format
'(:eval (if (buffer-file-name)
(abbreviate-file-name (buffer-file-name)) "%b"))
;; Size new windows proportionally wrt other windows
window-combination-resize t)
(setq-default line-spacing 0.2) ; A bit more spacing between lines
(defun lunaryorn-display-buffer-fullframe (buffer alist)
"Display BUFFER in fullscreen.
ALIST is a `display-buffer' ALIST.
Return the new window for BUFFER."
(let ((window (display-buffer-pop-up-window buffer alist)))
(when window
(delete-other-windows window))
window))
;; Configure `display-buffer' behaviour for some special buffers.
(setq display-buffer-alist
`(
;; Magit status window in fullscreen
(,(rx "*magit: ")
(lunaryorn-display-buffer-fullframe)
(reusable-frames . nil))
;; Give Helm Help a non-side window because Helm as very peculiar ideas
;; about how to display its help
(,(rx bos "*Helm Help" (* nonl) "*" eos)
(display-buffer-use-some-window
display-buffer-pop-up-window))
;; Nail Helm to the side window
(,(rx bos "*" (* nonl) "helm" (* nonl) "*" eos)
(display-buffer-in-side-window)
(side . bottom)
(window-height . 0.4)
(window-width . 0.6))
;; Put REPLs and error lists into the bottom side window
(,(rx bos
(or "*Help" ; Help buffers
"*Warnings*" ; Emacs warnings
"*Compile-Log*" ; Emacs byte compiler log
"*compilation" ; Compilation buffers
"*Flycheck errors*" ; Flycheck error list
"*shell" ; Shell window
"*sbt" ; SBT REPL and compilation buffer
"*ensime-update*" ; Server update from Ensime
"*SQL" ; SQL REPL
"*Cargo" ; Cargo process buffers
(and (1+ nonl) " output*") ; AUCTeX command output
))
(display-buffer-reuse-window
display-buffer-in-side-window)
(side . bottom)
(reusable-frames . visible)
(window-height . 0.33))
;; Let `display-buffer' reuse visible frames for all buffers. This must
;; be the last entry in `display-buffer-alist', because it overrides any
;; later entry with more specific actions.
("." nil (reusable-frames . visible))))
(use-package frame ; Frames
:bind (("C-c w F" . toggle-frame-fullscreen))
:init (progn
;; Kill `suspend-frame'
(global-set-key (kbd "C-z") nil)
(global-set-key (kbd "C-x C-z") nil))
;; :config (add-to-list 'initial-frame-alist '(fullscreen . fullboth))
)
(use-package focus-autosave-mode ; Save buffers when focus is lost
:ensure t
:init (focus-autosave-mode)
:diminish focus-autosave-mode)
(use-package helm-buffers ; Manage buffers with Helm
:ensure helm
:defer t
:bind (([remap switch-to-buffer] . helm-mini))
:config (setq helm-buffers-fuzzy-matching t))
(use-package lunaryorn-buffers ; Personal buffer tools
:load-path "lisp/"
:demand t ; Prevent a mysterious recursive load error
:bind (("C-c b k" . lunaryorn-kill-this-buffer))
:config
(add-hook 'kill-buffer-query-functions
'lunaryorn-do-not-kill-important-buffers))
(use-package uniquify ; Make buffer names unique
:config (setq uniquify-buffer-name-style
;; 'forward
'post-forward-angle-brackets
))
(use-package ibuffer ; Better buffer list
:bind (([remap list-buffers] . ibuffer)
("C-x b" . ibuffer))
;; Show VC Status in ibuffer
:config
(setq ibuffer-expert t)
(setq ibuffer-formats
'((mark modified read-only vc-status-mini " "
(name 18 18 :left :elide)
" "
(size 9 -1 :right)
" "
(mode 16 16 :left :elide)
" "
(vc-status 16 16 :left)
" "
filename-and-process)
(mark modified read-only " "
(name 18 18 :left :elide)
" "
(size 9 -1 :right)
" "
(mode 16 16 :left :elide)
" " filename-and-process)
(mark " " (name 16 -1) " " filename))))
(use-package ibuffer-vc ; Group buffers by VC project and status
:ensure t
:defer t
:init (add-hook 'ibuffer-hook
(lambda ()
(ibuffer-vc-set-filter-groups-by-vc-root)
(unless (eq ibuffer-sorting-mode 'alphabetic)
(ibuffer-do-sort-by-alphabetic)))))
(use-package ibuffer-projectile ; Group buffers by Projectile project
:ensure t
:disabled t
:defer t
;; :commands (ibuffer-projectile-filter)
;; :init
;; (progn
;; (defun ibuffer-projectile-filter (&optional arg)
;; (ibuffer-projectile-set-filter-groups)
;; (unless (eq ibuffer-sorting-mode 'alphabetic)
;; (ibuffer-do-sort-by-alphabetic)))
;; (add-hook 'ibuffer-hook 'ibuffer-projectile-filter))
:init (add-hook 'ibuffer-hook #'ibuffer-projectile-set-filter-groups))
;; Standard window commands
(bind-key "C-c w =" #'balance-windows)
(bind-key "C-c w k" #'delete-window)
(bind-key "C-c w /" #'split-window-right)
(bind-key "C-c w -" #'split-window-below)
(bind-key "C-c w m" #'delete-other-windows)
(use-package lunaryorn-window ; Personal window utilities
:load-path "lisp/"
:defer t
:bind (("C-c w q" . lunaryorn-quit-all-side-windows)
("C-c w d" . lunaryorn-toggle-current-window-dedication)
("C-c w b" . lunaryorn-switch-to-minibuffer-window)))
(use-package windmove ; Move between windows with Shift+Arrow
:bind (("C-c w <left>" . windmove-left)
("C-c w <right>" . windmove-right)
("C-c w <up>" . windmove-up)
("C-c w <down>" . windmove-down))
:config (windmove-default-keybindings 'shift))
(use-package winner ; Undo and redo window configurations
:commands (winner-undo-redo)
:bind (("M-N" . winner-redo)
("C-'" . winner-undo)
("M-P" . winner-undo)
("C-c C-;" . winner-undo))
:init
(progn
(winner-mode 1)
(windmove-default-keybindings))
:config
(progn
(defun winner-undo-redo (&optional arg)
(interactive "P")
(if arg (winner-redo)
(winner-undo)))))
(use-package ace-window ; Fast window switching
:ensure t
:bind (("C-x o" . ace-window)
("C-c w w" . ace-window)))
(use-package golden-ratio ; Automatically resize windows
:ensure t
:init
(defun lunaryorn-toggle-golden-ratio ()
(interactive)
(if (bound-and-true-p golden-ratio-mode)
(progn
(golden-ratio-mode -1)
(balance-windows))
(golden-ratio-mode)
(golden-ratio)))
:bind (("C-c t g" . lunaryorn-toggle-golden-ratio))
:config
(setq golden-ratio-extra-commands '(windmove-up
windmove-down
windmove-left
windmove-right
ace-window
ace-delete-window
ace-select-window
ace-swap-window
ace-maximize-window)
;; Exclude a couple of special modes from golden ratio, namely
;; Flycheck's error list, calc
golden-ratio-exclude-modes '(flycheck-error-list-mode
calc-mode
dired-mode
ediff-mode
)
;; Exclude a couple of special buffers from golden ratio, namely Helm,
;; WhichKey, NeoTree, etc.
golden-ratio-exclude-buffer-regexp
`(,(rx bos "*" (any "h" "H") "elm*" eos)
,(rx bos "*which-key*" eos)
,(rx bos "*NeoTree*" eos)))
:diminish (golden-ratio-mode . "ⓖ"))
(use-package ediff-wind ; Ediff window management
:defer t
:config
;; Prevent Ediff from spamming the frame
(setq ediff-window-setup-function #'ediff-setup-windows-plain
ediff-split-window-function #'split-window-horizontally))
(use-package desktop ; Save buffers, windows and frames
:disabled t
:init (desktop-save-mode)
:config
;; Save desktops a minute after Emacs was idle.
(setq desktop-auto-save-timeout 60)
;; Don't save Magit and Git related buffers
(dolist (mode '(magit-mode magit-log-mode))
(add-to-list 'desktop-modes-not-to-save mode))
(add-to-list 'desktop-files-not-to-save (rx bos "COMMIT_EDITMSG")))
(use-package writeroom-mode ; Distraction-free editing
:ensure t
:bind (("C-c t r" . writeroom-mode)))
(use-package popup ; Popup menus
;; We don't ensure this package, because we definitely don't want to have this
;; mess, but unfortunately it's a dependency of Ensime :(
:ensure nil
:defer t
:config
;; Bring Popup bindings in line with Company bindings, by getting rid of C-n/p
;; for navigation and introducing M-n/p
(define-key popup-menu-keymap "\C-n" nil)
(define-key popup-menu-keymap [down] nil)
(define-key popup-menu-keymap "\C-p" nil)
(define-key popup-menu-keymap [up] nil)
(define-key popup-menu-keymap (kbd "M-n") #'popup-next)
(define-key popup-menu-keymap (kbd "M-p") #'popup-previous))
;;; File handling
;; Keep backup and auto save files out of the way
(setq backup-directory-alist `((".*" . ,(locate-user-emacs-file ".backup")))
auto-save-file-name-transforms `((".*" ,temporary-file-directory t)))
;; Delete files to trash
(setq delete-by-moving-to-trash t)
(use-package files ; Core commands for files
:bind (("C-c f z" . revert-buffer)
("C-c f /" . revert-buffer))
:config
;; Use GNU ls for Emacs
(when-let (gnu-ls (and (eq system-type 'darwin) (executable-find "gls")))
(setq insert-directory-program gnu-ls)))
(use-package helm-files ; Manage files with Helm
:ensure helm
:defer t
:bind (([remap find-file] . helm-find-files)
("C-c f f" . helm-for-files)