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.

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