My attempt to optimize my emacs load time <1 second
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.

500 lines
15 KiB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
  1. ;;; custom-packages --- Provide all the use-package declarations
  2. ;;; Commentary:
  3. ;;
  4. ;; See https://github.com/jwiegley/use-package for help
  5. ;; USE PACKAGE help
  6. ;; (use-package package-here
  7. ;; :commands (cmd cmd-all cmd-etc) ;; List commands used to ":defer" the package
  8. ;; :bind-keymap
  9. ;; ("M-q" . package-here-keymap) ;; Setup an entire keymap using Prefix "M-q"
  10. ;; :bind
  11. ;; (("M-s" . cmd) ;; Available Globally
  12. ;; :map here-mode-map
  13. ;; ("C-t" . cmd-all) ;; Available only in "here-mode"
  14. ;; ("C-e" . cmd-etc)) ;; Available only in "here-mode"
  15. ;; :init
  16. ;; (setq stuff t) ;; declar vars etc...
  17. ;; :config
  18. ;; (here-mode 1) ;; eval stuff here after the init
  19. ;;
  20. ;; (use-package ruby-mode
  21. ;; :mode "\\.rb\\'"
  22. ;; :interpreter "ruby"
  23. ;;
  24. ;; ;; OR when the package name isn't the same as the =mode=
  25. ;; (use-package python
  26. ;; :mode ("\\.py\\'" . python-mode)
  27. ;; :interpreter ("python" . python-mode))
  28. ;;
  29. ;; USE ":defer" when you aren't using either :commands, :bind, :bind*, :bind-keymap, :bind-keymap*, :mode, :interpreter, or :hook
  30. ;; (use-package deferred-package
  31. ;; :defer t)
  32. ;;; Code:
  33. ;; https://github.com/jwiegley/use-package/blob/master/bind-key.el
  34. (use-package bind-key
  35. :ensure t
  36. :bind
  37. ("C-<tab>" . leo/tidy)
  38. ("C-;" . leo/comment-or-uncomment-region-or-line)
  39. ("C-c e" . leo/find-user-init-file)
  40. ("M-q" . leo/kill-this-buffer-unless-scratch)
  41. ("C-c d" . leo/duplicate-thing)
  42. ("M-n" . leo/jump-to-next-symbol)
  43. ("M-p" . leo/jump-to-prev-symbol)
  44. ("M-u" . upcase-dwim)
  45. ("M-c" . capitalize-dwim)
  46. ("M-l" . downcase-dwim)
  47. )
  48. ;; https://github.com/myrjola/diminish.el
  49. (use-package diminish
  50. :ensure t
  51. :demand t)
  52. ;; https://github.com/winterTTr/ace-jump-mode
  53. (use-package ace-jump-mode
  54. :bind
  55. (("C-c SPC" . just-one-space)
  56. ("M-SPC" . ace-jump-mode)))
  57. ;; https://github.com/abo-abo/ace-window
  58. (use-package ace-window
  59. :ensure t
  60. :bind
  61. ([remap other-window] . ace-window)
  62. :init
  63. (setq aw-keys '(?a ?s ?h ?t ?g ?y ?n ?e ?o ?i)))
  64. ;; https://github.com/hlissner/emacs-doom-themes
  65. (use-package doom-themes
  66. :ensure t
  67. :config
  68. (load-theme 'doom-one t))
  69. ;; https://github.com/belak/base16-emacs
  70. (use-package base16-theme
  71. :disabled
  72. :ensure t
  73. :config
  74. (load-theme 'base16-onedark t))
  75. ;; https://github.com/Malabarba/beacon
  76. (use-package beacon
  77. :ensure t
  78. :commands beacon-mode
  79. :demand t
  80. :init
  81. (setq beacon-size 30
  82. beacon-color "#5B6268"
  83. beacon-blink-delay 0.2
  84. beacon-blink-duration 0.5
  85. beacon-blink-when-focused t)
  86. (beacon-mode 1))
  87. ;; https://github.com/iqbalansari/emacs-emojify
  88. (use-package emojify
  89. :ensure t
  90. :defer 15
  91. :config
  92. (global-emojify-mode 1))
  93. ;; https://github.com/hrs/engine-mode
  94. (use-package engine-mode
  95. :ensure t
  96. :defer 5
  97. :commands (engine/get-query engine/execute-search)
  98. :config
  99. (defengine google "https://www.google.com/search?q=%s"
  100. :keybinding "g")
  101. (defengine duckduckgo "https://duckduckgo.com/?q=%s"
  102. :keybinding "d")
  103. (engine-mode 1))
  104. ;; https://github.com/coldnew/linum-relative
  105. (use-package linum-relative
  106. :ensure t
  107. :config
  108. (linum-relative-mode))
  109. ;; https://github.com/Fanael/rainbow-delimiters
  110. (use-package rainbow-delimiters
  111. :ensure t
  112. :hook (prog-mode . rainbow-delimiters-mode))
  113. ;; M-x all-the-icons-install-fonts
  114. (use-package all-the-icons
  115. :ensure t)
  116. ;; https://github.com/tarsius/minions
  117. (use-package minions
  118. :ensure t
  119. :config
  120. (minions-mode 1))
  121. (use-package doom-modeline
  122. :ensure t
  123. :after (all-the-icons minions)
  124. :hook (after-init . doom-modeline-mode)
  125. :commands (doom-modeline-def-modeline doom-modeline-set-modeline)
  126. :init
  127. (setq doom-modeline-height 40)
  128. (setq doom-modeline-bar-width 6)
  129. (setq doom-modeline-checker-simple-format nil)
  130. (setq doom-modeline-minor-modes (featurep 'minions))
  131. :config
  132. (doom-modeline-def-modeline 'leo/custom-modeline
  133. '(bar matches buffer-info remote-host buffer-position parrot selection-info)
  134. '(misc-info minor-modes input-method buffer-encoding major-mode process vcs checker " "))
  135. (defun leo/setup-custom-doom-modeline ()
  136. (doom-modeline-set-modeline 'leo/custom-modeline 'default))
  137. (add-hook 'doom-modeline-mode-hook 'leo/setup-custom-doom-modeline)
  138. )
  139. (use-package dashboard
  140. :ensure t
  141. :preface
  142. (defvar show-week-agenda-p)
  143. :init
  144. (setq dashboard-items '((recents . 6)
  145. (bookmarks . 5)
  146. ;; (projects . 5)
  147. (agenda . 5)))
  148. (setq dashboard-center-content t)
  149. (setq dashboard-banner-logo-title "Let's begin...")
  150. (setq dashboard-startup-banner 1)
  151. (setq dashboard-show-shortcuts t)
  152. (setq show-week-agenda-p t)
  153. (setq dashboard-org-agenda-categories '("work" "tasks"))
  154. :config
  155. (dashboard-setup-startup-hook))
  156. (use-package helm
  157. :ensure t
  158. :commands (helm-M-x helm-buffers-list helm-find-files helm-candidate-number-at-point)
  159. :demand t
  160. :bind
  161. ("M-x" . helm-M-x)
  162. ("C-c b" . helm-buffers-list)
  163. ("C-x C-f" . helm-find-files)
  164. :config
  165. (declare-function helm-candidate-number-at-point "helm.el")
  166. )
  167. ;; https://github.com/emacsorphanage/helm-swoop
  168. (use-package helm-swoop
  169. :ensure t
  170. :after (helm)
  171. :bind
  172. ("C-s" . helm-swoop)
  173. :config
  174. ;; If you prefer fuzzy matching
  175. (setq helm-swoop-use-fuzzy-match t))
  176. ;; https://github.com/syohex/emacs-helm-ag
  177. (use-package helm-ag
  178. :ensure t
  179. :after (helm)
  180. :bind
  181. ("C-c k" . helm-ag))
  182. ;; https://github.com/magnars/expand-region.el
  183. (use-package expand-region
  184. :ensure t
  185. :bind
  186. ("C-@" . er/expand-region)
  187. ("C-#" . er/contract-region))
  188. ;; https://github.com/magnars/multiple-cursors.el
  189. (use-package multiple-cursors
  190. :ensure t
  191. :bind
  192. ("C-}" . mc/mark-next-like-this)
  193. ("C-)" . mc/unmark-next-like-this)
  194. ("C-{" . mc/mark-previous-like-this)
  195. ("C-(" . mc/unmark-previous-like-this))
  196. ;; https://github.com/joodland/bm
  197. (use-package bm
  198. :ensure t
  199. :demand t
  200. :bind (("C-x b b" . bm-toggle)
  201. ("C-x b n" . bm-next)
  202. ("C-x b p" . bm-previous))
  203. :commands (bm-repository-load
  204. bm-repository-save
  205. bm-buffer-save
  206. bm-buffer-save-all
  207. bm-buffer-restore)
  208. :preface
  209. (setq left-fringe-width 6)
  210. (setq right-fringe-width 0)
  211. (defface bm-face '((t nil)) "Specify face used to highlight the current line" :group 'bm)
  212. (defface bm-fringe-face '((t (:background "DarkOrange1" :foreground "DarkOrange1"))) "Specify face used to highlight the fringe" :group 'bm)
  213. (defface bm-fringe-persistent-face '((t (:background "DarkOrange1" :foreground "DarkOrange1"))) "Specify face used to highlight the fringe for persistant bookmarks" :group 'bm)
  214. (defface bm-persistent-face '((t nil)) "Specify face used to highlight the current line for persistant bookmarks" :group 'bm)
  215. (defface fringe '((t nil)) "Specify face used for the fringe" :group 'basic-faces :group 'frames)
  216. :init
  217. (setq bm-restore-repository-on-load t)
  218. :config
  219. (setq bm-cycle-all-buffers t)
  220. (setq bm-repository-file (concat user-emacs-directory "bookmark-repo"))
  221. (setq-default bm-buffer-persistence t)
  222. (setq bm-highlight-style 'bm-highlight-only-fringe)
  223. (add-hook 'after-init-hook 'bm-repository-load)
  224. (add-hook 'find-file-hooks 'bm-buffer-restore)
  225. (add-hook 'after-revert-hook #'bm-buffer-restore)
  226. (add-hook 'kill-buffer-hook #'bm-buffer-save)
  227. (add-hook 'after-save-hook #'bm-buffer-save)
  228. (add-hook 'vc-before-checkin-hook #'bm-buffer-save)
  229. (add-hook 'kill-emacs-hook #'(lambda nil
  230. (bm-buffer-save-all)
  231. (bm-repository-save))))
  232. ;; link
  233. (use-package elfeed
  234. :ensure t
  235. :commands (elfeed)
  236. :bind ("C-x C-l e" . elfeed)
  237. :init
  238. (setq elfeed-feeds
  239. '(
  240. ("http://telescoper.wordpress.com/feed/" daily)
  241. ("http://xkcd.com/rss.xml" daily)
  242. ("http://timharford.com/feed/" daily)
  243. ("http://understandinguncertainty.org/rss.xml" daily)
  244. ("http://pragmaticemacs.com/feed/" emacs)
  245. ("http://www.reddit.com/r/emacs/.rss" emacs)
  246. ("http://planet.emacsen.org/atom.xml" emacs)
  247. ("http://feeds.feedburner.com/XahsEmacsBlog" emacs)
  248. ("http://emacs.stackexchange.com/feeds" emacs)
  249. )))
  250. ;; https://github.com/rmuslimov/browse-at-remote
  251. (use-package browse-at-remote
  252. :bind ("C-c B" . browse-at-remote))
  253. ;; https://github.com/justbur/emacs-which-key
  254. (use-package which-key
  255. :ensure t
  256. :config
  257. (which-key-setup-minibuffer)
  258. (which-key-mode))
  259. ;; https://github.com/lewang/fic-mode
  260. (use-package fic-mode
  261. :ensure t
  262. :hook prog-mode
  263. :init
  264. (defface fic-face '((t :foreground "red" :weight bold)) "Specify face used for fic-mode highlighting" :group 'basic-faces)
  265. (defface fic-author-face '((t :foreground "red" :underline t)) "Specify face used for fic-mode highlighting" :group 'basic-faces)
  266. )
  267. ;; https://github.com/joaotavora/yasnippet
  268. (use-package yasnippet
  269. :ensure t
  270. :commands (yas-reload-all)
  271. :hook (prog-mode . yas-minor-mode)
  272. :init
  273. (setq yas-snippet-dirs (list (concat user-emacs-directory "snippets")))
  274. :config
  275. (yas-reload-all))
  276. ;; https://company-mode.github.io/
  277. (use-package company
  278. :ensure t
  279. :defer 5
  280. :commands (company-mode)
  281. :hook (prog-mode . company-mode))
  282. ;; https://github.com/pashky/restclient.el
  283. (use-package restclient
  284. :ensure t
  285. :mode ("\\.rest\\'" . restclient-mode))
  286. ;; https://github.com/iquiw/company-restclient
  287. (use-package company-restclient
  288. :ensure t
  289. :after (company restclient))
  290. ;; https://github.com/magit/magit
  291. (use-package magit
  292. :commands magit-status
  293. :ensure t
  294. :init
  295. (setq magit-completing-read-function 'helm-completing-read-default-handler)
  296. :bind
  297. ("C-x g" . magit-status)
  298. ("C-c g" . magit-status))
  299. ;; https://github.com/bbatsov/projectile
  300. (use-package projectile
  301. :ensure t
  302. :bind-keymap
  303. ("C-c p" . projectile-command-map)
  304. )
  305. ;; https://github.com/magit/git-modes
  306. (use-package gitignore-mode
  307. :ensure t)
  308. ;; https://github.com/magit/git-modes
  309. (use-package gitconfig-mode
  310. :ensure t)
  311. ;; http://web-mode.org/
  312. (use-package web-mode
  313. :ensure t
  314. :mode "\\.html?\\'")
  315. ;; https://github.com/joshwnj/json-mode
  316. (use-package json-mode
  317. :ensure t
  318. :mode "\\.json\\'")
  319. ;; https://github.com/antonj/scss-mode
  320. (use-package scss-mode
  321. :ensure t
  322. :mode ("\\.s?css\\'" . scss-mode))
  323. ;; https://elpa.gnu.org/packages/csv-mode.html
  324. (use-package csv-mode
  325. :disabled
  326. :ensure t
  327. :mode ("\\.csv\\'" . csv-mode))
  328. ;; https://github.com/kwrooijen/cargo.el
  329. (use-package cargo
  330. :hook (rust-mode . cargo-minor-mode))
  331. ;; https://github.com/andre-r/centered-cursor-mode.el
  332. (use-package centered-cursor-mode
  333. :disabled
  334. :commands centered-cursor-mode
  335. :hook prog-mode)
  336. ;; https://github.com/flycheck/flycheck
  337. (use-package flycheck
  338. :ensure t
  339. :preface
  340. (defvar flycheck-emacs-lisp-load-path)
  341. :init
  342. (setq flycheck-emacs-lisp-load-path 'inherit)
  343. (global-flycheck-mode))
  344. ;; https://orgmode.org/elpa.html
  345. (use-package org
  346. :commands (org-cycle-agenda-files org-capture)
  347. :ensure org-plus-contrib
  348. :mode ("\\.org\\'" . org-mode)
  349. :bind (
  350. ("C-," . org-cycle-agenda-files)
  351. ("C-c C-d" . org-capture)
  352. :map org-mode-map
  353. ("M-RET" . org-insert-todo-heading)
  354. )
  355. :preface
  356. (defvar org-html-validation-link)
  357. (defvar org-html-text-markup-alist)
  358. :init
  359. (setq org-agenda-files '("~/Dropbox/Org/todo.org"
  360. "~/Dropbox/Org/archive.org"
  361. "~/Dropbox/Org/diary/eaglecrk.org"))
  362. (setq org-todo-keywords '((sequence "TODO(t)" "|" "DONE(d)")
  363. (sequence "BUG(b)" "INPROGRESS(i)" "|" "FIXED(f)")
  364. (sequence "TEST(T)" "NOTEST(N)" "|" "COMPLETE(C)")
  365. (sequence "|" "CANCELED(c)")
  366. (sequence "|" "NEEDCLARIFICATION(n)")
  367. (sequence "|" "PROVIDEUPDATE(p)")
  368. (sequence "|" "WAITING(w)"))
  369. org-refile-targets '((nil :maxlevel . 3)
  370. (org-agenda-files :maxlevel . 3))
  371. org-directory "~/Dropbox/Org"
  372. org-default-notes-file (concat org-directory "/todo.org")
  373. org-startup-folded t
  374. org-startup-indented t
  375. org-startup-align-all-tables t
  376. org-startup-with-inline-images t
  377. org-startup-with-latex-preview t
  378. org-src-tab-acts-natively t
  379. org-confirm-babel-evaluate nil
  380. org-log-done t
  381. org-log-done-with-time t
  382. org-log-into-drawer t
  383. org-hide-leading-stars t
  384. org-pretty-entities t
  385. org-use-property-inheritance t
  386. org-html-validation-link nil
  387. org-html-text-markup-alist '((bold . "<b>%s</b>")
  388. (code . "<code>%s</code>")
  389. (italic . "<i>%s</i>")
  390. (strike-through . "<del>%s</del>")
  391. (underline . "<span class=\"underline\">%s</span>")
  392. (verbatim . "<code class=\"verbatim\">%s</code>"))
  393. )
  394. :config
  395. (org-babel-do-load-languages 'org-babel-load-languages '((js . t)
  396. (shell . t)
  397. (emacs-lisp . t)))
  398. (add-to-list 'org-structure-template-alist
  399. (list "e" (concat "#+BEGIN_SRC emacs-lisp :results silent\n"
  400. "\n"
  401. "#+END_SRC")))
  402. (add-to-list 'org-structure-template-alist
  403. (list "j" (concat "#+BEGIN_SRC js :cmd \"/usr/local/bin/babel-node\" :results output code\n"
  404. "\n"
  405. "#+END_SRC")))
  406. (add-to-list 'org-structure-template-alist
  407. (list "r" (concat "#+BEGIN_SRC restclient :results raw\n"
  408. "\n"
  409. "#+END_SRC")))
  410. )
  411. ;; https://github.com/sabof/org-bullets
  412. (use-package org-bullets
  413. :ensure t
  414. :after (org)
  415. :hook (org-mode . org-bullets-mode)
  416. :config
  417. (set-face-attribute 'org-level-1 nil :height 1.3)
  418. (set-face-attribute 'org-level-2 nil :height 1.1)
  419. (set-face-attribute 'org-level-3 nil :height 1.05)
  420. (set-face-attribute 'org-level-4 nil :height 1.05)
  421. (set-face-attribute 'org-scheduled-today nil :height 1.0)
  422. (set-face-attribute 'org-agenda-date-today nil :height 1.1))
  423. ;; https://orgmode.org/worg/org-contrib/org-protocol.html
  424. (use-package org-protocol
  425. :ensure org-plus-contrib
  426. :after (org)
  427. :preface
  428. (defvar org-capture-templates)
  429. :init
  430. (setq org-capture-templates
  431. '(("t" "new task" entry (file+headline "~/Dropbox/Org/todo.org" "Tasks")
  432. "* TODO [#A] %?\nSCHEDULED: %(org-insert-time-stamp (org-read-date nil t \"+0d\"))\n%a\n")
  433. ("n" "new note" entry (file+headline org-default-notes-file "Notes")
  434. "* %?\n%i\n")
  435. ("l" "store link" entry (file+olp org-default-notes-file "Links" "Unfiled")
  436. "* %a\n%?\n")
  437. ("d" "store link w/drawer" entry (file+olp org-default-notes-file "Links" "Unfiled")
  438. "* %?\n%l\n:COPIED_TEXT:\n %i\n:END:\n")
  439. ("f" "dotfile" entry (file+headline "~/Dropbox/Org/dotfiles.org" "Other")
  440. "* %?\n:PROPERTIES:\n:CUSTOM_ID: %(org-id-get-create)\n:END:\n")
  441. ))
  442. )
  443. ;; https://github.com/seanohalpin/org-link-minor-mode
  444. (use-package org-link-minor-mode
  445. :ensure t
  446. :defer t
  447. :commands (org-link-minor-mode))
  448. (provide 'custom-packages)
  449. ;;; custom-packages.el ends here