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.

523 lines
19 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
  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" :size 20 :weight 'regular)
  21. doom-big-font (font-spec :family "PragmataPro" :size 30 :weight 'regular)
  22. ;; doom-variable-pitch-font (font-spec :family "PragmataPro" :size 20)
  23. doom-variable-pitch-font (font-spec :family "Overpass" :size 20 :weight 'thin)
  24. doom-unicode-font (font-spec :family "PragmataPro" :size 20)
  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)
  30. (remove-hook 'window-setup-hook #'doom-init-theme-h)
  31. (add-hook 'after-init-hook #'doom-init-theme-h 'append)
  32. (delq! t custom-theme-load-path)
  33. (setq doom-modeline-height 45)
  34. ;; If you use `org' and don't want your org files in the default location below,
  35. ;; change `org-directory'. It must be set before org loads!
  36. (setq org-directory "~/Nextcloud/Org")
  37. ;; Some nicer defaults
  38. (setq doom-fallback-buffer-name "*Doom*"
  39. +doom-dashboard-name "*Doom*")
  40. (map! :g "s-<right>" #'next-buffer
  41. :g "s-<left>" #'previous-buffer)
  42. ;; This determines the style of line numbers in effect. If set to `nil', line
  43. ;; numbers are disabled. For relative line numbers, set this to `relative'.
  44. (setq display-line-numbers-type t)
  45. (setq projectile-project-search-path "~/Projects")
  46. (require 's)
  47. (when (eq system-type 'gnu/linux)
  48. (when (s-contains? "microsoft" operating-system-release t)
  49. (progn
  50. (setq org-directory "/mnt/c/Users/Levi/Nextcloud/Org")
  51. (add-to-list 'default-frame-alist '(top . 400))
  52. (add-to-list 'default-frame-alist '(left . 750))
  53. (add-to-list 'default-frame-alist '(height . 60))
  54. (add-to-list 'default-frame-alist '(width . 235))
  55. (setq browse-url-chrome-program "/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe")
  56. (setq browse-url-chromium-program "/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe")
  57. )))
  58. (when (eq system-type 'darwin)
  59. (progn
  60. (setq org-directory "/Users/leviolson/Nextcloud/Org")
  61. (add-to-list 'default-frame-alist '(top . 0))
  62. (add-to-list 'default-frame-alist '(left . 0))
  63. (add-to-list 'default-frame-alist '(height . 49))
  64. (add-to-list 'default-frame-alist '(width . 178))
  65. (setq browse-url-chrome-program "/Applications/Safari.app")
  66. (setq browse-url-chromium-program "/Applications/Safari.app")
  67. ))
  68. ;; Here are some additional functions/macros that could help you configure Doom:
  69. ;;
  70. ;; - `load!' for loading external *.el files relative to this one
  71. ;; - `use-package!' for configuring packages
  72. ;; - `after!' for running code after a package has loaded
  73. ;; - `add-load-path!' for adding directories to the `load-path', relative to
  74. ;; this file. Emacs searches the `load-path' when you load packages with
  75. ;; `require' or `use-package'.
  76. ;; - `map!' for binding new keys
  77. ;;
  78. ;; To get information about any of these functions/macros, move the cursor over
  79. ;; the highlighted symbol at press 'K' (non-evil users must press 'C-c c k').
  80. ;; This will open documentation for it, including demos of how they are used.
  81. ;;
  82. ;; You can also try 'gd' (or 'C-c c d') to jump to their definition and see how
  83. ;; they are implemented.
  84. (unless (string-match-p "^Power N/A" (battery)) ; On laptops...
  85. (display-battery-mode 1))
  86. (display-time-mode 1)
  87. (global-subword-mode 1)
  88. (defvar mixed-pitch-modes '(org-mode LaTeX-mode markdown-mode gfm-mode Info-mode)
  89. "Modes that `mixed-pitch-mode' should be enabled in, but only after UI initialisation.")
  90. (defun init-mixed-pitch-h ()
  91. "Hook `mixed-pitch-mode' into each mode in `mixed-pitch-modes'.
  92. Also immediately enables `mixed-pitch-modes' if currently in one of the modes."
  93. (when (memq major-mode mixed-pitch-modes)
  94. (mixed-pitch-mode 1))
  95. (dolist (hook mixed-pitch-modes)
  96. (add-hook (intern (concat (symbol-name hook) "-hook")) #'mixed-pitch-mode)))
  97. (add-hook 'doom-init-ui-hook #'init-mixed-pitch-h)
  98. (defun my-generate-tab-stops (&optional width max)
  99. "Return a sequence suitable for `tab-stop-list'."
  100. (let* ((max-column (or max 200))
  101. (tab-width (or width tab-width))
  102. (count (/ max-column tab-width)))
  103. (number-sequence tab-width (* tab-width count) tab-width)))
  104. (defun my-setup-indent (n)
  105. (setq c-basic-offset n)
  106. (setq coffee-tab-width n) ; coffeescript
  107. (setq javascript-indent-level n) ; javascript-mode
  108. (setq js-indent-level n) ; js-mode
  109. (setq js2-basic-offset n) ; js2-mode, in latest js2-mode, it's alias of js-indent-level
  110. (setq web-mode-markup-indent-offset n) ; web-mode, html tag in html file
  111. (setq web-mode-css-indent-offset n) ; web-mode, css in html file
  112. (setq web-mode-code-indent-offset n) ; web-mode, js code in html file
  113. (setq css-indent-offset n) ; css-mode
  114. (setq tab-width n)
  115. (setq indent-tabs-mode nil)
  116. (setq tab-stop-list (my-generate-tab-stops))
  117. )
  118. (my-setup-indent 2)
  119. (load! "functions.el")
  120. (use-package! functions)
  121. ;; (load! "setup-elfeed.el")
  122. ;; (use-package! setup-elfeed)
  123. ;; (load! "fancy-banner.el")
  124. ;; (use-package! fancy-banner)
  125. (use-package! emacs
  126. :config
  127. (setq +ligatures-in-modes '(not special-mode comint-mode eshell-mode term-mode
  128. vterm-mode Info-mode elfeed-search-mode elfeed-show-mode)))
  129. (use-package! magit-delta
  130. :hook (magit-mode . magit-delta-mode))
  131. ;; Tabnine::version ;; Which version of Tabnine
  132. ;; Tabnine::restart ;; restart the Tabnine service
  133. ;; Tabnine::sem ;; enables semantic completion for the current language
  134. ;; Tabnine::no_sem ;; disables semantic completion for the current language
  135. ;; Tabnine::active ;; checks if Tabnine is activated
  136. ;; Tabnine::config ;; to open the config
  137. ;; Tabnine::config_dir ;; /Users/leviolson/Library/Preferences/TabNine
  138. (use-package company-tabnine
  139. :ensure t
  140. :config
  141. (add-to-list 'company-backends 'company-tabnine))
  142. (use-package! graphql-mode
  143. :config
  144. (set-company-backend! 'graphql-mode '(:separate company-tabnine company-capf company-yasnippet)))
  145. (use-package! emacs
  146. :config
  147. (set-company-backend! 'emacs-lisp-mode '(:separate company-tabnine company-capf company-yasnippet)))
  148. ;; (use-package! typescript-mode
  149. ;; :config
  150. ;; (set-company-backend! 'typescript-mode '(company-tabnine company-capf company-yasnippet)))
  151. (use-package! company
  152. :config
  153. ;; Trigger completion immediately.
  154. (setq company-idle-delay 0.2)
  155. ;; Number the candidates (use M-1, M-2 etc to select completions).
  156. (setq company-show-quick-access nil))
  157. (use-package! darkroom
  158. :commands darkroom-mode
  159. :custom
  160. (darkroom-margins (cons 40 0))
  161. (darkroom-text-scale-increase 0)
  162. (darkroom-fringes-outside-margins nil)
  163. (darkroom-margin-increment 0.2)
  164. )
  165. (use-package! org
  166. ;; :disabled t
  167. :commands org-capture
  168. :mode ("\\.org\\'" . org-mode)
  169. :bind (
  170. ("C-," . org-cycle-agenda-files)
  171. ;; ("C-c C-d" . org-capture)
  172. :map org-mode-map
  173. ("M-n" . leo/org-narrow-next-tree)
  174. ("M-p" . leo/org-narrow-prev-tree)
  175. ("M-P" . leo/org-present)
  176. )
  177. :preface
  178. (defvar org-html-validation-link)
  179. (defvar org-html-text-markup-alist)
  180. (defvar org-capture-templates)
  181. :init
  182. (setq org-agenda-files (list (concat org-directory "/todo.org")
  183. (concat org-directory "/projects.org")
  184. (concat org-directory "/Recipies.org")
  185. (concat org-directory "/help.org")
  186. (concat org-directory "/personal.org")
  187. (concat org-directory "/archive.org")
  188. ))
  189. (setq org-agenda-include-diary t)
  190. (add-to-list 'safe-local-variable-values '(eval leo/deft-insert-boilerplate))
  191. (setq org-refile-targets '((nil :maxlevel . 3)
  192. (org-agenda-files :maxlevel . 3))
  193. org-default-notes-file (concat org-directory "/todo.org"))
  194. (setq org-todo-keyword-faces
  195. '(("TODO" . org-roam-link-shielded)
  196. ("WAIT" . org-roam-link-shielded)
  197. ("HOLD" . org-roam-link-shielded)
  198. ("NEXT" . org-roam-link-current)
  199. ("PLAN" . org-target)
  200. ("SPIKE" . org-target)
  201. ("ACTIVE" . org-todo)))
  202. (setq org-todo-keywords '(
  203. (sequence "TODO(t)" "NEXT(n)" "|" "DONE(d!)")
  204. (sequence "PLAN(p)" "SPIKE(s)" "ACTIVE(a)" "WAIT(w@/!)" "HOLD(h)" "|" "DONE(d!)" "CANCELLED(c@)")
  205. ))
  206. :config
  207. (require 'org-protocol)
  208. (org-babel-do-load-languages 'org-babel-load-languages '((js . t)
  209. (typescript . t)
  210. (shell . t)
  211. (apex . t)
  212. (soql . t)
  213. (emacs-lisp . t)))
  214. (setq org-capture-templates
  215. '(("w" "Default template" entry (file+headline org-default-notes-file "Unfiled")
  216. "* %^{Title}%?\n\nSource: %:link\n:COPIED_TEXT:\n %i\n:END:\n")
  217. ("t" "new task" entry (file+headline (concat org-directory "/todo.org") "Tasks")
  218. "* TODO [#A] %?\nSCHEDULED: %(org-insert-time-stamp (org-read-date nil t \"+0d\"))\n%a\n")
  219. ("n" "new note" entry (file+headline org-default-notes-file "Notes")
  220. "* %?\n%i\n")
  221. ("l" "store link" entry (file+olp org-default-notes-file "Links" "Unfiled")
  222. "* %a\n%?\n")
  223. ))
  224. (setq org-structure-template-alist
  225. '(("r" . "src restclient :results raw")
  226. ("j" . "src js :cmd \"/usr/local/bin/babel-node\" :results output code")
  227. ("e" . "src emacs-lisp :results silent")
  228. ("a" . "export ascii")
  229. ("c" . "center")
  230. ("C" . "comment")
  231. ("E" . "export")
  232. ("h" . "export html")
  233. ("l" . "export latex")
  234. ("q" . "quote")
  235. ("s" . "src")
  236. ("v" . "verse")))
  237. (defconst checkbox-fontlock-keywords-alist
  238. (mapcar (lambda (regex-char-pair)
  239. `(,(car regex-char-pair)
  240. (0 (prog1 ()
  241. (compose-region (match-beginning 1)
  242. (match-end 1)
  243. ,(concat (list ?\C-i)
  244. (list (decode-char 'ucs (cadr regex-char-pair)))))))))
  245. '(("\\(\\[ \\]\\)" #XF096);2B1C;F096;
  246. ("\\(\\[-\\]\\)" #XF147);29C7;F458;F147;
  247. ("\\(\\[X\\]\\)" #XF046);2BBD;F046;
  248. )))
  249. (defun add-checkbox-symbol-keywords ()
  250. "Add checkbox font to font-lock."
  251. (font-lock-add-keywords nil checkbox-fontlock-keywords-alist))
  252. (add-hook 'org-mode-hook 'add-checkbox-symbol-keywords)
  253. (add-hook 'org-mode-hook '(lambda ()
  254. (visual-line-mode 0)
  255. (variable-pitch-mode 1)
  256. (org-indent-mode)
  257. (auto-fill-mode 0)
  258. ))
  259. )
  260. (use-package org-roam
  261. :disabled t
  262. :custom
  263. (org-roam-directory (concat org-directory "/Roam/"))
  264. (org-roam-link-title-format "r::%s")
  265. :bind (:map org-roam-mode-map
  266. (("C-c n l" . org-roam)
  267. ("C-c n f" . org-roam-find-file)
  268. ("C-c n g" . org-roam-graph))
  269. :map org-mode-map
  270. (("C-c n i" . org-roam-insert))
  271. (("C-c n I" . org-roam-insert-immediate))))
  272. (use-package! deft
  273. :bind
  274. ("C-c n d" . deft)
  275. :config
  276. (setq deft-recursive t
  277. deft-use-filter-string-for-filename t
  278. deft-default-extension "org"
  279. deft-directory (concat org-directory "/Roam/")
  280. deft-recursive-ignore-dir-regexp "\\(?:\\.\\|\\.\\.\\|setup\\)$"))
  281. (use-package! org-pandoc-import
  282. :after org
  283. :commands (org-pandoc-import-html-as-org org-pandoc-import-html-to-org)
  284. :config
  285. (org-pandoc-import-backend html)
  286. )
  287. (use-package! lsp-mode
  288. :config
  289. (setq +lsp-company-backends '(:separate company-tabnine company-lsp company-yasnippet company-capf))
  290. (setq lsp-enable-symbol-highlighting nil
  291. lsp-headerline-breadcrumb-enable t))
  292. (use-package! apex-mode
  293. :mode "\\.cls\\'"
  294. :bind ("M-q" . #'leo/kill-this-buffer-unless-scratch)
  295. )
  296. (use-package! web-mode
  297. :mode "\\.\\(app\\|page\\)\\'")
  298. (use-package! so-long
  299. :config
  300. (setq so-long-action 'so-long-minor-mode))
  301. (use-package! dired
  302. :config
  303. (setq dired-listing-switches "-ahgo --group-directories-first"))
  304. (use-package! dired-x
  305. :disabled t
  306. :custom
  307. (dired-omit-files nil))
  308. (use-package! hydra
  309. :ensure t)
  310. (use-package! elfeed
  311. :after hydra
  312. :bind (:map elfeed-search-mode-map
  313. ("a" . elfeed-search-clear)
  314. ("e" . elfeed-search-emacs)
  315. ("E" . (lambda () (interactive) (elfeed-search-toggle "+emacs")))
  316. ("t" . elfeed-search-tesla)
  317. ("T" . (lambda () (interactive) (elfeed-search-toggle "+tesla")))
  318. ("y" . elfeed-search-video)
  319. ("Y" . (lambda () (interactive) (elfeed-search-toggle "+youtube")))
  320. ("v" . elfeed-search-browse-url)
  321. ("o" . elfeed-search-show-entry)
  322. ("g" . elfeed-search-fetch)
  323. ("U" . elfeed-search-toggle-unread)
  324. )
  325. :config
  326. (defun elfeed-search-clear () (interactive) (setq elfeed-search-filter "") (elfeed-search-update :force))
  327. (defun elfeed-search-emacs () (interactive) (setq elfeed-search-filter "+emacs") (elfeed-search-update :force))
  328. (defun elfeed-search-tesla () (interactive) (setq elfeed-search-filter "+tesla") (elfeed-search-update :force))
  329. (defun elfeed-search-video () (interactive) (setq elfeed-search-filter "+youtube") (elfeed-search-update :force))
  330. (defun elfeed-search-toggle-unread ()
  331. (interactive)
  332. (let ((filter elfeed-search-filter))
  333. (if (s-contains-p "+unread" filter)
  334. (setq elfeed-search-filter (s-trim (s-replace "+unread" "" filter)))
  335. (setq elfeed-search-filter (concat filter " +unread"))))
  336. (elfeed-search-update :force)
  337. )
  338. (defun elfeed-search-toggle (term)
  339. "Accepts a TERM and returns a function that toggles TERM in the `elfeed' filter."
  340. (interactive "Mtag: ")
  341. (let ((filter elfeed-search-filter))
  342. (if (s-contains-p term filter)
  343. (setq elfeed-search-filter (s-trim (s-replace term "" filter)))
  344. (setq elfeed-search-filter (concat filter " " term))))
  345. (elfeed-search-update :force)
  346. )
  347. )
  348. (after! xref
  349. (add-to-list '+lookup-provider-url-alist '("Melpa" "https://melpa.org/#/?q=%s"))
  350. (add-to-list '+lookup-provider-url-alist '("GitHub - LifeOmic" "https://github.com/search?q=user:LifeOmic+%s")))
  351. ;;;;;;;;;;;
  352. ;; HOOKS ;;
  353. ;;;;;;;;;;;
  354. (add-hook 'text-mode-hook 'leo/remove-dos-eol) ;; Don't show `^M' at the end of lines
  355. (add-hook 'prog-mode-hook 'leo/remove-dos-eol) ;; same, but for prog modes
  356. ;;;;;;;;;;;;;;;;;
  357. ;; KEYBINDINGS ;;
  358. ;;;;;;;;;;;;;;;;;
  359. (map! :map global-map
  360. :prefix "C-x"
  361. "C-l" nil
  362. (:prefix ("C-l" . "launch app")
  363. "a" #'org-agenda
  364. "e" #'elfeed
  365. "g" #'magit-status
  366. ))
  367. (map! :map global-map
  368. :prefix "C-c"
  369. "a" nil
  370. (:prefix ("a" . "launch app")
  371. "a" #'org-agenda
  372. "e" #'elfeed
  373. "g" #'magit-status
  374. ))
  375. (map! :map comint-mode-map
  376. "q" '(lambda()
  377. (interactive)
  378. (if (s-contains? "sfdx" (buffer-name))
  379. (progn
  380. (leo/kill-this-buffer-unless-scratch)
  381. (+workspace/close-window-or-workspace)
  382. ))))
  383. (map! :map xwidget-webkit-mode-map
  384. "C-i" 'xwidget-webkit-insert-string
  385. "C-m" 'xwidget-webkit-insert-string
  386. "C-s" 'isearch-forward
  387. "M-w" 'xwidget-webkit-copy-selection-as-kill
  388. "C-w" 'xwidget-webkit-copy-selection-as-kill
  389. "o" 'xwidget-webkit-goto-url
  390. "C-l" 'xwidget-webkit-goto-url
  391. "n" 'xwidget-webkit-scroll-up
  392. "p" 'xwidget-webkit-scroll-down
  393. "C-y" 'yank
  394. )
  395. (defun leo/search-lifeomic-repos()
  396. "Search for LifeOmic Repo"
  397. (interactive)
  398. (setq query (read-string (format "Search for repository (in %s): " "LifeOmic")))
  399. (funcall +lookup-open-url-fn (format "https://github.com/search?q=user:LifeOmic+%s" (url-encode-url query)))
  400. )
  401. (use-package! vs-restclient
  402. :bind (:map vs-restclient-mode-map
  403. ("C-c C-c" . 'vs-restclient-http-send-current-stay-in-window))
  404. :ensure t)
  405. (use-package! vs-restclient-jq
  406. :after vs-restclient
  407. :ensure t
  408. :config
  409. (vs-restclient-register-result-func
  410. "jq-set-var" #'vs-restclient-jq-json-var-function
  411. "Set a vs-restclient variable with the value jq expression,
  412. takes var & jq expression as args.
  413. eg. -> jq-set-var :my-token .token")
  414. (define-key vs-restclient-response-mode-map (kbd "C-c C-j") #'vs-restclient-jq-interactive-result)
  415. )
  416. (map! :map global-map
  417. "M-t" #'treemacs-select-window
  418. "M-q" #'leo/kill-this-buffer-unless-scratch
  419. "M-RET" #'eshell
  420. :desc "Format Document or Region"
  421. "C-<tab>" #'leo/tidy
  422. :desc "Comment or Uncomment Line or Region"
  423. "C-;" #'leo/comment-or-uncomment-region-or-line
  424. :desc "Open Private Doom Config"
  425. "C-c C-e" #'leo/edit-config
  426. "C-c d" #'leo/duplicate-thing
  427. "C-c g" #'magit-status
  428. "M-n" #'leo/jump-to-next-symbol
  429. "M-p" #'leo/jump-to-prev-symbol
  430. "M-u" #'upcase-dwim
  431. "M-c" #'capitalize-dwim
  432. "M-l" #'downcase-dwim
  433. :desc "Search LifeOmic Repos"
  434. "C-c s g" #'leo/search-lifeomic-repos
  435. ;; Perspective.el
  436. "C-c C-n" #'persp-next
  437. "C-c C-p" #'persp-prev
  438. "C-c C-r" #'persp-rename
  439. "C-c C-l" #'persp-switch
  440. "C-c C-s" #'persp-switch
  441. "C-c b" #'ivy-switch-buffer
  442. ;; "C-c b" #'counsel-switch-buffer
  443. "C-s" #'swiper
  444. "C-}" #'mc/mark-next-like-this
  445. "C-)" #'mc/unmark-next-like-this
  446. "C-{" #'mc/mark-previous-like-this
  447. "C-(" #'mc/unmark-previous-like-this
  448. "C-M-}" #'mc/mark-next-like-this-word
  449. "C-M-)" #'mc/unmark-next-like-this
  450. "C-M-{" #'mc/mark-previous-like-this-word
  451. "C-M-(" #'mc/unmark-previous-like-this
  452. "C-@" #'er/expand-region
  453. "C-#" #'er/contract-region
  454. )