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

;;; $DOOMDIR/config.el -*- lexical-binding: t; -*-
;; Place your private configuration here! Remember, you do not need to run 'doom
;; sync' after modifying this file!
;; Some functionality uses this to identify you, e.g. GPG configuration, email
;; clients, file templates and snippets.
(setq user-full-name "Levi Olson"
user-mail-address "olson.levi@gmail.com")
;; Doom exposes five (optional) variables for controlling fonts in Doom. Here
;; are the three important ones:
;;
;; + `doom-font'
;; + `doom-variable-pitch-font'
;; + `doom-big-font' -- used for `doom-big-font-mode'; use this for
;; presentations or streaming.
;;
;; They all accept either a font-spec, font string ("Input Mono-12"), or xlfd
;; font string. You generally only need these two:
;; (setq doom-font (font-spec :family "monospace" :size 12 :weight 'semi-light)
;; doom-variable-pitch-font (font-spec :family "sans" :size 13))
(setq doom-font (font-spec :family "PragmataPro" :size 20 :weight 'regular)
doom-big-font (font-spec :family "PragmataPro" :size 30 :weight 'regular)
;; doom-variable-pitch-font (font-spec :family "PragmataPro" :size 20)
doom-variable-pitch-font (font-spec :family "Overpass" :size 20 :weight 'thin)
doom-unicode-font (font-spec :family "PragmataPro" :size 20)
doom-serif-font (font-spec :family "Baskerville" :size 20))
;; There are two ways to load a theme. Both assume the theme is installed and
;; available. You can either set `doom-theme' or manually load a theme with the
;; `load-theme' function. This is the default:
(setq doom-theme 'doom-one)
(remove-hook 'window-setup-hook #'doom-init-theme-h)
(add-hook 'after-init-hook #'doom-init-theme-h 'append)
(delq! t custom-theme-load-path)
(setq doom-modeline-height 45)
;; If you use `org' and don't want your org files in the default location below,
;; change `org-directory'. It must be set before org loads!
(setq org-directory "~/Nextcloud/Org")
;; Some nicer defaults
(setq doom-fallback-buffer-name "*Doom*"
+doom-dashboard-name "*Doom*")
(map! :g "s-<right>" #'next-buffer
:g "s-<left>" #'previous-buffer)
;; This determines the style of line numbers in effect. If set to `nil', line
;; numbers are disabled. For relative line numbers, set this to `relative'.
(setq display-line-numbers-type t)
(setq projectile-project-search-path "~/Projects")
(require 's)
(when (eq system-type 'gnu/linux)
(when (s-contains? "microsoft" operating-system-release t)
(progn
(setq org-directory "/mnt/c/Users/Levi/Nextcloud/Org")
(add-to-list 'default-frame-alist '(top . 400))
(add-to-list 'default-frame-alist '(left . 750))
(add-to-list 'default-frame-alist '(height . 60))
(add-to-list 'default-frame-alist '(width . 235))
(setq browse-url-chrome-program "/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe")
(setq browse-url-chromium-program "/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe")
)))
(when (eq system-type 'darwin)
(progn
(setq org-directory "/Users/leviolson/Nextcloud/Org")
(add-to-list 'default-frame-alist '(top . 0))
(add-to-list 'default-frame-alist '(left . 0))
(add-to-list 'default-frame-alist '(height . 49))
(add-to-list 'default-frame-alist '(width . 178))
(setq browse-url-chrome-program "/Applications/Safari.app")
(setq browse-url-chromium-program "/Applications/Safari.app")
))
;; Here are some additional functions/macros that could help you configure Doom:
;;
;; - `load!' for loading external *.el files relative to this one
;; - `use-package!' for configuring packages
;; - `after!' for running code after a package has loaded
;; - `add-load-path!' for adding directories to the `load-path', relative to
;; this file. Emacs searches the `load-path' when you load packages with
;; `require' or `use-package'.
;; - `map!' for binding new keys
;;
;; To get information about any of these functions/macros, move the cursor over
;; the highlighted symbol at press 'K' (non-evil users must press 'C-c c k').
;; This will open documentation for it, including demos of how they are used.
;;
;; You can also try 'gd' (or 'C-c c d') to jump to their definition and see how
;; they are implemented.
(unless (string-match-p "^Power N/A" (battery)) ; On laptops...
(display-battery-mode 1))
(display-time-mode 1)
(global-subword-mode 1)
(defvar mixed-pitch-modes '(org-mode LaTeX-mode markdown-mode gfm-mode Info-mode)
"Modes that `mixed-pitch-mode' should be enabled in, but only after UI initialisation.")
(defun init-mixed-pitch-h ()
"Hook `mixed-pitch-mode' into each mode in `mixed-pitch-modes'.
Also immediately enables `mixed-pitch-modes' if currently in one of the modes."
(when (memq major-mode mixed-pitch-modes)
(mixed-pitch-mode 1))
(dolist (hook mixed-pitch-modes)
(add-hook (intern (concat (symbol-name hook) "-hook")) #'mixed-pitch-mode)))
(add-hook 'doom-init-ui-hook #'init-mixed-pitch-h)
(defun my-generate-tab-stops (&optional width max)
"Return a sequence suitable for `tab-stop-list'."
(let* ((max-column (or max 200))
(tab-width (or width tab-width))
(count (/ max-column tab-width)))
(number-sequence tab-width (* tab-width count) tab-width)))
(defun my-setup-indent (n)
(setq c-basic-offset n)
(setq coffee-tab-width n) ; coffeescript
(setq javascript-indent-level n) ; javascript-mode
(setq js-indent-level n) ; js-mode
(setq js2-basic-offset n) ; js2-mode, in latest js2-mode, it's alias of js-indent-level
(setq web-mode-markup-indent-offset n) ; web-mode, html tag in html file
(setq web-mode-css-indent-offset n) ; web-mode, css in html file
(setq web-mode-code-indent-offset n) ; web-mode, js code in html file
(setq css-indent-offset n) ; css-mode
(setq tab-width n)
(setq indent-tabs-mode nil)
(setq tab-stop-list (my-generate-tab-stops))
)
(my-setup-indent 2)
(load! "functions.el")
(use-package! functions)
;; (load! "setup-elfeed.el")
;; (use-package! setup-elfeed)
;; (load! "fancy-banner.el")
;; (use-package! fancy-banner)
(use-package! emacs
:config
(setq +ligatures-in-modes '(not special-mode comint-mode eshell-mode term-mode
vterm-mode Info-mode elfeed-search-mode elfeed-show-mode)))
(use-package! magit-delta
:hook (magit-mode . magit-delta-mode))
;; Tabnine::version ;; Which version of Tabnine
;; Tabnine::restart ;; restart the Tabnine service
;; Tabnine::sem ;; enables semantic completion for the current language
;; Tabnine::no_sem ;; disables semantic completion for the current language
;; Tabnine::active ;; checks if Tabnine is activated
;; Tabnine::config ;; to open the config
;; Tabnine::config_dir ;; /Users/leviolson/Library/Preferences/TabNine
(use-package company-tabnine
:ensure t
:config
(add-to-list 'company-backends 'company-tabnine))
(use-package! graphql-mode
:config
(set-company-backend! 'graphql-mode '(:separate company-tabnine company-capf company-yasnippet)))
(use-package! emacs
:config
(set-company-backend! 'emacs-lisp-mode '(:separate company-tabnine company-capf company-yasnippet)))
;; (use-package! typescript-mode
;; :config
;; (set-company-backend! 'typescript-mode '(company-tabnine company-capf company-yasnippet)))
(use-package! company
:config
;; Trigger completion immediately.
(setq company-idle-delay 0.2)
;; Number the candidates (use M-1, M-2 etc to select completions).
(setq company-show-quick-access nil))
(use-package! darkroom
:commands darkroom-mode
:custom
(darkroom-margins (cons 40 0))
(darkroom-text-scale-increase 0)
(darkroom-fringes-outside-margins nil)
(darkroom-margin-increment 0.2)
)
(use-package! org
;; :disabled t
:commands org-capture
:mode ("\\.org\\'" . org-mode)
:bind (
("C-," . org-cycle-agenda-files)
;; ("C-c C-d" . org-capture)
:map org-mode-map
("M-n" . leo/org-narrow-next-tree)
("M-p" . leo/org-narrow-prev-tree)
("M-P" . leo/org-present)
)
:preface
(defvar org-html-validation-link)
(defvar org-html-text-markup-alist)
(defvar org-capture-templates)
:init
(setq org-agenda-files (list (concat org-directory "/todo.org")
(concat org-directory "/projects.org")
(concat org-directory "/Recipies.org")
(concat org-directory "/help.org")
(concat org-directory "/personal.org")
(concat org-directory "/archive.org")
))
(setq org-agenda-include-diary t)
(add-to-list 'safe-local-variable-values '(eval leo/deft-insert-boilerplate))
(setq org-refile-targets '((nil :maxlevel . 3)
(org-agenda-files :maxlevel . 3))
org-default-notes-file (concat org-directory "/todo.org"))
(setq org-todo-keyword-faces
'(("TODO" . org-roam-link-shielded)
("WAIT" . org-roam-link-shielded)
("HOLD" . org-roam-link-shielded)
("NEXT" . org-roam-link-current)
("PLAN" . org-target)
("SPIKE" . org-target)
("ACTIVE" . org-todo)))
(setq org-todo-keywords '(
(sequence "TODO(t)" "NEXT(n)" "|" "DONE(d!)")
(sequence "PLAN(p)" "SPIKE(s)" "ACTIVE(a)" "WAIT(w@/!)" "HOLD(h)" "|" "DONE(d!)" "CANCELLED(c@)")
))
:config
(require 'org-protocol)
(org-babel-do-load-languages 'org-babel-load-languages '((js . t)
(typescript . t)
(shell . t)
(apex . t)
(soql . t)
(emacs-lisp . t)))
(setq org-capture-templates
'(("w" "Default template" entry (file+headline org-default-notes-file "Unfiled")
"* %^{Title}%?\n\nSource: %:link\n:COPIED_TEXT:\n %i\n:END:\n")
("t" "new task" entry (file+headline (concat org-directory "/todo.org") "Tasks")
"* TODO [#A] %?\nSCHEDULED: %(org-insert-time-stamp (org-read-date nil t \"+0d\"))\n%a\n")
("n" "new note" entry (file+headline org-default-notes-file "Notes")
"* %?\n%i\n")
("l" "store link" entry (file+olp org-default-notes-file "Links" "Unfiled")
"* %a\n%?\n")
))
(setq org-structure-template-alist
'(("r" . "src restclient :results raw")
("j" . "src js :cmd \"/usr/local/bin/babel-node\" :results output code")
("e" . "src emacs-lisp :results silent")
("a" . "export ascii")
("c" . "center")
("C" . "comment")
("E" . "export")
("h" . "export html")
("l" . "export latex")
("q" . "quote")
("s" . "src")
("v" . "verse")))
(defconst checkbox-fontlock-keywords-alist
(mapcar (lambda (regex-char-pair)
`(,(car regex-char-pair)
(0 (prog1 ()
(compose-region (match-beginning 1)
(match-end 1)
,(concat (list ?\C-i)
(list (decode-char 'ucs (cadr regex-char-pair)))))))))
'(("\\(\\[ \\]\\)" #XF096);2B1C;F096;
("\\(\\[-\\]\\)" #XF147);29C7;F458;F147;
("\\(\\[X\\]\\)" #XF046);2BBD;F046;
)))
(defun add-checkbox-symbol-keywords ()
"Add checkbox font to font-lock."
(font-lock-add-keywords nil checkbox-fontlock-keywords-alist))
(add-hook 'org-mode-hook 'add-checkbox-symbol-keywords)
(add-hook 'org-mode-hook '(lambda ()
(visual-line-mode 0)
(variable-pitch-mode 1)
(org-indent-mode)
(auto-fill-mode 0)
))
)
(use-package org-roam
:disabled t
:custom
(org-roam-directory (concat org-directory "/Roam/"))
(org-roam-link-title-format "r::%s")
:bind (:map org-roam-mode-map
(("C-c n l" . org-roam)
("C-c n f" . org-roam-find-file)
("C-c n g" . org-roam-graph))
:map org-mode-map
(("C-c n i" . org-roam-insert))
(("C-c n I" . org-roam-insert-immediate))))
(use-package! deft
:bind
("C-c n d" . deft)
:config
(setq deft-recursive t
deft-use-filter-string-for-filename t
deft-default-extension "org"
deft-directory (concat org-directory "/Roam/")
deft-recursive-ignore-dir-regexp "\\(?:\\.\\|\\.\\.\\|setup\\)$"))
(use-package! org-pandoc-import
:after org
:commands (org-pandoc-import-html-as-org org-pandoc-import-html-to-org)
:config
(org-pandoc-import-backend html)
)
(use-package! lsp-mode
:config
(setq +lsp-company-backends '(:separate company-tabnine company-lsp company-yasnippet company-capf))
(setq lsp-enable-symbol-highlighting nil
lsp-headerline-breadcrumb-enable t))
(use-package! apex-mode
:mode "\\.cls\\'"
:bind ("M-q" . #'leo/kill-this-buffer-unless-scratch)
)
(use-package! web-mode
:mode "\\.\\(app\\|page\\)\\'")
(use-package! so-long
:config
(setq so-long-action 'so-long-minor-mode))
(use-package! dired
:config
(setq dired-listing-switches "-ahgo --group-directories-first"))
(use-package! dired-x
:disabled t
:custom
(dired-omit-files nil))
(use-package! hydra
:ensure t)
(use-package! elfeed
:after hydra
:bind (:map elfeed-search-mode-map
("a" . elfeed-search-clear)
("e" . elfeed-search-emacs)
("E" . (lambda () (interactive) (elfeed-search-toggle "+emacs")))
("t" . elfeed-search-tesla)
("T" . (lambda () (interactive) (elfeed-search-toggle "+tesla")))
("y" . elfeed-search-video)
("Y" . (lambda () (interactive) (elfeed-search-toggle "+youtube")))
("v" . elfeed-search-browse-url)
("o" . elfeed-search-show-entry)
("g" . elfeed-search-fetch)
("U" . elfeed-search-toggle-unread)
)
:config
(defun elfeed-search-clear () (interactive) (setq elfeed-search-filter "") (elfeed-search-update :force))
(defun elfeed-search-emacs () (interactive) (setq elfeed-search-filter "+emacs") (elfeed-search-update :force))
(defun elfeed-search-tesla () (interactive) (setq elfeed-search-filter "+tesla") (elfeed-search-update :force))
(defun elfeed-search-video () (interactive) (setq elfeed-search-filter "+youtube") (elfeed-search-update :force))
(defun elfeed-search-toggle-unread ()
(interactive)
(let ((filter elfeed-search-filter))
(if (s-contains-p "+unread" filter)
(setq elfeed-search-filter (s-trim (s-replace "+unread" "" filter)))
(setq elfeed-search-filter (concat filter " +unread"))))
(elfeed-search-update :force)
)
(defun elfeed-search-toggle (term)
"Accepts a TERM and returns a function that toggles TERM in the `elfeed' filter."
(interactive "Mtag: ")
(let ((filter elfeed-search-filter))
(if (s-contains-p term filter)
(setq elfeed-search-filter (s-trim (s-replace term "" filter)))
(setq elfeed-search-filter (concat filter " " term))))
(elfeed-search-update :force)
)
)
(after! xref
(add-to-list '+lookup-provider-url-alist '("Melpa" "https://melpa.org/#/?q=%s"))
(add-to-list '+lookup-provider-url-alist '("GitHub - LifeOmic" "https://github.com/search?q=user:LifeOmic+%s")))
;;;;;;;;;;;
;; HOOKS ;;
;;;;;;;;;;;
(add-hook 'text-mode-hook 'leo/remove-dos-eol) ;; Don't show `^M' at the end of lines
(add-hook 'prog-mode-hook 'leo/remove-dos-eol) ;; same, but for prog modes
;;;;;;;;;;;;;;;;;
;; KEYBINDINGS ;;
;;;;;;;;;;;;;;;;;
(map! :map global-map
:prefix "C-x"
"C-l" nil
(:prefix ("C-l" . "launch app")
"a" #'org-agenda
"e" #'elfeed
"g" #'magit-status
))
(map! :map global-map
:prefix "C-c"
"a" nil
(:prefix ("a" . "launch app")
"a" #'org-agenda
"e" #'elfeed
"g" #'magit-status
))
(map! :map comint-mode-map
"q" '(lambda()
(interactive)
(if (s-contains? "sfdx" (buffer-name))
(progn
(leo/kill-this-buffer-unless-scratch)
(+workspace/close-window-or-workspace)
))))
(map! :map xwidget-webkit-mode-map
"C-i" 'xwidget-webkit-insert-string
"C-m" 'xwidget-webkit-insert-string
"C-s" 'isearch-forward
"M-w" 'xwidget-webkit-copy-selection-as-kill
"C-w" 'xwidget-webkit-copy-selection-as-kill
"o" 'xwidget-webkit-goto-url
"C-l" 'xwidget-webkit-goto-url
"n" 'xwidget-webkit-scroll-up
"p" 'xwidget-webkit-scroll-down
"C-y" 'yank
)
(defun leo/search-lifeomic-repos()
"Search for LifeOmic Repo"
(interactive)
(setq query (read-string (format "Search for repository (in %s): " "LifeOmic")))
(funcall +lookup-open-url-fn (format "https://github.com/search?q=user:LifeOmic+%s" (url-encode-url query)))
)
(use-package! vs-restclient
:bind (:map vs-restclient-mode-map
("C-c C-c" . 'vs-restclient-http-send-current-stay-in-window))
:ensure t)
(use-package! vs-restclient-jq
:after vs-restclient
:ensure t
:config
(vs-restclient-register-result-func
"jq-set-var" #'vs-restclient-jq-json-var-function
"Set a vs-restclient variable with the value jq expression,
takes var & jq expression as args.
eg. -> jq-set-var :my-token .token")
(define-key vs-restclient-response-mode-map (kbd "C-c C-j") #'vs-restclient-jq-interactive-result)
)
(map! :map global-map
"M-t" #'treemacs-select-window
"M-q" #'leo/kill-this-buffer-unless-scratch
"M-RET" #'eshell
:desc "Format Document or Region"
"C-<tab>" #'leo/tidy
:desc "Comment or Uncomment Line or Region"
"C-;" #'leo/comment-or-uncomment-region-or-line
:desc "Open Private Doom Config"
"C-c C-e" #'leo/edit-config
"C-c d" #'leo/duplicate-thing
"C-c g" #'magit-status
"M-n" #'leo/jump-to-next-symbol
"M-p" #'leo/jump-to-prev-symbol
"M-u" #'upcase-dwim
"M-c" #'capitalize-dwim
"M-l" #'downcase-dwim
:desc "Search LifeOmic Repos"
"C-c s g" #'leo/search-lifeomic-repos
;; Perspective.el
"C-c C-n" #'persp-next
"C-c C-p" #'persp-prev
"C-c C-r" #'persp-rename
"C-c C-l" #'persp-switch
"C-c C-s" #'persp-switch
"C-c b" #'ivy-switch-buffer
;; "C-c b" #'counsel-switch-buffer
"C-s" #'swiper
"C-}" #'mc/mark-next-like-this
"C-)" #'mc/unmark-next-like-this
"C-{" #'mc/mark-previous-like-this
"C-(" #'mc/unmark-previous-like-this
"C-M-}" #'mc/mark-next-like-this-word
"C-M-)" #'mc/unmark-next-like-this
"C-M-{" #'mc/mark-previous-like-this-word
"C-M-(" #'mc/unmark-previous-like-this
"C-@" #'er/expand-region
"C-#" #'er/contract-region
)