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.

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