Skip to content

Instantly share code, notes, and snippets.

@emilypi
Last active April 7, 2018 00:51
Show Gist options
  • Save emilypi/9b7446fde75f81c237580a9489bcf11a to your computer and use it in GitHub Desktop.
Save emilypi/9b7446fde75f81c237580a9489bcf11a to your computer and use it in GitHub Desktop.
Emacs dotfiles
;; includes
(add-to-list 'load-path "~/.emacs.d/znc.el")
;; Initialize
(package-initialize)
;; global variables
(setq
inhibit-startup-screen t
create-lockfiles nil
make-backup-files nil
column-number-mode t
scroll-error-top-bottom t
show-paren-delay 0.5
use-package-always-ensure t
sentence-end-double-space nil)
;; buffer local variables
(setq-default
indent-tabs-mode nil
tab-width 4
c-basic-offset 4)
;; modes
(electric-indent-mode 0)
;; global keybindings
(global-unset-key (kbd "C-z"))
;; the package manager
(require 'package)
(setq
package-archives '(("gnu" . "http://elpa.gnu.org/packages/")
("org" . "http://orgmode.org/elpa/")
("melpa" . "http://melpa.org/packages/")
("melpa-stable" . "http://stable.melpa.org/packages/"))
package-archive-priorities '(("melpa-stable" . 1)))
(when (not package-archive-contents)
(package-refresh-contents)
(package-install 'use-package))
(require 'use-package)
;; https://github.com/purcell/exec-path-from-shell
(when (memq window-system '(mac ns x))
(exec-path-from-shell-initialize))
;; on OSX - this is necessary - emacs is started from application, not ~/
(exec-path-from-shell-copy-env "PATH")
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; The theme
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(ansi-color-faces-vector
[default bold shadow italic underline bold bold-italic bold])
'(ansi-color-names-vector
(vector "#839496" "#dc322f" "#859900" "#b58900" "#268bd2" "#d33682" "#2aa198" "#002b36"))
'(background-color "#202020")
'(background-mode dark)
'(company-ghc-show-info t)
'(compilation-message-face (quote default))
'(cursor-color "#cccccc")
'(custom-enabled-themes (quote (molokai)))
'(custom-safe-themes
(quote
("96998f6f11ef9f551b427b8853d947a7857ea5a578c75aa9c4e7c73fe04d10b4" "e8825f26af32403c5ad8bc983f8610a4a4786eb55e3a363fa9acb48e0677fe7e" "a317b11ec40485bf2d2046d2936946e38a5a7440f051f3fcc4cdda27bde6c5d4" "a56a6bf2ecb2ce4fa79ba636d0a5cf81ad9320a988ec4e55441a16d66b0c10e0" "4980e5ddaae985e4bae004280bd343721271ebb28f22b3e3b2427443e748cd3f" "b571f92c9bfaf4a28cb64ae4b4cdbda95241cd62cf07d942be44dc8f46c491f4" "cdd26fa6a8c6706c9009db659d2dffd7f4b0350f9cc94e5df657fa295fffec71" "1db337246ebc9c083be0d728f8d20913a0f46edc0a00277746ba411c149d7fe5" "e9460a84d876da407d9e6accf9ceba453e2f86f8b86076f37c08ad155de8223c" "987b709680284a5858d5fe7e4e428463a20dfabe0a6f2a6146b3b8c7c529f08b" "b3775ba758e7d31f3bb849e7c9e48ff60929a792961a2d536edec8f68c671ca5" "b97a01622103266c1a26a032567e02d920b2c697ff69d40b7d9956821ab666cc" "3cc2385c39257fed66238921602d8104d8fd6266ad88a006d0a4325336f5ee02" "3d5ef3d7ed58c9ad321f05360ad8a6b24585b9c49abcee67bdcbb0fe583a6950" "c48551a5fb7b9fc019bf3f61ebf14cf7c9cdca79bcb2a4219195371c02268f11" "9b59e147dbbde5e638ea1cde5ec0a358d5f269d27bd2b893a0947c4a867e14c1" "58c6711a3b568437bab07a30385d34aacf64156cc5137ea20e799984f4227265" "72a81c54c97b9e5efcc3ea214382615649ebb539cb4f2fe3a46cd12af72c7607" "e9776d12e4ccb722a2a732c6e80423331bcb93f02e089ba2a4b02e85de1cf00e" "3cd28471e80be3bd2657ca3f03fbb2884ab669662271794360866ab60b6cb6e6" "e0d42a58c84161a0744ceab595370cbe290949968ab62273aed6212df0ea94b4" "4cf3221feff536e2b3385209e9b9dc4c2e0818a69a1cdb4b522756bcdf4e00a4" "4aee8551b53a43a883cb0b7f3255d6859d766b6c5e14bcb01bed572fcbef4328" "61003d455ba1bad9a3bf8be7342e848ca3febe899319e95a9dc3d804d9697608" "eea01f540a0f3bc7c755410ea146943688c4e29bea74a29568635670ab22f9bc" default)))
'(fci-rule-color "#073642")
'(foreground-color "#cccccc")
'(haskell-align-imports-pad-after-name t)
'(haskell-process-auto-import-loaded-modules t)
'(haskell-process-log t)
'(haskell-process-suggest-remove-import-lines t)
'(haskell-process-type (quote cabal-repl))
'(haskell-stylish-on-save t)
'(haskell-tags-on-save t)
'(highlight-changes-colors (quote ("#FD5FF0" "#AE81FF")))
'(highlight-tail-colors
(quote
(("#3C3D37" . 0)
("#679A01" . 20)
("#4BBEAE" . 30)
("#1DB4D0" . 50)
("#9A8F21" . 60)
("#A75B00" . 70)
("#F309DF" . 85)
("#3C3D37" . 100))))
'(linum-format " %5i ")
'(magit-diff-use-overlays nil)
'(package-selected-packages
(quote
(subatomic256-theme subatomic-theme planet-theme noctilux-theme molokai-theme farmhouse-theme dracula-theme sublime-themes atom-dark-theme ample-zen-theme ace-window ## color-theme-sanityinc-solarized exec-path-from-shell shm company-ghc ghc hindent znc haskell-mode rainbow-delimiters prettify-greek focus-autosave-mode rainbow-mode flycheck-cask git-gutter use-package monokai-theme monokai-alt-theme expand-region ensime)))
'(pos-tip-background-color "#FFFACE")
'(pos-tip-foreground-color "#272822")
'(vc-annotate-background nil)
'(vc-annotate-color-map
(quote
((20 . "#dc322f")
(40 . "#cb4b16")
(60 . "#b58900")
(80 . "#859900")
(100 . "#2aa198")
(120 . "#268bd2")
(140 . "#d33682")
(160 . "#6c71c4")
(180 . "#dc322f")
(200 . "#cb4b16")
(220 . "#b58900")
(240 . "#859900")
(260 . "#2aa198")
(280 . "#268bd2")
(300 . "#d33682")
(320 . "#6c71c4")
(340 . "#dc322f")
(360 . "#cb4b16"))))
'(vc-annotate-very-old-color nil)
'(weechat-color-list
(unspecified "#272822" "#3C3D37" "#F70057" "#F92672" "#86C30D" "#A6E22E" "#BEB244" "#E6DB74" "#40CAE4" "#66D9EF" "#FB35EA" "#FD5FF0" "#74DBCD" "#A1EFE4" "#F8F8F2" "#F8F8F0"))
'(when
(or
(not
(boundp
(quote ansi-term-color-vector)))
(not
(facep
(aref ansi-term-color-vector 0)))))
'(znc-detatch-on-kill t)
'(znc-servers
(quote
(("localhost" 6697 t
((emilypi "emilypi" "######")))))))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Ace Window
(require 'ace-window)
(global-set-key (kbd "M-o") 'ace-window)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; General ensime config
(use-package ensime
:ensure t
:pin melpa)
(add-to-list 'exec-path "/usr/local/bin")
(setq ensime-startup-notification nil)
(use-package projectile
:demand
:init (setq projectile-use-git-grep t)
:config (projectile-global-mode t)
:bind (("s-f" . projectile-find-file)
("s-F" . projectile-grep)))
(use-package undo-tree
:diminish undo-tree-mode
:config (global-undo-tree-mode)
:bind ("s-/" . undo-tree-visualize))
(use-package flx-ido
:demand
:init
(setq
ido-enable-flex-matching t
ido-use-faces nil ;; ugly
ido-case-fold nil ;; https://github.com/lewang/flx#uppercase-letters
ido-show-dot-for-dired nil ;; remember C-d
ido-enable-dot-prefix t)
:config
(ido-mode t)
(ido-everywhere t)
(flx-ido-mode t))
(use-package highlight-symbol
:diminish highlight-symbol-mode
:commands highlight-symbol
:bind ("s-h" . highlight-symbol))
(use-package goto-chg
:commands goto-last-change
;; complementary to
;; C-x r m / C-x r l
;; and C-<space> C-<space> / C-u C-<space>
:bind (("C-." . goto-last-change)
("C-," . goto-last-change-reverse)))
(use-package popup-imenu
:commands popup-imenu
:bind ("M-i" . popup-imenu))
(use-package magit
:commands magit-status magit-blame
:init (setq
magit-revert-buffers nil)
:bind (("s-g" . magit-status)
("s-b" . magit-blame)))
(use-package company
:diminish company-mode
:commands company-mode
:init
(setq
company-dabbrev-ignore-case nil
company-dabbrev-code-ignore-case nil
company-dabbrev-downcase nil
company-idle-delay 0
company-minimum-prefix-length 4)
:config
;; disables TAB in company-mode, freeing it for yasnippet
(define-key company-active-map [tab] nil)
(define-key company-active-map (kbd "TAB") nil))
(use-package yasnippet
:diminish yas-minor-mode
:commands yas-minor-mode
:config (yas-reload-all))
(use-package yatemplate
:defer 2 ;; WORKAROUND https://github.com/mineo/yatemplate/issues/3
:config
(auto-insert-mode)
(setq auto-insert-alist nil)
(yatemplate-fill-alist))
(use-package smartparens
:diminish smartparens-mode
:commands
smartparens-strict-mode
smartparens-mode
sp-restrict-to-pairs-interactive
sp-local-pair
:init
(setq sp-interactive-dwim t)
:config
(require 'smartparens-config)
(sp-use-smartparens-bindings)
(sp-pair "(" ")" :wrap "C-(") ;; how do people live without this?
(sp-pair "[" "]" :wrap "s-[") ;; C-[ sends ESC
(sp-pair "{" "}" :wrap "C-{")
;; WORKAROUND https://github.com/Fuco1/smartparens/issues/543
(bind-key "C-<left>" nil smartparens-mode-map)
(bind-key "C-<right>" nil smartparens-mode-map)
(bind-key "s-<delete>" 'sp-kill-sexp smartparens-mode-map)
(bind-key "s-<backspace>" 'sp-backward-kill-sexp smartparens-mode-map))
(defun contextual-backspace ()
"Hungry whitespace or delete word depending on context."
(interactive)
(if (looking-back "[[:space:]\n]\\{2,\\}" (- (point) 2))
(while (looking-back "[[:space:]\n]" (- (point) 1))
(delete-char -1))
(cond
((and (boundp 'smartparens-strict-mode)
smartparens-strict-mode)
(sp-backward-kill-word 1))
((and (boundp 'subword-mode)
subword-mode)
(subword-backward-kill 1))
(t
(backward-kill-word 1)))))
(defun scala-mode-newline-comments ()
"Custom newline appropriate for `scala-mode'."
;; shouldn't this be in a post-insert hook?
(interactive)
(newline-and-indent)
(scala-indent:insert-asterisk-on-multiline-comment))
(bind-key "RET" 'scala-mode-newline-comments scala-mode-map)
(setq comment-start "/* "
comment-end " */"
comment-style 'multi-line
comment-empty-lines t)
(bind-key "C-<tab>" 'dabbrev-expand scala-mode-map)
(sp-local-pair 'scala-mode "(" nil :post-handlers '(("||\n[i]" "RET")))
(sp-local-pair 'scala-mode "{" nil :post-handlers '(("||\n[i]" "RET") ("| " "SPC")))
(defun sp-restrict-c (sym)
"Smartparens restriction on `SYM' for C-derived parenthesis."
(sp-restrict-to-pairs-interactive "{([" sym))
(bind-key "s-<delete>" (sp-restrict-c 'sp-kill-sexp) scala-mode-map)
(bind-key "s-<backspace>" (sp-restrict-c 'sp-backward-kill-sexp) scala-mode-map)
(bind-key "s-<home>" (sp-restrict-c 'sp-beginning-of-sexp) scala-mode-map)
(bind-key "s-<end>" (sp-restrict-c 'sp-end-of-sexp) scala-mode-map)
(use-package expand-region
:commands 'er/expand-region
:bind ("C-=" . er/expand-region))
(require 'ensime-expand-region)
(scala-mode:goto-start-of-code)
(add-hook 'scala-mode-hook
(lambda ()
(show-paren-mode)
(smartparens-mode)
(yas-minor-mode)
(git-gutter-mode)
(company-mode)
(ensime-mode)
(scala-mode:goto-start-of-code)))
(bind-key "RET" 'comment-indent-new-line emacs-lisp-mode-map)
(use-package eldoc
:ensure nil
:diminish eldoc-mode
:commands eldoc-mode)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; Emacs mod
(add-hook 'emacs-lisp-mode-hook
(lambda ()
(setq show-trailing-whitespace t)
(show-paren-mode)
(rainbow-mode)
(prettify-symbols-mode)
(eldoc-mode)
(flycheck-mode)
(yas-minor-mode)
(company-mode)
(smartparens-strict-mode)
(rainbow-delimiters-mode)))
(defun indent-buffer ()
"Indent the entire buffer."
(interactive)
(save-excursion
(delete-trailing-whitespace)
(indent-region (point-min) (point-max) nil)
(untabify (point-min) (point-max))))
(use-package flycheck-cask
:commands flycheck-cask-setup
:config (add-hook 'emacs-lisp-mode-hook (flycheck-cask-setup)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Gitter + Irc
(use-package erc
:commands erc erc-tls
:init
(setq
erc-prompt-for-password t ;; prefer ~/.authinfo for passwords
erc-hide-list '("JOIN" "PART" "QUIT")
erc-autojoin-channels-alist
'(("irc.freenode.net" "#emacs" "#scalaz" "#scala" "#haskell" "#haskell-for-beginners" "#qfpl" "#scala-ops")
("irc.psych0tik.net" "#hackers")
("irc.gitter.im" "#ensime/ensime-server" "#ensime/ensime-emacs" "#scalaz/scalaz" "#slamdata/matryoshka" "#typelevel/cats" "#typelevel/cats-effect"))))
;; Gitter
(defun gitter()
"Connect to Gitter."
(interactive)
(erc-tls :server "irc.gitter.im" :port 6697))
;; Irc via znc
(require 'znc)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; Haskell Mode
(add-hook 'haskell-mode-hook 'interactive-haskell-mode)
;; hindent
(add-hook 'haskell-mode-hook #'hindent-mode)
;; navigate imports via [f8]
(eval-after-load 'haskell-mode
'(define-key haskell-mode-map [f8] 'haskell-navigate-imports))
;; hasktags
(let ((my-cabal-path (expand-file-name "~/Library/Haskell/bin")))
(setenv "PATH" (concat my-cabal-path path-separator(getenv "PATH")))
(add-to-list 'exec-path my-cabal-path))
;; interactive key-bindings
(eval-after-load 'haskell-mode '(progn
(define-key haskell-mode-map (kbd "C-c C-l") 'haskell-process-load-or-reload)
(define-key haskell-mode-map (kbd "C-c C-z") 'haskell-interactive-switch)
(define-key haskell-mode-map (kbd "C-c C-n C-t") 'haskell-process-do-type)
(define-key haskell-mode-map (kbd "C-c C-n C-i") 'haskell-process-do-info)
(define-key haskell-mode-map (kbd "C-c C-n C-c") 'haskell-process-cabal-build)
(define-key haskell-mode-map (kbd "C-c C-n c") 'haskell-process-cabal)))
(eval-after-load 'haskell-cabal '(progn
(define-key haskell-cabal-mode-map (kbd "C-c C-z") 'haskell-interactive-switch)
(define-key haskell-cabal-mode-map (kbd "C-c C-k") 'haskell-interactive-mode-clear)
(define-key haskell-cabal-mode-map (kbd "C-c C-c") 'haskell-process-cabal-build)
(define-key haskell-cabal-mode-map (kbd "C-c c") 'haskell-process-cabal)))
;; NOTE: Does not build on ghc >=8.2 yet.
;; initialize ghc-mod
(add-to-list 'load-path "~/Library/Haskell/bin/ghc-mod")
(autoload 'ghc-init "ghc" nil t)
(autoload 'ghc-debug "ghc" nil t)
(add-hook 'haskell-mode-hook (lambda () (ghc-init)))
;; company-mode for haskell
(require 'company)
(add-hook 'haskell-mode-hook 'company-mode)
(add-hook 'after-init-hook 'global-company-mode)
(add-to-list 'company-backends 'company-ghc)
;; repl
(custom-set-variables '(haskell-process-type 'cabal-repl))
;; disable popup errors
(setq haskell-interactive-popup-errors nil)
(setq haskell-process-args-ghci
'("-ferror-spans" "-fshow-loaded-modules"))
(setq haskell-process-args-cabal-repl
'("--ghc-options=-ferror-spans -fshow-loaded-modules"))
(setq haskell-process-args-cabal-new-repl
'("--ghc-options=-ferror-spans -fshow-loaded-modules"))
;; Rainbow Delimiters
(require 'rainbow-delimiters)
(add-hook 'haskell-mode-hook 'rainbow-delimiters-mode)
;; Hoogle
(require 'haskell-mode)
(define-key haskell-mode-map "\C-ch" 'haskell-hoogle)
;; Structured Haskell mode
(add-hook 'haskell-mode-hook 'structured-haskell-mode)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Greek letters
(global-set-key (kbd "M-g a") "α")
(global-set-key (kbd "M-g b") "β")
(global-set-key (kbd "M-g g") "γ")
(global-set-key (kbd "M-g d") "δ")
(global-set-key (kbd "M-g e") "ε")
(global-set-key (kbd "M-g z") "ζ")
(global-set-key (kbd "M-g h") "η")
(global-set-key (kbd "M-g q") "θ")
(global-set-key (kbd "M-g i") "ι")
(global-set-key (kbd "M-g k") "κ")
(global-set-key (kbd "M-g l") "λ")
(global-set-key (kbd "M-g m") "μ")
(global-set-key (kbd "M-g n") "ν")
(global-set-key (kbd "M-g x") "ξ")
(global-set-key (kbd "M-g o") "ο")
(global-set-key (kbd "M-g p") "π")
(global-set-key (kbd "M-g r") "ρ")
(global-set-key (kbd "M-g s") "σ")
(global-set-key (kbd "M-g t") "τ")
(global-set-key (kbd "M-g u") "υ")
(global-set-key (kbd "M-g f") "ϕ")
(global-set-key (kbd "M-g j") "φ")
(global-set-key (kbd "M-g c") "χ")
(global-set-key (kbd "M-g y") "ψ")
(global-set-key (kbd "M-g w") "ω")
(global-set-key (kbd "M-g A") "Α")
(global-set-key (kbd "M-g B") "Β")
(global-set-key (kbd "M-g G") "Γ")
(global-set-key (kbd "M-g D") "Δ")
(global-set-key (kbd "M-g E") "Ε")
(global-set-key (kbd "M-g Z") "Ζ")
(global-set-key (kbd "M-g H") "Η")
(global-set-key (kbd "M-g Q") "Θ")
(global-set-key (kbd "M-g I") "Ι")
(global-set-key (kbd "M-g K") "Κ")
(global-set-key (kbd "M-g L") "Λ")
(global-set-key (kbd "M-g M") "Μ")
(global-set-key (kbd "M-g N") "Ν")
(global-set-key (kbd "M-g X") "Ξ")
(global-set-key (kbd "M-g O") "Ο")
(global-set-key (kbd "M-g P") "Π")
(global-set-key (kbd "M-g R") "Ρ")
(global-set-key (kbd "M-g S") "Σ")
(global-set-key (kbd "M-g T") "Τ")
(global-set-key (kbd "M-g U") "Υ")
(global-set-key (kbd "M-g F") "Φ")
(global-set-key (kbd "M-g J") "Φ")
(global-set-key (kbd "M-g C") "Χ")
(global-set-key (kbd "M-g Y") "Ψ")
(global-set-key (kbd "M-g W") "Ω")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment