emacs/lisp/mitch-packages.el

1309 lines
40 KiB
EmacsLisp
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

;;; mitch-packages --- Declare and configure use-package statements
;;; Commentary:
;; -----------------------------------------------------------------------------
;; This is a file in which I put declarations for packages and things.
;; -----------------------------------------------------------------------------
;;; Code:
(use-package emacs
:elpaca nil
:custom
(scroll-margin 2)
(scroll-conservatively 100)
(scroll-up-aggressively 0.01)
(scroll-down-aggressively 0.01)
(auto-window-vscroll nil)
:init
(global-visual-line-mode t)
(set-language-environment "UTF-8")
(global-prettify-symbols-mode 1)
(auto-insert-mode))
(use-package compat)
;; save minibuffer history, see Vertico below
(use-package savehist
:elpaca nil
:init (savehist-mode)
:custom (savehist-file
(expand-file-name "minibuffer-history" backup-directory)))
;; save place in all files
(use-package saveplace
:elpaca nil
:init (save-place-mode t)
:custom
(save-place-file
(expand-file-name "file-position-save" backup-directory)))
(use-package tramp
:elpaca nil
;; :after eshell
:custom (tramp-persistency-file-name
(expand-file-name "tramp-history" backup-directory))
:config
(defun find-file-sudo (&rest throwaway)
(unless (and buffer-file-name
(file-writable-p buffer-file-name))
(find-alternate-file (concat "/sudo:root@localhost:" buffer-file-name))))
(advice-add #'find-file :after #'find-file-sudo))
;; Visualize whitespace. In a very chill and invisible way.
(use-package image-mode
:elpaca nil
:config
(turn-off-line-numbers)
(blink-cursor-mode -1))
;; scribble SVGs in org buffers like it's 2005 (idk I was a baby then)
(use-package edraw
:elpaca (:repo "https://github.com/misohena/el-easydraw")
:after org
:config
(require 'edraw-org)
(edraw-org-setup-default)
;; following function taken from https://github.com/wn/doom.d/blob/46ca46f2ef21e933fb76b1568be1a62b262ed288/config.el#L47
(defun org-mode-open-edraw (&optional filename)
(interactive)
(let ((filename (or filename
(concat "./"
(file-relative-name
(read-file-name (edraw-msg "Write svg file: ")
default-directory)
default-directory)))))
(insert (format "[[edraw:file=%s]]" filename))
(backward-char)
(org-return))))
;; diminish
(use-package diminish)
;; Keybinding manager
(use-package general
:demand t
:custom (default-input-method "japanese")
:config (mitch/general-config))
(elpaca-wait)
(use-package eldoc
:elpaca nil
:diminish
:custom (eldoc-echo-area-use-multiline-p nil))
(use-package whitespace
:elpaca nil
:diminish (whitespace-mode org-indent-mode org-vw-mode auto-fill-mode)
:custom
(whitespace-style '(face lines-tail))
(whitespace-line-column 80)
(fill-column 80)
:hook
(prog-mode . whitespace-mode)
(org-mode . auto-fill-mode))
;; ...and finally, sync files with disk changes
(use-package autorevert
:elpaca nil
:diminish auto-revert-mode
:config (global-auto-revert-mode))
;; (use-package use-package-ensure-system-package)
;; load evil
(use-package evil
:general
;; Visual lines. Redefined for auto-scrolling madness.
(general-define-key
:states 'normal
"<escape>" 'evil-beginning-of-line
"j" 'evil-next-visual-line
"k" 'evil-previous-visual-line
"C-n" 'move-screen-up-line
"C-p" 'move-screen-down-line)
(general-define-key
:states 'insert
"C-w" 'evil-window-map
"C-V" (general-key-dispatch
'evil-quoted-insert
"u" 'insert-char))
:diminish visual-line-mode
:custom
(echo-keystrokes 0.5)
(evil-want-integration t)
(evil-want-keybinding nil)
(evil-want-C-u-scroll nil)
(evil-want-C-i-jump nil)
(evil-vsplit-window-right t)
(evil-split-window-below t)
(evil-undo-system
(if (>= (string-to-number emacs-version) 28)
(quote undo-redo)
(quote undo-fu)))
:init (evil-mode t)
:config (mitch/evil-config))
(use-package evil-collection
:after evil
:diminish evil-collection-unimpaired-mode
:config (evil-collection-init))
(use-package evil-commentary
:after evil
:diminish 'evil-commentary-mode
:config (evil-commentary-mode)
:hook (prog-mode . evil-commentary-mode))
(use-package evil-surround
:after evil
:diminish 'global-evil-surround-mode
:hook (prog-mode . evil-surround-mode)
:config (global-evil-surround-mode 1))
(use-package evil-matchit
:after evil
:diminish 'evil-matchit-mode
:config (global-evil-matchit-mode 1))
(use-package evil-terminal-cursor-changer
:after evil
:diminish
:if (not (display-graphic-p))
:custom
(evil-motion-state-cursor 'box) ; █
(evil-visual-state-cursor 'box) ; █
(evil-normal-state-cursor 'box) ; █
(evil-insert-state-cursor 'bar) ; ⎸
(evil-emacs-state-cursor 'hbar) ; _
:config
(evil-terminal-cursor-changer-activate)
(xterm-mouse-mode))
(use-package undo-fu
:after evil
:if (< (string-to-number emacs-version) 28)
:diminish)
(use-package vundo
:custom (vundo-glyph-alist vundo-unicode-symbols))
(use-package evil-goggles
:diminish
:after evil
:init (evil-goggles-mode)
:custom-face
(evil-goggles-default-face
((t (:background "#303030" :foreground "#2233aa")))))
(use-package altcaps
:after evil
:elpaca (:host github
:repo "protesilaos/altcaps")
:general (general-define-key
:states 'visual
"`" 'altcaps-region))
;; eshell. Pretty good actually.
(use-package eshell
:elpaca nil
;; :commands (eshell/emacs eshell/man)
;; :init
;; (defun eshell-banner-initialize ()
;; "Run Neofetch in eshell."
;; (eshell/ls nil))
:custom
(eshell-scroll-to-bottom-on-input t)
(eshell-hist-ignoredups t)
(eshell-history-file-name nil)
(eshell-history-size nil)
(eshell-banner-message "")
(eshell-expand-input-functions '(eshell-expand-history-references))
:config
(add-to-list 'eshell-modules-list 'eshell-rebind)
(add-to-list 'eshell-modules-list 'eshell-hist)
(add-to-list 'eshell-modules-list 'eshell-tramp)
(add-hook 'kill-emacs-hook #'eshell-save-some-history)
(defun eshell-evil-insert-line (count &optional vcount)
(interactive "p")
(eshell-bol)
(evil-insert count vcount))
(defun mitch/edit-file-or-lib (name)
"Edit library called NAME if it exists, otherwise edit FILE.
If the current window occupies the whole frame, split it."
(let* ((old-buffer (current-buffer))
(old-default-dir default-directory) ; needed to preserve environment
find-fun lib-fun ; scope these so we can bind them later
(openfun (lambda (arg)
"Implicit function for opening a file or library."
(let ((arg-file-name (expand-file-name arg))
(arg-lib-name (locate-library arg)))
(if (file-exists-p arg-file-name)
(funcall find-fun arg-file-name)
(if arg-lib-name
(funcall lib-fun arg)
(funcall find-fun arg-file-name)))))))
(if (one-window-p)
(setq find-fun #'find-file-other-window
lib-fun #'find-library-other-window)
(setq find-fun #'find-file
lib-fun #'find-library))
(let ((result (funcall openfun name)))
(with-current-buffer old-buffer
(setq default-directory old-default-dir))
result)))
(defun eshell/emacs (&rest args)
"run external Emacs."
(eshell-eval-using-options ; this is somewhat broken but works okay
"emacs" args
'(
(nil "batch" nil batch "Non-interactive")
(nil "chdir" t change-dir "change to directory DIR")
("nw" nil nil no-window "open in terminal mode, no window")
("fs" "fullscreen" nil full-screen "Open in full screen")
:external "emacs"
:usage "[FILE] etc placeholder text...")
(mapcar #'mitch/edit-file-or-lib
(eshell-stringify-list (flatten-tree (reverse args))))))
(defun mitch/eshell-setup-keys ()
(evil-collection-define-key
'normal
'eshell-mode-map
(kbd "I") 'eshell-evil-insert-line
(kbd "RET") 'hkey-either))
(advice-add 'evil-collection-eshell-setup-keys
:after 'mitch/eshell-setup-keys))
;; show command that caused last scrollback in eshell etc
(use-package sticky-shell
:elpaca (sticky-shell
:host github
:repo "andyjda/sticky-shell")
:after eshell
:config
(defun esh--turn-off-sticky-shell ()
"Disable `sticky-shell-mode'."
(sticky-shell-mode -1))
(defun esh--turn-on-sticky-shell ()
"Enable `sticky-shell-mode'."
(sticky-shell-mode 1))
(defun mitch/sticky-shell-refresh ()
"Only turn on sticky-shell if the prompt is at the bottom line of window."
(if (>= (line-number-at-pos (point)) (window-height))
(esh--turn-on-sticky-shell)
(esh--turn-off-sticky-shell)))
(add-hook 'eshell-post-command-hook #'mitch/sticky-shell-refresh)
;; https://emacs.ch/@bram85/109612654687707030
(defun mitch/esh-outline-setup ()
(outline-minor-mode)
(diminish 'outline-minor-mode)
(setq-local outline-regexp eshell-prompt-regexp))
(add-hook 'eshell-mode-hook #'mitch/esh-outline-setup))
(use-package eat
:elpaca (eat :type git
:host codeberg
:repo "akib/emacs-eat"
:files ("*.el" ("term" "term/*.el") "*.texi"
"*.ti" ("terminfo/e" "terminfo/e/*")
("terminfo/65" "terminfo/65/*")
("integration" "integration/*")
(:exclude ".dir-locals.el" "*-tests.el")))
:custom
(eat-kill-buffer-on-exit t)
:hook
(eshell-mode . eat-eshell-visual-command-mode)
(eshell-mode . eat-eshell-mode)
(eat-mode . evil-insert-state))
(use-package hide-mode-line
:commands (hide-mode-line-mode))
;; (use-package eshell-vterm
;; :after eshell
;; :custom (eshell-destroy-buffer-when-process-dies t)
;; :hook (eshell-mode . eshell-vterm-mode))
(use-package eshell-syntax-highlighting
:after eshell
:hook (eshell-mode . eshell-syntax-highlighting-mode))
(use-package eshell-dat
:elpaca (eshell-dat
:repo "https://git.mitchmarq42.xyz/mitch/eshell-dat")
:after eshell)
(use-package ansilove
:elpaca (:host gitlab
:repo "xgqt/emacs-ansilove")
:commands ansilove)
(use-package gitstatus
:elpaca (:host github
:repo "igorepst/gitstatus-el")
:after eshell
:init
(setq system-architecture (car (split-string system-configuration "-")))
(setq gitstatusd-exe (format "~/.cache/gitstatus/gitstatusd-linux-%s"
system-architecture))
(add-hook 'eshell-before-prompt-hook #'gitstatus-eshell-start))
(use-package p11k
:elpaca (:repo "https://git.mitchmarq42.xyz/mitch/p11k-el")
:after eshell
:hook (eshell-first-time-mode . p11k-mode))
;; File manager. Only breaks when you brag about how it doesn't.
(use-package all-the-icons
:elpaca (all-the-icons :post-build
("emacsclient" "--eval '(all-the-icons-install-fonts t)'")))
(use-package nerd-fonts
:elpaca (:host github
:repo "twlz0ne/nerd-fonts.el"))
(use-package dirvish
:elpaca (:files (:defaults "extensions/*.el"))
:defer 0.5
:commands dirvish
:custom
(dirvish-attributes '(all-the-icons collapse))
(dirvish-cache-dir (expand-file-name ".dirvish/" user-emacs-directory))
(dired-listing-switches "-l --almost-all")
(dirvish-side-display-alist '((window-width . 0.15)
(slot . -1)
(side . left)))
;; :init (dirvish-override-dired-mode t)
:config
(general-define-key
:states 'normal
:keymaps 'dirvish-mode-map
"h" 'dired-up-directory
"l" 'dired-find-file
"/" 'dirvish-narrow
"q" 'dirvish-quit)
(general-define-key
:states 'normal
:prefix-command 'file-tree-map-prefix
:prefix-map 'file-tree-map
:prefix "SPC t"
"t" 'dirvish-side))
;; Completion framework...
(use-package vertico
:elpaca (:files (:defaults "extensions/vertico-mouse.el"))
:custom (vertico-resize t)
:init (vertico-mode t)
:config
(add-hook 'minibuffer-setup-hook 'turn-off-line-numbers)
(defun backspace-in-minibuffer ()
"If previous character is `/', kill to the previous `/'.
Otherwise, kill back 1 letter.
see https://www.reddit.com/r/emacs/comments/xq6rpa/comment/iqynyu9/?utm_source=share&utm_medium=web2x&context=3"
(interactive)
(if (string-match-p "/." (minibuffer-contents))
(let ((end (point)))
(re-search-backward "/.")
(forward-char)
(delete-region (point) end))
(backward-delete-char 1)))
:general
(general-define-key
:prefix-map 'minibuffer-mode-map
"DEL" 'backspace-in-minibuffer))
(elpaca nil
(use-package vertico-mouse
:elpaca nil
:after vertico
:config
(vertico-mouse-mode)))
(use-package app-launcher
:elpaca (app-launcher
:host github :repo "SebastienWae/app-launcher")
:after vertico
:config
;; modified from https://www.reddit.com/r/unixporn/comments/s7p7pr/so_which_run_launcher_do_you_use_rofi_or_dmenu/
(defun emacs-run-launcher ()
"Create and select a frame called emacs-run-launcher which
consists only of a minibuffer and has specific dimensions. Run
counsel-linux-app on that frame, which is an Emacs command that
prompts you to select an app and open it in a dmenu like
behaviour. Delete the frame after that command has exited"
(interactive)
(with-selected-frame
(make-frame '(;; see ~/.config/sway/config
(name . "dentarthurdent")
(minibuffer . only)
(width . 120)
(height . 11)))
(unwind-protect
(app-launcher-run-app)
(delete-frame)))))
(use-package consult
:after vertico
:general
(general-define-key
[remap switch-to-buffer] 'consult-buffer))
;; Minibuffer generic stuff
(use-package marginalia
:init (marginalia-mode))
(use-package orderless
:custom
(completion-styles '(orderless partial-completion basic))
(completion-category-defaults nil)
;; (completion-category-overrides '((file (styles basic partial-completion))))
(completion-category-overrides nil))
;; weird multi-path thing
(use-package embark
:general
(general-define-key
:keymap minibuffer-mode-map
"C-." 'embark-act ; broken by default on gnome. Run `ibus-setup' -> emoji
"C-;" 'embark-dwim)
:init
;; :TODO: Should we put this in the which-key section?
(defun embark-which-key-indicator ()
"An embark indicator that displays keymaps using which-key.
The which-key help message will show the type and value of the
current target followed by an ellipsis if there are further
targets."
(lambda (&optional keymap targets prefix)
(if (null keymap) (which-key--hide-popup-ignore-command)
(which-key--show-keymap
(if (eq (plist-get (car targets) :type) 'embark-become)
"Become"
(format "Act on %s '%s'%s" (plist-get (car targets) :type)
(embark--truncate-target (plist-get (car targets) :target))
(if (cdr targets) "" "")))
(if prefix (pcase (lookup-key keymap prefix 'accept-default)
((and (pred keymapp) km) km)
(_ (key-binding prefix 'accept-default))) keymap)
nil nil t (lambda (binding)
(not (string-suffix-p "-argument" (cdr binding))))))))
(setq embark-indicators
'(embark-which-key-indicator
embark-highlight-indicator
embark-isearch-highlight-indicator))
(defun embark-hide-which-key-indicator (fn &rest args)
"Hide the which-key indicator immediately when using the completing-read prompter."
(which-key--hide-popup-ignore-command)
(let ((embark-indicators
(remq #'embark-which-key-indicator embark-indicators)))
(apply fn args)))
(advice-add #'embark-completing-read-prompter
:around #'embark-hide-which-key-indicator)
:custom (enable-recursive-minibuffers t))
;; Consult users will also want the embark-consult package.
(use-package embark-consult)
;; SORTA WORKING: Relative line numbers with stuff
(use-package nlinum-relative
:custom
(nlinum-relative-redisplay-delay 0)
:hook (prog-mode . nlinum-relative-mode)
:init
(defun mitch/nlinum-buffer-setup ()
(nlinum-relative-mode -1)
(nlinum-relative-mode 99)
(setq nlinum-format-function
(lambda (line width)
(let* ((line-display (abs (- line nlinum-relative--current-line)))
(is-current-line? (eq line-display 0))
(line-display (if is-current-line?
nlinum-relative--current-line
(+ nlinum-relative-offset line-display)))
(numwidth (length (number-to-string line-display)))
(spaces (make-string (- width numwidth) ?\ ))
(nlinum-format (if is-current-line?
(format "%%d%s" spaces)
(format "%s%%d" spaces)))
(str (if (and (not (string-equal
nlinum-relative-current-symbol ""))
is-current-line?)
nlinum-relative-current-symbol
(format nlinum-format line-display))))
(if is-current-line?
(put-text-property
0 width 'face 'nlinum-relative-current-face str)
(put-text-property 0 width 'face 'linum str))
str)))
(setq-local nlinum--width (length (number-to-string
(line-number-at-pos (point-max))))))
(add-hook 'minibuffer-exit-hook #'mitch/nlinum-buffer-setup))
;; broken terminal that doesn't compile but at least it's fast when it does
(use-package vterm
:custom
(vterm-always-compile-module t)
(vterm-module-cmake-args "-DUSE_SYSTEM_LIBVTERM=no")
(vterm-clear-scrollback-when-clearing t)
:config
(evil-collection-define-key 'insert 'vterm-mode-map
(kbd "C-w") 'evil-window-map)
(evil-collection-define-key 'normal 'vterm-mode-map
(kbd "RET") 'hkey-either
(kbd "k") 'vterm-send-up
(kbd "j") 'vterm-send-down)
(add-to-list 'vterm-keymap-exceptions
"C-w")
(add-to-list 'vterm-keymap-exceptions
"RET")
(setq mitch/vterm-eval-cmds-strings
'("update-pwd"
"restart-emacs"
"find-file-other-window"
"find-file-other-frame"
"eshell/emacs"
"eshell/man"
"dirvish"
"magit"
"info-other-window"
"add-vterm-eval-cmd"))
(defun add-vterm-eval-cmd (function)
"Add FUNCTION to `vterm-eval-cmds' so it can be ran through sh in vterm."
(add-to-list 'vterm-eval-cmds
(list function (intern function))))
(dolist (emacs-function mitch/vterm-eval-cmds-strings)
(add-vterm-eval-cmd emacs-function))
:hook
(vterm-mode . mitch/terminal-setup)
(vterm-exit-functions . save-buffers-kill-terminal))
(use-package multi-vterm
:commands (multi-vterm multi-vterm-other-window)
:config
(defun multi-vterm-other-window ()
"Run a new-ish vterm in the other window"
(interactive)
(other-window 1) (multi-vterm))
:general
(general-define-key
:states '(normal visual)
:prefix "SPC"
:non-normal-prefix "SPC"
"v" 'multi-vterm)
(general-define-key
:states 'normal
:prefix-map 'ctl-x-4-map
:prefix "SPC 4"
"v" 'multi-vterm-other-window))
;; Better modeline? Better modeline.
(use-package powerline
:custom
(powerline-display-buffer-size nil)
(powerline-default-separator 'utf-8)
(powerline-utf-8-separator-left (string-to-char ""))
(powerline-utf-8-separator-right (string-to-char "")))
(use-package airline-themes
:custom
(airline-cursor-colors nil)
(airline-display-directory t)
(airline-eshell-colors nil)
(airline-shortened-directory-length 20)
:custom-face
(mode-line
((t (:box (:style released-button :line-width (0.5 . 0.5))))))
;; :config (load-theme 'airline-kolor t)
)
;; see https://github.com/dbordak/telephone-line/issues/126
;; (no telephone-line because why)
;; Custom Theme.
;; Not to be confused with a color theme, or a color scheme, or a custom scheme.
(use-package sv-theme
:elpaca (sv-theme
:repo
"https://git.mitchmarq42.xyz/mitch/vimcolors")
:config
(mitch/visual-setup)
(load-theme 'airline-ravenpower t)
:init (load-theme 'sv t))
;; (use-package doom-themes
;; :config (mitch/visual-setup)
;; (load-theme 'airline-ravenpower t)
;; :init (load-theme 'doom-acario-dark t))
(use-package page-break-lines
:diminish
:hook (emacs-lisp-mode . page-break-lines-mode))
(use-package yascroll
:diminish
:defer 1
;; :if (not (display-graphic-p))
:custom (yascroll:delay-to-hide nil)
;; :custom-face
;; (yascroll:thumb-fringe
;; ((t (:background "green3"))))
:config
(defun yascroll:make-thumb-overlay-fringe (left-or-right)
"Make thumb overlay on the LEFT-OR-RIGHT fringe."
(let* ((pos (point))
;; If `pos' is at the beginning of line, overlay of the
;; fringe will be on the previous visual line.
(pos (if (= (line-end-position) pos) pos (1+ pos)))
;; below originally said `filled-rectangle' instead of `empty-line'.
;; Changed to fix transparency.
(display-string `(,left-or-right empty-line yascroll:thumb-fringe))
(after-string (propertize "." 'display display-string))
(overlay (make-overlay pos pos)))
(overlay-put overlay 'after-string after-string)
(overlay-put overlay 'fringe-helper t)
(overlay-put overlay 'window (selected-window))
(overlay-put overlay 'priority yascroll:priority)
overlay))
(add-to-list 'yascroll:disabled-modes 'org-mode)
;; (global-yascroll-bar-mode 1)
)
;; parentheses settingses
(elpaca (paredit :depth nil)
(use-package paredit
:elpaca nil
;; elpaca declaration is broken, I just cloned it manually to .config/emacs/elpaca/repos
;; see my issue https://github.com/progfolio/elpaca/issues/40
:diminish
:general (general-define-key
"M-j" 'paredit-forward-slurp-sexp
"M-k" 'paredit-forward-barf-sexp
"M-h" 'paredit-backward-barf-sexp
"M-l" 'paredit-backward-slurp-sexp)
:hook (prog-mode . paredit-mode)
:init
(show-paren-mode 1)
(paredit-mode 1)
(electric-pair-mode 1)
:custom
(show-paren-delay 0)
(show-paren-style 'parenthesis)))
(use-package evil-paredit
:after paredit
:hook (evil-mode . evil-paredit-mode))
;; org mode and messy things
(use-package org
:elpaca nil
:diminish (org-indent-mode org-vw-mode)
:custom
;; (org-hide-leading-stars t)
;; (org-startup-indented t)
;; (org-hide-emphasis-markers t)
(inhibit-compacting-font-caches t)
(org-element-use-cache nil)
:config
(add-hook 'after-save-hook
(lambda () (if (equal major-mode 'org-mode)
(org-babel-tangle))))
(remove '(?< . ?>) electric-pair-pairs)
(electric-pair-mode -1)
(defvar org-electric-pairs '((?_ . ?_)
(?/ . ?/)
(?* . ?*)
(?+ . ?+)
(?~ . ?~)
(?= . ?=))
"Electric pairs for org-mode.
See https://emacs.stackexchange.com/questions/2538/how-to-define-additional-mode-specific-pairs-for-electric-pair-mode")
;; (defun org-add-electric-pairs ()
;; (setq-local electric-pair-pairs (append electric-pair-pairs org-electric-pairs))
;; (setq-local electric-pair-text-pairs electric-pair-pairs))
;; (add-hook 'org-mode-hook 'org-add-electric-pairs)
(require 'mitch-orgstuff)
(defun insert-zws ()
(interactive)
(insert 8203)) ; this is a Zero Width Space. It makes things confusing.
(defun insert-ï ()
(interactive)
(insert 239)) ; this is a lowercase I with an umlaut. Used for the word `naiive'.
:hook
(org-mode . turn-off-line-numbers)
(org-mode . org-vw-mode)
(org-mode . yas-minor-mode)
:general (general-define-key
:states 'insert
:keymaps 'org-mode-map
"`" (general-key-dispatch 'self-insert-command
:timeout 0.1
"SPC" 'insert-zws
"i" 'insert-ï))
(general-define-key
:states '(normal visual insert)
:keymaps 'org-mode-map
"_" 'mitch/org-dwim-char
"/" 'mitch/org-dwim-char
"*" 'mitch/org-dwim-char
"+" 'mitch/org-dwim-char
"~" 'mitch/org-dwim-char
"=" 'mitch/org-dwim-char)
(general-define-key
:states 'normal
:keymaps 'org-src-mode-map
"ZZ" 'org-edit-src-exit))
(use-package org-block-capf
:elpaca (org-block-capf
:host github
:repo "xenodium/org-block-capf")
:after org
:init (add-hook 'org-mode-hook
#'org-block-capf-add-to-completion-at-point-functions))
(use-package org-tempo
:elpaca nil
:after org
:config
(add-to-list 'org-structure-template-alist '("sh" . "src shell"))
(add-to-list 'org-structure-template-alist '("el" . "src elisp"))
(add-to-list 'org-structure-template-alist '("html" . "src html")))
;; (use-package org-variable-pitch
;; :after org
;; :if (display-graphic-p)
;; :diminish (buffer-face-mode org-variable-pitch-minor-mode)
;; :custom-face (org-meta-line
;; ((nil (:inherit
;; (font-lock-comment-delimiter-face fixed-pitch)))))
;; :hook (org-mode . org-variable-pitch-minor-mode))
;; (use-package org-appear
;; :hook (org-mode . org-appear-mode)
;; :after org
;; :custom
;; (org-appear-autolinks t)
;; (org-appear-autoemphasis t)
;; (org-appear-autoentities t)
;; (org-appear-autokeywords t)
;; (org-appear-autosubmarkers t))
(use-package org-pretty-table
:elpaca (org-pretty-table
:host github
:repo "Fuco1/org-pretty-table")
:diminish
:hook (org-mode . org-pretty-table-mode))
(use-package ox-hugo
:after org
:config
(defun hugo-dir-above (dir)
"Return path of Hugo project root above or at DIR.
Return nil if DIR is not in a hugo project at all."
(let ((thisdir dir))
(let ((lexical-binding t))
(if (eq thisdir nil) nil
(if (file-exists-p (expand-file-name "config.toml" thisdir))
thisdir
(let ((updir (file-name-directory (string-trim-right thisdir "/"))))
(hugo-dir-above updir)))))))
;; (hugo-dir-above "~/.local/git/mitchmarq42.github.io/content-org/")
(defun hugo-compile (&optional dir)
(interactive)
(if (bound-and-true-p dir) nil
(setq dir default-directory))
(let ((hugo-dir (hugo-dir-above dir)))
(if hugo-dir
(progn
(if (string-match-p (rx bol (* any) "/content-org" (opt "/") eol)
default-directory)
(org-hugo-export-wim-to-md-after-save))
(let* ((default-directory hugo-dir)
(buffer (get-buffer-create "*hugo*")))
(with-current-buffer buffer
;; (compilation-mode)
(let* ((inhibit-read-only t)
(status-code (call-process-shell-command "hugo" nil buffer)))
(if (zerop status-code)
(message "Hugo re-generated!")
(error "Hugo exited %s, better change something!" status-code)))))))))
(add-hook 'after-save-hook #'hugo-compile))
;; fake indentation, other than the other fake indentation
;; (use-package adaptive-wrap
;; :custom (adaptive-wrap-extra-indent 2)
;; :hook (org-mode . adaptive-wrap-prefix-mode))
;; cheaty key popups
(use-package which-key
:diminish
:defer 5
:custom (which-key-idle-delay 2.5)
:init (which-key-mode t))
;; parentheses are boring
(use-package rainbow-delimiters
:diminish
:defer 1
:hook (prog-mode . rainbow-delimiters-mode))
;; Hex colors
(use-package rainbow-mode
:diminish
:hook (prog-mode . rainbow-mode))
;; Nobody loves a good language
(use-package powershell
:mode ("\\.ps1\\'" . powershell-mode))
;; c sharp; taken from https://www.reddit.com/r/emacs/comments/k8tnzg/help_setting_up_c_lsp_omnisharproslyn/
;; (there is nothing here because I'm not using c sharp...)
(use-package lsp-mode
:hook ((powershell-mode . lsp-mode)
(lsp-mode . lsp-enable-which-key-integration)
(lsp-completion-mode . corfu/lsp-mode-setup-completion))
:commands lsp
:diminish lsp-lens-mode
:custom (lsp-completion-provider :none)
:init (defun corfu/lsp-mode-setup-completion ()
(setf (alist-get 'styles (alist-get 'lsp-capf completion-category-defaults))
'(flex))))
(use-package treesit-auto
:elpaca (treesit-auto
:host github
:repo "renzmann/treesit-auto")
:custom (treesit-auto-install 'prompt)
;; :init (add-to-list 'treesit-auto-fallback-alist '(bash-ts-mode . sh-mode))
)
;; broken snippets I don't care about...
(use-package yasnippet
:diminish yas-minor-mode
:hook (prog-mode . yas-minor-mode))
;; Better help-pages. Genuinely pretty great.
(use-package helpful
:general (general-define-key
[remap describe-key] 'helpful-key
[remap describe-variable] 'helpful-variable
[remap describe-function] 'helpful-callable)
(general-define-key
:keymaps 'help-map
"F" 'describe-face
"k" 'helpful-key)
(general-define-key
:keymaps 'emacs-lisp-mode-map
:states 'normal
"K" 'helpful-at-point)
:custom (elisp-refs-verbose nil))
;; Better lisp highlighting?
(use-package highlight-defined
:hook (emacs-lisp-mode . highlight-defined-mode))
(use-package relint)
(use-package elisp-autofmt
:elpaca (elisp-autofmt
:host codeberg
:repo "ideasman42/emacs-elisp-autofmt"
:files ("*"))
:custom (elisp-autofmt-python-bin "/usr/bin/python3"))
;; Shell linting?
(use-package flymake
:diminish
:custom
(flymake-note-bitmap '(right-arrow compilation-info))
(flymake-error-bitmap '(right-arrow compilation-info))
(flymake-warning-bitmap '(right-arrow compilation-info))
:hook (prog-mode . flymake-mode))
;; Emacs startup profiling -- may not work with chemacs2
(use-package esup
:commands esup)
;; Blingy laggy minimap on the right
(use-package minimap
:general (general-define-key
:states 'normal
:prefix-command 'mini-map-prefix
:prefix-map 'mini-map
:prefix "SPC m"
"m" 'minimap-mode
"k" 'minimap-kill)
:diminish
:custom
(minimap-window-location 'right)
(minimap-update-delay 0)
:custom-face
(minimap-active-region-background
((t (:background "#303030" :extend t))))
(minimap-current-line-face
((nil (:background "#afafaf" :extend t)))))
;; epic drop-down completion
;; (use-package company
;; :diminish
;; :custom ;(company-require-match nil)
;; (company-tooltip-align-annotations t)
;; :hook (prog-mode . company-mode))
(use-package corfu
:elpaca (:files (:defaults "extensions/*.el"))
;; :if (display-graphic-p) ; breaks in emacsclient
:custom
(corfu-cycle t) ;; Enable cycling for `corfu-next/previous'
(corfu-auto t) ;; Enable auto completion
(corfu-auto-delay 1.5)
(corfu-auto-prefix 2)
(corfu-separator ?-) ;; Orderless field separator
(corfu-quit-at-boundary 'separator) ;; Never quit at completion boundary
(corfu-quit-no-match 'separator) ;; Never quit, even if there is no match
(corfu-preview-current nil) ;; Disable current candidate preview
(corfu-preselect-first nil) ;; Disable candidate preselection
(corfu-on-exact-match nil) ;; Configure handling of exact matches
(corfu-scroll-margin 5) ;; Use scroll margin
(completion-cycle-threshold 0)
(tab-always-indent 'complete)
(tooltip-delay 0.01)
(use-system-tooltips nil)
(tooltip-hide-delay 60)
:custom-face
(tooltip
((t (:inherit 'corfu-default))))
:init (global-corfu-mode)
(tooltip-mode)
:config
(advice-add 'pcomplete-completions-at-point :around #'cape-wrap-silent)
(advice-add 'pcomplete-completions-at-point :around #'cape-wrap-purify)
:general
(general-define-key
:states 'insert
:keymaps 'corfu-map
[tab] 'corfu-next
[backtab] 'corfu-previous
"RET" 'corfu-insert
"ESC" 'corfu-quit
"C-h" 'corfu-info-documentation
"C-f" 'corfu-info-location))
(elpaca nil
(use-package corfu-echo
:elpaca corfu
:custom (corfu-echo-delay t)
:after corfu
:config (corfu-echo-mode))
(use-package corfu-history
:elpaca corfu
:after corfu
:config (corfu-history-mode)))
(use-package cape
:after corfu
:init
(add-to-list 'completion-at-point-functions #'cape-dabbrev)
(add-to-list 'completion-at-point-functions #'cape-file)
(add-to-list 'completion-at-point-functions #'cape-ispell))
(use-package pcmpl-args
:after eshell)
(use-package popon
:elpaca (:type git
:repo "https://codeberg.org/akib/emacs-popon")
:if (not (display-graphic-p)))
(use-package corfu-terminal
:elpaca (corfu-terminal
:type git
:repo "https://codeberg.org/akib/emacs-corfu-terminal")
:after popon
:init (unless
(display-graphic-p)
(corfu-terminal-mode +1)))
(use-package magit
:commands (madots magit-status magit)
:hook (magit-mode . turn-off-line-numbers)
:custom (vc-follow-symlinks t)
(transient-history-file
(expand-file-name "transient/history.el" backup-directory))
:config
(defun madots--magit-buffers-p ()
(not (not ; converts all non-nil values to t
(remove nil ; clean useless elements
(mapcar (lambda (buffer)
(if (string-match-p "magit: " (buffer-name buffer))
buffer))
(buffer-list))))))
(defun madots--kill-all-magit-buffers ()
(mapcar (lambda (buffer)
(if (string-match-p "^magit" (buffer-name buffer))
(kill-buffer buffer)))
(buffer-list)))
(defun madots--cleanup ()
"Remove modifications made for `madots' once all magit buffers are killed."
(if (not (madots--magit-buffers-p))
(progn
(setq magit-git-executable madots--old-magit-exe)
(setq magit-bury-buffer-function madots--old-magit-bury-buf-func)
(cancel-function-timers #'madots--cleanup))))
(defun madots (&optional exe)
"Magit but with custom EXE, default \"dots\"."
(interactive)
(require 'magit)
(setq madots--old-magit-exe magit-git-executable)
(setq magit-git-executable (or exe "dots"))
(setq madots--old-magit-bury-buf-func magit-bury-buffer-function)
(setq magit-bury-buffer-function #'kill-buffer-and-window)
(magit-status)
(run-with-timer 5 3 #'madots--cleanup)))
(use-package magit-todos
:after magit
:init (magit-todos-mode))
(use-package blamer
:elpaca (:host github :repo "artawower/blamer.el")
:custom
(blamer-view 'overlay)
(blamer-idle-time 10)
(blamer-min-offset 70)
(blamer-prettify-time-p t)
(blamer-show-avatar-p t)
:custom-face
(blamer-face ((t :foreground "#7a88cf"
:background nil
:height 140
:italic t)))
:commands blamer-show-posframe-commit-info)
(use-package magit-stats
:elpaca (:host github :repo "LionyxML/magit-stats")
:after magit
:commands magit-stats)
(use-package hyperbole
:elpaca (:files ("*.el"
("kotl" "kotl/*.el")
"man/*.info" "man/*.texi")
:host github :repo "rswgnu/hyperbole")
:diminish
:general (general-define-key
:states 'normal
"RET" 'hkey-either))
(use-package dconf-mode
:elpaca (dconf-mode
:type git
:repo "https://git.mitchmarq42.xyz/mitch/dconf-mode.el"))
(use-package info-variable-pitch
:elpaca (info-variable-pitch
:host github
:repo "kisaragi-hiu/info-variable-pitch")
:config
(add-hook 'Info-mode-hook #'info-variable-pitch-mode))
;; (elpaca nil
;; (use-package exwm
;; :elpaca nil
;; :if (package-installed-p 'exwm)
;; :init
;; (require 'exwm-config)
;; (exwm-config-example)))
(elpaca nil
(use-package xwidget
:elpaca nil
:commands xwidget-webkit-browse-url
:config
(defun mitch/webkit-isearch ()
(interactive)
(xwidget-webkit-search
(setq isearch-string
(read-from-minibuffer "Find in page: "))
(car xwidget-list)
'insensitive nil t))
(defun mitch/webkit-isearch-next ()
(interactive)
(xwidget-webkit-search isearch-string
(car xwidget-list) 'insensitive nil t))
(defun mitch/webkit-isearch-prev ()
(interactive)
(xwidget-webkit-search isearch-string
(car xwidget-list) 'insensitive t t))
;; (posframe-show ) ;; need posframe package
:general (general-define-key
:states 'normal
:keymaps 'xwidget-webkit-mode-map
"/" 'mitch/webkit-isearch
"n" 'mitch/webkit-isearch-next
"N" 'mitch/webkit-isearch-prev)))
(use-package ani-el
:elpaca (ani-el
:repo "https://git.mitchmarq42.xyz/mitch/ani-el"
:files ("ani-el.el" "lib")))
(use-package slime
:if (file-exists-p (expand-file-name "~/quicklisp/slime-helper.el"))
:commands (slime slime-connect)
:custom (inferior-lisp-program "sbcl")
:config (load (expand-file-name "~/quicklisp/slime-helper.el")))
;; built in spell checker, for losers
(use-package flyspell
:elpaca nil
:diminish
:custom
(flyspell-auto-correct-word t)
:hook
(org-mode . flyspell-mode))
;; Java never looked so useful...
(use-package clojure-mode
:mode "\\.cljs\\'")
(use-package inf-clojure
:after clojure-mode)
;; or an okay language
(use-package cider
:after clojure-mode)
;; unique buffer names
(use-package uniquify
:elpaca nil
:custom (uniquify-buffer-name-style 'forward))
;; cache file cleanup
(use-package kkc
:elpaca nil
:custom (kkc-init-file-name (expand-file-name "kkcrc" backup-directory)))
;; see https://www.reddit.com/r/emacs/comments/xyo2fo/orgmode_vterm_tmux/
(use-package ob-tmux
:after (org dash)
:config
(setq org-src-lang-modes (-replace
'("tmux" . sh)
'("tmux" . powershell)
org-src-lang-modes))
:custom
(org-babel-default-header-args:tmux
'((:results . "display")
(:session . "default")
(:socket . nil)))
(org-babel-tmux-session-prefix "ob-")
(org-babel-tmux-terminal "/home/mitch/.local/bin/emacs-term-shim.sh")
(org-babel-tmux-terminal-opts))
(use-package dwim-shell-command
:elpaca (dwim-shell-command
:files (:defaults "dwim-shell-commands.el"))
:config (require 'dwim-shell-commands)
:commands dwim-shell-commands-kill-process)
;; https://laurencewarne.github.io/emacs/programming/2022/12/26/exploring-proced.html
(elpaca nil
(use-package proced
:elpaca nil
:commands proced
:custom
(proced-auto-update-flag t)
(proced-goal-attribute nil)
(proced-show-remote-processes t)
(proced-enable-color-flag t)
(proced-format 'custom)
:config
(add-to-list
'proced-format-alist
'(custom user pid ppid sess tree pcpu pmem rss start time state
(args comm)))))
(use-package youtube-sub-extractor
:elpaca (youtube-sub-extractor
:host github
:repo "agzam/youtube-sub-extractor.el")
:custom (youtube-sub-extractor-timestamps 'left-margin)
:commands youtube-sub-extractor-extract-subs)
;; Cheat sheet
(use-package cheat-sh
:elpaca (cheat-sh :host github :repo "davep/cheat-sh.el")
:commands cheat-sh)
(use-package pcre2el
:elpaca (:host github
:repo "joddie/pcre2el")
:config
(defmacro prx (&rest expressions)
"Convert the rx-compatible regular EXPRESSIONS to PCRE.
Most shell applications accept Perl Compatible Regular Expressions.
Taken from https://howardism.org/Technical/Emacs/eshell-why.html"
`(rx-let ((integer (1+ digit))
(float (seq integer "." integer))
(b256 (seq (optional (or "1" "2"))
(regexp "[0-9]\\{1,2\\}")))
(ipaddr (seq b256 "." b256 "." b256 "." b256))
(time (seq
digit (optional digit)
":" (= 2 digit) (optional ":" (= 2 digit))))
(email (seq (1+ (regexp "[^,< ]")) "@"
(1+ (seq (1+ (any alnum "-"))) ".") (1+ alnum)))
(date (seq (= 2 digit) (or "/" "-")
(= 2 digit) (or "/" "-") (= 4 digit)))
(ymd (seq (= 4 digit) (or "/" "-")
(= 2 digit) (or "/" "-") (= 2 digit)))
(uuid (seq (= 8 hex) "-" (= 3 (seq (= 4 hex) "-")) (= 12 hex)))
(guid (seq uuid)))
(rxt-elisp-to-pcre (rx ,@expressions)))))
(use-package org-modern
:after org
:custom
(org-modern-tag nil)
(org-modern-todo nil)
(org-modern-block-name nil)
(org-modern-table nil)
(org-modern-hide-stars nil)
(org-modern-star nil)
;; (org-modern-block-fringe 16)
:hook (org-mode . org-modern-mode)
:config
(defun mitch/org-grayify-stars ()
"Make the `*' characters in Org headlines look like the `#'s in markdown."
(interactive)
(font-lock-add-keywords
nil
`((,(rx bol (+ "*")) . ;; shadow
font-lock-doc-markup-face))))
;; (add-hook 'org-mode-hook
;; #'mitch/org-grayify-stars 90)
(advice-add 'org-modern--make-font-lock-keywords
:after #'mitch/org-grayify-stars)
)
(use-package svg-tag-mode
:elpaca (svg-tag-mode
:host github
:repo "rougier/svg-tag-mode")
;; :after org-modern
:hook (org-modern-mode . svg-tag-mode)
:custom (svg-tag-tags
`((,(rx blank (group (= 4 upper)) blank) .
((lambda (tag)
(svg-tag-make tag
:inverse t
:face (intern
(format "org-%s" (downcase tag)))))))
(,(rx (group "#+" (or "begin" "end") "_src")) .
((lambda (tag)
(let* ((begend (string-trim tag "#\\+" "_src"))
(upcased (upcase begend)))
(svg-tag-make upcased
:face 'org-block-begin-line)))))))
)
(use-package haskell-mode)
(use-package yuck-mode)
(use-package klondike
:elpaca (:host codeberg
:repo "WammKD/Emacs-Klondike")
:commands klondike)
;; disabled because error and useless
;; (use-package aggressive-indent
;; :after paredit
;; :commands aggressive-indent-mode
;; :hook (emacs-lisp-mode . aggresssive-indent-mode))
;; disabled because it breaks things and I don't care
(use-package perspective
:init (persp-mode)
:custom
(persp-suppress-no-prefix-key-warning t)
(persp-show-modestring nil)
;; :config
;; (consult-customize consult--source-buffer :hidden t :default nil)
;; (add-to-list 'consult-buffer-sources persp-consult-source)
)
(use-package perspective-tabs
:elpaca (perspective-tabs
:host sourcehut
:repo "woozong/perspective-tabs")
:after perspective
:init (perspective-tabs-mode +1))
(use-package empv
:after embark
:custom
(empv-invidious-instance "https://invidious.sethforprivacy.com/api/v1")
:config (empv-embark-initialize-extra-actions)
(add-to-list 'empv-mpv-args "--ytdl-format=best"))
(use-package fretboard
:elpaca (:host github :repo "vifon/fretboard.el")
:defer t)
(provide 'mitch-packages)
;;; mitch-packages.el ends here