Skip to content

Instantly share code, notes, and snippets.

@ericavonb
Created February 7, 2017 04:07
Show Gist options
  • Save ericavonb/e2f58fd7e76408198ac06544a6e86e67 to your computer and use it in GitHub Desktop.
Save ericavonb/e2f58fd7e76408198ac06544a6e86e67 to your computer and use it in GitHub Desktop.
Emacs Config
;; ========================================================================== ;;
;; Emacs Initialization File ;;
;; ========================================================================== ;;
;; -------------------------------------------------------------------------- ;;
;; Package Management and Marmalade ;;
;; -------------------------------------------------------------------------- ;;
(when (equal system-type 'darwin)
(setenv "PATH" (concat "/opt/local/bin:/usr/local/bin:" (getenv "PATH")))
(push "/opt/local/bin" exec-path))
(require 'package)
(add-to-list 'package-archives
'("melpa" . "http://melpa.milkbox.net/packages/") t)
(when (< emacs-major-version 24)
;; For important compatibility libraries like cl-lib
(add-to-list 'package-archives '("gnu" . "http://elpa.gnu.org/packages/")))
(package-initialize)
;; -------------------------------------------------------------------------- ;;
;; Custom Settings and Themes ;;
;; -------------------------------------------------------------------------- ;;
;; Custom Symbols - used to annotate sidebar for git, etc
(when (bound-and-true-p x-bitmap-file-path)
(add-to-list 'x-bitmap-file-path
"/Users/evonbuelow/Productivity/profiles/emacs/assets"))
;; __________________________________________________________________________ ;;
;; ////////////////////////////////////////////////////////////////////////// ;;
;; // DO NOT TOUCH - AUTO-GENERATED BY CUSTOM // ;;
;; ////////////////////////////////////////////////////////////////////////// ;;
;; ============================ !!! WARNING !!! ============================= ;;
;; **Auto-Generated Code**
(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-names-vector
["#212526" "#ff4b4b" "#b4fa70" "#fce94f" "#729fcf" "#ad7fa8" "#8cc4ff" "#eeeeec"])
'(column-number-mode t)
'(compilation-message-face (quote default))
'(custom-safe-themes
(quote
("b9652923b04f7bf31f74896b29de03d477979c6ec057d004573eeb5a7b8eba65" "196cc00960232cfc7e74f4e95a94a5977cb16fd28ba7282195338f68c84058ec" "60f04e478dedc16397353fb9f33f0d895ea3dab4f581307fbf0aa2f07e658a40" "0e121ff9bef6937edad8dfcff7d88ac9219b5b4f1570fd1702e546a80dba0832" "56f8527b43406a9cc1b21740e35b46426403f882fea08bceda2be52d303df3bc" "d03bf94c18073b71faadd588bc4ee9c7ae130dbf76c10e5cde3c865097de0309" "349938685eb27d010437dd0f9c648dcb090b8097e6d548ec6cec6deaec6e142b" "c0b0f86e7cc745ceab301fd4c5921394ddaef6c79041f835a791c18995e639c5" "d76c54f90521f08c0a6f51622f85237d1f5ee5c3f6b5c6704dac5c786ca56289" "971fe604b9761cbe0e49ab40b72eb077062acb1c2f181e7cab3e0b653730dfb8" "0f05bf68078e532ef4da0d88e25a782bdd6c9f13b777caaac9dfe11012cbcd54" "c7c3d9583f61857a275922cc41658abbc520e969c27c03bddb382fdfc43e7949" "4416d08b8ab4b3e8c3899d1952b7525f84f0645b9c592ded6cd4e4ff121b3c2c" "c36450ea8a39ad60cdbaf06f31048fd42a1db512cc69ac938a0de12547d1cb25" "71efabb175ea1cf5c9768f10dad62bb2606f41d110152f4ace675325d28df8bd" default)))
'(fci-rule-color "#49483E")
'(fringe-mode 1 nil (fringe))
'(global-fringe-current-line-mode 1)
'(highlight-changes-colors (quote ("#FD5FF0" "#AE81FF")))
'(highlight-tail-colors
(quote
(("#49483E" . 0)
("#67930F" . 20)
("#349B8D" . 30)
("#21889B" . 50)
("#968B26" . 60)
("#A45E0A" . 70)
("#A41F99" . 85)
("#49483E" . 100))))
'(magit-diff-use-overlays nil)
'(menu-bar-mode nil)
'(monokai-distinct-fringe-background t)
'(tabbar-background-color "#262626")
'(tabbar-mode t nil (tabbar))
'(tabbar-separator (quote (1.0)))
'(vc-annotate-background nil)
'(vc-annotate-color-map
(quote
((20 . "#F92672")
(40 . "#CF4F1F")
(60 . "#C26C0F")
(80 . "#E6DB74")
(100 . "#AB8C00")
(120 . "#A18F00")
(140 . "#989200")
(160 . "#8E9500")
(180 . "#A6E22E")
(200 . "#729A1E")
(220 . "#609C3C")
(240 . "#4E9D5B")
(260 . "#3C9F79")
(280 . "#A1EFE4")
(300 . "#299BA6")
(320 . "#2896B5")
(340 . "#2790C3")
(360 . "#66D9EF"))))
'(vc-annotate-very-old-color nil)
'(visual-line-fringe-indicators (quote (left-curly-arrow right-curly-arrow)))
'(web-mode-attr-indent-offset 2)
'(web-mode-attr-value-indent-offset 2)
'(web-mode-enable-block-face t)
'(web-mode-enable-css-colorization t)
'(web-mode-jsx-depth-faces 1)
'(web-mode-markup-indent-offset 2)
'(weechat-color-list
(unspecified "#272822" "#49483E" "#A20C41" "#F92672" "#67930F" "#A6E22E" "#968B26" "#E6DB74" "#21889B" "#66D9EF" "#A41F99" "#FD5FF0" "#349B8D" "#A1EFE4" "#F8F8F2" "#F8F8F0")))
;; ============================ !!! WARNING !!! ============================= ;;
;; **Auto-Generated Code**
(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.
'(fringe ((t (:background "dark blue" :foreground "dark red" :overline "black"))))
'(highlight-current-line-face ((t (:background "color-16"))))
'(highlight-indentation-current-column-face ((t (:inherit default :background "#4b3500"))))
'(highlight-indentation-face ((t (:inherit default :background "#1f1f1f"))))
'(markdown-bold-face ((t (:inherit font-lock-variable-name-face :weight extra-bold))))
'(markdown-header-face-1 ((t (:inherit markdown-header-face :foreground "green"))))
'(markdown-header-face-2 ((t (:inherit markdown-header-face))))
'(tabbar-button ((t (:foreground "blue" :box (:line-width 10 :color "grey75" :style released-button) :width condensed))))
'(tabbar-button-highlight ((t nil)))
'(tabbar-default ((t (:background "color-236" :distant-foreground "color-16" :foreground "#75715E" :weight ultra-light :height 1 :width condensed :foundry "Helvetica" :family "nueue"))))
'(tabbar-selected ((t (:inherit tabbar-default :foreground "dark red" :underline "color-235"))))
'(tabbar-separator ((t (:background "color-235" :foreground "brightwhite" :weight normal :height 1.0 :width normal :family "neue"))))
'(tabbar-unselected ((t (:inherit tabbar-default))))
'(web-mode-block-comment-face ((t (:inherit web-mode-comment-face :foreground "brightblack"))))
'(web-mode-block-delimiter-face ((t (:inherit (default font-lock-preprocessor-face) :foreground "color-245"))))
'(web-mode-comment-face ((t (:inherit font-lock-comment-face :foreground "color-219"))))
'(web-mode-constant-face ((t (:inherit font-lock-constant-face :foreground "color-98"))))
'(web-mode-filter-face ((t (:inherit font-lock-function-name-face :foreground "color-32"))))
'(web-mode-folded-face ((t (:underline t))))
'(web-mode-function-call-face ((t (:inherit font-lock-function-name-face :foreground "color-32"))))
'(web-mode-function-name-face ((t (:inherit font-lock-function-name-face :foreground "color-26"))))
'(web-mode-html-attr-equal-face ((t (:inherit web-mode-html-attr-name-face :foreground "color-59"))))
'(web-mode-html-attr-name-face ((t (:foreground "color-180"))))
'(web-mode-html-attr-value-face ((t (:inherit web-mode-string-face))))
'(web-mode-html-entity-face ((t (:slant italic))))
'(web-mode-html-tag-bracket-face ((t (:foreground "color-59"))))
'(web-mode-html-tag-custom-face ((t (:inherit web-mode-html-tag-face :foreground "color-66"))))
'(web-mode-html-tag-face ((t (:foreground "color-65"))))
'(web-mode-italic-face ((t (:foreground "brightblack" :slant italic))))
'(web-mode-jsx-depth-4-face ((t (:background "color-198"))))
'(web-mode-keyword-face ((t (:inherit font-lock-keyword-face :foreground "color-61"))))
'(web-mode-param-name-face ((t (:foreground "color-59"))))
'(web-mode-string-face ((t (:inherit font-lock-string-face :foreground "color-132"))))
'(web-mode-type-face ((t (:inherit font-lock-type-face :foreground "color-116"))))
'(web-mode-variable-name-face ((t (:inherit font-lock-variable-name-face :foreground "color-31")))))
;; ////////////////////////////////////////////////////////////////////////// ;;
;; // END AUTO-GENERATED CODE - OK TO EDIT BELOW // ;;
;; ////////////////////////////////////////////////////////////////////////// ;;
;; __________________________________________________________________________ ;;
;; -------------------------------------------------------------------------- ;;
;; Custom Settings ;;
;; -------------------------------------------------------------------------- ;;
;; . ........................ Allow Mouse in Terminal ....................... ;;
(require 'mouse)
(require 'mwheel)
(xterm-mouse-mode t)
(defun track-mouse (e))
(setq mouse-sel-mode t)
(setq t-mouse-mode t)
;; ............................ Smoother Scrolling .......................... ;;
(setq redisplay-dont-pause t) ; Pending input does not preempt redisplay
(setq scroll-margin 1) ; Point can come within 1 line of top or bottom of window
(setq scroll-step 1) ; Scroll by 1 line at a time
(setq scroll-conservatively 10000) ; automatic scrolling never centers point
(setq scroll-preserve-screen-position 1) ; keep the cursor at same screen position
(setq auto-window-vscroll nil) ; automatically modify the vertical scroll
; position to scroll through display rows
; that are taller than the height of the window
(setq mouse-wheel-scroll-amount '(1 ((shift) . 1))) ; scroll one line at a time
(setq mouse-wheel-follow-mouse 't) ;scroll window under mouse
;; ........................... Unique Buffer Names .......................... ;;
(require 'uniquify)
(setq
uniquify-buffer-name-style 'post-forward
uniquify-separator " : ")
;; ........................... Relative Line Numbers ........................ ;;
(require 'relative-line-numbers)
;; If you enable global minor mode
(setq linum-offset 2)
(setq linum-format "%3d")
(setq relativelinum-offset t)
(global-linum-mode 1) ; show line numbers
;; .............................. Custom Fringe ............................. ;;
(setq centered nil)
(setq-default fill-column 100)
(fringe-mode 1)
(set-frame-parameter (selected-frame) 'internal-border-width 0)
(set-frame-parameter (selected-frame) 'border-width 0)
(setq margin-color "#262626")
(setq fringe-color "#212014")
(setq-default left-margin-width 0)
(setq-default right-margin-width 0)
(setq-default fringes-outside-margins t)
(set-window-fringes nil 0 0 t)
(set-face-attribute 'fringe nil :background fringe-color)
(set-face-attribute 'linum nil :foreground "#5f5f5f") ; alt "#87875f"
(set-face-attribute 'linum nil :background margin-color)
(global-hl-line-mode 1)
(global-hl-line-highlight)
(set-face-background 'hl-line "#151515")
;;;; TabBar mode on
(require 'tabbar)
(tabbar-mode nil)
(setq-default indent-tabs-mode nil)
;; Custom Frame title
(setq frame-title-format
(list
"[ %* ] : " ; modified (*), readonly (&), neither (-)
'(:eval ; file path relative to user's home dir
(if (buffer-file-name) (abbreviate-file-name (buffer-file-name)) "%b"))
'(:eval ; git branch name
(if (buffer-file-name)
(shell-command-to-string
(concat "(cd " (file-name-directory (buffer-file-name))
"; /usr/bin/git branch --no-color 2> /dev/null | grep \"^*\" "
"| awk '{printf(\" (%s\)\",$2);}' 2> /dev/null )"))))
" : %m" ; emacs mode
))
;; ............................ System Settings ............................. ;;
;; put backup files in temp directory
(setq backup-directory-alist
`((".*" . ,temporary-file-directory)))
(setq auto-save-file-name-transforms
`((".*" ,temporary-file-directory t)))
(setq auto-save-default nil)
;; disable welcome mode
(setq inhibit-startup-message t)
(setq inhibit-startup-echo-area-message t)
(setq initial-scratch-message nil)
;; default directory
(setq default-directory "~/code/src/github.com/ericavonb/")
;; hitting delete on marked text deletes the text
(delete-selection-mode 1)
;; .......................... Whitespace Settings ........................... ;;
;; add final newline if none on save
(setq require-final-newline t)
;; delete trailing whitespace on save for specific modes
(setq trailing-whitespace-ok nil)
(defun delete-trailing-ws-safe ()
(interactive)
(if (eq trailing-whitespace-ok nil)
(delete-trailing-whitespace)))
(add-hook 'before-save-hook 'delete-trailing-ws-safe)
;; Highlight long lines and trailing whitespace
(require 'whitespace)
(setq whitespace-style '(face lines-tail tabs trailing))
(setq whitespace-line-column 80)
(setq whitespace-iine-count 80)
(global-whitespace-mode +1)
;; ........................... Colorify Everything ........................... ;;
;; Show colors in color!
(require 'rainbow-mode)
(setq-default rainbow-mode 1)
;; Pretty Rainbow Parens and such!
(require 'rainbow-delimiters)
(setq-default rainbow-delimiters-mode 1)
;; Pretty!
(setq prettify-symbols-mode 1)
(global-prettify-symbols-mode 1)
;; -------------------------------------------------------------------------- ;;
;; Language Specific Settings ;;
;; -------------------------------------------------------------------------- ;;
;; ................................. Golang ................................. ;;
;; Run 'Gofmt' before saving Go files
(when (memq window-system '(mac ns))
(exec-path-from-shell-initialize))
(require 'go-mode)
;; Formatting settings
(add-hook 'go-mode-hook
(lambda ()
(setq indent-tabs-mode t)
(setq tab-width 4)
(setq trailing-whitespace-ok nil)
(setq whitespace-line-column 100)
(setq whitespace-iine-count 100)
(set-fill-column 100)
(setq whitespace-style '(face empty lines-tail trailing))))
(add-hook 'before-save-hook 'gofmt-before-save)
;; .............................. CoffeeScript .............................. ;;
(require 'coffee-mode)
(setq-default tab-width 2)
(add-hook 'coffee-mode-hook
(lambda ()
(setq coffee-indent-tabs-mode nil)
(setq coffee-tab-width 2)
(setq indent-tabs-mode nil)
(setq trailing-whitespace-ok nil)
(setq whitespace-style '(face lines-tail tabs trailing))
(setq whitespace-line-column 100)
(setq whitespace-iine-count 100)
(set-fill-column 100)
(setq tab-width 2)
(setq coffee-indent 2)))
;; .............................. LESS-CSS ................................. ;;
(require 'less-css-mode)
(add-hook 'less-css-mode-hook
(lambda ()
(setq indent-tabs-mode nil)
(setq trailing-whitespace-ok nil)
(setq whitespace-style '(face lines-tail tabs trailing))
(setq whitespace-line-column 100)
(setq whitespace-iine-count 100)
(set-fill-column 100)
(setq tab-width 2)))
;; ................................. JSON .................................. ;;
(require 'json-mode)
(add-hook 'json-mode-hook
(lambda ()
(setq tab-width 2)))
;; .......................... Web - HTML/JS/JSX/CSS ......................... ;;
(require 'web-mode)
;; use web-mode for .jsx files
(add-to-list 'auto-mode-alist '("\\.jsx\\'" . web-mode))
(defun my-web-mode-hook ()
;; Hooks for Web mode
(setq web-mode-code-indent-offset 2)
(setq web-mode-markup-indent-offset 2)
)
(add-hook 'web-mode-hook 'my-web-mode-hook)
(add-hook 'web-mode-hook
(lambda ()
(setq indent-tabs-mode nil)
(setq trailing-whitespace-ok nil)
(setq whitespace-style '(face lines-tail tabs trailing))
(setq whitespace-line-column 80)
(setq whitespace-iine-count 80)
(set-fill-column 80)
(setq tab-width 2)
;; short circuit js mode and just do everything in jsx-mode
(if (equal web-mode-content-type "javascript")
(web-mode-set-content-type "jsx")
(message "web-mode -- set to: %s" web-mode-content-type))))
;; ................................ Python .................................. ;;
(require 'python-mode)
(setq-default tab-width 2)
(add-hook 'python-mode-hook
(lambda ()
(setq indent-tabs-mode nil)
(setq trailing-whitespace-ok nil)
(setq whitespace-style '(face lines-tail tabs trailing))
(setq whitespace-line-column 100)
(setq whitespace-iine-count 100)
(set-fill-column 100)
(setq tab-width 2)))
;; ................................ Js .................................. ;;
(require 'js)
(setq-default tab-width 2)
(add-hook 'js-mode-hook
(lambda ()
(setq indent-tabs-mode nil)
(setq js-indent-level 2)
(setq trailing-whitespace-ok nil)
(setq whitespace-style '(face lines-tail tabs trailing))
(setq whitespace-line-column 100)
(setq whitespace-iine-count 100)
(set-fill-column 100)
(setq tab-width 2)))
;; -------------------------------------------------------------------------- ;;
;; Custom Commands ;;
;; -------------------------------------------------------------------------- ;;
;; .......................... Highlight Indentation ......................... ;;
(require 'highlight-indentation)
(highlight-indentation-mode 0)
(highlight-indentation-current-column-mode 0)
(setq highlight-on nil)
(defun highlight ()
(interactive)
(highlight-indentation-mode (if (eq highlight-on t) 0 1))
(highlight-indentation-current-column-mode (if (eq highlight-on t) 0 1))
(setq highlight-on (if (eq highlight-on t) nil t))
)
;; .............................. Split Window .............................. ;;
(defun split-sidebar-left ()
(interactive)
(split-window nil (floor (* (window-total-width nil) 0.35)) 'right))
(defun split-sidebar-right ()
(interactive)
(split-window nil (floor (* (window-total-width nil) 0.65)) 'left))
(defun split-sidebar-above ()
(interactive)
(split-window-below (* -1 (floor (* (window-total-height nil) 0.65)))))
(defun split-sidebar-below ()
(interactive)
(split-window-below (* 1 (floor (* (window-total-height nil) 0.65)))))
;; -------------------------------------------------------------------------- ;;
;; Key Bindings ;;
;; -------------------------------------------------------------------------- ;;
;; ........................ Window & Buffer Shortcuts........................ ;;
(global-set-key "\C-c\C-w" 'other-window)
(global-set-key "\C-c\C-b" 'switch-to-buffer)
(global-set-key "\C-b" 'electric-buffer-list)
(global-set-key (kbd "C-c <left>") 'split-sidebar-left)
(global-set-key (kbd "C-c <right>") 'split-sidebar-right)
(global-set-key (kbd "C-c <up>") 'split-sidebar-above)
(global-set-key (kbd "C-c <down>") 'split-sidebar-below)
(global-set-key "\M-\`" 'ff-find-other-file)
(global-set-key "\M-g" 'goto-line)
(global-set-key "\M-r" 'goto-line)
(global-set-key "\C-X\c-K" 'compile)
(global-set-key "\C-c\C-f" 'gofmt)
;; search & replace shortcuts
(global-set-key "\M-q" 'query-replace)
(global-set-key "\C-cr" 'regexp-replace)
(global-set-key "\C-c\C-r" 'replace-regexp)
;;(scroll-bar-mode -1)
(fset 'yes-or-no-p 'y-or-n-p)
(global-set-key "\C-c\C-l" 'relativelinum-mode)
(global-set-key "\C-c\C-a" 'highlight)
(global-set-key (kbd "C-c a") 'highlight)
(put 'upcase-region 'disabled nil)
(put 'downcase-region 'disabled nil)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment