From 9b862b7d2b3874e4dface5e0e5b7b1e87d34f98a Mon Sep 17 00:00:00 2001 From: Lucas Sta Maria Date: Sun, 3 Nov 2024 18:31:17 -0500 Subject: [PATCH] refactor(emacs): remove misc.el Signed-off-by: Lucas Sta Maria --- .emacs.d/include/misc.el | 288 ------------------ .emacs.d/include/priime-completion.el | 4 +- .emacs.d/include/priime-convenience.el | 6 +- .emacs.d/include/priime-edit.el | 108 ++++++- .emacs.d/include/priime-general.el | 11 +- .emacs.d/include/priime-languages.el | 26 +- .emacs.d/include/priime-ui.el | 57 +++- .../include/{utils.el => priime-utils.el} | 16 +- .emacs.d/include/priime-vc.el | 1 + .emacs.d/init.el | 3 +- 10 files changed, 219 insertions(+), 301 deletions(-) delete mode 100644 .emacs.d/include/misc.el rename .emacs.d/include/{utils.el => priime-utils.el} (52%) diff --git a/.emacs.d/include/misc.el b/.emacs.d/include/misc.el deleted file mode 100644 index a849666..0000000 --- a/.emacs.d/include/misc.el +++ /dev/null @@ -1,288 +0,0 @@ -;;; misc.el --- Miscellaneous configuration for packages. -;;; Commentary: -;; Miscellaneous configuration for packages. If a package doesn't -;; necessarily require its own configuration file (its configuration could be -;; short), then it belongs here. -;;; Code: - -(require 'meow) -(require 'git-gutter) -(require 'seq) -(require 'justl) - -(defun config-compile () - "(Re)compile the current Emacs configuration." - (interactive) - (byte-recompile-directory "~/.emacs.d/")) - -(defun config-download (&optional confirm) - "Download the latest Emacs config files from the GitHub repository if CONFIRM." - (interactive) - (let* ((confirm (or confirm - (read-string "Type `YES' to confirm download: ")))) - (if (not (string= confirm "YES")) - (print "Cancelling config download/update...") - (let* ((gh-url "https://raw.githubusercontent.com/priime0/dotfiles/master/.emacs.d/") - (target-dir "~/.emacs.d/") - (filenames - '("init.el" - "include/general.el" - "include/misc.el" - "include/utils.el" - "include/racket.el" - "include/pdfconfig.el" - "include/cppconfig.el" - "include/latexconfig.el" - "include/mu4econfig.el" - "include/orgconfig.el")) - (file-paths (mapcar (lambda (s) (concat target-dir s)) - filenames)) - (file-urls (mapcar (lambda (s) (concat gh-url s)) - filenames)) - (file-path-urls (lists->alist file-paths file-urls))) - (mkdir (concat target-dir "include") t) - (mapc (lambda (f) - (url-copy-file (cdr f) (car f) t)) - file-path-urls))))) - - -(defun download-file (&optional url filepath) - "Download the file from URL to FILEPATH." - (interactive) - (let* ((url (or url - (read-string "url: "))) - (filepath (or filepath (read-file-name "filename: ")))) - (url-copy-file url filepath 1))) - -;; meow -(defun meow-mx (arg) - "Press alt + x." - (interactive "P") - (execute-extended-command arg)) - -(defun meow-mq () - "Reformat/reindent." - (interactive) - (call-interactively (global-key-binding "\M-q"))) - -(defun meow-yank-above () - "Yank the killed text to the line above." - (interactive) - (save-excursion - (move-beginning-of-line nil) - (meow-yank))) - -(defun meow-change-line () - "Kill rest of line and switch to insert state." - (interactive) - (kill-line) - (meow-insert)) - -(defun meow-setup () - "Set up meow." - (keymap-global-set "C-q" #'meow-quit) - (setq meow-cheatsheet-layout meow-cheatsheet-layout-dvp) - (meow-leader-define-key '("u" . "C-u")) - (meow-leader-define-key '("l" . "s-l")) - (meow-motion-overwrite-define-key - ;; custom keybinding for motion state - '("" . ignore)) - (meow-normal-define-key - '("?" . meow-cheatsheet) - '("*" . meow-expand-0) - '("=" . meow-expand-9) - '("!" . meow-expand-8) - '("[" . meow-expand-7) - '("]" . meow-expand-6) - '("{" . meow-expand-5) - '("+" . meow-expand-4) - '("}" . meow-expand-3) - '(")" . meow-expand-2) - '("(" . meow-expand-1) - '("1" . digit-argument) - '("2" . digit-argument) - '("3" . digit-argument) - '("4" . digit-argument) - '("5" . digit-argument) - '("6" . digit-argument) - '("7" . digit-argument) - '("8" . digit-argument) - '("9" . digit-argument) - '("0" . digit-argument) - '("-" . negative-argument) - '(";" . meow-reverse) - '("," . meow-inner-of-thing) - '("." . meow-bounds-of-thing) - '("<" . meow-beginning-of-thing) - '(">" . meow-end-of-thing) - '("a" . meow-append) - '("A" . meow-open-below) - '("b" . meow-back-word) - '("B" . meow-back-symbol) - '("c" . meow-change) - '("C" . meow-change-line) - '("d" . meow-delete) - '("D" . meow-backward-delete) - '("e" . meow-line) - '("E" . meow-goto-line) - '("f" . meow-find) - '("g" . meow-cancel-selection) - '("G" . meow-grab) - '("h" . meow-left) - '("H" . meow-left-expand) - '("i" . meow-insert) - '("I" . meow-open-above) - '("j" . meow-join) - '("k" . meow-kill) - '("l" . meow-till) - '("m" . meow-mark-word) - '("M" . meow-mark-symbol) - '("n" . meow-next) - '("N" . meow-next-expand) - '("o" . meow-block) - '("O" . meow-to-block) - '("p" . meow-prev) - '("P" . meow-prev-expand) - '("q" . meow-mq) - '("r" . meow-replace) - '("R" . meow-swap-grab) - '("s" . meow-search) - '("t" . meow-right) - '("T" . meow-right-expand) - '("u" . meow-undo) - '("U" . meow-undo-in-selection) - '("v" . meow-visit) - '("w" . meow-next-word) - '("W" . meow-next-symbol) - '("x" . meow-save) - '("X" . meow-sync-grab) - '("y" . meow-yank) - '("Y" . meow-yank-above) - '("z" . meow-pop-selection) - '("'" . repeat) - '(":" . meow-mx) - '("" . ignore))) - -(meow-setup) - -(setq read-process-output-max (* 4 1024 1024)) - -;; Magit -(setq auth-sources '("~/.authinfo")) - -;; Projectile -(projectile-mode +1) -(define-key projectile-mode-map (kbd "C-c p") 'projectile-command-map) - -;; Neotree -(defun neotree-toggle-dir-or-project () - "By default, toggle the directory at the project level, with prefix current." - (interactive) - (if (eq current-prefix-arg nil) - (neotree-toggle-project) - (neotree-toggle-current-directory))) - -(defun neotree-toggle-project () - "Toggle neotree at the project level if the project exists, otherwise current." - (interactive) - (if (projectile-project-p) - (neotree-toggle-directory (projectile-project-root)) - (neotree-toggle-current-directory))) - -(defun neotree-toggle-current-directory () - "Toggle neotree at the current directory." - (interactive) - (let ((current-directory - (or (and buffer-file-name (file-name-directory buffer-file-name)) - (and (eq major-mode 'dired-mode) (dired-current-directory)) - (and (eq major-mode 'magit-status-mode) (magit-toplevel)) - "~"))) - (neotree-toggle-directory current-directory))) - -(defun neotree-toggle-directory (dir) - "Toggle neotree at the given DIR." - (if (and (fboundp 'neo-global--window-exists-p) - (neo-global--window-exists-p)) - (neotree-hide) - (neotree-dir dir))) - - -;; hledger -(setq hledger-currency-string "$") -(add-to-list 'auto-mode-alist '("\\.journal\\'" . hledger-mode)) -(setq hledger-jfile "~/finance/2024.journal") - - -;; SLIME -(setq inferior-lisp-program "sbcl") - -;; Markdown -(custom-set-faces - '(markdown-header-face-1 ((t (:inherit nano-strong :height 1.3 :family "Inter")))) - '(markdown-header-face-2 ((t (:inherit nano-strong :height 1.25 :family "Inter")))) - '(markdown-header-face-3 ((t (:inherit nano-strong :height 1.2 :family "Inter")))) - '(markdown-header-face-4 ((t (:inherit nano-strong :height 1.15 :family "Inter")))) - '(markdown-header-face-5 ((t (:inherit nano-strong :height 1.1 :family "Inter")))) - '(markdown-header-face-6 ((t (:inherit nano-strong :height 1.05 :family "Inter"))))) -(add-hook 'markdown-mode-hook #'markdown-toggle-fontify-code-blocks-natively) -(add-hook 'markdown-mode-hook #'olivetti-mode) - -;; Consult -(keymap-global-set "C-c r r" #'consult-ripgrep) -(keymap-global-set "C-c r g" #'consult-grep) - -;; hl-todo -(custom-set-faces - '(hl-todo ((t (:inherit nano-salient-i))))) -(setq hl-todo-keyword-faces - '(("HOLD" . "#ffffff") - ("TODO" . "#ffffff") - ("NEXT" . "#ffffff") - ("THEM" . "#ffffff") - ("PROG" . "#ffffff") - ("OKAY" . "#ffffff") - ("DONT" . "#ffffff") - ("FAIL" . "#ffffff") - ("DONE" . "#ffffff") - ("NOTE" . "#ffffff") - ("MAYBE" . "#ffffff") - ("KLUDGE" . "#ffffff") - ("HACK" . "#ffffff") - ("TEMP" . "#ffffff") - ("FIXME" . "#ffffff") - ("XXXX*" . "#ffffff"))) - -;; justl - -(defun justl-recipes () - "Pick and execute a just recipe." - (interactive) - (let* ((justfile (justl--find-justfile default-directory)) - (raw-entries (justl--get-recipes justfile)) - (entry-names (mapcar #'justl--recipe-name raw-entries)) - (just-recipe (completing-read "just recipe: " entry-names nil t nil))) - (justl--exec - justl-executable - just-recipe - (append (transient-args 'justl-help-popup) - (list just-recipe))))) - -;; rjsx - -(setq auto-mode-alist (cons '("\\.tsx$" . rjsx-mode) auto-mode-alist)) - -;; elixir - -(defvar-keymap inf-elixir-keymap - "i" #'inf-elixir - "p" #'inf-elixir-project - "c" #'inf-elixir-send-line - "b" #'inf-elixir-send-buffer - "r" #'inf-elixir-send-region - "R" #'inf-elixir-reload-module) -(add-hook 'elixir-mode-hook - (lambda () - (keymap-local-set "C-c i" inf-elixir-keymap))) - -(provide 'misc) -;;; misc.el ends here diff --git a/.emacs.d/include/priime-completion.el b/.emacs.d/include/priime-completion.el index 153bf35..cbab15b 100644 --- a/.emacs.d/include/priime-completion.el +++ b/.emacs.d/include/priime-completion.el @@ -31,7 +31,9 @@ :init (add-hook 'after-init-hook 'marginalia-mode)) (use-package orderless :straight t) -(use-package consult :straight t) +(use-package consult :straight t + :bind (("C-c r r" . consult-ripgrep) + ("C-c r g" . consult-grep))) (use-package yasnippet :straight t) (use-package yasnippet-snippets :straight t) diff --git a/.emacs.d/include/priime-convenience.el b/.emacs.d/include/priime-convenience.el index 9ad36e0..a4973e4 100644 --- a/.emacs.d/include/priime-convenience.el +++ b/.emacs.d/include/priime-convenience.el @@ -6,7 +6,11 @@ (use-package projectile :straight t :custom - (projectile-completion-system 'auto)) + (projectile-completion-system 'auto) + :bind + (("C-c p" . projectile-command-map)) + :init + (projectile-mode 1)) (use-package bufler :straight t :bind (("C-x C-b" . bufler-list) ("C-x b" . bufler-switch-buffer)) diff --git a/.emacs.d/include/priime-edit.el b/.emacs.d/include/priime-edit.el index 6cfce90..79032d5 100644 --- a/.emacs.d/include/priime-edit.el +++ b/.emacs.d/include/priime-edit.el @@ -4,10 +4,116 @@ ;; syntax-checking and formatting. ;;; Code: +(defun meow-mx (arg) + "Press alt + x." + (interactive "P") + (execute-extended-command arg)) + +(defun meow-mq () + "Reformat/reindent." + (interactive) + (call-interactively (global-key-binding "\M-q"))) + +(defun meow-yank-above () + "Yank the killed text to the line above." + (interactive) + (save-excursion + (move-beginning-of-line nil) + (meow-yank))) + +(defun meow-change-line () + "Kill rest of line and switch to insert state." + (interactive) + (kill-line) + (meow-insert)) + (use-package meow :straight t + :bind (("C-q" . meow-quit)) + :custom + (meow-cheatsheet-layout meow-cheatsheet-layout-dvp) :init (meow-global-mode) - (meow-setup-indicator)) + (meow-setup-indicator) + (meow-leader-define-key '("u" . "C-u")) + (meow-leader-define-key '("l" . "s-l")) + (meow-motion-overwrite-define-key + ;; custom keybinding for motion state + '("" . ignore)) + (meow-normal-define-key + '("?" . meow-cheatsheet) + '("*" . meow-expand-0) + '("=" . meow-expand-9) + '("!" . meow-expand-8) + '("[" . meow-expand-7) + '("]" . meow-expand-6) + '("{" . meow-expand-5) + '("+" . meow-expand-4) + '("}" . meow-expand-3) + '(")" . meow-expand-2) + '("(" . meow-expand-1) + '("1" . digit-argument) + '("2" . digit-argument) + '("3" . digit-argument) + '("4" . digit-argument) + '("5" . digit-argument) + '("6" . digit-argument) + '("7" . digit-argument) + '("8" . digit-argument) + '("9" . digit-argument) + '("0" . digit-argument) + '("-" . negative-argument) + '(";" . meow-reverse) + '("," . meow-inner-of-thing) + '("." . meow-bounds-of-thing) + '("<" . meow-beginning-of-thing) + '(">" . meow-end-of-thing) + '("a" . meow-append) + '("A" . meow-open-below) + '("b" . meow-back-word) + '("B" . meow-back-symbol) + '("c" . meow-change) + '("C" . meow-change-line) + '("d" . meow-delete) + '("D" . meow-backward-delete) + '("e" . meow-line) + '("E" . meow-goto-line) + '("f" . meow-find) + '("g" . meow-cancel-selection) + '("G" . meow-grab) + '("h" . meow-left) + '("H" . meow-left-expand) + '("i" . meow-insert) + '("I" . meow-open-above) + '("j" . meow-join) + '("k" . meow-kill) + '("l" . meow-till) + '("m" . meow-mark-word) + '("M" . meow-mark-symbol) + '("n" . meow-next) + '("N" . meow-next-expand) + '("o" . meow-block) + '("O" . meow-to-block) + '("p" . meow-prev) + '("P" . meow-prev-expand) + '("q" . meow-mq) + '("r" . meow-replace) + '("R" . meow-swap-grab) + '("s" . meow-search) + '("t" . meow-right) + '("T" . meow-right-expand) + '("u" . meow-undo) + '("U" . meow-undo-in-selection) + '("v" . meow-visit) + '("w" . meow-next-word) + '("W" . meow-next-symbol) + '("x" . meow-save) + '("X" . meow-sync-grab) + '("y" . meow-yank) + '("Y" . meow-yank-above) + '("z" . meow-pop-selection) + '("'" . repeat) + '(":" . meow-mx) + '("" . ignore))) (use-package flycheck :straight t :custom (flycheck-check-syntax-automatically '(save mode-enable)) diff --git a/.emacs.d/include/priime-general.el b/.emacs.d/include/priime-general.el index 6d7a670..7b15480 100644 --- a/.emacs.d/include/priime-general.el +++ b/.emacs.d/include/priime-general.el @@ -72,6 +72,14 @@ (display-line-numbers-mode 1) (setq display-line-numbers t)))) +(defun download-file (&optional url filepath) + "Download the file from URL to FILEPATH." + (interactive) + (let* ((url (or url + (read-string "url: "))) + (filepath (or filepath (read-file-name "filename: ")))) + (url-copy-file url filepath 1))) + (defvar-keymap priime-fill-map "f" #'set-fill-column "i" #'display-fill-column-indicator-mode @@ -120,11 +128,12 @@ ;; Misc (epa-file-encrypt-to '("lucas@priime.dev")) (epa-file-select-keys 1) + (read-process-output-max (* 4 1024 1024)) :custom-face (default ((t (:family ,priime-fixed-font :weight medium)))) (region ((t (:inherit nano-subtle :background "#EBE5F5")))) - (italic) ((t (:family inherit :slant italic :weight medium))) + (italic ((t (:family inherit :slant italic :weight medium)))) (lazy-highlight ((t (:inherit region)))) (variable-pitch ((t (:inherit default :family ,priime-variable-font :height 125 :weight regular)))) (fixed-pitch ((t (:family ,priime-fixed-font :height ,priime-fixed-height :inherit nil)))) diff --git a/.emacs.d/include/priime-languages.el b/.emacs.d/include/priime-languages.el index d14623b..9c63a10 100644 --- a/.emacs.d/include/priime-languages.el +++ b/.emacs.d/include/priime-languages.el @@ -3,6 +3,19 @@ ;; Provides configuration for programming language packages. ;;; Code: +(defun justl-recipes () + "Pick and execute a just recipe." + (interactive) + (let* ((justfile (justl--find-justfile default-directory)) + (raw-entries (justl--get-recipes justfile)) + (entry-names (mapcar #'justl--recipe-name raw-entries)) + (just-recipe (completing-read "just recipe: " entry-names nil t nil))) + (justl--exec + justl-executable + just-recipe + (append (transient-args 'justl-help-popup) + (list just-recipe))))) + (use-package racket-mode :straight t :hook ((racket-mode . racket-xp-mode) @@ -12,8 +25,16 @@ (use-package rustic :straight t) (use-package markdown-mode :straight t + :hook ((markdown-mode . markdown-toggle-fontify-code-blocks-natively) + (markdown-mode . olivetti-mode)) :custom-face - (markdown-inline-code-face ((t (:inherit nano-salient))))) + (markdown-inline-code-face ((t (:inherit nano-salient)))) + (markdown-header-face-1 ((t (:inherit nano-strong :height 1.3 :family "Inter")))) + (markdown-header-face-2 ((t (:inherit nano-strong :height 1.25 :family "Inter")))) + (markdown-header-face-3 ((t (:inherit nano-strong :height 1.2 :family "Inter")))) + (markdown-header-face-4 ((t (:inherit nano-strong :height 1.15 :family "Inter")))) + (markdown-header-face-5 ((t (:inherit nano-strong :height 1.1 :family "Inter")))) + (markdown-header-face-6 ((t (:inherit nano-strong :height 1.05 :family "Inter"))))) (use-package rjsx-mode :straight t) (use-package just-mode :straight t) (use-package justl :straight t @@ -23,7 +44,8 @@ (use-package cdlatex :straight t) (use-package yaml-mode :straight t) (use-package poetry :straight t) -(use-package sly :straight t) +(use-package sly :straight t + :custom (inferior-lisp-program "sbcl")) (use-package haskell-mode :straight t) (use-package llvm-mode :straight diff --git a/.emacs.d/include/priime-ui.el b/.emacs.d/include/priime-ui.el index 90c612d..47cfe27 100644 --- a/.emacs.d/include/priime-ui.el +++ b/.emacs.d/include/priime-ui.el @@ -3,6 +3,40 @@ ;; Provides configuration for the UI. ;;; Code: +(require 'projectile) +(require 'magit) + +(defun neotree-toggle-dir-or-project () + "By default, toggle the directory at the project level, with prefix current." + (interactive) + (if (eq current-prefix-arg nil) + (neotree-toggle-project) + (neotree-toggle-current-directory))) + +(defun neotree-toggle-project () + "Toggle neotree at the project level if the project exists, otherwise current." + (interactive) + (if (projectile-project-p) + (neotree-toggle-directory (projectile-project-root)) + (neotree-toggle-current-directory))) + +(defun neotree-toggle-current-directory () + "Toggle neotree at the current directory." + (interactive) + (let ((current-directory + (or (and buffer-file-name (file-name-directory buffer-file-name)) + (and (eq major-mode 'dired-mode) (dired-current-directory)) + (and (eq major-mode 'magit-status-mode) (magit-toplevel)) + "~"))) + (neotree-toggle-directory current-directory))) + +(defun neotree-toggle-directory (dir) + "Toggle neotree at the given DIR." + (if (and (fboundp 'neo-global--window-exists-p) + (neo-global--window-exists-p)) + (neotree-hide) + (neotree-dir dir))) + (use-package nano-theme :straight '(nano-theme :type git :host github :repo "rougier/nano-theme") @@ -25,7 +59,28 @@ :config (git-gutter:start-update-timer)) (use-package hl-todo :straight t - :hook (prog-mode . hl-todo-mode)) + :hook ((prog-mode . hl-todo-mode) + (LaTeX-mode . hl-todo-mode)) + :custom-face + (hl-todo ((t (:inherit nano-salient-i)))) + :custom + '(hl-todo-keyword-faces + (("HOLD" . "#ffffff") + ("TODO" . "#ffffff") + ("NEXT" . "#ffffff") + ("THEM" . "#ffffff") + ("PROG" . "#ffffff") + ("OKAY" . "#ffffff") + ("DONT" . "#ffffff") + ("FAIL" . "#ffffff") + ("DONE" . "#ffffff") + ("NOTE" . "#ffffff") + ("MAYBE" . "#ffffff") + ("KLUDGE" . "#ffffff") + ("HACK" . "#ffffff") + ("TEMP" . "#ffffff") + ("FIXME" . "#ffffff") + ("XXXX*" . "#ffffff")))) (provide 'priime-ui) diff --git a/.emacs.d/include/utils.el b/.emacs.d/include/priime-utils.el similarity index 52% rename from .emacs.d/include/utils.el rename to .emacs.d/include/priime-utils.el index 8d5813b..09bd043 100644 --- a/.emacs.d/include/utils.el +++ b/.emacs.d/include/priime-utils.el @@ -1,6 +1,6 @@ -;;; utils.el --- Utility functions. +;;; priime-utils.el --- Utility functions and commands ;;; Commentary: -;; Provides utility functions. +;; Provides utility functions and commands. ;;; Code: (defun lists->alist (l1 l2) @@ -17,6 +17,14 @@ (lists->alist (cdr l1) (cdr l2)))))) -(provide 'utils) +(defun download-file (&optional url filepath) + "Download the file from URL to FILEPATH." + (interactive) + (let* ((url (or url + (read-string "url: "))) + (filepath (or filepath (read-file-name "filename: ")))) + (url-copy-file url filepath 1))) -;;; utils.el ends here +(provide 'priime-utils) + +;;; priime-utils.el ends here diff --git a/.emacs.d/include/priime-vc.el b/.emacs.d/include/priime-vc.el index 686b571..14dc52c 100644 --- a/.emacs.d/include/priime-vc.el +++ b/.emacs.d/include/priime-vc.el @@ -4,6 +4,7 @@ ;;; Code: (use-package magit :straight t + :custom (auth-sources '("~/.authinfo")) :bind (("" . magit-status) ("C-x g" . magit-status))) (use-package forge :straight t diff --git a/.emacs.d/init.el b/.emacs.d/init.el index 500f169..6813f0d 100644 --- a/.emacs.d/init.el +++ b/.emacs.d/init.el @@ -21,6 +21,7 @@ (add-to-list 'load-path "~/.emacs.d/include") (load-library "priime-elisp") +(load-library "priime-utils") (load-library "priime-general") (load-library "priime-lsp") (load-library "priime-completion") @@ -31,8 +32,6 @@ (load-library "priime-org") (load-library "priime-languages") -(load-library "misc") -(load-library "utils") (load-library "orgconfig") (when (eq system-type 'gnu/linux) (load-library "mu4econfig"))