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.

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