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.

586 lines
18 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
5 years ago
5 years ago
  1. ;;; 08-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. (use-package use-package-ensure-system-package
  34. :defer t)
  35. (use-package ag
  36. :commands ag)
  37. ;; https://melpa.org/#/async
  38. (use-package async
  39. :commands (async-start async-start-process))
  40. ;; https://github.com/myrjola/diminish.el
  41. (use-package diminish
  42. :demand t)
  43. ;; https://elpa.gnu.org/packages/delight.html
  44. (use-package delight
  45. :demand t)
  46. ;; https://github.com/winterTTr/ace-jump-mode
  47. (use-package ace-jump-mode
  48. :bind
  49. (("C-c SPC" . just-one-space)
  50. ("M-SPC" . ace-jump-mode)))
  51. ;; https://github.com/NicolasPetton/zerodark-theme
  52. (use-package zerodark-theme
  53. :demand t
  54. :config
  55. (load-theme 'zerodark t)
  56. (zerodark-setup-modeline-format))
  57. ;; https://github.com/Malabarba/beacon
  58. (use-package beacon
  59. :commands beacon-mode
  60. :diminish
  61. :init
  62. (setq beacon-size 70
  63. beacon-color "#5B6268"
  64. beacon-blink-delay 0.1
  65. beacon-blink-duration 0.4
  66. beacon-blink-when-focused t)
  67. (beacon-mode 1))
  68. ;; https://github.com/iqbalansari/emacs-emojify
  69. (use-package emojify
  70. :defer 25
  71. :config
  72. (global-emojify-mode 1))
  73. ;; https://github.com/hrs/engine-mode
  74. (use-package engine-mode
  75. :commands (engine/get-query engine/execute-search)
  76. :config
  77. ;; C-x / to start
  78. (defengine google "https://www.google.com/search?q=%s"
  79. :keybinding "a")
  80. (defengine github "https://github.com/search?q=%s"
  81. :keybinding "g")
  82. (defengine vlocity "https://success.vlocity.com/s/searchunifylightning?searchString=%s"
  83. :keybinding "v")
  84. (defengine duckduckgo "https://duckduckgo.com/?q=%s"
  85. :keybinding "d")
  86. (defengine melpa "https://melpa.org/#/?q=%s"
  87. :keybinding "m")
  88. (engine-mode 1))
  89. ;; https://github.com/Fanael/rainbow-delimiters
  90. (use-package rainbow-delimiters
  91. :hook (prog-mode . rainbow-delimiters-mode))
  92. ;; rainbow-mode
  93. (use-package rainbow-mode
  94. :hook prog-mode)
  95. ;; M-x all-the-icons-install-fonts
  96. (use-package all-the-icons
  97. :demand t
  98. :config
  99. (setq inhibit-compacting-font-caches t))
  100. ;; https://github.com/emacs-dashboard/emacs-dashboard
  101. (use-package dashboard
  102. :demand t
  103. :preface
  104. (defvar show-week-agenda-p)
  105. :init
  106. (setq dashboard-items '((recents . 10)
  107. (bookmarks . 10)
  108. (projects . 5)
  109. (agenda . 5)))
  110. (setq dashboard-center-content t)
  111. (setq dashboard-banner-logo-title "Let's do this...")
  112. (setq dashboard-startup-banner 1)
  113. (setq dashboard-show-shortcuts t)
  114. (setq show-week-agenda-p t)
  115. (setq dashboard-org-agenda-categories '("work" "tasks"))
  116. :config
  117. (dashboard-setup-startup-hook))
  118. (use-package amx
  119. :commands amx-mode)
  120. ;; https://github.com/abo-abo/swiper
  121. (use-package counsel
  122. :bind
  123. ("M-x" . counsel-M-x)
  124. ("C-c k" . counsel-rg)
  125. ("C-x C-f" . counsel-find-file)
  126. ("C-x f" . counsel-recentf)
  127. ("C-x C-d" . counsel-dired)
  128. ("C-x p" . counsel-package)
  129. ("C-x b" . counsel-bookmark)
  130. ("C-x c" . counsel-colors-web)
  131. ("C-c C-d" . counsel-org-capture)
  132. ;; Describe Replacements
  133. ("C-h f" . counsel-describe-function)
  134. ("C-h v" . counsel-describe-variable)
  135. ("C-h b" . counsel-descbinds)
  136. ("M-y" . counsel-yank-pop)
  137. ;; Ivy
  138. ("C-c b" . ivy-switch-buffer)
  139. ("C-c c" . ivy-resume)
  140. ;; Swiper
  141. ("C-s" . swiper)
  142. :config
  143. (ivy-mode 1)
  144. (amx-mode 1)
  145. )
  146. ;; https://github.com/magnars/expand-region.el
  147. (use-package expand-region
  148. :bind
  149. ("C-@" . er/expand-region)
  150. ("C-#" . er/contract-region))
  151. ;; https://github.com/thanhvg/emacs-howdoyou
  152. (use-package howdoyou
  153. :bind
  154. ("C-c h q" . howdoyou-query)
  155. ("C-c h n" . howdoyou-next-link)
  156. ("C-c h p" . howdoyou-previous-link)
  157. ("C-c h f" . howdoyou-go-back-to-first-link)
  158. ("C-c h r" . howdoyou-reload-link))
  159. ;; https://github.com/magnars/multiple-cursors.el
  160. (use-package multiple-cursors
  161. :bind
  162. ("C-}" . mc/mark-next-like-this)
  163. ("C-)" . mc/unmark-next-like-this)
  164. ("C-{" . mc/mark-previous-like-this)
  165. ("C-(" . mc/unmark-previous-like-this))
  166. ;; https://github.com/skeeto/elfeed
  167. (use-package elfeed
  168. :bind
  169. (("C-x C-l e" . elfeed)
  170. :map elfeed-search-mode-map
  171. ("a" . (lambda () (interactive) (elfeed-search-set-filter "")))
  172. ("e" . (lambda () (interactive) (elfeed-search-set-filter "+emacs")))
  173. ("d" . (lambda () (interactive) (elfeed-search-set-filter "+daily")))
  174. ("x" . (lambda () (interactive) (elfeed-search-set-filter "xkcd"))))
  175. :init
  176. (setq elfeed-feeds
  177. '(
  178. ("http://telescoper.wordpress.com/feed/" daily)
  179. ("http://xkcd.com/rss.xml" daily)
  180. ("http://timharford.com/feed/" daily)
  181. ("http://understandinguncertainty.org/rss.xml" daily)
  182. ("http://pragmaticemacs.com/feed/" emacs)
  183. ("http://endlessparentheses.com/atom.xml" emacs)
  184. ("http://feeds.feedburner.com/XahsEmacsBlog" emacs)
  185. ("http://emacs.stackexchange.com/feeds" emacs)
  186. ("https://www.google.com/alerts/feeds/13353713273807811484/2710948715805064535" tesla)
  187. ("https://www.google.com/alerts/feeds/13353713273807811484/17638090915837343269" pixel4)
  188. ("https://www.google.com/alerts/feeds/13353713273807811484/14416938028701328804" stadia)
  189. ))
  190. :config
  191. (elfeed-update))
  192. ;; https://github.com/rmuslimov/browse-at-remote
  193. (use-package browse-at-remote
  194. :bind ("C-c B" . browse-at-remote))
  195. ;; https://github.com/justbur/emacs-which-key
  196. (use-package which-key
  197. :diminish
  198. :defer 5
  199. :config
  200. (which-key-setup-minibuffer)
  201. (which-key-mode))
  202. ;; https://github.com/lewang/fic-mode
  203. (use-package fic-mode
  204. :hook (prog-mode js-mode javascript-mode)
  205. :custom-face
  206. (fic-face ((t :foreground "red" :weight bold)))
  207. (fic-author-face ((t :foreground "red" :underline t))))
  208. ;; https://github.com/joaotavora/yasnippet
  209. (use-package yasnippet
  210. :commands yas-reload-all
  211. :hook (prog-mode . yas-minor-mode)
  212. :init
  213. (setq yas-snippet-dirs (list (concat user-emacs-directory "snippets")))
  214. :config
  215. (yas-reload-all))
  216. ;; https://company-mode.github.io/
  217. (use-package company
  218. :defer 25
  219. :commands company-mode
  220. :hook (prog-mode . company-mode)
  221. :bind
  222. (:map company-active-map
  223. ("M-n" . nil)
  224. ("M-p" . nil)
  225. ("C-n" . company-select-next)
  226. ("C-p" . company-select-previous))
  227. :config
  228. (setq company-idle-delay 0.1)
  229. (setq company-minimum-prefix-length 3)
  230. (setq company-dabbrev-downcase nil))
  231. ;; https://github.com/pashky/restclient.el
  232. (use-package restclient
  233. :mode ("\\.rest\\'" . restclient-mode))
  234. ;; https://github.com/iquiw/company-restclient
  235. (use-package company-restclient
  236. :after (company restclient))
  237. ;; https://github.com/magit/magit
  238. (use-package magit
  239. :bind
  240. ("C-x g" . magit-status)
  241. ("C-c g" . magit-status))
  242. ;; This is used in `rg-menu'
  243. (use-package rg
  244. :defer t)
  245. ;; This is used in `projectile'
  246. (use-package ripgrep
  247. :commands rg-project)
  248. ;; https://github.com/bbatsov/projectile
  249. (use-package projectile
  250. :delight '(:eval (concat " [" (projectile-project-name) "]"))
  251. :bind (
  252. ("C-c p" . projectile-command-map)
  253. :map projectile-command-map
  254. ("s r" . rg-project)
  255. )
  256. :init
  257. (setq projectile-completion-system 'ivy)
  258. :config
  259. (projectile-mode 1))
  260. ;; https://github.com/magit/git-modes
  261. (use-package gitignore-mode
  262. :mode ("\\.gitignore\\'"))
  263. ;; https://github.com/magit/git-modes
  264. (use-package gitconfig-mode
  265. :mode ("\\.gitconfig\\'"))
  266. ;; http://web-mode.org/
  267. (use-package web-mode
  268. :hook (html-mode xml-mode))
  269. ;; https://github.com/smihica/emmet-mode
  270. (use-package emmet-mode
  271. :hook (html-mode web-mode css-mode))
  272. (use-package dash-at-point
  273. :if (eq system-type 'darwin)
  274. :ensure-system-package
  275. ("/Applications/Dash.app" . "brew cask install dash"))
  276. ;; https://github.com/joshwnj/json-mode
  277. (use-package json-mode
  278. :mode "\\.json\\'")
  279. ;; https://github.com/mojochao/npm-mode
  280. ;; Disabled in favor of just running npm commands in comint buffer via
  281. ;; (leo/exec-process "npm run start" "npm-start" t)
  282. (use-package npm-mode
  283. :disabled
  284. :defer 10
  285. :custom
  286. (npm-mode-command-prefix "C-c r"))
  287. ;; https://github.com/antonj/scss-mode
  288. (use-package scss-mode
  289. :mode ("\\.s?css\\'" . scss-mode))
  290. ;; https://github.com/yoshiki/yaml-mode
  291. (use-package yaml-mode
  292. :mode ("\\.ya?ml\\'" . yaml-mode))
  293. ;; https://github.com/kwrooijen/cargo.el
  294. (use-package cargo
  295. :hook (rust-mode . cargo-minor-mode))
  296. ;; https://github.com/flycheck/flycheck
  297. (use-package flycheck
  298. :diminish
  299. :preface
  300. (defvar flycheck-emacs-lisp-load-path)
  301. :init
  302. (setq flycheck-emacs-lisp-load-path 'inherit)
  303. (global-flycheck-mode))
  304. ;; https://orgmode.org/elpa.html
  305. (use-package org
  306. :commands org-capture
  307. :ensure org-plus-contrib
  308. :mode ("\\.org\\'" . org-mode)
  309. :bind (
  310. ("C-," . org-cycle-agenda-files)
  311. ("C-c C-d" . org-capture)
  312. ("C-x C-l a" . org-agenda)
  313. :map org-mode-map
  314. ("M-RET" . org-insert-todo-heading)
  315. ("M-n" . leo/org-narrow-next-tree)
  316. ("M-p" . leo/org-narrow-prev-tree)
  317. ("M-P" . leo/org-present)
  318. )
  319. :preface
  320. (defvar org-html-validation-link)
  321. (defvar org-html-text-markup-alist)
  322. (defvar org-capture-templates)
  323. :init
  324. (setq org-agenda-files '("~/Dropbox/Org/todo.org"
  325. ;; "~/Dropbox/Org/projects.org"
  326. "~/Dropbox/Org/archive.org"
  327. ;; "~/Dropbox/Org/diary/eaglecrk.org"
  328. ))
  329. (add-to-list 'safe-local-variable-values '(eval leo/deft-insert-boilerplate))
  330. (setq org-todo-keywords '((sequence "TODO(t)" "|" "DONE(d)")
  331. (sequence "BUG(b)" "INPROGRESS(i)" "|" "FIXED(f)")
  332. (sequence "TEST(T)" "NOTEST(N)" "|" "COMPLETE(C)")
  333. (sequence "|" "CANCELED(c)")
  334. (sequence "|" "NEEDCLARIFICATION(n)")
  335. (sequence "|" "PROVIDEUPDATE(p)")
  336. (sequence "|" "WAITING(w)"))
  337. org-refile-targets '((nil :maxlevel . 3)
  338. (org-agenda-files :maxlevel . 3))
  339. org-directory "~/Dropbox/Org"
  340. org-default-notes-file (concat org-directory "/todo.org")
  341. org-src-fontify-natively t
  342. org-startup-folded t
  343. org-startup-indented t
  344. org-startup-align-all-tables t
  345. org-startup-with-inline-images t
  346. org-startup-with-latex-preview t
  347. org-src-tab-acts-natively t
  348. org-confirm-babel-evaluate nil
  349. org-log-done t
  350. org-log-done-with-time t
  351. org-log-into-drawer t
  352. org-hide-leading-stars t
  353. org-pretty-entities t
  354. org-use-property-inheritance t
  355. org-html-validation-link nil
  356. org-html-text-markup-alist '((bold . "<b>%s</b>")
  357. (code . "<code>%s</code>")
  358. (italic . "<i>%s</i>")
  359. (strike-through . "<del>%s</del>")
  360. (underline . "<span class=\"underline\">%s</span>")
  361. (verbatim . "<code class=\"verbatim\">%s</code>"))
  362. )
  363. :config
  364. (defun org-src-disable-flycheck-doc ()
  365. "Disable flycheck comment doc string checking when (C-c ') ing a file."
  366. (interactive)
  367. (setq flycheck-disabled-checkers '(emacs-lisp-checkdoc)))
  368. (add-to-list 'org-src-mode-hook 'org-src-disable-flycheck-doc)
  369. (when (version<= "9.2" (org-version))
  370. (require 'org-tempo))
  371. (org-babel-do-load-languages 'org-babel-load-languages '((js . t)
  372. (shell . t)
  373. (restclient . t)
  374. (emacs-lisp . t)))
  375. (setq org-capture-templates
  376. '(("t" "new task" entry (file+headline "~/Dropbox/Org/todo.org" "Tasks")
  377. "* TODO [#A] %?\nSCHEDULED: %(org-insert-time-stamp (org-read-date nil t \"+0d\"))\n%a\n")
  378. ("n" "new note" entry (file+headline org-default-notes-file "Notes")
  379. "* %?\n%i\n")
  380. ("l" "store link" entry (file+olp org-default-notes-file "Links" "Unfiled")
  381. "* %a\n%?\n")
  382. ("d" "store link w/drawer" entry (file+olp org-default-notes-file "Links" "Unfiled")
  383. "* %?\n%l\n:COPIED_TEXT:\n %i\n:END:\n")
  384. ))
  385. (setq org-structure-template-alist
  386. '(("r" . "src restclient :results raw")
  387. ("j" . "src js :cmd \"/usr/local/bin/babel-node\" :results output code")
  388. ("e" . "src emacs-lisp :results silent")
  389. ("a" . "export ascii")
  390. ("c" . "center")
  391. ("C" . "comment")
  392. ("E" . "export")
  393. ("h" . "export html")
  394. ("l" . "export latex")
  395. ("q" . "quote")
  396. ("s" . "src")
  397. ("v" . "verse")))
  398. (defconst checkbox-fontlock-keywords-alist
  399. (mapcar (lambda (regex-char-pair)
  400. `(,(car regex-char-pair)
  401. (0 (prog1 ()
  402. (compose-region (match-beginning 1)
  403. (match-end 1)
  404. ,(concat (list ?\C-i)
  405. (list (decode-char 'ucs (cadr regex-char-pair)))))))))
  406. '(("\\(\\[ \\]\\)" #XF096);2B1C
  407. ("\\(\\[-\\]\\)" #XF147);29C7;F458
  408. ("\\(\\[X\\]\\)" #XF046);2BBD
  409. )))
  410. (defun add-checkbox-symbol-keywords ()
  411. "Add checkbox font to font-lock."
  412. (font-lock-add-keywords nil checkbox-fontlock-keywords-alist))
  413. (add-hook 'org-mode-hook 'add-checkbox-symbol-keywords)
  414. )
  415. (use-package ob-restclient
  416. :disabled
  417. :ensure t
  418. :config
  419. (setq org-babel-default-header-args:restclient
  420. `((:results . "output"))))
  421. ;; https://github.com/astahlman/ob-async
  422. ;; Run a begin_src block asynchronously via :async
  423. (use-package ob-async
  424. :disabled
  425. :ensure t
  426. :after org)
  427. ;; https://github.com/sabof/org-bullets
  428. (use-package org-bullets
  429. :hook (org-mode . org-bullets-mode)
  430. :config
  431. (setq org-bullets-bullet-list '( "" "" "" "" "" "" ""))
  432. (set-face-attribute 'org-level-1 nil :height 1.5)
  433. (set-face-attribute 'org-level-2 nil :height 1.0)
  434. (set-face-attribute 'org-level-3 nil :height 1.0)
  435. (set-face-attribute 'org-level-4 nil :height 1.0)
  436. (set-face-attribute 'org-level-5 nil :height 1.0)
  437. (set-face-attribute 'org-scheduled-today nil :height 2.0)
  438. (set-face-attribute 'org-agenda-date-today nil :height 2.0))
  439. ;; https://orgmode.org/worg/org-contrib/org-protocol.html
  440. (use-package org-protocol
  441. :ensure org-plus-contrib
  442. :after org)
  443. ;; https://github.com/marsmining/ox-twbs
  444. (use-package ox-twbs
  445. :defer 10
  446. :after org)
  447. (use-package ox-extra
  448. :defer 10
  449. :ensure org-plus-contrib
  450. :after org
  451. :config
  452. (ox-extras-activate '(ignore-headlines)))
  453. ;; https://github.com/yjwen/org-reveal
  454. (use-package ox-reveal
  455. :defer 10
  456. :after org)
  457. ;; https://github.com/jethrokuan/org-roam/
  458. (use-package org-roam
  459. :hook
  460. ((org-mode . org-roam-mode)
  461. (after-init . org-roam--build-cache-async) ;; optional!
  462. )
  463. :straight (:host github :repo "jethrokuan/org-roam" :branch "develop")
  464. :custom
  465. (org-roam-directory "~/Dropbox/Org/Roam/")
  466. :config
  467. (org-roam--build-cache-async)
  468. (setq org-roam-graphviz-executable "/usr/local/Cellar/graphviz/2.42.2/bin/dot")
  469. (setq org-roam-graph-viewer "/usr/bin/open")
  470. (setq org-roam-link-title-format "r::%s")
  471. :bind
  472. ("C-c n l" . org-roam)
  473. ("C-c n t" . org-roam-today)
  474. ("C-c n f" . org-roam-find-file)
  475. ("C-c n i" . org-roam-insert)
  476. ("C-c n g" . org-roam-show-graph))
  477. ;; https://github.com/jrblevin/deft
  478. (use-package deft
  479. :bind
  480. ("C-c n d" . deft)
  481. :custom
  482. (deft-recursive t)
  483. (deft-use-filter-string-for-filename t)
  484. (deft-default-extension "org")
  485. (deft-directory "~/Dropbox/Org/Roam/"))
  486. ;; https://github.com/hniksic/emacs-htmlize
  487. (use-package htmlize
  488. :defer 10
  489. :after org)
  490. ;; https://github.com/jwiegley/use-package/blob/master/bind-key.el
  491. (use-package bind-key
  492. :bind
  493. ("C-<tab>" . leo/tidy)
  494. ("C-;" . leo/comment-or-uncomment-region-or-line)
  495. ("C-c e" . leo/find-user-init-file)
  496. ("M-q" . leo/kill-this-buffer-unless-scratch)
  497. ("C-c d" . leo/duplicate-thing)
  498. ("M-n" . leo/jump-to-next-symbol)
  499. ("M-p" . leo/jump-to-prev-symbol)
  500. ("M-u" . upcase-dwim)
  501. ("M-c" . capitalize-dwim)
  502. ("M-l" . downcase-dwim))
  503. ;; https://github.com/nflath/sudo-edit
  504. (use-package sudo-edit
  505. :commands (sudo-edit))
  506. ;; https://www.emacswiki.org/emacs/ParEdit
  507. (use-package paredit
  508. :hook (
  509. (emacs-lisp-mode . enable-paredit-mode)
  510. (lisp-mode . enable-paredit-mode)
  511. (lisp-interaction-mode . enable-paredit-mode)
  512. (scheme-mode . enable-paredit-mode)
  513. (eval-expression-minibuffer-setup . enable-paredit-mode)
  514. )
  515. :config
  516. (unbind-key "M-q" paredit-mode-map))
  517. (provide '08-custom-packages)
  518. ;;; 08-custom-packages.el ends here