diff options
author | Roger Gonzalez <roger@rogs.me> | 2023-10-01 22:41:52 -0300 |
---|---|---|
committer | Roger Gonzalez <roger@rogs.me> | 2023-10-01 22:41:52 -0300 |
commit | 9dcc0b756204771137cdd28239a2e29f03c1c41f (patch) | |
tree | d4dfcb03218e7a20551841db90e5c53ae3c18a9a /.config/doom/config.org | |
parent | 803aca06e3f3c2e39cc492ee5c66b1c631d22628 (diff) |
Changed Emacs config to a literate config
Diffstat (limited to '.config/doom/config.org')
-rw-r--r-- | .config/doom/config.org | 583 |
1 files changed, 583 insertions, 0 deletions
diff --git a/.config/doom/config.org b/.config/doom/config.org new file mode 100644 index 00000000..dd8069f3 --- /dev/null +++ b/.config/doom/config.org @@ -0,0 +1,583 @@ +#+TITLE: rogs DOOM Emacs config +#+AUTHOR: Roger Gonzalez (rogs) +#+DESCRIPTION: rogs personal Doom Emacs config. + +* Basic configuration +:PROPERTIES: +:ID: 4e8ec984-b517-4e34-b018-7464650b2b9f +:END: + +First off, set my user and email +#+begin_src emacs-lisp +(setq user-full-name "Roger Gonzalez" + user-mail-address "roger@rogs.me") +#+end_src + +* Look and feel +:PROPERTIES: +:ID: 0b198a7a-c736-4dd4-84a3-0ea21bcdc4fb +:END: + +This part of the configuration focus on the look and feel of Doom Emacs. + +** Fonts +:PROPERTIES: +:ID: b4df4ef4-d0ca-4047-90b3-f4128425aa9f +:END: + +This works only in Linux. On MacOS we keep the default fonts. + +#+begin_src emacs-lisp +(if (not (eq system-type 'darwin)) + (progn + (setq doom-font (font-spec :family "MesloLGS NF" :size 14) + doom-variable-pitch-font (font-spec :family "sans") + doom-big-font (font-spec :family "MesloLGS NF" :size 24)))) +#+end_src + +** Theme +:PROPERTIES: +:ID: 3bae130e-3336-4bc7-9378-82c315e2aea6 +:END: + +#+begin_src emacs-lisp +(after! doom-themes + (setq doom-themes-enable-bold t + doom-themes-enable-italic t)) +(custom-set-faces! + '(font-lock-comment-face :slant italic) + '(font-lock-keyword-face :slant italic)) +(setq doom-theme 'doom-badger) +#+end_src + +** Misc +:PROPERTIES: +:ID: cf3c202b-7610-4038-8e15-654a95a9d1dc +:END: + +*** Display relative numbers on the buffer +:PROPERTIES: +:ID: 6a510691-0b78-44b8-ab92-518971051d8a +:END: +#+begin_src emacs-lisp +(setq display-line-numbers-type 'relative) +#+end_src + +* Org Mode + Org Roam +:PROPERTIES: +:ID: 96b93a81-3272-4f7a-a667-8a8783849d64 +:END: + +The big one. My entire life is in Org Mode and/or Org Roam. + +** Set the directory +:PROPERTIES: +:ID: 99cbc04c-604c-4427-94fc-aa0603c78809 +:END: + +#+begin_src emacs-lisp +(setq org-directory "~/org/") +(setq org-roam-directory "~/roam/") +#+end_src + +** Configuration +:PROPERTIES: +:ID: 37915445-e875-4da0-bab0-3f8f8b8e89f5 +:END: + +TODO: Breakup later + +#+begin_src emacs-lisp +(after! org + ;; Include diary + (setq org-agenda-include-diary t) + ;; Logs + (setq org-log-state-notes-insert-after-drawers nil + org-log-into-drawer "LOGBOOK" + org-log-done 'time + org-log-repeat 'time + org-log-redeadline 'note + org-log-reschedule 'note) + ;; Keyword and faces + (setq-default org-todo-keywords + '((sequence "REPEAT(r)" "NEXT(n@/!)" "DELEGATED(e@/!)" "TODO(t@/!)" "WAITING(w@/!)" "SOMEDAY(s@/!)" "PROJ(p)" "|" "DONE(d@)" "CANCELLED(c@/!)" "FORWARDED(f@)"))) + (setq-default org-todo-keyword-faces + '( + ( "REPEAT" . (:foreground "white" :background "indigo" :weight bold)) + ( "NEXT" . (:foreground "red" :background "orange" :weight bold)) + ( "DELEGATED" . (:foreground "white" :background "blue" :weight bold)) + ( "TODO" . (:foreground "white" :background "violet" :weight bold)) + ( "WAITING" (:foreground "white" :background "#A9BE00" :weight bold)) + ( "SOMEDAY" . (:foreground "white" :background "#00807E" :weight bold)) + ( "PROJ" . (:foreground "white" :background "deeppink3" :weight bold)) + ( "DONE" . (:foreground "white" :background "forest green" :weight bold)) + ( "CANCELLED" . (:foreground "light gray" :slant italic)) + ( "FORWARDED" . (:foreground "light gray" :slant italic)) + )) + (setq org-fontify-done-headline t) + (setq org-fontify-todo-headline t) + ;; Priorities + ;; A: Do it now + ;; B: Decide when to do it + ;; C: Delegate it + ;; D: Just an idea + (setq org-highest-priority ?A) + (setq org-lowest-priority ?D) + (setq org-default-priority ?B) + (setq org-priority-faces '((?A . (:foreground "white" :background "dark red" :weight bold)) + (?B . (:foreground "white" :background "dark green" :weight bold)) + (?C . (:foreground "yellow")) + (?D . (:foreground "gray")))) + ;; Capture templates + (setq org-capture-templates + (quote + ( + ("G" "Define a goal" entry (file+headline "~/org/capture.org" "Capture") (file "~/org/templates/goal.org") :empty-lines-after 1) + ("R" "REPEAT entry" entry (file+headline "~/org/capture.org" "Capture") (file "~/org/templates/repeat.org") :empty-lines-before 1) + ("N" "NEXT entry" entry (file+headline "~/org/capture.org" "Capture") (file "~/org/templates/next.org") :empty-lines-before 1) + ("T" "TODO entry" entry (file+headline "~/org/capture.org" "Capture") (file "~/org/templates/todo.org") :empty-lines-before 1) + ("W" "WAITING entry" entry (file+headline "~/org/capture.org" "Capture") (file "~/org/templates/waiting.org") :empty-lines-before 1) + ("S" "SOMEDAY entry" entry (file+headline "~/org/capture.org" "Capture") (file "~/org/templates/someday.org") :empty-lines-before 1) + ("P" "PROJ entry" entry (file+headline "~/org/capture.org" "Capture") (file "~/org/templates/proj.org") :empty-lines-before 1) + ("B" "Book on the to-read-list" entry (file+headline "~/org/private.org" "Libros para leer") (file "~/org/templates/book.org") :empty-lines-after 2) + ("p" "Create a daily plan") + ("pP" "Daily plan private" plain (file+olp+datetree "~/org/plan-free.org") (file "~/org/templates/dailyplan.org") :immediate-finish t :jump-to-captured t) + ("pX" "Daily plan X-Team" plain (file+olp+datetree "~/org/plan-xteam.org") (file "~/org/templates/dailyplan.org") :immediate-finish t :jump-to-captured t) + ("j" "Journal entry") + ("jP" "Journal entry private" entry (file+olp+datetree "~/org/journal-private.org") "** %U - %^{Heading}") + ("jX" "Journal entry X-Team" entry (file+olp+datetree "~/org/journal-xteam.org") "** %U - %^{Heading}") + ))) + ;; Custom agenda views + (setq org-agenda-custom-commands + (quote + ( + ("A" . "Agendas") + ("AT" "Daily overview" + ((tags-todo "URGENT" + ((org-agenda-overriding-header "Urgent Tasks"))) + (tags-todo "RADAR" + ((org-agenda-overriding-header "On my radar"))) + (tags-todo "PHONE+TODO=\"NEXT\"" + ((org-agenda-overriding-header "Phone Calls"))) + (tags-todo "COMPANY" + ((org-agenda-overriding-header "Cuquitoni"))) + (tags-todo "SHOPPING" + ((org-agenda-overriding-header "Shopping"))) + (tags-todo "Depth=\"Deep\"/NEXT" + ((org-agenda-overriding-header "Next Actions requiring deep work"))) + (agenda "" + ((org-agenda-overriding-header "Today") + (org-agenda-span 1) + (org-agenda-start-day "1d") + (org-agenda-sorting-strategy + (quote + (time-up priority-down))))) + nil nil)) + ("AW" "Weekly overview" agenda "" + ((org-agenda-overriding-header "Weekly overview"))) + ("AM" "Monthly overview" agenda "" + ((org-agenda-overriding-header "Monthly overview")) + (org-agenda-span + (quote month)) + (org-deadline-warning-days 0) + (org-agenda-sorting-strategy + (quote + (time-up priority-down tag-up)))) + ("W" . "Weekly Review Helper") + ("Wn" "New tasks" tags "NEW" + ((org-agenda-overriding-header "NEW Tasks"))) + ("Wd" "Check DELEGATED tasks" todo "DELEGATED" + ((org-agenda-overriding-header "DELEGATED tasks"))) + ("Ww" "Check WAITING tasks" todo "WAITING" + ((org-agenda-overriding-header "WAITING tasks"))) + ("Ws" "Check SOMEDAY tasks" todo "SOMEDAY" + ((org-agenda-overriding-header "SOMEDAY tasks"))) + ("Wf" "Check finished tasks" todo "DONE|CANCELLED|FORWARDED" + ((org-agenda-overriding-header "Finished tasks"))) + ("WP" "Planing ToDos (unscheduled) only" todo "TODO|NEXT" + ((org-agenda-overriding-header "To plan") + (org-agenda-skip-function + (quote + (org-agenda-skip-entry-if + (quote scheduled) + (quote deadline))))))) + )) + ;; + ;; Enforce ordered tasks + (setq org-enforce-todo-dependencies t) + (setq org-enforce-todo-checkbox-dependencies t) + (setq org-track-ordered-property-with-tag t) + + ;; Org bullets + (require 'org-bullets) + (add-hook 'org-mode-hook (lambda () (org-bullets-mode 1))) + + ;; Org recur + (use-package org-recur + :hook ((org-mode . org-recur-mode) + (org-agenda-mode . org-recur-agenda-mode)) + :demand t + :config + (define-key org-recur-mode-map (kbd "C-c d") 'org-recur-finish) + + ;; Rebind the 'd' key in org-agenda (default: `org-agenda-day-view'). + (define-key org-recur-agenda-mode-map (kbd "C-c d") 'org-recur-finish) + (define-key org-recur-agenda-mode-map (kbd "C-c 0") 'org-recur-schedule-today) + + (setq org-recur-finish-done t + org-recur-finish-archive t)) + + ;; Truncate lines to 105 chars + ;; Why 105 chars? Because that's the max my screen can handle on vertical split + (add-hook 'org-mode-hook #'auto-fill-mode) + (setq-default fill-column 105) + + ;; Custom ORG functions + ;; Refresh org-agenda after rescheduling a task. + (defun org-agenda-refresh () + "Refresh all `org-agenda' buffers." + (dolist (buffer (buffer-list)) + (with-current-buffer buffer + (when (derived-mode-p 'org-agenda-mode) + (org-agenda-maybe-redo))))) + + (defadvice org-schedule (after refresh-agenda activate) + "Refresh org-agenda." + (org-agenda-refresh)) + + (defun org-focus-private() "Set focus on private things." + (interactive) + (setq org-agenda-files '("~/org/private.org")) + (message "Focusing on private Org files")) + (defun org-focus-xteam() "Set focus on X-Team things." + (interactive) + (setq org-agenda-files '("~/org/xteam.org")) + (message "Focusing on X-Team Org files")) + (defun org-focus-all() "Set focus on all things." + (interactive) + (setq org-agenda-files '("~/org/")) + (message "Focusing on all Org files")) + + (defun my/org-add-ids-to-headlines-in-file () + "Add ID properties to all headlines in the current file which +do not already have one." + (interactive) + (org-map-entries 'org-id-get-create)) + (add-hook 'org-mode-hook + (lambda () + (add-hook 'before-save-hook + 'my/org-add-ids-to-headlines-in-file nil 'local))) + (defun my/copy-idlink-to-clipboard() "Copy an ID link with the +headline to killring, if no ID is there then create a new unique +ID. This function works only in org-mode or org-agenda buffers. + +The purpose of this function is to easily construct id:-links to +org-mode items. If its assigned to a key it saves you marking the +text and copying to the killring." + (interactive) + (when (eq major-mode 'org-agenda-mode) ;if we are in agenda mode we switch to orgmode + (org-agenda-show) + (org-agenda-goto)) + (when (eq major-mode 'org-mode) ; do this only in org-mode buffers + (setq mytmphead (nth 4 (org-heading-components))) + (setq mytmpid (funcall 'org-id-get-create)) + (setq mytmplink (format "[[id:%s][%s]]" mytmpid mytmphead)) + (kill-new mytmplink) + (message "Copied %s to killring (clipboard)" mytmplink) + )) + + (global-set-key (kbd "<f5>") 'my/copy-idlink-to-clipboard) + + (defun org-reset-checkbox-state-maybe () + "Reset all checkboxes in an entry if the `RESET_CHECK_BOXES' property is set" + (interactive "*") + (if (org-entry-get (point) "RESET_CHECK_BOXES") + (org-reset-checkbox-state-subtree))) + + (defun org-checklist () + (when (member org-state org-done-keywords) ;; org-state dynamically bound in org.el/org-todo + (org-reset-checkbox-state-maybe))) + + (add-hook 'org-after-todo-state-change-hook 'org-checklist) + + (defun org-roam-node-insert-immediate (arg &rest args) + (interactive "P") + (let ((args (cons arg args)) + (org-roam-capture-templates (list (append (car org-roam-capture-templates) + '(:immediate-finish t))))) + (apply #'org-roam-node-insert args))) + + ;; Save all org buffers on each save + (add-hook 'auto-save-hook 'org-save-all-org-buffers) + (add-hook 'after-save-hook 'org-save-all-org-buffers) + (require 'org-download) + (add-hook 'dired-mode-hook 'org-download-enable)) +#+end_src + +* Programming languages +:PROPERTIES: +:ID: fcb176c9-c9e5-42f6-b31d-3dafe8d0f64b +:END: + +** LSP +:PROPERTIES: +:ID: 84836840-8642-46ad-8068-dc07086708f3 +:END: + +#+begin_src emacs-lisp +(after! lsp-mode + (setq lsp-headerline-breadcrumb-enable t) + (setq lsp-headerline-breadcrumb-icons-enable t)) +#+end_src + +** Python +:PROPERTIES: +:ID: 8f3279cf-53e2-4fe5-b30b-724d2d081cbe +:END: + +#+begin_src emacs-lisp +(require 'auto-virtualenv) +(after! python + :init + (add-hook 'python-mode-hook 'auto-virtualenv-set-virtualenv) + (setq enable-local-variables :all)) +#+end_src +** Groovy +:PROPERTIES: +:ID: 8f8956c2-a7a3-4508-8f30-dc7a2f5e105b +:END: + +#+begin_src emacs-lisp +(after! groovy-mode + (define-key groovy-mode-map (kbd "<f4>") 'my/jenkins-verify)) +#+end_src + +** Go +:PROPERTIES: +:ID: ee0c0fc1-7801-45ba-9302-73a78ce3d329 +:END: + +#+begin_src emacs-lisp +(setq lsp-go-analyses '((shadow . t) + (simplifycompositelit . :json-false))) +#+end_src + +* Custom +:PROPERTIES: +:ID: cd8a28bd-d91f-4ba8-b637-cb542ff5cca4 +:END: + +Here's where custom functionalities get configured. + +** Custom packages +:PROPERTIES: +:ID: 483ed79c-9eba-4544-8333-dda0139e9a08 +:END: + + | Package name | Description | URL | + |-----------------+------------------------------------------------+-----------------------------------------| + | ~screenshot.el~ | Good for taking screenshots directly in Emacs. | https://github.com/tecosaur/screenshot | + | ~private.el~ | This is a file for private values. | ~./custom-packages/private.el.example~. | + +#+begin_src emacs-lisp +(add-to-list 'load-path "~/.config/doom/custom-packages") + +(require 'screenshot) +(require 'private) +#+end_src + +** Custom functions +:PROPERTIES: +:ID: 0888b2db-9a0d-463d-89ad-371fcbfa0473 +:END: +*** Update DOOM Emacs init.el file +:PROPERTIES: +:ID: af485cc4-be52-4bb4-889d-7de8bea1ed66 +:END: + +This function brings up a comparisson between the current ~init.el~ file and the example file +(~templates/init.example.el~). Very useful for upgrading manually. + +More info here: https://github.com/doomemacs/doomemacs/issues/581#issuecomment-645448095 + +#+begin_src emacs-lisp +(defun rg/ediff-init-and-example () + (interactive) + (ediff-files (concat doom-user-dir "init.el") + (concat doom-emacs-dir "templates/init.example.el"))) + +(define-key! help-map "di" #'rg/ediff-init-and-example) +#+end_src +*** HTTP Statuses +:PROPERTIES: +:ID: 3fa9d843-f163-4f04-8129-918fb57603a4 +:END: + +This is a custom helm command that displays all the HTTP status with its description. + +#+begin_src emacs-lisp +(defvar helm-httpstatus-source + '((name . "HTTP STATUS") + (candidates . (("100 Continue") ("101 Switching Protocols") + ("102 Processing") ("200 OK") + ("201 Created") ("202 Accepted") + ("203 Non-Authoritative Information") ("204 No Content") + ("205 Reset Content") ("206 Partial Content") + ("207 Multi-Status") ("208 Already Reported") + ("300 Multiple Choices") ("301 Moved Permanently") + ("302 Found") ("303 See Other") + ("304 Not Modified") ("305 Use Proxy") + ("307 Temporary Redirect") ("400 Bad Request") + ("401 Unauthorized") ("402 Payment Required") + ("403 Forbidden") ("404 Not Found") + ("405 Method Not Allowed") ("406 Not Acceptable") + ("407 Proxy Authentication Required") ("408 Request Timeout") + ("409 Conflict") ("410 Gone") + ("411 Length Required") ("412 Precondition Failed") + ("413 Request Entity Too Large") + ("414 Request-URI Too Large") + ("415 Unsupported Media Type") + ("416 Request Range Not Satisfiable") + ("417 Expectation Failed") ("418 I'm a teapot") + ("421 Misdirected Request") + ("422 Unprocessable Entity") ("423 Locked") + ("424 Failed Dependency") ("425 No code") + ("426 Upgrade Required") ("428 Precondition Required") + ("429 Too Many Requests") + ("431 Request Header Fields Too Large") + ("449 Retry with") ("500 Internal Server Error") + ("501 Not Implemented") ("502 Bad Gateway") + ("503 Service Unavailable") ("504 Gateway Timeout") + ("505 HTTP Version Not Supported") + ("506 Variant Also Negotiates") + ("507 Insufficient Storage") ("509 Bandwidth Limit Exceeded") + ("510 Not Extended") + ("511 Network Authentication Required"))) + (action . message))) + +(defun helm-httpstatus () + (interactive) + (helm-other-buffer '(helm-httpstatus-source) "*helm httpstatus*")) +#+end_src + +*** Convert HTML to org +:PROPERTIES: +:ID: b81dff7f-9bc5-4601-97fe-6c2b9e78366c +:END: + +Depends on ~pandoc~ and ~xclip~. + +Convert clipboard contents from HTML to Org and then paste (yank). + +#+begin_src emacs-lisp +(defun rg/html2org-clipboard () + (interactive) + (kill-new (shell-command-to-string "timeout 1 xclip -selection clipboard -o -t text/html | pandoc -f html -t json | pandoc -f json -t org --wrap=none")) + (yank) + (message "Pasted HTML in org")) +(after! org + (define-key org-mode-map (kbd "<f4>") 'rg/html2org-clipboard)) +#+end_src +*** My own menu +:PROPERTIES: +:ID: 60a0316f-8bb8-40fe-af45-e42cdb6da60a +:END: + +This is a custom menu for my own functions + +#+begin_src emacs-lisp +(map! :leader + (:prefix-map ("a" . "applications") + :desc "HTTP Status cheatsheet" "h" #'helm-httpstatus) + (:prefix-map ("ao" . "org") + :desc "Org focus X-Team" "x" #'org-focus-xteam + :desc "Org focus private" "p" #'org-focus-private + :desc "Org focus all" "a" #'org-focus-all + )) +#+end_src +* Misc +:PROPERTIES: +:ID: b57fe5fe-18ce-4215-ba94-8deee3a2b64f +:END: +** Clipmon +:PROPERTIES: +:ID: 7b6776af-f357-4f87-9850-4eae4f8daa76 +:END: + +Clipmon is my clipboard manager in Emacs. + +#+begin_src emacs-lisp +(global-set-key (kbd "M-y") 'helm-show-kill-ring) +(add-to-list 'after-init-hook 'clipmon-mode-start) +(defadvice clipmon--on-clipboard-change (around stop-clipboard-parsing activate) (let ((interprogram-cut-function nil)) ad-do-it)) +(setq clipmon-timer-interval 1) +#+end_src + +** Git +:PROPERTIES: +:ID: 51176440-f985-4c90-94a7-bed48286272c +:END: +*** Add UnderArmour to forge-alist +:PROPERTIES: +:ID: 559b5963-3aee-480c-a982-7e49fa41c52b +:END: + +I had to do this to manage multiple git profiles. + +#+begin_src emacs-lisp +(after! forge +(add-to-list 'forge-alist '("github.com-underarmour" forge-github-repository))) +#+end_src + +*** Set ~delta~ as the default magit diff +:PROPERTIES: +:ID: fa6dc3cb-50d7-49cd-96cb-e91a122b1316 +:END: + +#+begin_src emacs-lisp +(add-hook 'magit-mode-hook (lambda () (magit-delta-mode +1))) +#+end_src + +** ChatGPT +:PROPERTIES: +:ID: 0a32d2a9-2156-42a3-90f7-419ac1a25496 +:END: + +#+begin_src emacs-lisp +(setq chatgpt-shell-model-version "gpt-4") +(setq chatgpt-shell-streaming "t") +(setq chatgpt-shell-system-prompt "You are a senior developer knowledgeable in every programming language") +#+end_src +** Github Copilot +:PROPERTIES: +:ID: 7f88ce20-846c-47e4-aeed-d853212c9db5 +:END: + +#+begin_src emacs-lisp +(use-package! copilot + :hook (prog-mode . copilot-mode) + :bind (:map copilot-completion-map + ("<tab>" . 'copilot-accept-completion) + ("TAB" . 'copilot-accept-completion) + ("C-TAB" . 'copilot-accept-completion-by-word) + ("C-<tab>" . 'copilot-accept-completion-by-word))) +#+end_src + +** PlantUML +:PROPERTIES: +:ID: 87ed3201-3df7-4ee1-a4ce-4fe8312f9d08 +:END: + +#+begin_src emacs-lisp +(setq plantuml-executable-path "/usr/bin/plantuml") +(setq plantuml-default-exec-mode 'executable) +(setq org-plantuml-exec-mode 'plantuml) +(setq plantuml-server-url 'nil) + +(org-babel-do-load-languages 'org-babel-load-languages '((plantuml . t))) +(add-to-list 'auto-mode-alist '("\\.plantuml\\'" . plantuml-mode)) +(setq org-babel-default-header-args:plantuml + '((:results . "verbatim") (:exports . "results") (:cache . "no"))) +(after! org +(add-to-list 'org-src-lang-modes '("plantuml" . plantuml))) +#+end_src |