My personal configuration files for Doom emacs
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.

1124 lines
41 KiB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
  1. ;;; $DOOMDIR/config.el -*- lexical-binding: t; -*-
  2. ;; Place your private configuration here! Remember, you do not need to run 'doom
  3. ;; sync' after modifying this file!
  4. ;; Some functionality uses this to identify you, e.g. GPG configuration, email
  5. ;; clients, file templates and snippets.
  6. (setq user-full-name "Levi Olson"
  7. user-mail-address "olson.levi@gmail.com")
  8. ;; Doom exposes five (optional) variables for controlling fonts in Doom. Here
  9. ;; are the three important ones:
  10. ;;
  11. ;; + `doom-font'
  12. ;; + `doom-variable-pitch-font'
  13. ;; + `doom-big-font' -- used for `doom-big-font-mode'; use this for
  14. ;; presentations or streaming.
  15. ;;
  16. ;; They all accept either a font-spec, font string ("Input Mono-12"), or xlfd
  17. ;; font string. You generally only need these two:
  18. ;; (setq doom-font (font-spec :family "monospace" :size 12 :weight 'semi-light)
  19. ;; doom-variable-pitch-font (font-spec :family "sans" :size 13))
  20. (setq doom-font (font-spec :family "PragmataPro Liga" :size 18 :weight 'regular)
  21. doom-big-font (font-spec :family "PragmataPro Liga" :size 18 :weight 'regular)
  22. ;; doom-variable-pitch-font (font-spec :family "PragmataPro Liga" :size 20)
  23. doom-variable-pitch-font (font-spec :family "Overpass" :size 20 :weight 'thin)
  24. doom-unicode-font (font-spec :family "Fira Code" :size 15 :weight 'regular) ;;Fira Code
  25. doom-serif-font (font-spec :family "Baskerville" :size 20))
  26. ;; There are two ways to load a theme. Both assume the theme is installed and
  27. ;; available. You can either set `doom-theme' or manually load a theme with the
  28. ;; `load-theme' function. This is the default:
  29. (setq doom-theme 'doom-one) ;; doom-material is nice too
  30. ;; Light theme alternatives
  31. ;; doom-ayu-light
  32. ;; doom-acario-light
  33. ;; doom-earl-grey
  34. ;; doom-flatwhite
  35. ;; doom-one-light
  36. ;; doom-nord-light *
  37. ;; doom-opera-light
  38. ;; doom-solarized-light
  39. ;; doom-tomorrow-day *
  40. (remove-hook 'window-setup-hook #'doom-init-theme-h)
  41. (add-hook 'after-init-hook #'doom-init-theme-h 'append)
  42. (delq! t custom-theme-load-path)
  43. (setq doom-modeline-height 60)
  44. ;; If you use `org' and don't want your org files in the default location below,
  45. ;; change `org-directory'. It must be set before org loads!
  46. (setq org-directory "~/Nextcloud/Org")
  47. ;; Some nicer defaults
  48. (setq doom-fallback-buffer-name "*Doom*"
  49. +doom-dashboard-name "*Doom*")
  50. (map! :g "s-<right>" #'next-buffer
  51. :g "s-<left>" #'previous-buffer)
  52. ;; Enable tramp so we can use webdav to connect to nextcloud
  53. (use-package! tramp-gvfs
  54. :init
  55. (setq tramp-gvfs-enabled t)
  56. )
  57. ;; This determines the style of line numbers in effect. If set to `nil', line
  58. ;; numbers are disabled. For relative line numbers, set this to `relative'.
  59. (setq display-line-numbers-type t)
  60. (setq projectile-project-search-path "~/Projects")
  61. (require 's)
  62. (when (eq system-type 'gnu/linux)
  63. (when (s-contains? "microsoft" operating-system-release t) ;; TODO: maybe use variable system-configuration instead?
  64. (progn
  65. (setq org-directory "/mnt/c/Users/Levi/Nextcloud/Org")
  66. (add-to-list 'default-frame-alist '(top . 400))
  67. (add-to-list 'default-frame-alist '(left . 750))
  68. (add-to-list 'default-frame-alist '(height . 60))
  69. (add-to-list 'default-frame-alist '(width . 235))
  70. (setq browse-url-chrome-program "/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe")
  71. (setq browse-url-chromium-program "/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe")
  72. )))
  73. (when (eq system-type 'darwin)
  74. (progn
  75. (setq org-directory "/Users/Levi_Olson/Nextcloud/Org")
  76. (add-to-list 'default-frame-alist '(top . 0))
  77. (add-to-list 'default-frame-alist '(left . 0))
  78. (add-to-list 'default-frame-alist '(height . 49))
  79. (add-to-list 'default-frame-alist '(width . 178))
  80. (setq browse-url-chrome-program "/Applications/Safari.app")
  81. (setq browse-url-chromium-program "/Applications/Safari.app")
  82. ))
  83. ;; Here are some additional functions/macros that could help you configure Doom:
  84. ;;
  85. ;; - `load!' for loading external *.el files relative to this one
  86. ;; - `use-package!' for configuring packages
  87. ;; - `after!' for running code after a package has loaded
  88. ;; - `add-load-path!' for adding directories to the `load-path', relative to
  89. ;; this file. Emacs searches the `load-path' when you load packages with
  90. ;; `require' or `use-package'.
  91. ;; - `map!' for binding new keys
  92. ;;
  93. ;; To get information about any of these functions/macros, move the cursor over
  94. ;; the highlighted symbol at press 'K' (non-evil users must press 'C-c c k').
  95. ;; This will open documentation for it, including demos of how they are used.
  96. ;;
  97. ;; You can also try 'gd' (or 'C-c c d') to jump to their definition and see how
  98. ;; they are implemented.
  99. (unless (string-match-p "^Power N/A" (battery)) ; On laptops...
  100. (display-battery-mode 1))
  101. (display-time-mode 1)
  102. (global-subword-mode 1)
  103. (defvar mixed-pitch-modes '(org-mode LaTeX-mode markdown-mode gfm-mode Info-mode)
  104. "Modes that `mixed-pitch-mode' should be enabled in, but only after UI initialisation.")
  105. (defun init-mixed-pitch-h ()
  106. "Hook `mixed-pitch-mode' into each mode in `mixed-pitch-modes'.
  107. Also immediately enables `mixed-pitch-modes' if currently in one of the modes."
  108. (when (memq major-mode mixed-pitch-modes)
  109. (mixed-pitch-mode 1))
  110. (dolist (hook mixed-pitch-modes)
  111. (add-hook (intern (concat (symbol-name hook) "-hook")) #'mixed-pitch-mode)))
  112. (add-hook 'doom-init-ui-hook #'init-mixed-pitch-h)
  113. (defun my-generate-tab-stops (&optional width max)
  114. "Return a sequence suitable for `tab-stop-list'."
  115. (let* ((max-column (or max 200))
  116. (tab-width (or width tab-width))
  117. (count (/ max-column tab-width)))
  118. (number-sequence tab-width (* tab-width count) tab-width)))
  119. (defun my-setup-indent (n)
  120. (setq c-basic-offset n)
  121. (setq coffee-tab-width n) ; coffeescript
  122. (setq javascript-indent-level n) ; javascript-mode
  123. (setq js-indent-level n) ; js-mode
  124. (setq js2-basic-offset n) ; js2-mode, in latest js2-mode, it's alias of js-indent-level
  125. (setq web-mode-markup-indent-offset n) ; web-mode, html tag in html file
  126. (setq web-mode-css-indent-offset n) ; web-mode, css in html file
  127. (setq web-mode-code-indent-offset n) ; web-mode, js code in html file
  128. (setq css-indent-offset n) ; css-mode
  129. (setq tab-width n)
  130. (setq indent-tabs-mode nil)
  131. (setq tab-stop-list (my-generate-tab-stops))
  132. )
  133. (my-setup-indent 2)
  134. (load! "functions.el")
  135. (use-package! functions)
  136. ;; (use-package! setup-elfeed)
  137. ;; (load! "fancy-banner.el")
  138. ;; (use-package! fancy-banner)
  139. (use-package! emacs
  140. :config
  141. (setq +ligatures-in-modes '(not special-mode comint-mode eshell-mode term-mode
  142. vterm-mode Info-mode elfeed-search-mode elfeed-show-mode)))
  143. (use-package! magit-delta
  144. :hook (magit-mode . magit-delta-mode))
  145. ;; Tabnine::version ;; Which version of Tabnine
  146. ;; Tabnine::restart ;; restart the Tabnine service
  147. ;; Tabnine::sem ;; enables semantic completion for the current language
  148. ;; Tabnine::no_sem ;; disables semantic completion for the current language
  149. ;; Tabnine::active ;; checks if Tabnine is activated
  150. ;; Tabnine::config ;; to open the config
  151. ;; Tabnine::config_dir ;; /Users/leviolson/Library/Preferences/TabNine
  152. ;; Tabnine::config
  153. (use-package! company-tabnine
  154. :config
  155. (add-to-list 'company-backends 'company-tabnine))
  156. (use-package! graphql-mode
  157. :config
  158. (set-company-backend! 'graphql-mode '(:separate company-tabnine company-capf company-yasnippet)))
  159. (use-package! emacs
  160. :config
  161. (set-company-backend! 'emacs-lisp-mode '(:separate company-tabnine company-capf company-yasnippet)))
  162. ;; (use-package! typescript-mode
  163. ;; :config
  164. ;; (set-company-backend! 'typescript-mode '(company-tabnine company-capf company-yasnippet)))
  165. (use-package! company
  166. :config
  167. ;; Trigger completion immediately.
  168. (setq company-idle-delay 0.2)
  169. ;; Number the candidates (use M-1, M-2 etc to select completions).
  170. (setq company-show-quick-access t))
  171. (use-package! darkroom
  172. :commands darkroom-mode
  173. :custom
  174. (darkroom-margins (cons 40 0))
  175. (darkroom-text-scale-increase 0)
  176. (darkroom-fringes-outside-margins nil)
  177. (darkroom-margin-increment 0.2)
  178. )
  179. (use-package! org
  180. ;; :disabled t
  181. :commands org-capture
  182. :mode ("\\.org\\'" . org-mode)
  183. :bind (
  184. ("C-," . org-cycle-agenda-files)
  185. ;; ("C-c C-d" . org-capture)
  186. :map org-mode-map
  187. ;; ("M-n" . leo/org-narrow-next-tree)
  188. ;; ("M-p" . leo/org-narrow-prev-tree)
  189. ;; ("M-P" . leo/org-present)
  190. )
  191. :preface
  192. (defvar org-html-validation-link)
  193. (defvar org-html-text-markup-alist)
  194. (defvar org-capture-templates)
  195. :init
  196. (setq org-agenda-files (list
  197. (concat org-directory "/todo.org")
  198. (concat org-directory "/projects.org")
  199. (concat org-directory "/Recipies.org")
  200. (concat org-directory "/help.org")
  201. (concat org-directory "/personal.org")
  202. (concat org-directory "/archive.org")
  203. (concat "/Users/Levi_Olson/Projects" "/verastar/epc_guided_flow.org")
  204. ))
  205. (setq org-agenda-include-diary t)
  206. (add-to-list 'safe-local-variable-values '(eval leo/deft-insert-boilerplate))
  207. (setq org-refile-targets '((nil :maxlevel . 3)
  208. (org-agenda-files :maxlevel . 3)))
  209. (setq org-todo-keyword-faces
  210. '(("TODO" . org-roam-link-shielded)
  211. ("WAIT" . org-roam-link-shielded)
  212. ("NEXT" . org-roam-link-current)
  213. ("PLAN" . org-target)
  214. ("SPIKE" . org-target)
  215. ("ACTIVE" . org-todo)))
  216. (setq org-todo-keywords '(
  217. (sequence "TODO(t)" "NEXT(n)" "|" "DONE(d!)")
  218. (sequence "PLAN(p)" "SPIKE(s)" "ACTIVE(a)" "WAIT(w@/!)" "|" "DONE(d!)" "CANCELLED(c@)")
  219. ))
  220. :config
  221. (require 'org-protocol)
  222. (setq org-default-notes-file (concat org-directory "/todo.org"))
  223. (setq org-display-remote-inline-images t)
  224. (setq org-image-actual-width (list 1000))
  225. (org-babel-do-load-languages 'org-babel-load-languages '((js . t)
  226. (typescript . t)
  227. (shell . t)
  228. (apex . t)
  229. (soql . t)
  230. (emacs-lisp . t)))
  231. (setq org-capture-templates
  232. '(("w" "Default template" entry (file+headline org-default-notes-file "Unfiled")
  233. "* %^{Title}%?\n\nSource: %:link\n:COPIED_TEXT:\n %i\n:END:\n")
  234. ("t" "new task" entry (file+headline org-default-notes-file "Tasks")
  235. "* TODO [#A] %?\nSCHEDULED: %(org-insert-time-stamp (org-read-date nil t \"+0d\"))\n%a\n")
  236. ("n" "new note" entry (file+headline org-default-notes-file "Notes")
  237. "* %?\n%i\n")
  238. ("l" "store link" entry (file+olp org-default-notes-file "Links" "Unfiled")
  239. "* %a\n%?\n")
  240. ))
  241. (setq org-structure-template-alist
  242. '(("r" . "src restclient :results raw")
  243. ("j" . "src js :cmd \"/usr/local/bin/babel-node\" :results output code")
  244. ("e" . "src emacs-lisp :results silent")
  245. ("a" . "export ascii")
  246. ("c" . "center")
  247. ("C" . "comment")
  248. ("E" . "export")
  249. ("h" . "export html")
  250. ("l" . "export latex")
  251. ("q" . "quote")
  252. ("s" . "src")
  253. ("v" . "verse")))
  254. (defconst checkbox-fontlock-keywords-alist
  255. (mapcar (lambda (regex-char-pair)
  256. `(,(car regex-char-pair)
  257. (0 (prog1 ()
  258. (compose-region (match-beginning 1)
  259. (match-end 1)
  260. ,(concat (list ?\C-i)
  261. (list (decode-char 'ucs (cadr regex-char-pair)))))))))
  262. '(
  263. ;; Fira Code PragmataPro Liga Alternate
  264. ;; 2B1C -> ⬜ F096 -> 
  265. ;; 29C7 -> ⧇ F147 ->  F458 -> 
  266. ;; 2BBD -> ⮽ F046 -> 
  267. ;; 25A1 -> □
  268. ;; 25A2 -> ▢
  269. ;; 25A3 -> ▣
  270. ;; 25C6 -> ◆
  271. ;; 25C7 -> ◇
  272. ;; 25C9 -> ◉
  273. ;; 2610 -> ☐
  274. ;; 2611 -> ☑
  275. ;; 229F -> ⊟
  276. ;; 2612 -> ☒
  277. ;; PragmataPro Liga
  278. ;; ("\\(\\[ \\]\\)" #XF096)
  279. ;; ("\\(\\[-\\]\\)" #XF147)
  280. ;; ("\\(\\[X\\]\\)" #XF046)
  281. ;; Fira Code
  282. ("\\(\\[ \\]\\)" #X2B1C)
  283. ("\\(\\[-\\]\\)" #XF147)
  284. ("\\(\\[X\\]\\)" #X2BBD)
  285. )))
  286. (defun add-checkbox-symbol-keywords ()
  287. "Add checkbox font to font-lock."
  288. (font-lock-add-keywords nil checkbox-fontlock-keywords-alist))
  289. (add-hook 'org-mode-hook 'add-checkbox-symbol-keywords)
  290. (add-hook 'org-mode-hook '(lambda ()
  291. (visual-line-mode 0)
  292. (variable-pitch-mode 1)
  293. (org-indent-mode 1)
  294. (auto-fill-mode 0)
  295. ))
  296. (setq org-display-remote-inline-images t)
  297. (setq org-image-actual-width (list 1000))
  298. )
  299. (use-package org-roam
  300. :disabled t
  301. :custom
  302. (org-roam-directory (concat org-directory "/Roam/"))
  303. (org-roam-link-title-format "r::%s")
  304. :bind (:map org-roam-mode-map
  305. (("C-c n l" . org-roam)
  306. ("C-c n f" . org-roam-find-file)
  307. ("C-c n g" . org-roam-graph))
  308. :map org-mode-map
  309. (("C-c n i" . org-roam-insert))
  310. (("C-c n I" . org-roam-insert-immediate))))
  311. (use-package! org-agenda
  312. :after org
  313. :bind ("C-c a" . (lambda() (interactive) (org-agenda nil "z")))
  314. :init
  315. (set-face-attribute 'org-agenda-structure nil :weight 'bold :slant 'italic :foreground "#51afef")
  316. ;; Override stubborn vars
  317. (setq org-deadline-warning-days 0)
  318. (setq org-agenda-custom-commands
  319. '(
  320. ("z" "Show All Ze Things"
  321. (
  322. (todo "TODO"
  323. ((org-agenda-skip-function '(org-agenda-skip-if nil '(timestamp)))
  324. (org-agenda-skip-function
  325. `(org-agenda-skip-entry-if
  326. 'notregexp ,(format "\\[#%s\\]" (char-to-string org-priority-highest))))
  327. ;; (org-agenda-skip-function '(org-agenda-skip-entry-if 'wait))
  328. (org-agenda-block-separator nil)
  329. (org-agenda-overriding-header "\nImportant tasks without a date\n")
  330. ))
  331. (todo "TODO"
  332. ((org-agenda-overriding-header "\nTasks Ready\n")
  333. (org-agenda-skip-function '(org-agenda-skip-entry-if 'regexp "\\[#A\\]"))
  334. (org-agenda-block-separator nil)
  335. ))
  336. (todo "WAIT"
  337. ((org-agenda-overriding-header "\nTasks on hold\n")
  338. (org-agenda-block-separator nil)
  339. ))
  340. (agenda ""
  341. ((org-agenda-overriding-header "\nDaily Agenda\n")
  342. (org-agenda-span 1)
  343. (org-agenda-start-day nil)
  344. (org-deadline-warning-days 0)
  345. (org-deadline-warning-days 0)
  346. (org-scheduled-past-days 0)
  347. (org-deadline-past-days 0)
  348. (org-agenda-day-face-function (lambda(date) 'org-agenda-date))
  349. (org-agenda-format-date "")
  350. (org-agenda-skip-deadline-if-done t)
  351. (org-agenda-skip-scheduled-if-done t)
  352. (org-agenda-block-separator nil)))))
  353. ))
  354. )
  355. (use-package! org-super-agenda
  356. :disabled t
  357. :after org-agenda
  358. :init
  359. (setq
  360. org-agenda-time-grid '((daily today require-timed) (800 1000 1200 1400 1600 1800 2000) "----------------------" "......")
  361. org-agenda-skip-scheduled-if-done t
  362. org-agenda-skip-deadline-if-done t
  363. org-agenda-include-deadlines t
  364. org-agenda-include-diary t
  365. org-agenda-block-separator nil
  366. org-agenda-compact-blocks t
  367. org-agenda-start-day nil
  368. org-agenda-span 'day
  369. org-agenda-start-on-weekday nil
  370. org-agenda-start-with-log-mode t
  371. )
  372. (setq org-super-agenda-groups
  373. '((:discard (:and (:scheduled t
  374. :todo "DONE"
  375. :not (:log closed))))
  376. (:name "Done today"
  377. :log closed
  378. :order 4)
  379. (:name "Today"
  380. :time-grid t)
  381. (:name "Deadlines"
  382. :deadline today
  383. :order 0)
  384. (:name "Overdue"
  385. :deadline past
  386. :order 2)
  387. (:name "Next"
  388. :category "next")
  389. (:name "Personal tasks"
  390. :scheduled today)))
  391. (setq org-agenda-custom-commands
  392. '(("z" "Super view"
  393. ((agenda "" ((org-agenda-span 1)
  394. (org-agenda-start-day nil)
  395. (org-super-agenda-groups
  396. '((:name "Today"
  397. :time-grid t
  398. ;; :date today
  399. ;; :todo "TODAY"
  400. :scheduled today
  401. :order 1)))))
  402. (alltodo "" ((org-agenda-span 1)
  403. (org-agenda-start-day nil)
  404. (org-agenda-overriding-header "")
  405. (org-super-agenda-groups
  406. '(
  407. (:name "Next to do"
  408. :todo "NEXT"
  409. :order 1)
  410. (:name "Important"
  411. :tag "Important"
  412. :priority "A"
  413. :order 2)
  414. (:name "Due Today"
  415. :deadline today
  416. :order 3)
  417. (:name "Overdue"
  418. :deadline past
  419. :order 7)
  420. (:name "Due Soon"
  421. :deadline future
  422. :order 8)
  423. ;; (:name "Assignments"
  424. ;; :tag "Assignment"
  425. ;; :order 10)
  426. ;; (:name "Issues"
  427. ;; :tag "Issue"
  428. ;; :order 12)
  429. ;; (:name "Projects"
  430. ;; :tag "Project"
  431. ;; :order 14)
  432. ;; (:name "Emacs"
  433. ;; :tag "Emacs"
  434. ;; :order 13)
  435. ;; (:name "Research"
  436. ;; :tag "Research"
  437. ;; :order 15)
  438. ;; (:name "To read"
  439. ;; :tag "Read"
  440. ;; :order 30)
  441. ;; (:name "Waiting"
  442. ;; :todo "WAITING"
  443. ;; :order 20)
  444. ;; (:name "trivial"
  445. ;; :priority<= "C"
  446. ;; :tag ("Trivial" "Unimportant")
  447. ;; :todo ("SOMEDAY" )
  448. ;; :order 90)
  449. ;; (:discard (:tag ("Chore" "Routine" "Daily")))
  450. ))))))))
  451. :config
  452. (org-super-agenda-mode)
  453. )
  454. (use-package! deft
  455. :bind
  456. ("C-c n d" . deft)
  457. :config
  458. (setq deft-recursive t
  459. deft-use-filter-string-for-filename t
  460. deft-default-extension "org"
  461. deft-directory (concat org-directory "/Roam/")
  462. deft-recursive-ignore-dir-regexp "\\(?:\\.\\|\\.\\.\\|setup\\)$"))
  463. (use-package! org-pandoc-import
  464. :after org
  465. :commands (org-pandoc-import-html-as-org org-pandoc-import-html-to-org)
  466. :config
  467. (org-pandoc-import-backend html)
  468. )
  469. (use-package! lsp-mode
  470. :disabled t
  471. :config
  472. (setq +lsp-company-backends '(:separate company-tabnine company-lsp company-yasnippet company-capf))
  473. (setq lsp-enable-symbol-highlighting nil
  474. lsp-headerline-breadcrumb-enable t))
  475. (use-package! apex-mode
  476. :mode "\\.cls\\'"
  477. :bind ("M-q" . #'leo/kill-this-buffer-unless-scratch)
  478. )
  479. (use-package! web-mode
  480. :mode "\\.\\(app\\|page\\)\\'")
  481. (use-package! so-long
  482. :config
  483. (setq so-long-action 'so-long-minor-mode))
  484. (use-package! dired
  485. :config
  486. (setq dired-listing-switches "-ahgo --group-directories-first"))
  487. (use-package! dired-x
  488. :disabled t
  489. :custom
  490. (dired-omit-files nil))
  491. (use-package! hydra
  492. :config
  493. ;; (global-set-key (kbd "C-x o") (defhydra hydra-window ()
  494. ;; "window"
  495. ;; ("v" (lambda()
  496. ;; (interactive)
  497. ;; (split-window-right)
  498. ;; (windmove-right))
  499. ;; "vert")
  500. ;; ("x" (lambda()
  501. ;; (interactive)
  502. ;; (split-window-below)
  503. ;; (windmove-down))
  504. ;; "horz")
  505. ;; ("o" delete-other-windows "one" :color blue)
  506. ;; ("m" ace-window "ace")
  507. ;; ("b" ivy-switch-buffer "buf")
  508. ;; ("q" nil "quit")
  509. ;; ))
  510. )
  511. (use-package! pretty-hydra
  512. :init
  513. (defun with-faicon (icon str &optional height v-adjust)
  514. (s-concat (all-the-icons-faicon icon :v-adjust (or v-adjust 0) :height (or height 1)) " " str))
  515. (defun with-fileicon (icon str &optional height v-adjust)
  516. (s-concat (all-the-icons-fileicon icon :v-adjust (or v-adjust 0) :height (or height 1)) " " str))
  517. (defun with-octicon (icon str &optional height v-adjust)
  518. (s-concat (all-the-icons-octicon icon :v-adjust (or v-adjust 0) :height (or height 1)) " " str))
  519. (defun with-material (icon str &optional height v-adjust)
  520. (s-concat (all-the-icons-material icon :v-adjust (or v-adjust 0) :height (or height 1)) " " str))
  521. (defun with-mode-icon (mode str &optional height nospace face)
  522. (let* ((v-adjust (if (eq major-mode 'emacs-lisp-mode) 0.0 0.05))
  523. (args `(:height ,(or height 1) :v-adjust ,v-adjust))
  524. (_ (when face
  525. (lax-plist-put args :face face)))
  526. (icon (apply #'all-the-icons-icon-for-mode mode args))
  527. (icon (if (symbolp icon)
  528. (apply #'all-the-icons-octicon "file-text" args)
  529. icon)))
  530. (s-concat icon (if nospace "" " ") str)))
  531. (defun icon-displayable-p ()
  532. "Return non-nil if icons are displayable."
  533. (and t
  534. (or (display-graphic-p) (daemonp))
  535. (or (featurep 'all-the-icons)
  536. (require 'all-the-icons nil t))))
  537. (cl-defun pretty-hydra-title (title &optional icon-type icon-name
  538. &key face height v-adjust)
  539. "Add an icon in the hydra title."
  540. (let ((face (or face `(:foreground ,(face-background 'highlight))))
  541. (height (or height 1.0))
  542. (v-adjust (or v-adjust 0.0)))
  543. (concat
  544. (when (and (icon-displayable-p) icon-type icon-name)
  545. (let ((f (intern (format "all-the-icons-%s" icon-type))))
  546. (when (fboundp f)
  547. (concat
  548. (apply f (list icon-name :face face :height height :v-adjust v-adjust))
  549. " "))))
  550. (propertize title 'face face))))
  551. (defun leo/load-theme (theme)
  552. (setq doom-theme theme)
  553. (load-theme theme))
  554. (defvar leo/toggles--title (with-faicon "toggle-on" "Toggles" 1 -0.05))
  555. (pretty-hydra-define leo/toggles
  556. (:color amaranth :quit-key ("q" "C-g") :title leo/toggles--title)
  557. ("Basic"
  558. (
  559. ("n" doom/toggle-line-numbers "line numbers")
  560. ("w" whitespace-mode "whitespace" :toggle t)
  561. ("r" rainbow-mode "rainbow" :toggle t)
  562. )
  563. "Highlight"
  564. (
  565. ("h l" hl-line-mode "line" :toggle t)
  566. ("h t" hl-todo-mode "todo" :toggle t)
  567. )
  568. "UI"
  569. (
  570. ("d" (leo/load-theme 'doom-one) "dark theme" :toggle (eq doom-theme 'doom-one))
  571. ("l" (leo/load-theme 'doom-nord-light) "light theme" :toggle (eq doom-theme 'doom-nord-light))
  572. )
  573. "Modeline"
  574. (
  575. ("m" doom-modeline-mode "modern mode-line" :toggle t)
  576. ("b" display-battery-mode "battery" :toggle t)
  577. ("t" display-time-mode "time" :toggle t)
  578. )
  579. "Coding"
  580. (
  581. ("f" flycheck-mode "flycheck" :toggle t)
  582. ("F" flymake-mode "flymake" :toggle t)
  583. ("p" smartparens-mode "smartparens" :toggle t)
  584. ("P" smartparens-strict-mode "smartparens strict" :toggle t)
  585. ("S" show-smartparens-mode "show smartparens" :toggle t)
  586. )
  587. "Emacs"
  588. (
  589. ("D" toggle-debug-on-error "debug on error" :toggle (default-value 'debug-on-error))
  590. ("X" toggle-debug-on-quit "debug on quit" :toggle (default-value 'debug-on-quit))
  591. )
  592. )
  593. )
  594. )
  595. (use-package! podcaster
  596. :custom
  597. (podcaster-mp3-player "mpv")
  598. (podcaster-feeds-urls '(
  599. "https://feeds.fireside.fm/linuxunplugged/rss" ;; Linux Unplugged
  600. "https://feeds.fireside.fm/office/rss" ;; Office Hours
  601. "https://feeds.fireside.fm/linuxactionnews/rss" ;; Linux Action News
  602. "https://feeds.fireside.fm/selfhosted/rss" ;; Self Hosted
  603. "https://feeds.fireside.fm/coder/rss" ;; Coder Radio
  604. "https://feeds.fireside.fm/extras/rss" ;; Extras
  605. ))
  606. (podcaster-mp3-player-extra-params '("--quiet" "--really-quiet" "--no-audio-display" "--force-window=no"))
  607. :config
  608. (defun podcaster ()
  609. "Play podcasts."
  610. (interactive)
  611. (let* ((ivy-sort-functions-alist nil)
  612. (items (podcaster--collect-podcasts))
  613. (titles (mapcar #'car items))
  614. (title (completing-read "Podcasts: " titles))
  615. (item (cdr (assoc-string title items))))
  616. (when (ignore-errors (podcaster--player-process))
  617. (podcaster-stop))
  618. (podcaster--play-podcast item)))
  619. )
  620. (use-package! emms
  621. :disabled t
  622. :commands emms
  623. :init
  624. (add-hook 'emms-player-started-hook 'emms-show)
  625. (setq emms-show-format "Playing: %s")
  626. :config
  627. (emms-minimalistic)
  628. (emms-default-players)
  629. (setq emms-player-list '(emms-player-mpv)
  630. emms-playlist-buffer-name "*Media*")
  631. (setq emms-info-asynchronously nil)
  632. (setq-default
  633. emms-source-file-default-directory "~/Music/"
  634. emms-source-playlist-default-format 'm3u
  635. emms-playlist-mode-center-when-go t
  636. emms-playlist-default-major-mode 'emms-playlist-mode
  637. emms-show-format "NP: %s"
  638. emms-player-list '(emms-player-mpv))
  639. :bind (:map global-map
  640. ("C-c m" . nil)
  641. ("C-c m" . emms-hydra/body))
  642. :pretty-hydra
  643. ((:color amaranth :quit-key "q")
  644. ("emms"
  645. (("p" emms-start "Play/Pause")
  646. ("s" emms-stop "Stop")
  647. ("i" emms-show "Info")
  648. )
  649. )
  650. )
  651. )
  652. (use-package! emacs
  653. :bind (:map global-map
  654. ("s-." . emacs-hydra/body))
  655. :config
  656. (defun leo/music-play (url title album)
  657. (setq podcast-hard-link (car (car org-stored-links)))
  658. (message podcast-hard-link)
  659. (do-applescript
  660. (format "
  661. tell application \"Music\"
  662. open location \"%s\"
  663. play
  664. set name of current track to \"%s\"
  665. set album of current track to \"%s\"
  666. end tell" url title album)))
  667. (defun leo/music-visual-scrubber ()
  668. "Show a graphical representation of the player progress bar."
  669. (interactive)
  670. (dotimes (i 5)
  671. (message (do-applescript
  672. "tell application \"Music\"
  673. set player_pos to get player position
  674. set player_dur to get duration of current track
  675. set player_time to get time of current track
  676. set get_seconds to round (player_pos) mod 60
  677. set get_minutes to round (player_pos) / 60
  678. set get_hours to round (player_pos) / (60 * 60)
  679. set pad_seconds to text -2 thru -1 of (\"00\" & get_seconds)
  680. set pad_minutes to text -2 thru -1 of (\"00\" & get_minutes)
  681. set pad_hours to text -2 thru -1 of (\"00\" & get_hours)
  682. set current_pos to pad_hours & \":\" & pad_minutes & \":\" & pad_seconds
  683. set final_pos to text -1 thru -8 of (\"00000000\" & player_time)
  684. set perc to player_pos / player_dur
  685. set bar_length to 40
  686. set done to round (bar_length * perc)
  687. if done is 0 then set done to 1
  688. set progress_completed to text 1 thru done of (\"\")
  689. set total_progress to text 1 thru bar_length of (progress_completed & \"\")
  690. set total_progress to \"\" & total_progress & \"\"
  691. set right_aligned_final_pos to text -1 thru -(bar_length - 8 + 2) of (\" \" & final_pos)
  692. set total_progress to total_progress & \"
  693. \" & current_pos & right_aligned_final_pos
  694. end tell"))
  695. (sit-for 1)
  696. )
  697. (message "")
  698. )
  699. ;;
  700. ;;01:34:37 01:21:27
  701. ;;
  702. ;;00000
  703. (defun leo/music-get-info ()
  704. (interactive)
  705. (do-applescript "tell application \"Music\"
  706. set myName to get name of current track
  707. set myAlbum to get album of current track
  708. myName & \" - \" & myAlbum
  709. end tell"))
  710. (defun leo/music-playpause ()
  711. (interactive)
  712. (do-applescript
  713. (format "tell application \"Music\" to playpause")))
  714. (defun leo/music-skip-forward-30 ()
  715. (interactive)
  716. (do-applescript
  717. (format "tell application \"Music\" to set player position to (player position + 30)")))
  718. (defun leo/music-skip-backward-10 ()
  719. (interactive)
  720. (do-applescript
  721. (format "tell application \"Music\" to set player position to (player position - 10)")))
  722. (defun leo/play-podcast-in-music-app ()
  723. "When in an elfeed-entry buffer, open mp3 url in Music.app on macos."
  724. (interactive)
  725. (org-store-link nil nil)
  726. (when (not (string= (buffer-name) "*elfeed-entry*"))
  727. (error "Not in an elfeed entry buffer"))
  728. (let (
  729. (url (car (car (elfeed-entry-enclosures elfeed-show-entry))))
  730. (title (elfeed-entry-title elfeed-show-entry))
  731. (podcast (elfeed-feed-title (elfeed-entry-feed elfeed-show-entry)))
  732. )
  733. (leo/music-play url title podcast)
  734. ))
  735. (defun leo/music-open-show-notes ()
  736. (interactive)
  737. (org-link-open-from-string podcast-hard-link)
  738. (elfeed-show-refresh--mail-style)
  739. )
  740. :pretty-hydra
  741. ((:title (pretty-hydra-title (leo/music-get-info) 'faicon "headphones" :face 'all-the-icons-purple :height 1.1 :v-adjust -0.05)
  742. :color amaranth
  743. :quit-key ("q" "C-g" "s-."))
  744. ("Scrub"
  745. (
  746. ("j" leo/music-skip-backward-10 "back 10 sec")
  747. ("l" leo/music-skip-forward-30 "forward 30 sec")
  748. ("v" leo/music-visual-scrubber "view scrubber")
  749. )
  750. "Controls"
  751. (
  752. ("p" leo/music-playpause "play/pause" :color blue)
  753. ("SPC" leo/music-playpause "play/pause" :color blue) ;; [[elfeed:feeds.fireside.fm#e27c3bf8-55cd-47fa-9a14-4eb93d6dc632][475: I Do Declare]]
  754. )
  755. "Other"
  756. (
  757. ("s" leo/music-open-show-notes "show notes" :color blue)
  758. ("b" elfeed "browse" :color blue)
  759. )
  760. ))
  761. )
  762. (use-package! elfeed
  763. :after hydra
  764. :bind (:map elfeed-search-mode-map
  765. ("?" . elfeed-hydra/body))
  766. :config
  767. (load! "setup-elfeed.el")
  768. (setq elfeed-show-refresh-function 'elfeed-show-refresh--mail-style)
  769. :init
  770. (defun elfeed-search-clear () (interactive) (setq elfeed-search-filter "") (elfeed-search-update :force))
  771. (defun elfeed-search-emacs () (interactive) (setq elfeed-search-filter "+emacs") (elfeed-search-update :force))
  772. (defun elfeed-search-tesla () (interactive) (setq elfeed-search-filter "+tesla") (elfeed-search-update :force))
  773. (defun elfeed-search-podcast () (interactive) (setq elfeed-search-filter "+podcast") (elfeed-search-update :force))
  774. (defun elfeed-search-video () (interactive) (setq elfeed-search-filter "+youtube") (elfeed-search-update :force))
  775. (defun elfeed-search-toggle-unread ()
  776. (interactive)
  777. (let ((filter elfeed-search-filter))
  778. (if (s-contains-p "+unread" filter)
  779. (setq elfeed-search-filter (s-trim (s-replace "+unread" "" filter)))
  780. (setq elfeed-search-filter (concat filter " +unread"))))
  781. (elfeed-search-update :force)
  782. )
  783. (defun elfeed-search-toggle (term)
  784. "Accepts a TERM and returns a function that toggles TERM in the `elfeed' filter."
  785. (interactive "Mtag: ")
  786. (let ((filter elfeed-search-filter))
  787. (if (s-contains-p term filter)
  788. (setq elfeed-search-filter (s-trim (s-replace term "" filter)))
  789. (setq elfeed-search-filter (concat filter " " term))))
  790. (elfeed-search-update :force))
  791. :pretty-hydra
  792. ((:title (pretty-hydra-title "Elfeed" 'faicon "rss-square" :face 'all-the-icons-orange :height 1.1 :v-adjust -0.05)
  793. :color amaranth
  794. :quit-key ("q" "C-g" "s-."))
  795. ("Search"
  796. (("c" elfeed-db-compact "compact db")
  797. ("g" elfeed-search-update--force "refresh")
  798. ("G" elfeed-search-fetch "update")
  799. ("y" elfeed-search-yank "copy URL")
  800. ("+" elfeed-search-tag-all "tag all")
  801. ("-" elfeed-search-untag-all "untag all"))
  802. "Filter"
  803. (("/" elfeed-search-live-filter "live filter")
  804. ("f" (elfeed-search-set-filter "@6-months-ago +f") "favorites")
  805. ("c" (elfeed-search-set-filter "@6-months-ago") "clear search")
  806. ("t" (elfeed-search-set-filter "@1-day-ago") "today"))
  807. "Search Toggles"
  808. (
  809. ("se" (elfeed-search-toggle "+emacs") "emacs")
  810. ("st" (elfeed-search-toggle "+tesla") "tesla")
  811. ("sp" (elfeed-search-toggle "+podcast") "podcasts")
  812. ("sj" (elfeed-search-toggle "+jb") "jb")
  813. ("sy" (elfeed-search-toggle "+youtube") "youtube")
  814. ("sl" (elfeed-search-toggle "+linux") "linux")
  815. )
  816. "Media"
  817. (
  818. ("P" leo/play-podcast-in-music-app "Play Media")
  819. ("A" elfeed-show-add-enclosure-to-playlist "Add to playlist")
  820. )
  821. "Article"
  822. (("b" elfeed-search-browse-url "browse")
  823. ("n" next-line "next")
  824. ("p" previous-line "previous")
  825. ("u" elfeed-search-tag-all-unread "mark unread")
  826. ("r" elfeed-search-untag-all-unread "mark read")
  827. ("RET" elfeed-search-show-entry "show"))))
  828. )
  829. (after! xref
  830. (add-to-list '+lookup-provider-url-alist '("Melpa" "https://melpa.org/#/?q=%s"))
  831. (add-to-list '+lookup-provider-url-alist '("GitHub - LifeOmic" "https://github.com/search?q=user:LifeOmic+%s"))
  832. (add-to-list '+lookup-provider-url-alist '("Nix Packages" "https://search.nixos.org/packages?channel=22.05&from=0&size=50&sort=relevance&type=packages&query=%s"))
  833. (add-to-list '+lookup-provider-url-alist '("Home Manager" "https://mipmip.github.io/home-manager-option-search/?%s"))
  834. (add-to-list '+lookup-provider-url-alist '("Github - Nix Darwin" "https://github.com/LnL7/nix-darwin/search?q=%s"))
  835. )
  836. (after! world-clock
  837. ;; Seattle 13:27 PDT
  838. ;; New York 16:27 EDT
  839. ;; London 21:27 BST
  840. ;; Paris 22:27 CEST
  841. ;; Bangalore 01:57 IST
  842. ;; Tokyo 05:27 JST
  843. :config
  844. (setq world-clock-time-format "%I:%M %p")
  845. (setq world-clock-list '(
  846. ("+7:00" "Pacific")
  847. ("+5:00" "Central")
  848. ("+4:00" "Eastern")
  849. ("-1:00" "London")
  850. ("-5:30" "India")
  851. ))
  852. )
  853. ;;;;;;;;;;;
  854. ;; HOOKS ;;
  855. ;;;;;;;;;;;
  856. (add-hook 'text-mode-hook 'leo/remove-dos-eol) ;; Don't show `^M' at the end of lines
  857. (add-hook 'prog-mode-hook 'leo/remove-dos-eol) ;; same, but for prog modes
  858. ;;;;;;;;;;;;;;;;;
  859. ;; KEYBINDINGS ;;
  860. ;;;;;;;;;;;;;;;;;
  861. (map! :map global-map
  862. :prefix "C-x"
  863. "C-l" nil
  864. (:prefix ("C-l" . "Levi's Leader")
  865. "a" #'org-agenda
  866. "e" #'elfeed
  867. "m" #'emms-browser
  868. "g" #'magit-status
  869. "w" #'world-clock
  870. ))
  871. (map! :map org-mode-map
  872. :localleader
  873. "t" nil
  874. (:prefix ("t" . "tables")
  875. :desc "Insert row seperator below point"
  876. "-" #'org-table-hline-and-move
  877. :desc "Align Column Separators"
  878. "a" #'org-table-align
  879. :desc "Blank current field"
  880. "b" #'org-table-blank-field
  881. :desc "Create or Convert"
  882. "c" #'org-table-create-or-convert-from-region
  883. (:prefix ("d" . "delete")
  884. :desc "Column"
  885. "c" #'org-table-delete-column
  886. :desc "Row"
  887. "r" #'org-table-kill-row)
  888. :desc "Edit Field"
  889. "e" #'org-table-edit-field
  890. :desc "Edit Formula"
  891. "f" #'org-table-edit-formulas
  892. :desc "Help Show Field Info"
  893. "h" #'org-table-field-info
  894. (:prefix ("i" . "insert")
  895. :desc "Insert Column"
  896. "c" #'org-table-insert-column
  897. :desc "Insert Row"
  898. "r" #'org-table-insert-row
  899. )
  900. :desc "Recalculate This Table"
  901. "r" #'org-table-recalculate
  902. :desc "Recalculate All Buffer Tables"
  903. "R" #'org-table-recalculate-buffer-tables
  904. :desc "Sort by"
  905. "s" #'org-table-sort-lines
  906. (:prefix ("t" . "toggle")
  907. :desc "Toggle Formulas"
  908. "f" #'org-table-toggle-formula-debugger
  909. :desc "Toggle Coordinates"
  910. "c" #'org-table-toggle-coordinate-overlays
  911. )
  912. )
  913. )
  914. (map! :map comint-mode-map
  915. "q" '(lambda()
  916. (interactive)
  917. (if (s-contains? "sfdx" (buffer-name))
  918. (progn
  919. (leo/kill-this-buffer-unless-scratch)
  920. (+workspace/close-window-or-workspace)
  921. ))))
  922. (map! :map xwidget-webkit-mode-map
  923. "C-i" 'xwidget-webkit-insert-string
  924. "C-m" 'xwidget-webkit-insert-string
  925. "C-s" 'isearch-forward
  926. "M-w" 'xwidget-webkit-copy-selection-as-kill
  927. "C-w" 'xwidget-webkit-copy-selection-as-kill
  928. "o" 'xwidget-webkit-goto-url
  929. "C-l" 'xwidget-webkit-goto-url
  930. "n" 'xwidget-webkit-scroll-up
  931. "p" 'xwidget-webkit-scroll-down
  932. "C-y" 'yank
  933. )
  934. (defun leo/search-lifeomic-repos()
  935. "Search for LifeOmic Repo"
  936. (interactive)
  937. (setq query (read-string (format "Search for repository (in %s): " "LifeOmic")))
  938. (funcall +lookup-open-url-fn (format "https://github.com/search?q=user:LifeOmic+%s" (url-encode-url query)))
  939. )
  940. (use-package! vs-restclient
  941. :bind (:map vs-restclient-mode-map
  942. ("C-c C-c" . 'vs-restclient-http-send-current-stay-in-window)))
  943. (use-package! vs-restclient-jq
  944. :after vs-restclient
  945. :config
  946. (vs-restclient-register-result-func
  947. "jq-set-var" #'vs-restclient-jq-json-var-function
  948. "Set a vs-restclient variable with the value jq expression,
  949. takes var & jq expression as args.
  950. eg. -> jq-set-var :my-token .token")
  951. (define-key vs-restclient-response-mode-map (kbd "C-c C-j") #'vs-restclient-jq-interactive-result)
  952. )
  953. (map! :map global-map
  954. "M-t" #'treemacs-select-window
  955. "M-q" #'leo/kill-this-buffer-unless-scratch
  956. "s-w" #'leo/kill-this-buffer-unless-scratch
  957. "M-RET" #'eshell
  958. :desc "Format Document or Region"
  959. "C-<tab>" #'leo/tidy
  960. :desc "Comment or Uncomment Line or Region"
  961. "C-;" #'leo/comment-or-uncomment-region-or-line
  962. :desc "Open Private Doom Config"
  963. "C-c C-e" #'leo/edit-config
  964. "C-c d" #'leo/duplicate-thing
  965. "C-c g" #'magit-status
  966. "s-g" #'magit-status
  967. "M-n" #'leo/jump-to-next-symbol
  968. "M-p" #'leo/jump-to-prev-symbol
  969. "M-u" #'upcase-dwim
  970. "M-c" #'capitalize-dwim
  971. "M-l" #'downcase-dwim
  972. :desc "Search LifeOmic Repos"
  973. "C-c s g" #'leo/search-lifeomic-repos
  974. ;; Perspective.el
  975. "C-c C-n" #'persp-next
  976. "C-c C-p" #'persp-prev
  977. "C-c C-r" #'persp-rename
  978. "C-c C-l" #'persp-switch
  979. "C-c C-s" #'persp-switch
  980. "C-c b" #'+ivy/switch-workspace-buffer
  981. "s-b" #'+ivy/switch-workspace-buffer
  982. ;; "C-c b" #'counsel-switch-buffer
  983. "C-s" #'swiper
  984. "C-}" #'mc/mark-next-like-this
  985. "C-)" #'mc/unmark-next-like-this
  986. "C-{" #'mc/mark-previous-like-this
  987. "C-(" #'mc/unmark-previous-like-this
  988. "C-M-}" #'mc/mark-next-like-this-word
  989. "C-M-)" #'mc/unmark-next-like-this
  990. "C-M-{" #'mc/mark-previous-like-this-word
  991. "C-M-(" #'mc/unmark-previous-like-this
  992. "C-@" #'er/expand-region
  993. "C-#" #'er/contract-region
  994. )