packages.el 32 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097
  1. ;; Package installation
  2. (require 'package)
  3. ;; Create the package install directory if it doesn't exist
  4. (setq package-user-dir (format "%selpa_%s/"
  5. user-emacs-directory emacs-major-version)) ; default = ~/.emacs.d/elpa/
  6. (let* ((no-ssl (and (memq system-type '(windows-nt ms-dos))
  7. (not (gnutls-available-p))))
  8. (proto (if no-ssl "http" "https")))
  9. ;; Comment/uncomment these two lines to enable/disable MELPA and MELPA Stable as desired
  10. (add-to-list 'package-archives (cons "melpa" (concat proto "://melpa.org/packages/")) t)
  11. ;;(add-to-list 'package-archives (cons "melpa-stable" (concat proto "://stable.melpa.org/packages/")) t)
  12. (when (< emacs-major-version 24)
  13. ;; For important compatibility libraries like cl-lib
  14. (add-to-list 'package-archives '("gnu" . (concat proto "://elpa.gnu.org/packages/")))))
  15. (add-to-list 'package-archives '("org" . "http://orgmode.org/elpa/"))
  16. (package-initialize)
  17. (setq package-enable-at-startup nil)
  18. (unless (package-installed-p 'use-package)
  19. (package-refresh-contents)
  20. (package-install 'use-package))
  21. (eval-when-compile
  22. (require 'use-package))
  23. ;;;; Required packages
  24. (setq use-package-verbose t)
  25. (use-package diminish
  26. :ensure t)
  27. (diminish 'visual-line-mode)
  28. (diminish 'abbrev-mode)
  29. (diminish 'eldoc-mode)
  30. (use-package autorevert
  31. :diminish auto-revert-mode)
  32. (use-package iedit
  33. :ensure t)
  34. (defmacro hail (p)
  35. (list 'use-package p ':ensure 't))
  36. (hail hydra)
  37. (use-package engine-mode
  38. :ensure t)
  39. (defvar evil-want-integration nil)
  40. (use-package undo-tree
  41. :ensure t
  42. :diminish undo-tree-mode
  43. :init
  44. (setq undo-tree-enable-undo-in-region nil))
  45. (use-package evil
  46. :after undo-tree
  47. :ensure t
  48. :config
  49. (evil-mode t)
  50. (setq evil-want-C-i-jump nil)
  51. (setq evil-default-state 'normal)
  52. ;; Move all elements of evil-emacs-state-modes to evil-motion-state-modes
  53. (setq evil-motion-state-modes (append evil-emacs-state-modes evil-motion-state-modes)
  54. evil-emacs-state-modes (list 'magit-popup-mode))
  55. (delete 'magit-popup-mode evil-motion-state-modes)
  56. ;; Don't echo evil's states
  57. (setq evil-insert-state-message nil
  58. evil-visual-state-message nil)
  59. ;; Little words (camelCase)
  60. (evil-define-motion evil-little-word (count)
  61. :type exclusive
  62. (let* ((case-fold-search nil)
  63. (count (if count count 1)))
  64. (while (> count 0)
  65. (forward-char)
  66. (search-forward-regexp "[_A-Z]\\|\\W" nil t)
  67. (backward-char)
  68. (decf count))))
  69. ;; Don't litter registers with whitespace
  70. (defun destroy-whitespace--evil-delete-around (func beg end type &optional reg yh)
  71. (let ((clean-string (replace-regexp-in-string "[ \t\n]" "" (buffer-substring beg end))))
  72. (if (equal "" clean-string)
  73. (apply func beg end type ?_ yh)
  74. (apply func beg end type reg yh))))
  75. (advice-add 'evil-delete :around #'destroy-whitespace--evil-delete-around)
  76. ;; eval the last sexp while in normal mode (include the character the cursor is currently on)
  77. (defun evil-eval-last-sexp ()
  78. (interactive)
  79. (evil-append 1)
  80. (eval-last-sexp nil)
  81. (evil-normal-state))
  82. ;; select recently pasted text
  83. ;; from https://emacs.stackexchange.com/a/21093
  84. (defun my/evil-select-pasted ()
  85. (interactive)
  86. (let ((start-marker (evil-get-marker ?[))
  87. (end-marker (evil-get-marker ?])))
  88. (evil-visual-select start-marker end-marker)))
  89. ;; "pull" left and right with zs and ze
  90. (defun hscroll-cursor-left ()
  91. (interactive "@")
  92. (set-window-hscroll (selected-window) (current-column)))
  93. (defun hscroll-cursor-right ()
  94. (interactive "@")
  95. (set-window-hscroll (selected-window) (- (current-column) (window-width) -1)))
  96. ;; Horizontal scrolling
  97. (setq auto-hscroll-mode 't)
  98. (setq hscroll-margin 0
  99. hscroll-step 1)
  100. (defhydra hydra-window (global-map "C-w")
  101. "window layout"
  102. ("u" winner-undo "undo")
  103. ("U" winner-redo "redo"))
  104. ;; Make K select manpage or engine-mode (m for man, g for google?)
  105. (defengine google
  106. "http://www.google.com/search?ie=utf-8&oe=utf-8&q=%s")
  107. (defhydra hydra-lookup-menu ()
  108. "Choose lookup"
  109. ("g" engine/search-google "Google" :color blue)
  110. ("m" evil-lookup "man" :color blue))
  111. (define-key evil-normal-state-map "K" 'hydra-lookup-menu/body)
  112. (define-key evil-visual-state-map "K" 'hydra-lookup-menu/body)
  113. ;; These go out here, because undefining keybinds is hard
  114. (define-key global-map "\C-j" nil)
  115. (define-key evil-normal-state-map "\C-j" 'flyspell-goto-next-error)
  116. (evil-define-key 'normal package-menu-mode-map "q" 'quit-window)
  117. (defun evil-passthrough-key (state mode key)
  118. "Use the default binding for KEY in MODE, rather than the evil-mode binding, for STATE."
  119. (evil-define-key state mode (kbd key) (evil-lookup-key mode (kbd key))))
  120. :bind (:map evil-normal-state-map
  121. ("zs" . hscroll-cursor-left)
  122. ("ze" . hscroll-cursor-right)
  123. ("[s" . flyspell-goto-previous-error)
  124. ("]s" . flyspell-goto-next-error)
  125. ("\C-k" . flyspell-goto-previous-error)
  126. ("\C-x \C-e" . evil-eval-last-sexp)
  127. ("j" . evil-next-visual-line)
  128. ("k" . evil-previous-visual-line)
  129. ("gj" . evil-next-line)
  130. ("gk" . evil-previous-line)
  131. ; :map Info-mode-map
  132. ; ("g" . nil)
  133. ; ("n" . nil)
  134. ; ("p" . nil)
  135. :map evil-window-map
  136. ("q" . delete-window)
  137. ("C-q" . delete-window)
  138. ("x" . kill-buffer-and-window)
  139. :map Buffer-menu-mode-map
  140. ("SPC" . nil)))
  141. (use-package evil-numbers
  142. :ensure t
  143. :config
  144. ;; Increment and decrement (evil-numbers)
  145. (defhydra hydra-numbers (global-map "C-x")
  146. "modify numbers"
  147. ("a" evil-numbers/inc-at-pt "increment")
  148. ("x" evil-numbers/dec-at-pt "decrement")))
  149. (use-package undohist
  150. :ensure t
  151. :config
  152. ;; Save undo history under .emacs.d/undohist
  153. (setq undohist-directory "~/.emacs.d/undohist")
  154. (unless (file-exists-p "~/.emacs.d/undohist")
  155. (make-directory "~/.emacs.d/undohist"))
  156. (undohist-initialize))
  157. (use-package powerline-evil
  158. :ensure t
  159. :config
  160. (defun powerline-center-evil-theme ()
  161. "Setup a mode-line with major, evil, and minor modes centered."
  162. (interactive)
  163. (setq-default mode-line-format
  164. '("%e"
  165. (:eval
  166. (let* ((active (powerline-selected-window-active))
  167. (mode-line-buffer-id (if active 'mode-line-buffer-id 'mode-line-buffer-id-inactive))
  168. (mode-line (if active 'mode-line 'mode-line-inactive))
  169. (face1 (if active 'powerline-active1 'powerline-inactive1))
  170. (face2 (if active 'powerline-active2 'powerline-inactive2))
  171. (separator-left (intern (format "powerline-%s-%s"
  172. (powerline-current-separator)
  173. (car powerline-default-separator-dir))))
  174. (separator-right (intern (format "powerline-%s-%s"
  175. (powerline-current-separator)
  176. (cdr powerline-default-separator-dir))))
  177. (lhs (list (powerline-raw "%*" mode-line 'l)
  178. (powerline-buffer-id mode-line-buffer-id 'l)
  179. (powerline-raw " " mode-line)
  180. (funcall separator-left mode-line face1)
  181. (powerline-narrow face1 'l)
  182. (powerline-vc face1)))
  183. (rhs (list (funcall separator-right face1 mode-line)
  184. (powerline-raw mode-line-misc-info mode-line 'r)
  185. ;(powerline-raw global-mode-string face1 'r)
  186. (powerline-raw "%2l" mode-line 'r)
  187. (powerline-raw ":" mode-line)
  188. (powerline-raw "%2c" mode-line 'r)
  189. ;(powerline-raw " ")
  190. ;(powerline-raw "%6p" mode-line 'r)
  191. (powerline-hud face2 face1)))
  192. (center (append (list (powerline-raw " " face1)
  193. (funcall separator-left face1 face2)
  194. (when (and (boundp 'erc-track-minor-mode) erc-track-minor-mode)
  195. (powerline-raw erc-modified-channels-object face2 'l))
  196. (powerline-major-mode face2 'l)
  197. (powerline-process face2)
  198. (powerline-raw " " face2))
  199. (if (split-string (format-mode-line minor-mode-alist))
  200. (append (if evil-mode
  201. (list (funcall separator-right face2 face1)
  202. (powerline-raw evil-mode-line-tag face1 'l)
  203. (powerline-raw " " face1)
  204. (funcall separator-left face1 face2)))
  205. (list (powerline-minor-modes face2 'l)
  206. (powerline-raw " " face2)
  207. (funcall separator-right face2 face1)))
  208. (list (powerline-raw evil-mode-line-tag face2)
  209. (funcall separator-right face2 face1))))))
  210. (concat (powerline-render lhs)
  211. (powerline-fill-center face1 (/ (powerline-width center) 2.0))
  212. (powerline-render center)
  213. (powerline-fill face1 (powerline-width rhs))
  214. (powerline-render rhs)))))))
  215. (defun powerline-evil-vim-theme ()
  216. "Powerline's Vim-like mode-line with evil state at the beginning."
  217. (interactive)
  218. (setq-default mode-line-format
  219. '("%e"
  220. (:eval
  221. (let* ((active (powerline-selected-window-active))
  222. (mode-line (if active 'mode-line 'mode-line-inactive))
  223. (face1 (if active 'powerline-active1 'powerline-inactive1))
  224. (face2 (if active 'powerline-active2 'powerline-inactive2))
  225. (separator-left (intern (format "powerline-%s-%s"
  226. (powerline-current-separator)
  227. (car powerline-default-separator-dir))))
  228. (separator-right (intern (format "powerline-%s-%s"
  229. (powerline-current-separator)
  230. (cdr powerline-default-separator-dir))))
  231. (lhs (list (if evil-mode
  232. (powerline-raw (powerline-evil-tag) mode-line))
  233. (powerline-buffer-id `(mode-line-buffer-id ,mode-line) 'l)
  234. (powerline-raw "[" mode-line 'l)
  235. (powerline-major-mode mode-line)
  236. (powerline-process mode-line)
  237. (powerline-raw "]" mode-line)
  238. (when (buffer-modified-p)
  239. (powerline-raw "[+]" mode-line))
  240. (when buffer-read-only
  241. (powerline-raw "[RO]" mode-line))
  242. ;; (powerline-raw (concat "[" (mode-line-eol-desc) "]") mode-line)
  243. (when (and (boundp 'which-func-mode) which-func-mode)
  244. (powerline-raw which-func-format nil 'l))
  245. (when (boundp 'erc-modified-channels-object)
  246. (powerline-raw erc-modified-channels-object face1 'l))
  247. (powerline-raw "[" mode-line 'l)
  248. (powerline-minor-modes mode-line) (powerline-raw "%n" mode-line)
  249. (powerline-raw "]" mode-line)
  250. (when (and vc-mode buffer-file-name)
  251. (let ((backend (vc-backend buffer-file-name)))
  252. (when backend
  253. (concat (powerline-raw "[" mode-line 'l)
  254. (powerline-raw (format "%s / %s" backend (vc-working-revision buffer-file-name backend)))
  255. (powerline-raw "]" mode-line)))))))
  256. (rhs (list (powerline-raw mode-line-misc-info mode-line 'r)
  257. (powerline-raw global-mode-string mode-line 'r)
  258. (powerline-raw "%l," mode-line 'l)
  259. (powerline-raw (format-mode-line '(10 "%c")))
  260. (powerline-raw (replace-regexp-in-string "%" "%%" (format-mode-line '(-3 "%p"))) mode-line 'r))))
  261. (concat (powerline-render lhs)
  262. (powerline-fill mode-line (powerline-width rhs))
  263. (powerline-render rhs)))))))
  264. (if (or (display-graphic-p) (daemonp))
  265. (powerline-center-evil-theme)
  266. (powerline-evil-vim-theme)))
  267. ; (use-package smart-mode-line
  268. ; :ensure t
  269. ; :init
  270. ; :config
  271. ; (setq sml/no-confirm-load-theme t)
  272. ; (setq sml/mule-info nil)
  273. ; (setq sml/show-frame-identification nil)
  274. ; (sml/setup))
  275. ; (use-package spaceline
  276. ; :ensure t
  277. ; :config
  278. ; (require 'spaceline-config)
  279. ; (spaceline-spacemacs-theme))
  280. ; (use-package telephone-line
  281. ; :ensure t
  282. ; :after evil-surround
  283. ; :config
  284. ; ;; These don't have any effect, surprise surprise
  285. ; (set-face-attribute 'telephone-line-evil-emacs t :inherit 'telephone-line-evil)
  286. ; (set-face-attribute 'telephone-line-evil-insert t :inherit 'telephone-line-evil)
  287. ; (set-face-attribute 'telephone-line-evil-motion t :inherit 'telephone-line-evil)
  288. ; (set-face-attribute 'telephone-line-evil-normal t :inherit 'telephone-line-evil)
  289. ; (set-face-attribute 'telephone-line-evil-operator t :inherit 'telephone-line-evil)
  290. ; (setq telephone-line-evil-use-short-tag t)
  291. ; (telephone-line-evil-config))
  292. (use-package linum-relative
  293. :ensure t
  294. :diminish linum-relative-mode
  295. :config
  296. (setq linum-relative-current-symbol "")
  297. (if (not (or (display-graphic-p) (daemonp)))
  298. (setq linum-relative-format "%3s "))
  299. (add-hook 'prog-mode-hook 'linum-relative-mode)
  300. (defun linum-update-window-scale-fix (win)
  301. "fix linum for scaled text"
  302. (set-window-margins
  303. win
  304. (ceiling (* (if (boundp 'text-scale-mode-step)
  305. (expt text-scale-mode-step
  306. text-scale-mode-amount) 1)
  307. (if (car (window-margins))
  308. (car (window-margins)) 1)
  309. ))))
  310. (advice-add #'linum-update-window
  311. :after #'linum-update-window-scale-fix))
  312. (use-package bind-map
  313. :ensure t
  314. :after evil
  315. :after evil-numbers
  316. :config
  317. (bind-map
  318. my-base-leader-map
  319. :keys ("M-m")
  320. :evil-keys ("SPC")
  321. :evil-states (normal motion visual)
  322. :bindings
  323. ("d" 'define-word-at-point
  324. "b" 'buffer-menu
  325. "f" 'treemacs-toggle
  326. "u" 'undo-tree-visualize
  327. "l" 'auto-fill-mode
  328. "s" 'flyspell-toggle-correct-mode
  329. "a" 'company-mode
  330. "g" 'magit-status
  331. "c" 'flycheck-mode
  332. "w" '(lambda () (interactive)
  333. ;; "writing" mode
  334. (variable-pitch-mode)
  335. (visual-line-mode))
  336. "p" 'my/evil-select-pasted
  337. "/" 'swiper
  338. "v" 'ivy-switch-buffer
  339. "n" 'hydra-numbers/body
  340. "m" 'evil-visual-mark-mode
  341. "1" 'eyebrowse-switch-to-window-config-1
  342. "2" 'eyebrowse-switch-to-window-config-2
  343. "3" 'eyebrowse-switch-to-window-config-3
  344. "4" 'eyebrowse-switch-to-window-config-4
  345. "5" 'eyebrowse-switch-to-window-config-5
  346. "6" 'eyebrowse-switch-to-window-config-6
  347. "7" 'eyebrowse-switch-to-window-config-7
  348. "8" 'eyebrowse-switch-to-window-config-8
  349. "9" 'eyebrowse-switch-to-window-config-9))
  350. (bind-map
  351. my-elisp-map
  352. :keys ("M-m")
  353. :evil-keys ("SPC")
  354. :major-modes (emacs-lisp-mode)
  355. :bindings
  356. ("el" 'evil-eval-last-sexp
  357. "er" 'eval-region
  358. "eb" 'eval-buffer)))
  359. (use-package treemacs
  360. :ensure t
  361. :bind (:map treemacs-mode-map
  362. ("." . treemacs-toggle-show-dotfiles)))
  363. (use-package treemacs-evil
  364. :after treemacs
  365. :commands treemacs-toggle
  366. :ensure t)
  367. (use-package editorconfig
  368. :ensure t
  369. :diminish editorconfig-mode
  370. :config
  371. (editorconfig-mode 1))
  372. (use-package ivy
  373. :ensure t
  374. :diminish ivy-mode
  375. :config
  376. (ivy-mode)
  377. (setq ivy-use-virtual-buffers t))
  378. (use-package flx
  379. :ensure t
  380. :config
  381. (setq ivy-re-builders-alist '((t . ivy--regex-fuzzy))))
  382. (use-package company
  383. :ensure t
  384. :defer 2
  385. :diminish company-mode
  386. :config
  387. (add-hook 'prog-mode-hook 'company-mode)
  388. :custom
  389. (company-begin-commands '(self-insert-command))
  390. (company-idle-delay .1)
  391. (company-minimum-prefix-length 2)
  392. (company-show-numbers t)
  393. (company-tooltip-align-annotations 't))
  394. (use-package flycheck
  395. :ensure t
  396. :diminish flycheck-mode
  397. :config
  398. (add-hook 'prog-mode-hook 'flycheck-mode)
  399. (setq flycheck-check-syntax-automatically '(idle-change new-line save mode-enabled))
  400. (setq flycheck-checkers (delq 'emacs-lisp-checkdoc flycheck-checkers)))
  401. (use-package flycheck-pos-tip
  402. :ensure t
  403. :after flycheck
  404. :config
  405. (flycheck-pos-tip-mode))
  406. (use-package evil-surround
  407. :ensure t
  408. :config
  409. (global-evil-surround-mode 1))
  410. (use-package dtrt-indent
  411. :ensure t
  412. :config
  413. (setq global-mode-string (delq 'dtrt-indent-mode-line-info global-mode-string))
  414. (dtrt-indent-mode 1))
  415. (use-package org
  416. :commands org-mode
  417. :after bind-map
  418. :ensure t
  419. :config
  420. (setq org-log-done 'time)
  421. (defun org->odt->pdf ()
  422. "Someday I'll learn how to properly format the LaTeX to PDF output."
  423. (interactive)
  424. (org-odt-export-to-odt)
  425. (shell-command
  426. (concat
  427. "libreoffice --headless --convert-to pdf \"" (file-name-sans-extension (buffer-name)) ".odt\""
  428. " && echo Done")))
  429. (setq org-html-table-default-attributes '(:border "2" :cellspacing "0" :cellpadding "6" :rules "all" :frame "border"))
  430. (setq org-latex-minted-options
  431. '("breaklines"))
  432. (add-hook 'org-mode-hook 'visual-line-mode)
  433. (defun org-variable-toggle-latex-fragment ()
  434. "Toggle LaTeX fragment, taking into account the current zoom size of the buffer."
  435. (interactive)
  436. (if (boundp 'text-scale-mode-amount)
  437. (let ((org-format-latex-options (plist-put org-format-latex-options :scale text-scale-mode-amount)))
  438. (org-toggle-latex-fragment))
  439. (org-toggle-latex-fragment)))
  440. (face-attribute 'default :font)
  441. ;; I might experiemnt with gnuplot and notes in the future.
  442. ;; (org-babel-do-load-languages
  443. ;; 'org-babel-load-languages
  444. ;; '((gnuplot . t)))
  445. ;; (global-set-key (kbd "C-c c") 'org-capture)
  446. (bind-map
  447. my-org-map
  448. :keys ("M-m")
  449. :evil-keys ("SPC")
  450. :major-modes (org-mode)
  451. :bindings
  452. (;"ol" 'org-toggle-latex-fragment
  453. "ol" 'org-variable-toggle-latex-fragment
  454. "ot" 'org-timeline
  455. "oa" 'org-archive-subtree
  456. "od" 'org-deadline
  457. "os" 'org-schedule
  458. "oc" 'cfw:open-org-calendar
  459. "op" 'org-priority
  460. "t" 'org-todo)))
  461. (use-package org-agenda
  462. :commands org-agenda org-timeline
  463. :after org
  464. :after evil
  465. :config
  466. ;; Rip org-timeline
  467. (defun org-timeline ()
  468. (interactive)
  469. (let ((org-agenda-custom-commands
  470. '(("z" "" agenda ""
  471. ((org-agenda-span 'year)
  472. ;; (org-agenda-time-grid nil)
  473. (org-agenda-show-all-dates nil)
  474. ;; (org-agenda-entry-types '(:deadline)) ;; this entry excludes :scheduled
  475. (org-deadline-warning-days 0))))))
  476. (org-agenda nil "z" 'buffer)))
  477. ;; Not sure if this can be placed in a :bind statement
  478. (evil-define-key 'motion org-agenda-mode-map (kbd "RET") '(lambda () (interactive) (org-agenda-switch-to t)))
  479. (setq org-agenda-files (quote ("~/Owncloud/org/organizer.org"))))
  480. (use-package org-preview-html
  481. :commands org-preview-html/preview
  482. :after org
  483. :ensure t)
  484. (use-package evil-ediff
  485. :ensure t
  486. :config
  487. (add-hook 'ediff-load-hook 'evil-ediff-init))
  488. (use-package rainbow-delimiters
  489. :ensure t
  490. :config
  491. (add-hook 'prog-mode-hook #'rainbow-delimiters-mode))
  492. (use-package rainbow-identifiers
  493. :ensure t
  494. :config
  495. (add-hook 'prog-mode-hook #'rainbow-identifiers-mode)
  496. (setq rainbow-identifiers-faces-to-override
  497. '(
  498. font-lock-constant-face
  499. font-lock-type-face
  500. font-lock-function-name-face
  501. font-lock-variable-name-face
  502. font-lock-keyword-face)))
  503. (use-package rainbow-mode
  504. :ensure t
  505. :diminish rainbow-mode
  506. :config
  507. (add-hook 'prog-mode-hook #'rainbow-mode))
  508. (use-package eyebrowse
  509. :ensure t
  510. :config
  511. (eyebrowse-mode t)
  512. (eyebrowse-setup-evil-keys)
  513. (setq eyebrowse-new-workspace t))
  514. (use-package material-theme
  515. :ensure t)
  516. (use-package solaire-mode
  517. :ensure t
  518. :config
  519. ;; highlight the minibuffer when it is activated
  520. (set-face-attribute 'solaire-minibuffer-face nil :inherit 'solaire-default-face :background "gainsboro")
  521. (add-hook 'minibuffer-setup-hook #'solaire-mode-in-minibuffer))
  522. (use-package evil-goggles
  523. :ensure t
  524. :diminish evil-goggles-mode
  525. :config
  526. (evil-goggles-mode)
  527. ;; optionally use diff-mode's faces; as a result, deleted text
  528. ;; will be highlighed with `diff-removed` face which is typically
  529. ;; some red color (as defined by the color theme)
  530. ;; other faces such as `diff-added` will be used for other actions
  531. (evil-goggles-use-diff-faces))
  532. (use-package shackle
  533. :ensure t
  534. :init
  535. (shackle-mode)
  536. (setq shackle-rules '(("*Python*" :align t :size 0.2)
  537. ("*Help*" :align t :size 0.4 :select t)
  538. ("\\`\\*intero:.*:repl\\*\\'" :regexp t :align t :size 0.4))))
  539. (use-package which-key
  540. :ensure t
  541. :diminish which-key-mode
  542. :config
  543. (setq which-key-idle-delay 0.5)
  544. (which-key-mode)
  545. ;(which-key-setup-minibuffer)
  546. (which-key-setup-side-window-bottom)
  547. (defvar i 1)
  548. (while (< i 10)
  549. (let ((cell (cons (cons (number-to-string i) nil) '(lambda (cs) t))))
  550. (add-to-list 'which-key-replacement-alist cell))
  551. (setq i (+ i 1)))
  552. (makunbound 'i)
  553. (which-key-add-key-based-replacements
  554. "SPC d" "Diff buffer w/ file"))
  555. ;; OS specific
  556. (use-package magit-todos
  557. :if (not (eq system-type 'windows-nt))
  558. :ensure t
  559. :commands magit-todos-mode)
  560. (use-package evil-magit
  561. :if (not (eq system-type 'windows-nt))
  562. :ensure t
  563. :commands evil-magit-init)
  564. (use-package magit
  565. :commands magit-status
  566. :if (not (eq system-type 'windows-nt))
  567. :ensure t
  568. :defer t
  569. :diminish magit-auto-revert-mode
  570. :config
  571. (evil-magit-init)
  572. (magit-todos-mode))
  573. (use-package multi-term
  574. :if (not (eq system-type 'windows-nt))
  575. :ensure t)
  576. (use-package esup
  577. :commands esup
  578. :ensure t)
  579. (use-package highlight-indent-guides
  580. :ensure t
  581. :init
  582. (add-hook 'prog-mode-hook 'highlight-indent-guides-mode)
  583. :config
  584. (setq highlight-indent-guides-method 'column))
  585. (use-package evil-collection
  586. :ensure t
  587. :after evil
  588. :init
  589. (setq evil-collection-setup-minibuffer t)
  590. :config
  591. (evil-collection-init))
  592. ;; global-prettify-symbols doesn't play nice on Windows
  593. (if (not (eq system-type 'windows-nt))
  594. (global-prettify-symbols-mode))
  595. (require 'prettify-custom-symbols)
  596. (use-package yasnippet
  597. :ensure t
  598. :commands yas-minor-mode
  599. :init
  600. (add-hook 'prog-mode-hook 'yas-minor-mode)
  601. :config
  602. (yas-reload-all)
  603. ;; Add yasnippet support for all company backends
  604. ;; https://github.com/syl20bnr/spacemacs/pull/179
  605. (defvar company-mode/enable-yas t
  606. "Enable yasnippet for all backends.")
  607. (defun company-mode/backend-with-yas (backend)
  608. (if (or (not company-mode/enable-yas) (and (listp backend) (member 'company-yasnippet backend)))
  609. backend
  610. (append (if (consp backend) backend (list backend))
  611. '(:with company-yasnippet))))
  612. (setq company-backends (mapcar #'company-mode/backend-with-yas company-backends)))
  613. (use-package yasnippet-snippets
  614. :ensure t
  615. :after yasnippet)
  616. (use-package gnus
  617. :ensure t
  618. :init
  619. (add-hook 'gnus-group-mode-hook 'gnus-topic-mode)
  620. (add-hook 'gnus-startup-hook
  621. '(lambda ()
  622. (define-key gnus-summary-mode-map (kbd "RET") 'gnus-summary-next-page)
  623. (cl-loop for mode in (list gnus-article-mode-map gnus-group-mode-map gnus-summary-mode-map)
  624. do (cl-loop for key in (list "RET" "G")
  625. do (evil-passthrough-key 'motion mode key)))))
  626. (add-hook 'gnus-startup-hook '(lambda () (gnus-demon-add-handler 'gnus-demon-scan-mail 5 1)))
  627. :config
  628. (setq gnus-select-method '(nntp "news.gmane.org"))
  629. (setq gnus-thread-sort-functions '(gnus-thread-sort-by-most-recent-date gnus-thread-sort-by-most-recent-number))
  630. (add-to-list 'gnus-secondary-select-methods
  631. '(nnimap "gmail"
  632. (nnimap-address "imap.gmail.com")
  633. (nnimap-server-port 993)
  634. (nnimap-stream ssl)
  635. (nnir-search-engine imap)
  636. ;; @see http://www.gnu.org/software/emacs/manual/html_node/gnus/Expiring-Mail.html
  637. ;; press 'E' to expire email
  638. (nnmail-expiry-target "nnimap+gmail:[Gmail]/Trash")
  639. (nnmail-expiry-wait 90)))
  640. (add-to-list 'gnus-secondary-select-methods
  641. '(nnimap "comcast"
  642. (nnimap-address "imap.comcast.net")
  643. (nnimap-server-port 993)
  644. (nnimap-stream ssl)
  645. (nnir-search-engine imap)
  646. (nnmail-expiry-target "nnimap+comcast:Trash")
  647. (nnmail-expiry-wait 90)))
  648. (add-hook 'gnus-topic-mode-hook
  649. '(lambda ()
  650. (setq gnus-message-archive-group '((format-time-string "sent.%Y")))
  651. (setq gnus-topic-topology '(("Gnus" visible)
  652. (("misc" visible))
  653. (("comcast" visible nil nil))
  654. (("gmail" visible nil nil))
  655. (("feeds" visible nil nil))))
  656. (gnus-topic-move-matching ".*comcast.*" "comcast")
  657. (gnus-topic-move-matching ".*gmail.*" "gmail")
  658. (gnus-topic-move-matching "gwene.*" "feeds")
  659. (setq gnus-topic-alist (mapcar 'delete-dups gnus-topic-alist)))))
  660. (use-package gnus-desktop-notify
  661. :ensure t
  662. :after gnus
  663. :config
  664. (gnus-desktop-notify-mode))
  665. (use-package dumb-jump
  666. :after evil
  667. :ensure t
  668. :bind (:map evil-normal-state-map
  669. ("zs" . hscroll-cursor-left)
  670. ("gs" . dumb-jump-go-evil-mark))
  671. :config
  672. (setq dumb-jump-selector 'ivy)
  673. (defun dumb-jump-go-evil-mark ()
  674. (interactive)
  675. (evil-set-jump)
  676. (dumb-jump-go)))
  677. (use-package evil-visual-mark-mode
  678. :after evil
  679. :ensure t)
  680. (use-package define-word
  681. :ensure t)
  682. (use-package calfw
  683. :commands cfw:open-org-calendar
  684. :ensure t)
  685. (use-package calfw-org
  686. :ensure t
  687. )
  688. (use-package helpful
  689. :ensure t
  690. :bind (("C-h f" . helpful-callable)
  691. ("C-h v" . helpful-variable)
  692. ("C-h k" . helpful-key)))
  693. ;;;; Optional packages
  694. (use-package flymd
  695. :defer t
  696. :config
  697. (setq flymd-close-buffer-delete-temp-files t))
  698. (use-package web-mode
  699. :defer t
  700. :config
  701. ;; 2 spaces for an indent
  702. (defun my-web-mode-hook ()
  703. "Hooks for Web mode."
  704. (setq web-mode-markup-indent-offset 2
  705. web-mode-enable-auto-closing t
  706. web-mode-enable-auto-pairing t)
  707. )
  708. (add-hook 'web-mode-hook 'my-web-mode-hook)
  709. ;; Auto-enable web-mode when opening relevent files
  710. (add-to-list 'auto-mode-alist '("\\.html\\'" . web-mode))
  711. (add-to-list 'auto-mode-alist '("\\.hbs\\'" . web-mode))
  712. (add-to-list 'auto-mode-alist '("\\.handlebars\\'" . web-mode)))
  713. (setq js-indent-level 2)
  714. (use-package tide
  715. :mode "\\.ts\\'"
  716. :config
  717. (setq typescript-indent-level 2))
  718. (use-package racket-mode
  719. :mode "\\.scm\\'"
  720. :config
  721. ;; C-w prefix in racket-REPL
  722. (add-hook 'racket-repl-mode-hook 'racket-repl-evil-hook)
  723. (defun racket-repl-evil-hook ()
  724. (define-key racket-repl-mode-map "\C-w" 'evil-window-map)
  725. (global-set-key (kbd "C-w") 'racket-repl-mode-map)))
  726. (use-package haskell-mode
  727. :ensure t
  728. :init
  729. (add-hook 'haskell-mode-hook 'haskell-indentation-mode))
  730. (use-package intero
  731. :commands intero-mode
  732. :init
  733. (add-hook 'haskell-mode-hook 'intero-mode)
  734. :config
  735. (bind-map
  736. my-haskell-map
  737. :keys ("M-m")
  738. :evil-keys ("SPC")
  739. :major-modes (haskell-mode)
  740. :bindings
  741. ("l" 'intero-repl-load
  742. "r" 'intero-repl)))
  743. (use-package emojify
  744. :defer t
  745. :config
  746. (add-hook 'after-init-hook #'global-emojify-mode))
  747. (use-package latex-preview-pane
  748. :commands latex-preview-pane-mode)
  749. (use-package slime
  750. :after bind-key
  751. :commands slime slime-mode
  752. :init
  753. (setq auto-mode-alist (cons '("\\.cl$" . common-lisp-mode) auto-mode-alist))
  754. (add-hook 'lisp-mode-hook 'slime-mode)
  755. :config
  756. (setq inferior-lisp-program "sbcl")
  757. (slime-setup)
  758. (defun evil-slime-eval-last-expression ()
  759. (interactive)
  760. (evil-append 1)
  761. (slime-eval-last-expression)
  762. (evil-normal-state))
  763. (bind-map
  764. my-slime-map
  765. :keys ("M-m")
  766. :evil-keys ("SPC")
  767. :major-modes (lisp-mode)
  768. :bindings
  769. ("el" 'evil-slime-eval-last-expression
  770. "er" 'slime-eval-region
  771. "eb" 'slime-compile-and-load-file)))
  772. (use-package slime-company
  773. :defer t
  774. :after slime)
  775. (use-package auctex
  776. :defer t)
  777. (use-package atomic-chrome
  778. :defer t
  779. :config
  780. (atomic-chrome-start-server))
  781. (use-package elpy
  782. :defer t
  783. :init
  784. (add-hook 'python-mode-hook 'elpy-enable))
  785. (use-package jedi
  786. ;; Must run `pip3 install --user jedi flake8 autopep8 virtualenv epc`
  787. :defer t
  788. :init
  789. (add-hook 'python-mode-hook 'jedi:setup))
  790. (use-package company-jedi
  791. :after (company python-mode)
  792. :config (add-to-list 'company-backends 'company-jedi))
  793. (use-package py-autopep8
  794. :defer t
  795. :config
  796. (add-hook 'elpy-mode-hook 'py-autopep8-enable-on-save))
  797. (use-package rust-mode
  798. :defer t)
  799. (use-package flycheck-rust
  800. :defer t
  801. :after rust-mode
  802. :init
  803. (with-eval-after-load 'rust-mode
  804. (add-hook 'flycheck-mode-hook #'flycheck-rust-setup)))
  805. ;; List of optional packages
  806. (defvar optional-packages
  807. '(
  808. flymd
  809. web-mode
  810. tide
  811. racket-mode
  812. intero
  813. emojify
  814. latex-preview-pane
  815. slime
  816. slime-company
  817. markdown-mode
  818. auctex
  819. company-auctex
  820. atomic-chrome
  821. elpy
  822. jedi
  823. company-jedi
  824. py-autopep8
  825. flymake-php
  826. ))
  827. (defvar packages-installed-this-session nil)
  828. (defun ensure-package-installed (prompt package)
  829. "Ensure a package is installed, and (optionally) ask if it isn't."
  830. (if (not (package-installed-p package))
  831. (if (or prompt (y-or-n-p (format "Package %s is missing. Install it? " package)))
  832. ;; If this is the 1st install this session, update before install
  833. (cond ((not packages-installed-this-session)
  834. (package-refresh-contents)
  835. (setq packages-installed-this-session t)
  836. (package-install package))
  837. (t (package-install package))
  838. nil)
  839. package)))
  840. (defun optional-packages-install ()
  841. "Ask to install any optional packages."
  842. (interactive)
  843. (mapcar (lambda (package) (ensure-package-installed nil package)) optional-packages))
  844. ;;;; Builtin configs
  845. (defvar gdb-many-windows t)
  846. (setq tramp-syntax (quote default))
  847. (use-package flymake
  848. :config
  849. (use-package flymake-php
  850. :ensure t
  851. :init
  852. (add-hook 'php-mode-hook 'flymake-php-load)))
  853. (setq prolog-program-name "swipl")
  854. (add-to-list 'auto-mode-alist '("\\.pl\\'" . prolog-mode))
  855. (bind-map
  856. my-prolog-map
  857. :keys ("M-m")
  858. :evil-keys ("SPC")
  859. :major-modes (prolog-mode)
  860. :bindings
  861. ("l" 'prolog-consult-buffer))
  862. (use-package doc-view
  863. :defer t
  864. :config
  865. (evil-define-key 'motion doc-view-mode-map
  866. (kbd "k") 'doc-view-previous-line-or-previous-page
  867. (kbd "j") 'doc-view-next-line-or-next-page
  868. (kbd "C-b") 'doc-view-previous-page
  869. (kbd "C-f") 'doc-view-next-page)
  870. )
  871. (use-package flyspell
  872. :commands flyspell-goto-previous-error flyspell-goto-next-error flyspell-toggle-correct-mode
  873. :config
  874. ;; move point to previous error
  875. ;; based on code by hatschipuh at
  876. ;; http://emacs.stackexchange.com/a/14912/2017
  877. (defun flyspell-goto-previous-error (arg)
  878. "Go to arg previous spelling error."
  879. (interactive "p")
  880. (while (not (= 0 arg))
  881. (let ((pos (point))
  882. (min (point-min)))
  883. (if (and (eq (current-buffer) flyspell-old-buffer-error)
  884. (eq pos flyspell-old-pos-error))
  885. (progn
  886. (if (= flyspell-old-pos-error min)
  887. ;; goto beginning of buffer
  888. (progn
  889. (message "Restarting from end of buffer")
  890. (goto-char (point-max)))
  891. (backward-word 1))
  892. (setq pos (point))))
  893. ;; seek the next error
  894. (while (and (> pos min)
  895. (let ((ovs (overlays-at pos))
  896. (r '()))
  897. (while (and (not r) (consp ovs))
  898. (if (flyspell-overlay-p (car ovs))
  899. (setq r t)
  900. (setq ovs (cdr ovs))))
  901. (not r)))
  902. (backward-word 1)
  903. (setq pos (point)))
  904. ;; save the current location for next invocation
  905. (setq arg (1- arg))
  906. (setq flyspell-old-pos-error pos)
  907. (setq flyspell-old-buffer-error (current-buffer))
  908. (goto-char pos)
  909. (if (= pos min)
  910. (progn
  911. (message "No more miss-spelled word!")
  912. (setq arg 0))))))
  913. (defun flyspell-toggle-correct-mode ()
  914. "Decide whether to use flyspell-mode or flyspell-prog-mode, then properly toggle."
  915. (interactive)
  916. ;; use flyspell-mode when in text buffers
  917. ;; otherwise use flyspell-prog-mode
  918. (let* ((current-mode
  919. (buffer-local-value 'major-mode (current-buffer)))
  920. (flyspell-mode-to-call
  921. (if (or (string= current-mode "text-mode") (string= current-mode "markdown-mode"))
  922. 'flyspell-mode
  923. 'flyspell-prog-mode)))
  924. ;; toggle the current flyspell mode, and
  925. ;; eval the buffer if we turned it on
  926. (if flyspell-mode
  927. (funcall 'flyspell-mode '0)
  928. (funcall flyspell-mode-to-call)
  929. (flyspell-buffer))))
  930. (add-hook 'text-mode-hook 'flyspell-mode)
  931. (add-hook 'prog-mode-hook 'flyspell-prog-mode))
  932. (use-package hideshow
  933. :config
  934. (add-hook 'prog-mode-hook
  935. 'hs-minor-mode)
  936. (add-hook 'hs-minor-mode-hook
  937. (lambda ()
  938. (diminish 'hs-minor-mode))))
  939. (use-package recentf
  940. :config
  941. (recentf-mode 1)
  942. (setq recentf-max-saved-items 200
  943. recentf-max-menu-items 15)
  944. (add-to-list 'recentf-exclude ".*.emacs\\.d/elpa.*"))
  945. (use-package dired
  946. :config
  947. (evil-define-key 'normal dired-mode-map (kbd "SPC") nil))
  948. (provide 'packages)