unix dotfiles
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

init.el 12KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330
  1. ; source local configs
  2. (if (file-exists-p (concat user-emacs-directory "local.el")) (load-file (concat user-emacs-directory "local.el")))
  3. ; me
  4. (setq user-full-name "Cullum Smith"
  5. user-mail-address "cullum@c0ffee.net")
  6. ; gotta go fast
  7. (setq gc-cons-threshold (* 50 1000 1000))
  8. ; remove menubar, scrollbar, etc
  9. (cond ((not (string-equal system-type "darwin")) (progn
  10. (menu-bar-mode -1))))
  11. (when (fboundp 'tool-bar-mode)
  12. (tool-bar-mode -1))
  13. (when (fboundp 'scroll-bar-mode)
  14. (scroll-bar-mode -1))
  15. (when (fboundp 'horizontal-scroll-bar-mode)
  16. (horizontal-scroll-bar-mode -1))
  17. ; dark window border on OS X
  18. (add-to-list 'default-frame-alist '(ns-transparent-titlebar . t))
  19. (add-to-list 'default-frame-alist '(ns-appearance . dark))
  20. ; UTF-8 everywhere
  21. (prefer-coding-system 'utf-8)
  22. (set-default-coding-systems 'utf-8)
  23. (set-terminal-coding-system 'utf-8)
  24. (set-keyboard-coding-system 'utf-8)
  25. ; some sensible defaults
  26. (setq save-interprogram-paste-before-kill t) ; preserve OS clipboard before killing text
  27. (setq redisplay-dont-pause t) ; increase rendering performance
  28. (setq inhibit-startup-message t) ; don't show splash screen
  29. (setq initial-scratch-message nil) ; don't show scratch buffer message
  30. (setq vc-follow-symlinks t) ; don't ask before visiting symlinks
  31. (setq sentence-end-double-space nil) ; don't enforce two spaces to end sentences
  32. (setq require-final-newline t) ; put newlines at the end of every file
  33. (setq mouse-yank-at-point t) ; paste text wherever the point is
  34. (setq ns-pop-up-frames nil) ; open all files in the same emacs window
  35. (setq ring-bell-function 'ignore) ; no visual or audible bell
  36. (setq apropos-do-all t) ; search all defined documentation strings
  37. (setq load-prefer-newer t) ; don't load outdated bytecode files
  38. (show-paren-mode 1) ; show matching parens
  39. (setq show-paren-delay 0) ; ... but don't make me wait for it
  40. (fset 'yes-or-no-p 'y-or-n-p) ; ask y/n instead of full yes/no
  41. (global-hl-line-mode 1) ; highlight current line
  42. (column-number-mode t) ; show column number in modeline
  43. (line-number-mode t) ; show line number in modeline
  44. (size-indication-mode t) ; show filesize in modeline
  45. (delete-selection-mode t) ; replace highlighted text when typing
  46. (global-auto-revert-mode t) ; update buffer when file changes
  47. (setq-default indent-tabs-mode nil) ; use spaces instead of tabs
  48. (setq-default tab-width 2) ; 2-space tabs
  49. (setq-default fill-column 80) ; 80 character line width
  50. (save-place-mode 1) ; save cursor location in files
  51. (global-display-line-numbers-mode) ; show line numbers in left column
  52. (electric-indent-mode 1) ; smart auto-indent
  53. (setq-default electric-indent-inhibit t) ; ... disable indenting previous line (WHY?!)
  54. (setq-default truncate-lines 1) ; no line wrapping
  55. (electric-pair-mode 1) ; smart matching parens/braces
  56. (mouse-wheel-mode -1) ; disable scroll wheel
  57. (setq ediff-window-setup-function 'ediff-setup-windows-plain) ; keep all windows in one frame
  58. ; nice scrolling
  59. (setq scroll-margin 0
  60. scroll-conservatively 100000
  61. scroll-preserve-screen-position 1)
  62. ; vim-style delete-to-char
  63. (autoload 'zap-up-to-char "misc" "Kill up to, but not including ARGth occurrence of CHAR." t)
  64. ; better searching/completion
  65. (global-set-key (kbd "M-/") 'hippie-expand)
  66. (global-set-key (kbd "C-x C-b") 'ibuffer)
  67. (global-set-key (kbd "M-z") 'zap-up-to-char)
  68. (global-set-key (kbd "C-M-s") 'isearch-forward)
  69. (global-set-key (kbd "C-M-r") 'isearch-backward)
  70. ; ls command for dired view
  71. (setq-default dired-listing-switches
  72. (cond
  73. ((string-equal system-type "gnu/linux") "-alh --group-directories-first")
  74. (t "-alh")))
  75. ; navigate windows with shift + arrow keys
  76. (when (fboundp 'windmove-default-keybindings) (windmove-default-keybindings))
  77. ; no littering the filesystem with temp files
  78. (unless (file-directory-p (concat user-emacs-directory "backups"))
  79. (make-directory (concat user-emacs-directory "backups")))
  80. (unless (file-directory-p (concat user-emacs-directory "autosave"))
  81. (make-directory (concat user-emacs-directory "autosave")))
  82. (setq save-place-file (concat user-emacs-directory "places"))
  83. (setq abbrev-file-name (concat user-emacs-directory "abbrev_defs"))
  84. (setq backup-directory-alist `((".*" . ,(concat user-emacs-directory "backups"))))
  85. (setq tramp-backup-directory-alist `((".*" . ,(concat user-emacs-directory "backups"))))
  86. (setq auto-save-file-name-transforms `((".*" ,(concat user-emacs-directory "autosave/") t)))
  87. (setq custom-file (concat user-emacs-directory "custom.el"))
  88. ; hippie expand
  89. (setq hippie-expand-try-functions-list '(try-expand-dabbrev
  90. try-expand-dabbrev-all-buffers
  91. try-expand-dabbrev-from-kill
  92. try-complete-file-name-partially
  93. try-complete-file-name
  94. try-expand-all-abbrevs
  95. try-expand-list
  96. try-expand-line
  97. try-complete-lisp-symbol-partially
  98. try-complete-lisp-symbol))
  99. (global-set-key (kbd "M-/") #'hippie-expand)
  100. (global-set-key (kbd "s-/") #'hippie-expand)
  101. ; smart tab - indent or complete
  102. (setq tab-always-indent 'complete)
  103. ; replace buffer menu with ibuffer
  104. (global-set-key (kbd "C-x C-b") #'ibuffer)
  105. ; disable bold bonts on everything except OSX
  106. (cond ((not (string-equal system-type "darwin")) (progn
  107. (defun remap-faces-default-attributes ()
  108. (let ((family (face-attribute 'default :family))
  109. (height (face-attribute 'default :height)))
  110. (mapcar (lambda (face)
  111. (face-remap-add-relative
  112. face :family family :weight 'normal :slant 'normal :height height))
  113. (face-list))))
  114. (when (display-graphic-p)
  115. (add-hook 'minibuffer-setup-hook 'remap-faces-default-attributes)
  116. (add-hook 'change-major-mode-after-body-hook 'remap-faces-default-attributes)))))
  117. ;;;;; mode customizations ;;;;;
  118. (setq sh-basic-offset 2) ; 2-space indents for shell scripts
  119. ;;;;; packages ;;;;;
  120. ; enable package repositories
  121. (require 'package)
  122. (setq package-enable-at-startup nil)
  123. (add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/"))
  124. (add-to-list 'package-archives '("gnu" . "http://elpa.gnu.org/packages/"))
  125. (package-initialize)
  126. ; bootstrap use-package
  127. (unless (package-installed-p 'use-package)
  128. (package-refresh-contents)
  129. (package-install 'use-package))
  130. (eval-when-compile (require 'use-package))
  131. ; uniqify - better disambiguation for same-named files
  132. (use-package uniquify
  133. :config
  134. (setq uniquify-buffer-name-style 'forward)
  135. (setq uniquify-separator "/")
  136. ; rename after killing uniquified
  137. (setq uniquify-after-kill-buffer-p t)
  138. ; don't muck with special buffers
  139. (setq uniquify-ignore-buffers-re "^\\*"))
  140. ; zenburn
  141. (use-package zenburn-theme
  142. :ensure t
  143. :config
  144. (if (not (display-graphic-p)) (progn (setq linum-format "%d ")))
  145. :init
  146. (load-theme 'zenburn t)
  147. ; disable bold bonts on everything except OSX
  148. (cond ((not (string-equal system-type "darwin")) (progn
  149. (mapc (lambda (face)
  150. (when face
  151. (set-face-bold-p face nil)))
  152. (face-list))))))
  153. ; evil mode
  154. (use-package evil
  155. :ensure t
  156. :init
  157. (setq evil-want-integration t)
  158. (setq evil-want-keybinding nil)
  159. (setq evil-search-module 'evil-search) ; vim-style searching
  160. (setq evil-want-C-i-jump nil) ; restore tab functionality in org mode
  161. (setq evil-want-C-u-scroll t) ; ctrl-U scrolls up
  162. :config
  163. (evil-mode)
  164. (define-key evil-normal-state-map (kbd "C-h") #'evil-window-left)
  165. (define-key evil-normal-state-map (kbd "C-j") #'evil-window-down)
  166. (define-key evil-normal-state-map (kbd "C-k") #'evil-window-up)
  167. (define-key evil-normal-state-map (kbd "C-l") #'evil-window-right))
  168. ; org mode
  169. (use-package org
  170. :init
  171. (setq org-startup-indented t)
  172. (setq org-pretty-entities t)
  173. (setq org-hide-emphasis-markers t)
  174. (setq org-todo-keyword '((sequence "TODO(t)" "WAIT(w@/!)" "|" "DONE(d!)" "CANCELED(c@)")))
  175. (setq org-directory "~/org")
  176. )
  177. ; evil org mode
  178. (use-package evil-org
  179. :ensure t
  180. :after org
  181. :config
  182. (add-hook 'org-mode-hook 'evil-org-mode)
  183. (add-hook 'evil-org-mode-hook (lambda () (evil-org-set-key-theme)))
  184. (require 'evil-org-agenda)
  185. (evil-org-agenda-set-keys))
  186. ; evil collection
  187. (use-package evil-collection
  188. :after evil
  189. :ensure t
  190. :init
  191. :custom
  192. (evil-collection-setup-minibuffer t)
  193. :config
  194. (evil-collection-init))
  195. ; magit
  196. (use-package magit
  197. :ensure t
  198. :bind (("C-x g" . magit-status)))
  199. ; evil magit
  200. (use-package evil-magit
  201. :ensure t
  202. :after magit)
  203. ; projectile
  204. (use-package projectile
  205. :ensure t
  206. :init
  207. (setq projectile-completion-system 'ivy)
  208. :config
  209. (projectile-mode +1)
  210. (define-key projectile-mode-map (kbd "s-p") 'projectile-command-map)
  211. (define-key projectile-mode-map (kbd "C-c p") 'projectile-command-map))
  212. ; company
  213. (use-package company
  214. :ensure t
  215. :config
  216. (setq company-idle-delay 0.3)
  217. (setq company-minimum-prefix-length 2)
  218. (setq company-show-numbers t)
  219. (setq company-tooltip-align-annotations t)
  220. (setq company-tooltip-flip-when-above t)
  221. (global-company-mode))
  222. ; ivy
  223. (use-package ivy
  224. :ensure t
  225. :config
  226. (ivy-mode 1)
  227. (setq ivy-use-virtual-buffers t)
  228. (setq enable-recursive-minibuffers t)
  229. (global-set-key (kbd "C-c C-r") 'ivy-resume)
  230. (global-set-key (kbd "<f6>") 'ivy-resume))
  231. ; counsel
  232. (use-package counsel
  233. :ensure t
  234. :config
  235. (global-set-key (kbd "M-x") 'counsel-M-x)
  236. (global-set-key (kbd "C-x C-f") 'counsel-find-file)
  237. (global-set-key (kbd "<f1> f") 'counsel-describe-function)
  238. (global-set-key (kbd "<f1> v") 'counsel-describe-variable)
  239. (global-set-key (kbd "<f1> l") 'counsel-find-library)
  240. (global-set-key (kbd "<f2> i") 'counsel-info-lookup-symbol)
  241. (global-set-key (kbd "<f2> u") 'counsel-unicode-char)
  242. (global-set-key (kbd "C-c g") 'counsel-git)
  243. (global-set-key (kbd "C-c j") 'counsel-git-grep)
  244. (global-set-key (kbd "C-c a") 'counsel-ag)
  245. (global-set-key (kbd "C-x l") 'counsel-locate)
  246. (define-key minibuffer-local-map (kbd "C-r") 'counsel-minibuffer-history))
  247. ; swiper
  248. (use-package swiper
  249. :ensure t
  250. :config
  251. (global-set-key "\C-s" 'swiper)
  252. (global-set-key "\C-r" 'swiper))
  253. ; undo tree
  254. (use-package undo-tree
  255. :ensure t
  256. :config
  257. ; persistent undo
  258. (unless (file-directory-p (concat user-emacs-directory "undo"))
  259. (make-directory (concat user-emacs-directory "undo")))
  260. (setq undo-tree-history-directory-alist `((".*" . ,(concat user-emacs-directory "undo"))))
  261. (setq undo-tree-auto-save-history t))
  262. ; highlight todos
  263. (use-package hl-todo
  264. :ensure t
  265. :config
  266. (global-hl-todo-mode))
  267. ; which key
  268. (use-package which-key
  269. :ensure t
  270. :config
  271. (setq which-key-idle-delay 0.5)
  272. ; disable bold bonts on everything except OSX
  273. (cond ((not (string-equal system-type "darwin")) (progn
  274. (set-face-attribute 'which-key-key-face nil :inherit font-lock-function-name-face)
  275. (set-face-attribute 'which-key-note-face nil :inherit font-lock-comment-face :slant 'normal))))
  276. (which-key-mode +1))
  277. ; highlight VC diffs
  278. (use-package diff-hl
  279. :ensure t
  280. :config
  281. (global-diff-hl-mode +1)
  282. (add-hook 'dired-mode-hook 'diff-hl-dired-mode)
  283. (add-hook 'magit-post-refresh-hook 'diff-hl-magit-post-refresh))
  284. ; imenu anywhere
  285. (use-package imenu-anywhere
  286. :ensure t
  287. :bind (("C-c ." . imenu-anywhere)))
  288. ; yaml mode
  289. (use-package yaml-mode
  290. :ensure t)