From 9dcc0b756204771137cdd28239a2e29f03c1c41f Mon Sep 17 00:00:00 2001 From: Roger Gonzalez Date: Sun, 1 Oct 2023 22:41:52 -0300 Subject: Changed Emacs config to a literate config --- .config/doom/config.el | 274 +++++++++++++++---------------------------------- 1 file changed, 85 insertions(+), 189 deletions(-) (limited to '.config/doom/config.el') diff --git a/.config/doom/config.el b/.config/doom/config.el index 7758c93b..51878c0d 100644 --- a/.config/doom/config.el +++ b/.config/doom/config.el @@ -1,46 +1,12 @@ -;;; $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 "Roger Gonzalez" user-mail-address "roger@rogs.me") -;; Add custom packages -(add-to-list 'load-path "~/.config/doom/custom-packages") +(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)))) -;; Load custom packages -(require 'screenshot) -(require 'ox-slack) -(require 'deferred) -(require 'private) ;; Private file. Generate manually - -;; 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 "Mononoki Nerd Font" :size 14) - doom-variable-pitch-font (font-spec :family "sans") - doom-big-font (font-spec :family "Mononoki Nerd Font" :size 24)) -(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)) - -;; 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: (after! doom-themes (setq doom-themes-enable-bold t doom-themes-enable-italic t)) @@ -49,87 +15,11 @@ '(font-lock-keyword-face :slant italic)) (setq doom-theme 'doom-badger) -;; Update init file -;; More info here: https://github.com/doomemacs/doomemacs/issues/581#issuecomment-645448095 -(defun doom/ediff-init-and-example () - "ediff the current `init.el' with the example in doom-emacs-dir" - (interactive) - (ediff-files (concat doom-user-dir "init.el") - (concat doom-emacs-dir "templates/init.example.el"))) - -(define-key! help-map "di" #'doom/ediff-init-and-example) +(setq display-line-numbers-type 'relative) -;; 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 "~/org/") (setq org-roam-directory "~/roam/") -;; 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 'relative) - - -;; 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. -;; HTTP Statuses for Helm -(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*")) - -;; Org Mode (after! org ;; Include diary (setq org-agenda-include-diary t) @@ -355,17 +245,9 @@ text and copying to the killring." (require 'org-download) (add-hook 'dired-mode-hook 'org-download-enable)) -;; My own menu -(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 - )) - -;; Python +(after! lsp-mode + (setq lsp-headerline-breadcrumb-enable t) + (setq lsp-headerline-breadcrumb-icons-enable t)) (require 'auto-virtualenv) (after! python @@ -373,80 +255,98 @@ text and copying to the killring." (add-hook 'python-mode-hook 'auto-virtualenv-set-virtualenv) (setq enable-local-variables :all)) -;; LSP config -(after! lsp-mode - (setq lsp-headerline-breadcrumb-enable t) - (setq lsp-headerline-breadcrumb-icons-enable t)) +(after! groovy-mode + (define-key groovy-mode-map (kbd "") 'my/jenkins-verify)) + +(setq lsp-go-analyses '((shadow . t) + (simplifycompositelit . :json-false))) + +(add-to-list 'load-path "~/.config/doom/custom-packages") + +(require 'screenshot) +(require 'private) + +(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) + +(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*")) -;; Create new spikes, saved for later -;; (defun certn/new-spike () -;; "Create a new org spike in ~/org/Lazer/Certn/." -;; (interactive) -;; (let ((name (read-string "Ticket: "))) -;; (expand-file-name (format "%s.org" name) "~/org/Lazer/Certn/Spikes"))) - - -;; Dashboard mode -;; (use-package dashboard -;; :init ;; tweak dashboard config before loading it -;; (setq dashboard-set-heading-icons t) -;; (setq dashboard-set-file-icons t) -;; (setq dashboard-center-content nil) ;; set to 't' for centered content -;; (setq dashboard-items '((recents . 5) -;; (bookmarks . 5) -;; (projects . 5))) -;; (setq dashboard-set-navigator t) -;; :config -;; (dashboard-setup-startup-hook) -;; (dashboard-modify-heading-icons '((recents . "file-text") -;; (bookmarks . "book")))) -;; (setq initial-buffer-choice (lambda () (get-buffer-create "*dashboard*"))) -;; (setq doom-fallback-buffer-name "*dashboard*") - -(defun my/html2org-clipboard () - "Convert clipboard contents from HTML to Org and then paste (yank)." +(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")) -(define-key org-mode-map (kbd "") 'my/html2org-clipboard) +(after! org + (define-key org-mode-map (kbd "") 'rg/html2org-clipboard)) + +(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 + )) -;; Clipmon as emacs clipboard manager (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) -(after! groovy-mode - (define-key groovy-mode-map (kbd "") 'my/jenkins-verify)) +(after! forge +(add-to-list 'forge-alist '("github.com-underarmour" forge-github-repository))) -;; Git -(setq forge-alist '(("github.com-underarmour" "api.github.com" "github.com" forge-github-repository) - ("github.com" "api.github.com" "github.com" forge-github-repository) - ("gitlab.com" "gitlab.com/api/v4" "gitlab.com" forge-gitlab-repository) - ("salsa.debian.org" "salsa.debian.org/api/v4" "salsa.debian.org" forge-gitlab-repository) - ("framagit.org" "framagit.org/api/v4" "framagit.org" forge-gitlab-repository) - ("gitlab.gnome.org" "gitlab.gnome.org/api/v4" "gitlab.gnome.org" forge-gitlab-repository) - ("codeberg.org" "codeberg.org/api/v1" "codeberg.org" forge-gitea-repository) - ("code.orgmode.org" "code.orgmode.org/api/v1" "code.orgmode.org" forge-gogs-repository) - ("bitbucket.org" "api.bitbucket.org/2.0" "bitbucket.org" forge-bitbucket-repository) - ("git.savannah.gnu.org" nil "git.savannah.gnu.org" forge-cgit**-repository) - ("git.kernel.org" nil "git.kernel.org" forge-cgit-repository) - ("repo.or.cz" nil "repo.or.cz" forge-repoorcz-repository) - ("git.suckless.org" nil "git.suckless.org" forge-stagit-repository) - ("git.sr.ht" nil "git.sr.ht" forge-srht-repository))) - -;;;; Use delta instead of the default diff (add-hook 'magit-mode-hook (lambda () (magit-delta-mode +1))) -;; ChatGPT (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") -;; Github Copilot -;; accept completion from copilot and fallback to company -;; More info https://robert.kra.hn/posts/2023-02-22-copilot-emacs-setup/ (use-package! copilot :hook (prog-mode . copilot-mode) :bind (:map copilot-completion-map @@ -455,18 +355,14 @@ text and copying to the killring." ("C-TAB" . 'copilot-accept-completion-by-word) ("C-" . 'copilot-accept-completion-by-word))) -;; PlantUML (setq plantuml-executable-path "/usr/bin/plantuml") (setq plantuml-default-exec-mode 'executable) (setq org-plantuml-exec-mode 'plantuml) (setq plantuml-server-url 'nil) -(add-to-list 'org-src-lang-modes '("plantuml" . plantuml)) (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"))) - -;; Go -(setq lsp-go-analyses '((shadow . t) - (simplifycompositelit . :json-false))) +(after! org +(add-to-list 'org-src-lang-modes '("plantuml" . plantuml))) -- cgit v1.2.3