Skip to content
/ emacs Public

Mi configuración de GNU Emacs, usando org-mode y org-babel :)

Notifications You must be signed in to change notification settings

shackra/emacs

Repository files navigation

Configuración de GNU Emacs usando Doom

                   ✝
Actiones nostras tibi comítimus, Dómine,
 ut ad maiorem gloriam tuam repleamur.
                 ✝   ✝

Tabla de contenidos

Preámbulo

Datos personales y opciones de Emacs lisp.

;; -*- lexical-binding: t; -*-

(setq user-full-name "Jorge Araya Navarro"
      user-mail-address "jorge@esavara.cr")

Configuración por defecto, sabor Jorge

Hay comportamientos en Emacs que me gustaría que fueran usados en Doom, y que se pueda activar como una bandera en :config default, los defino aquí.

;; cambia ubicacion de snippets para YaSnippet
(setf +snippets-dir (expand-file-name "plantillas" doom-private-dir))

Aspecto visual de GNU Emacs

(setq doom-theme 'doom-challenger-deep)
(after! doom-themes
  (setq doom-themes-enable-bold t
        doom-themes-enable-italic t
        doom-themes-treemacs-theme "doom-atom"
        doom-themes-treemacs-enable-variable-pitch nil))
(after! doom-modeline
  (setq doom-modeline-persp-name t)
  (setq doom-modeline-buffer-file-name-style 'relative-from-project)
  ;; ajusta el alto del modeline de doom-modeline
  (setq-default doom-modeline-height 40)
  ;; ajusta el ancho de la barra
  (setq-default doom-modeline-bar-width 10))
(after! uniquify
  ;; hace unicos los nombres de buffers
  (setq uniquify-buffer-name-style 'reverse)
  (setq uniquify-separator "")
  (setq uniquify-after-kill-buffer-p t)
  (setq uniquify-ignore-buffers-re "^\\*"))

(setq display-line-numbers-type t)

(setq fancy-splash-image (expand-file-name "dashboard/sacred-heart.svg" doom-private-dir))
;; TODO: cambiar arte ASCII

(custom-set-faces!
  '(aw-leading-char-face
    :foreground "white" :background 'consult-key
    :weight bold :height 2.5 :box (:line-width 10 :color 'consult-key)))

;; cambia el tamaño del primer marco al ancho y alto de la pantalla
(when IS-MAC
  (add-to-list 'initial-frame-alist '(fullscreen . maximized)))

(when IS-LINUX
  (setq-default highlight-indent-guides-method 'bitmap)
  (setq-default highlight-indent-guides-bitmap-function 'highlight-indent-guides--bitmap-dots))

tipografía

(setq doom-font  (font-spec :family "Iosevka Nerd Font Mono" :size 18)
      doom-big-font (font-spec :family "Iosevka Nerd Font Mono" :size 26 :weight 'normal)
      doom-variable-pitch-font (font-spec :family "Iosevka Comfy" :size 18)
      doom-serif-font (font-spec :family "Iosevka Comfy Motion Duo" :size 18)
      doom-symbol-font (font-spec :family "Julia Mono" :size 18))

(custom-set-faces!
  '(font-lock-comment-face :slant italic)
  '(font-lock-keyword-face :slant italic))

cambia comportamiento de TAB

No estoy interesado en insertar un tabulador al presionar TAB.

(setq tab-always-indent t)

historial de archivos recientes y proyectos

vamos a pedirle a recentf ignorar ciertos archivos.

(after! recentf
(add-to-list 'recentf-exclude "~/.config/emacs")
(add-to-list 'recentf-exclude "\\`/[^:]+:"))

Hacemos lo mismo para Projectile

(defun shackra/projectile-ignore-projects (project-root)
  (or (file-remote-p project-root)
      (doom-project-ignored-p project-root)
      (string-match-p "^/nix/store" project-root)
      (string-match-p "/node_modules/" project-root)
      (string-match-p "go/pkg/mod" project-root)))

(after! projectile
  (setq projectile-ignored-project-function #'shackra/projectile-ignore-projects)
  (setq projectile-project-search-path '(("~/code" . 4)
                                         ("~/Documentos/sotsf/proyectos" . 1)
                                         ("~/Documentos/Straubinger Digital" . 1))))

Org

configuración básica

(setq org-directory "~/org/")
(setq org-agenda-files (expand-file-name ".agendas" doom-private-dir))
(setq org-refile-targets `((nil :maxlevel . 9)
                           (org-agenda-files :maxlevel . 9)
                           (org-default-notes-file :maxlevel . 9)
                           (,(expand-file-name "quizas.org" org-directory) :maxlevel . 9)))

plantillas

(after! org
  (setq org-todo-keywords
        '((sequence "POR-HACER(p)" "SIGNT(s)" "|" "TERMINADO(t)")
          (sequence "ESPERA(e@/!)" "RETENER(r@/!)" "|" "CANCELADO(c@/!)")))
  (setq org-todo-keyword-faces
        '(("POR-HACER" :foreground "red" :weight bold)
          ("SIGNT" :foreground "blue" :weight bold)
          ("TERMINADO" :foreground "forest green" :weight bold)
          ("ESPERA" :foreground "orange" :weight bold)
          ("RETENER" :foreground "magenta" :weight bold)
          ("CANCELADO" :foreground "forest green" :weight bold)))
  (setq org-agenda-custom-commands
        '(("a" "Agenda"
           ((tags "PRIORITY=\"A\""
                  ((org-agenda-skip-function '(org-agenda-skip-entry-if 'todo 'done))
                   (org-agenda-overriding-header "Tareas de alta prioridad por terminar:")))
            (agenda ""
                    ((org-agenda-span 'day)
                     (org-agenda-overriding-header "Hoy:")
                     (org-agenda-show-all-dates nil)))
            (agenda ""
                    ((org-agenda-span 'week)
                     (org-agenda-start-day "+1d") ;; A partir de mañana
                     (org-agenda-overriding-header "Semana:")
                     (org-agenda-show-all-dates nil)))
            (agenda ""
                    ((org-agenda-span 'month)
                     ;; A partir de la siguiente semana
                     (org-agenda-start-day "+1w")
                     (org-agenda-overriding-header "Mes:")
                     (org-agenda-show-all-dates nil)))
            (alltodo ""
                     ((org-agenda-skip-function
                       '(and
                         (org-agenda-skip-if nil '(scheduled deadline))))
                      (org-agenda-overriding-header "Todas las tareas de prioridad normal:"))))))))

(after! org-capture
  (setq org-plantillas-directory (expand-file-name "org-plantillas" doom-private-dir))
  (setq org-default-notes-file (expand-file-name "notas.org" org-directory))
  (setq org-capture-templates `(("T" "Anotacion técnica" entry (file "apuntes tecnicos.org")
                                 (file ,(expand-file-name "anotacion tecnica.orgcaptmpl" org-plantillas-directory))
                                 :kill-buffer t :clock-in t :clock-resume t)))
  (add-to-list 'org-capture-templates `("t" "Tarea por hacer" entry (file "cosas por hacer.org")
                                        (file ,(expand-file-name "tareas por hacer.orgcaptmpl" org-plantillas-directory))
                                        :kill-buffer t :clock-in t :clock-resume t) :append)
  (add-to-list 'org-capture-templates `("c" "Agregar al calendario" entry (file "agenda.org")
                                        (file ,(expand-file-name "tareas por hacer.orgcaptmpl" org-plantillas-directory))
                                        :kill-buffer t :clock-in t :clock-resume t) :append)
  (add-to-list 'org-capture-templates `("n" "Notas" entry (file+headline org-default-notes-file "Reorganizar")
                                        (file ,(expand-file-name "notas.orgcaptmpl" org-plantillas-directory))
                                        :kill-buffer t :clock-in t :clock-resume t) :append)
  (add-to-list 'org-capture-templates `("f" "Fechas o eventos" entry (file+headline "cosas por hacer.org" "Fechas")
                                        (file ,(expand-file-name "fecha o evento.orgcaptmpl" org-plantillas-directory))
                                        :kill-buffer t :clock-in t :clock-resume t) :append)
  (add-to-list 'org-capture-templates `("r" "Receta de cocina" entry (file "recetas.org")
                                        (file ,(expand-file-name "recetas.orgcaptmpl" org-plantillas-directory))
                                        :kill-buffer t :clock-in t :clock-resume t) :append)
  (add-to-list 'org-capture-templates `("P" "Protocol" entry (file+headline org-default-notes-file "Reorganizar")
                                        (file ,(expand-file-name "protocol.orgcaptmpl" org-plantillas-directory))
                                        :kill-buffer t :clock-in t :clock-resume t) :append)
  (add-to-list 'org-capture-templates `("l" "Protocol Link" entry (file+headline org-default-notes-file "Reorganizar")
                                        (file ,(expand-file-name "protocol.orgcaptmpl" org-plantillas-directory))
                                        :kill-buffer t :clock-in t :clock-resume t) :append)
  ;; Ajuste para LaTeX
  (add-to-list 'org-latex-packages-alist '("" "gchords" t)))

Corrección ortográfica

Con base al blog post Setting up spell checking with multiple dictionaries in Emacs activamos varios idiomas a la vez.

(after! spell-fu
  (defvar shackra-personal-dict-file-es (expand-file-name ".spell.es.pws" (getenv "HOME")) "Ubicación del archivo de palabras personales para revision ortografica en español")
  (defvar shackra-personal-dict-file-en (expand-file-name ".spell.en.pws" (getenv "HOME")) "Ubicación del archivo de palabras personales para revision ortografica en inglés")

  (defun shackra-spell-configure ()
    (spell-fu-dictionary-add (spell-fu-get-ispell-dictionary "es"))
    (spell-fu-dictionary-add (spell-fu-get-ispell-dictionary "en"))
    (spell-fu-dictionary-add (spell-fu-get-personal-dictionary "es-personal" shackra-personal-dict-file-es))
    (spell-fu-dictionary-add (spell-fu-get-personal-dictionary "en-personal" shackra-personal-dict-file-en)))
  (add-hook! spell-fu-mode #'shackra-spell-configure))

undo y redo

cambia atajos para llamar a undo y redo

(map! "C-z" #'undo)
(map! "C-S-z" #'undo-fu-only-redo)

Cierre de buffers

Cambia atajo para matar el buffer actual

(unbind-key "C-x k" global-map)
(map! "C-x k" #'kill-this-buffer)

iedit

Realiza ajustes pequeños para iedit-mode

(map! "C-M-;" #'iedit-mode)
(map! :map iedit-mode-keymap "RET" #'iedit--quit)

yasnippets

Configura yasnippet y modifica todos los backends de company-mode para incluirlo en los resultados

(defvar shackra-story-in-branch-rx (rx (submatch (+ (any (?A . ?z))) "-" (** 3 5 (any (?0 . ?9)))))
  "Expresion regular para encontrar una referencia a una historia en el nombre de la rama actual.")

(defvar shackra-story-default "xxx"
  "Dato por defecto en caso de que la rama no tenga una historia identificable.")

(defun shackra-get-branch-story ()
  "Retorna la historia enumerada en la rama de git actual."
  (let* ((result)
         (branch (magit-get-current-branch)))
    (save-match-data
      (upcase (if (string-match shackra-story-in-branch-rx branch)
                  (match-string-no-properties 1 branch)
                shackra-story-default)))))

(when (and (modulep! :completion company)
           (modulep! :editor snippets)
           (modulep! :tools lsp))

  (defun shackra-use-company-capf-with-yasnippet ()
    (setq company-backends '((company-capf company-yasnippet)))))

(after! yasnippet
  (add-to-list 'yas-snippet-dirs (expand-file-name "plantillas" doom-private-dir) nil))

(add-hook 'git-commit-mode-hook #'yas-minor-mode-on)

Golang

Ajustes menores para Golang

(after! go-mode
  (if (and (modulep! :lang go +lsp) (executable-find "gofumpt"))
      (setq lsp-go-use-gofumpt t)
    (message "gofumpt no instalado")))

Flutter y Dart

ajustes menores para estos modos mayores

(after! dart-mode
  (setq-default lsp-dart-sdk-dir nil)
  (setq-default flutter-sdk-path nil))

correo electrónico

(after! mu4e
  (setq +mu43-mu4e-mail-path "~/Maildir")
  (set-email-account! "jorge@esavara.cr"
                      '((mu4e-sent-folder       . "/personal/Sent Mail")
                        (mu4e-drafts-folder     . "/personal/Drafts")
                        (mu4e-trash-folder      . "/personal/Trash")
                        (mu4e-refile-folder     . "/personal/All Mail")
                        (smtpmail-smtp-user     . "jorge@esavara.cr")
                        (mu4e-compose-signature . "---\nJorge"))
                      t))

tramp

Ajustes para Tramp (sacados de Doom Emacs Configuration)

;; Añade una frase adicional a la lista de palabras
(add-to-list 'password-word-equivalents "verification code")

Ajustes para lsp-mode

;; ignora .log y .next
(after! lsp-mode
  (add-to-list 'lsp-file-watch-ignored-directories "[/\\\\]\\.log\\'")
  (add-to-list 'lsp-file-watch-ignored-directories "[/\\\\]\\.next\\'")
  (add-to-list 'lsp-file-watch-ignored-directories "[/\\\\]__snapshots?__\\'")
  ;; https://github.com/emacs-lsp/lsp-mode/issues/3577#issuecomment-1857344443
  (delete 'lsp-terraform lsp-client-packages))

Ajusta lsp-ui

(after! lsp-mode
  (setq lsp-headerline-breadcrumb-enable t)
  (setq lsp-ui-doc-enable t)
  (setq lsp-ui-doc-position 'top)
  (setq lsp-ui-doc-show-with-cursor nil)
  (setq lsp-ui-doc-show-with-mouse t)
  (setq lsp-signature-render-documentation nil)
  (setq lsp-eldoc-enable-hover t)
  (setq lsp-signature-auto-activate nil))

configuración de lsp-tailwind

(after! lsp-tailwindcss
  (setq lsp-tailwindcss-major-modes '(typescript-tsx-mode rjsx-mode web-mode html-mode css-mode svelte-mode)))

svelte-mode

(use-package! svelte-mode
  :defer)

typescript-mode

(after! indent-guides
  (defun turn-off-indent-guides ()
    (highlight-indent-guides-mode -1))

  (add-hook! 'typescript-tsx-mode-hook #'turn-off-indent-guides)
  (setq-hook! 'typescript-tsx-mode typescript-indent-level 2))

Configuración de vertico

ajustes para Vertico

(after! vertico
  (vertico-multiform-mode)
  (setq vertico-cycle t)
  (setq vertico-multiform-categories
        '((imenu buffer)
          (consult-grep buffer)
          (execute-extended-command unobtrusive)
          (file grid)
          (consult-grep buffer))))

dired

(after! dirvish
  (setq dirvish-attributes '(vc-state subtree-state all-the-icons collapse git-msg file-size)))

Configuración para PlantUML

(after! plantuml-mode
  (setq-default plantuml-jar-path (executable-find "plantuml"))
  (setq-default plantuml-output-type "svg"))

Structurzr

(use-package! structurzr-mode
  :defer)

SBCL

(let* ((slime-helper-file (expand-file-name "~/quicklisp/slime-helper.el")))
  (when (file-exists-p slime-helper-file)
    (load (expand-file-name "~/quicklisp/slime-helper.el"))
    (setq inferior-lisp-program (executable-find "sbcl"))))

Code Compass

(use-package! code-compass
  :defer
  :config
  (setq-default code-compass-preferred-browser "firefox"))

AI

ollama

(use-package! ellama
  :defer
  :config (setopt ellama-language "English"))

just

inspirado por make, corre comandos específicos a un proyecto.

(use-package! just-mode
    :defer)

Hashicorp Configuration Language

(use-package! hcl-mode
  :defer)

apheleia formateadores

nix-mode

(after! apheleia-formatters
  (add-to-list 'apheleia-formatters '(alejandra . ("alejandra"))))