diff --git a/init.el b/init.el index cfb35e6..8e4f028 100644 --- a/init.el +++ b/init.el @@ -208,6 +208,8 @@ (add-to-list 'eshell-modules-list 'eshell-rebind) (add-to-list 'eshell-modules-list 'eshell-hist) (add-to-list 'eshell-modules-list 'eshell-tramp) + (advice-add 'eshell-delete-backward-char :override + #'paredit-backward-delete) (add-hook 'kill-emacs-hook (lambda () (if (fboundp #'eshell-save-some-history) (eshell-save-some-history)))) @@ -271,7 +273,8 @@ If the current window occupies the whole frame, split it." (straight-use-package 'use-package) (setq straight-use-package-by-default t) (straight-use-package 'dash) - (require 'dash)) + (require 'dash) + (setq use-package-git-keyword :straight)) ;; actually, use elpaca instead ;; (require 'elpaca-bootstrap) @@ -294,23 +297,38 @@ If the current window occupies the whole frame, split it." (elpaca-use-package-mode) (setq elpaca-use-package-by-default t)) (elpaca-process-queues) - (require 'dash)) + (require 'dash) + (setq use-package-git-keyword :elpaca)) (defun nix-bootstrap () "placeholder function. Ideally, load nix packages" - (message "you never set up nix packages, baka!")) - -(if (executable-find "home-manager") - (nix-bootstrap) - (if (eq system-type 'windows-nt) - (straight-bootstrap) - (elpaca-bootstrap))) + (message "you never set up nix packages, baka!") + (require 'dash) + ;(setq use-package-git-keyword :nix) + (straight-bootstrap) + ) +(defun plist-remove (key plist) + "Remove KEY and its immediately following value from PLIST." + (if (member key plist) + (let ((index (cl-position key plist))) + (-remove-at-indices `(,index ,(1+ index)) plist)) + plist)) +;; (plist-remove :straight '(use-package package)) +;; (if (executable-find "home-manager") +;; ;; (nix-bootstrap) +;; (straight-bootstrap) +;; (if (eq system-type 'windows-nt) +;; (straight-bootstrap) +;; (elpaca-bootstrap))) +(straight-bootstrap) (fset #'use-package--orig (symbol-function #'use-package)) (defmacro use-package (&rest args) "re-definition of use-package to replace the downloader depending on system" ;; (require 'dash) - `(use-package--orig ,@(-replace :git :straight args))) + (if (eq use-package-git-keyword :nix) + `(use-package--orig ,@(plist-remove :git args)) + `(use-package--orig ,@(-replace :git use-package-git-keyword args)))) ;; (use-package lua-mode :git nil) ;; see https://www.reddit.com/r/emacs/comments/1937vaz/emacs_291_on_windows_install_magit_requires_seq/?rdt=48529 @@ -349,11 +367,944 @@ If the current window occupies the whole frame, split it." :init (add-to-list 'auto-mode-alist '("\\.ps1\\'" . powershell-mode))) - ;; (message "%s" elpaca--queues) (if (fboundp #'elpaca) (elpaca-process-queues)) -(require 'mir-packages) +;; diminish +(use-package diminish + :config (diminish 'visual-line-mode)) + +;; Keybinding manager +(use-package general + :demand t + :custom (default-input-method "japanese") + :config (require 'mir-keybinds)) +(if (fboundp #'elpaca) (elpaca-wait)) +(use-package eldoc-box + :after eldoc + :diminish (eldoc-mode eldoc-box-hover-at-point-mode) + :hook (prog-mode . eldoc-box-hover-at-point-mode)) + +;; load evil or meow +(require 'mir-evil) +;; (require 'mir-meow) + +(use-package undo-fu + :after evil + :if (< (string-to-number emacs-version) 28) + :diminish) +(use-package vundo + :custom (vundo-glyph-alist vundo-unicode-symbols) + :config + ;; taken from https://github.com/casouri/vundo/issues/56 + (defun my/vundo-diff () + (interactive) + (let* ((orig vundo--orig-buffer) + (source (vundo--current-node vundo--prev-mod-list)) + (dest (vundo-m-parent source))) + (if (or (not dest) (eq source dest)) + (message "vundo diff not available.") + (let ((buf (make-temp-name (concat (buffer-name orig) "-vundo-diff")))) + (vundo--move-to-node source dest orig vundo--prev-mod-list) + (with-current-buffer (get-buffer-create buf) + (insert-buffer orig)) + (vundo--refresh-buffer orig (current-buffer) 'incremental) + (vundo--move-to-node dest source orig vundo--prev-mod-list) + (vundo--refresh-buffer orig (current-buffer) 'incremental) + (diff-buffers buf orig) + (kill-buffer buf))))) + :general + (general-define-key + :states '(normal visual) + :prefix "SPC" + "u" 'vundo) + (general-define-key + :keymaps 'vundo-mode-map + "d" 'my/vundo-diff)) + +(use-package altcaps + :after evil + :git (:host github + :repo "protesilaos/altcaps") + :general (general-define-key + :states 'visual + "`" 'altcaps-region)) + +;; edwina window manager, like the kool kids +(use-package edwina + :after evil + :custom + (edwina-mfact 0.59) + ;; (display-buffer-base-action '(display-buffer-below-selected)) + :config (edwina-mode) + (advice-add 'balance-windows + :override 'edwina-arrange) + (add-hook 'server-after-make-frame-hook #'edwina-arrange) + (edwina-arrange) + :general + (general-define-key + [remap split-window-right] 'edwina-clone-window + [remap evil-window-move-far-left] 'edwina-zoom + [remap evil-window-move-far-right] 'edwina-zoom + [remap evil-window-increase-height] 'edwina-inc-mfact + [remap evil-window-decrease-height] 'edwina-dec-mfact + [remap balance-windows] 'edwina-arrange)) + +;; show command that caused last scrollback in eshell etc +(use-package sticky-shell + :git (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 mir/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 #'mir/sticky-shell-refresh) + ;; https://emacs.ch/@bram85/109612654687707030 + (defun mir/esh-outline-setup () + (outline-minor-mode) + (diminish 'outline-minor-mode) + (setq-local outline-regexp eshell-prompt-regexp)) + (add-hook 'eshell-mode-hook #'mir/esh-outline-setup)) +(use-package exec-path-from-shell + :hook (eshell-mode . exec-path-from-shell-initialize)) + +(use-package eat + :git (eat :type git + :repo "https://codeberg.org/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-syntax-highlighting + :after eshell + :hook + (eshell-mode . eshell-syntax-highlighting-mode) + (eshell-syntax-highlighting-elisp-buffer-setup + . rainbow-delimiters-mode) + (eshell-syntax-highlighting-elisp-buffer-setup + . highlight-defined-mode) + :custom + (eshell-syntax-highlighting-in-remote-dirs t)) +(use-package eshell-dat + :git (eshell-dat + :repo "https://git.marq42.xyz/mir/eshell-dat") + :after eshell) +(use-package ansilove + :git (:host gitlab + :repo "xgqt/emacs-ansilove") + :commands ansilove) +(use-package p11k + :git (:repo "https://git.marq42.xyz/mir/p11k") + :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 + :git (all-the-icons + ;; :post-build + ;; ("emacsclient" "--eval '(all-the-icons-install-fonts t)'") + )) +(use-package nerd-fonts + :git (:host github + :repo "twlz0ne/nerd-fonts.el")) +;; (use-package nerd-icons ;has error +;; :git (:host github :repo "rainstormstudio/nerd-icons.el") +;; :custom (nerd-icons-font-family "MesloLGS NF")) +(use-package dirvish + :git (: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 + :git (:files (:defaults "extensions/*.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)) +(use-package vertico-mouse + :git nil + :after vertico + :config + (vertico-mouse-mode)) +(use-package app-launcher + :git (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 と ~/.config/hypr/hyprland.conf + (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 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) + +;; el-patch, TODO remove linum requirement +(use-package el-patch) +;; 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 mir/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 #'mir/nlinum-buffer-setup)) + +;; 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 "")) + :init + (defun mir/powerline-never-select-cfwindow (orig) + "Only run ORIG if the current frame is not a child frame." + (unless (frame-parent) (funcall orig))) + (advice-add #'powerline-set-selected-window + :around #'mir/powerline-never-select-cfwindow)) +(use-package doom-modeline + :disabled + :after airline-themes + :custom + (doom-modeline-hud t) + (doom-modeline-buffer-encoding nil) + (doom-modeline-unicode-fallback t) + (doom-modeline-buffer-file-name-style 'truncate-upto-root) + (doom-modeline-highlight-modified-buffer-name nil) + :config (doom-modeline-mode)) +;; (elpaca-wait) +(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 + :git (sv-theme + :repo + "https://git.marq42.xyz/mir/sv-theme") + :config + (mir/visual-setup) + (load-theme 'airline-ravenpower t) + :init (load-theme 'sv t)) + +;; parentheses settingses +(use-package paredit + ;; :git 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) +(use-package lispyville + :diminish + :hook (paredit-mode . lispyville-mode)) + +;; org mode and messy things +(use-package org + :git 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)))) + (make-local-variable 'completion-at-point-functions) + (add-to-list 'completion-at-point-functions #'cape-ispell) + (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'. + (defun mir/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 + #'mir/org-grayify-stars 90) + (defun mir-insert-current-datetime () + "Insert the current date and time in my preffered format, with a newline at +the end." + (interactive) + (let ((calendar-date-display-form calendar-iso-date-display-form)) + (insert + (downcase + (format "%s %s\n" (calendar-date-string (calendar-current-date)) + (format-time-string "%-l:%M %p")))))) + (defun mir-1st-heading-now () + "Insert a brand new 2nd level Org heading containing the current date/time. +Start insert mode." + (interactive) + (goto-char (point-max)) + (insert "* ") + (mir-insert-current-datetime) + (evil-insert 1)) + + :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 + :keymaps 'org-src-mode-map + "ZZ" 'org-edit-src-exit)) +(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/marq42.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)) + (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)) +(use-package ox-clip + :commands ox-clip-formatted-copy) + +;; cheaty key popups +(use-package which-key + :diminish + :defer 5 + :custom (which-key-idle-delay 2.5) + :init (which-key-mode t)) +;; (use-package which-key-posframe +;; :after which-key +;; :config (which-key-posframe-mode)) + +;; parentheses are boring +(use-package rainbow-delimiters + :diminish + :defer 1 + :custom (rainbow-delimiters-max-face-count 2) + :hook (prog-mode . rainbow-delimiters-mode)) + +;; c sharp; see 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) + :config (defun corfu/lsp-mode-setup-completion () + (setf (alist-get 'styles (alist-get 'lsp-capf completion-category-defaults)) + '(flex)))) + +;; 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 + :git (elisp-autofmt + :url "https://codeberg.org/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 + :custom (esup-depth 0)) +;; (esup buffer-file-name) ;useless + +;; 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 corfu + :after eldoc + :git (: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 t) + (corfu-preview-current nil) + (corfu-on-exact-match 'insert) + ;; (corfu-scroll-margin 5) + (tab-always-indent 'complete) + (tab-first-completion 'eol) + (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) + (corfu-echo-mode) + (corfu-history-mode) + :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)) +(use-package cape + :after corfu + :init + (add-to-list 'completion-at-point-functions #'cape-dabbrev) + (add-to-list 'completion-at-point-functions #'cape-file)) +(use-package pcmpl-args + :after eshell) + +(use-package popon + :git (:type git + :repo "https://codeberg.org/akib/emacs-popon") + :if (not (display-graphic-p))) +(use-package corfu-terminal + :git (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 + :after seq + :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))) +;; ;; broken bc of hl-todo version issue +;; (use-package magit-todos +;; :after magit +;; :init (magit-todos-mode)) +(use-package blamer + :git (:host github :repo "artawower/blamer.el") + :after magit + :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" + :height 140 + :italic t))) + :commands blamer-show-posframe-commit-info) +(use-package magit-stats + :git (:host github :repo "LionyxML/magit-stats") + :after magit + :commands magit-stats) +(use-package magit-pretty-graph + :git (:host github :repo "georgek/magit-pretty-graph") + :after magit + :commands magit-pg-repo) +;; (use-package transient-posframe +;; ;; :after magit +;; :if (display-graphic-p) +;; :config +;; (transient-posframe-mode) +;; ;; (add-to-list 'display-buffer-alist +;; ;; '(" *transient*" . transient-posframe--show-buffer)) +;; ) + +(use-package hyperbole + :git (: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 + :git (dconf-mode + :type git + :repo "https://git.marq42.xyz/mir/dconf-mode")) + +(use-package info-variable-pitch + :git (info-variable-pitch + :host github + :repo "kisaragi-hiu/info-variable-pitch") + :config + (add-hook 'Info-mode-hook #'info-variable-pitch-mode)) + +(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"))) + +;; 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) + +(use-package dwim-shell-command + :git (dwim-shell-command + :files (:defaults "dwim-shell-commands.el")) + :config (require 'dwim-shell-commands) + :commands dwim-shell-commands-kill-process) + +(use-package youtube-sub-extractor + :git (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 + :git (cheat-sh :host github :repo "davep/cheat-sh.el") + :commands cheat-sh) + +(use-package pcre2el + :git (: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 haskell-mode) +(use-package yuck-mode) + +(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 + :git (:host github :repo "vifon/fretboard.el") + :commands fretboard) + +(use-package power-mode + :commands power-mode + :custom + (power-mode-streak-shake-threshold nil)) +(use-package notibox + :if (display-graphic-p) + :git (:host github :repo "MitchMarq42/notibox.el") + :demand t + :custom (notibox-corner 'topright) + :config (notibox/setup-timer)) + + +(use-package vidframe + :if (display-graphic-p) ;we won't yet bother with + ;kitty/sixel/catimg shit + :git (:host github :repo "MitchMarq42/vidframe.el") + ) + +;; Kitty Keyboard Protocol +(use-package kkp + :git (:host github :repo "benjaminor/kkp") + :unless (display-graphic-p) + :config (global-kkp-mode)) + +;; Rubix Cube +(use-package eagle + :git (:repo "https://codeberg.org/akib/emacs-eagle")) +(use-package cube + :git (:repo "https://codeberg.org/akib/emacs-cube")) + +;; Emacs App Framework. Definitely pretty broken but it worked once +(unless (eq system-type 'windows-nt) + (use-package eaf + :git (:host github :repo "emacs-eaf/emacs-application-framework" + :files ("*.el" "*.py" "core" "app" "*.json") + :pre-build (("python" "install-eaf.py" + "--install" "pdf-viewer" "browser" + "--ignore-sys-deps"))) + :commands (eaf-open-browser eaf-open-url-at-point) + :config (add-to-list 'load-path (expand-file-name "app/" eaf-source-dir)) + (if (and (string= (getenv "XDG_CURRENT_DESKTOP") "Hyprland") + (featurep 'hypop)) + (defun eaf--get-frame-coordinate () + "We need fetch Emacs coordinate to adjust coordinate of EAF if it running on system not support cross-process reparent technology. + +Such as, wayland native, macOS etc. + +This is redefined for use with `hypop' library because multiple Emacs frames may be open." + (cond ((string-equal (getenv "XDG_CURRENT_DESKTOP") "sway") + (eaf--split-number (shell-command-to-string (concat eaf-build-dir "swaymsg-treefetch/swaymsg-rectfetcher.sh emacs")))) + ((string-equal (getenv "XDG_CURRENT_DESKTOP") "Hyprland") + (let ((clients (json-parse-string (shell-command-to-string "hyprctl -j clients"))) + (coordinate)) + (dotimes (i (length clients)) + (when (and (equal (gethash "pid" (aref clients i)) (emacs-pid)) + (not (string= (gethash "title" (aref clients i)) hypop--frame-name))) + (setq coordinate (gethash "at" (aref clients i))))) + (list (aref coordinate 0) (aref coordinate 1)))) + ((eaf-emacs-running-in-wayland-native) + (require 'dbus) + (let* ((coordinate (eaf--split-number + (dbus-call-method :session "org.gnome.Shell" "/org/eaf/wayland" "org.eaf.wayland" "get_emacs_window_coordinate" :timeout 1000) + ",")) + ;; HiDPI need except by `frame-scale-factor'. + (frame-x (truncate (/ (car coordinate) (frame-scale-factor)))) + (frame-y (truncate (/ (cadr coordinate) (frame-scale-factor))))) + (list frame-x frame-y))) + (t (list 0 0))))) + (use-package eaf-browser + :git nil + :after eaf + :custom + (eaf-browser-continue-where-left-off t) + (eaf-browser-enable-adblocker t)))) + +(use-package dtache + :git (:repo "https://gitlab.com/niklaseklund/dtache") + :hook (after-init . dtache-setup)) + + +(use-package org-modern-indent + :git (:type git :host github :repo "jdtsmith/org-modern-indent") + :hook (org-mode . org-modern-indent-mode)) + +(use-package indent-bars + :git (:type git :host github :repo "jdtsmith/indent-bars") + :custom + (indent-bars-prefer-character t) + (indent-bars-color '(highlight :face-bg t :blend 0.75)) + (indent-bars-color-by-depth '(:palette ("lime" "yellow" "pink" "cyan") :blend 1)) + (indent-bars-unspecified-fg-color "white") + (indent-bars-unspecified-bg-color "black") + (indent-bars-highlight-current-depth '(:face error :blend 0.7)) + :hook (python-mode . indent-bars-mode)) + + +(use-package lua-mode) + +(use-package nix-mode) + +;(require 'mir-packages) ;; (setq esup-depth 0) ;; Absolute line numbers. Relative ones are an annoyance to set up, sadly. diff --git a/lisp/mir-packages.el b/lisp/mir-packages.el index 863cfc5..cb4c700 100644 --- a/lisp/mir-packages.el +++ b/lisp/mir-packages.el @@ -8,143 +8,7 @@ ;; (use-package no-littering) ;a bad start, and we need more -;; diminish -(use-package diminish - :config (diminish 'visual-line-mode)) - -;; Keybinding manager -(use-package general - :demand t - :custom (default-input-method "japanese") - :config (require 'mir-keybinds)) -(if (fboundp #'elpaca) (elpaca-wait)) -(use-package eldoc-box - :after eldoc - :diminish (eldoc-mode eldoc-box-hover-at-point-mode) - :hook (prog-mode . eldoc-box-hover-at-point-mode)) - ;; (use-package use-package-ensure-system-package) - -;; load evil or meow -(require 'mir-evil) -;; (require 'mir-meow) - -(use-package undo-fu - :after evil - :if (< (string-to-number emacs-version) 28) - :diminish) -(use-package vundo - :custom (vundo-glyph-alist vundo-unicode-symbols) - :config - ;; taken from https://github.com/casouri/vundo/issues/56 - (defun my/vundo-diff () - (interactive) - (let* ((orig vundo--orig-buffer) - (source (vundo--current-node vundo--prev-mod-list)) - (dest (vundo-m-parent source))) - (if (or (not dest) (eq source dest)) - (message "vundo diff not available.") - (let ((buf (make-temp-name (concat (buffer-name orig) "-vundo-diff")))) - (vundo--move-to-node source dest orig vundo--prev-mod-list) - (with-current-buffer (get-buffer-create buf) - (insert-buffer orig)) - (vundo--refresh-buffer orig (current-buffer) 'incremental) - (vundo--move-to-node dest source orig vundo--prev-mod-list) - (vundo--refresh-buffer orig (current-buffer) 'incremental) - (diff-buffers buf orig) - (kill-buffer buf))))) - :general - (general-define-key - :states '(normal visual) - :prefix "SPC" - "u" 'vundo) - (general-define-key - :keymaps 'vundo-mode-map - "d" 'my/vundo-diff)) - -(use-package altcaps - :after evil - :git (:host github - :repo "protesilaos/altcaps") - :general (general-define-key - :states 'visual - "`" 'altcaps-region)) - -;; edwina window manager, like the kool kids -(use-package edwina - :after evil - :custom - (edwina-mfact 0.59) - ;; (display-buffer-base-action '(display-buffer-below-selected)) - :config (edwina-mode) - (advice-add 'balance-windows - :override 'edwina-arrange) - (add-hook 'server-after-make-frame-hook #'edwina-arrange) - (edwina-arrange) - :general - (general-define-key - [remap split-window-right] 'edwina-clone-window - [remap evil-window-move-far-left] 'edwina-zoom - [remap evil-window-move-far-right] 'edwina-zoom - [remap evil-window-increase-height] 'edwina-inc-mfact - [remap evil-window-decrease-height] 'edwina-dec-mfact - [remap balance-windows] 'edwina-arrange)) - -;; show command that caused last scrollback in eshell etc -(use-package sticky-shell - :git (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 mir/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 #'mir/sticky-shell-refresh) - ;; https://emacs.ch/@bram85/109612654687707030 - (defun mir/esh-outline-setup () - (outline-minor-mode) - (diminish 'outline-minor-mode) - (setq-local outline-regexp eshell-prompt-regexp)) - (add-hook 'eshell-mode-hook #'mir/esh-outline-setup)) -(use-package exec-path-from-shell - :hook (eshell-mode . exec-path-from-shell-initialize)) - -(use-package eat - :git (eat :type git - :repo "https://codeberg.org/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-syntax-highlighting - :after eshell - :hook (eshell-mode . eshell-syntax-highlighting-mode)) -(use-package eshell-dat - :git (eshell-dat - :repo "https://git.marq42.xyz/mir/eshell-dat") - :after eshell) -(use-package ansilove - :git (:host gitlab - :repo "xgqt/emacs-ansilove") - :commands ansilove) ;; (use-package gitstatus ;; :git (:host github ;; :repo "igorepst/gitstatus-el") @@ -154,624 +18,6 @@ ;; (setq gitstatusd-exe (format "~/.cache/gitstatus/gitstatusd-linux-%s" ;; system-architecture)) ;; (add-hook 'eshell-before-prompt-hook #'gitstatus-eshell-start)) -(use-package p11k - :git (:repo "https://git.marq42.xyz/mir/p11k") - :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 - :git (all-the-icons - ;; :post-build - ;; ("emacsclient" "--eval '(all-the-icons-install-fonts t)'") - )) -(use-package nerd-fonts - :git (:host github - :repo "twlz0ne/nerd-fonts.el")) -;; (use-package nerd-icons ;has error -;; :git (:host github :repo "rainstormstudio/nerd-icons.el") -;; :custom (nerd-icons-font-family "MesloLGS NF")) -(use-package dirvish - :git (: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 - :git (:files (:defaults "extensions/*.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)) -(use-package vertico-mouse - :git nil - :after vertico - :config - (vertico-mouse-mode)) -(use-package app-launcher - :git (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 と ~/.config/hypr/hyprland.conf - (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 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) - -;; el-patch, TODO remove linum requirement -(use-package el-patch) -;; 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 mir/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 #'mir/nlinum-buffer-setup)) - -;; 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 "")) - :init - (defun mir/powerline-never-select-cfwindow (orig) - "Only run ORIG if the current frame is not a child frame." - (unless (frame-parent) (funcall orig))) - (advice-add #'powerline-set-selected-window - :around #'mir/powerline-never-select-cfwindow)) -(use-package doom-modeline - :disabled - :after airline-themes - :custom - (doom-modeline-hud t) - (doom-modeline-buffer-encoding nil) - (doom-modeline-unicode-fallback t) - (doom-modeline-buffer-file-name-style 'truncate-upto-root) - (doom-modeline-highlight-modified-buffer-name nil) - :config (doom-modeline-mode)) -;; (elpaca-wait) -(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 - :git (sv-theme - :repo - "https://git.marq42.xyz/mir/sv-theme") - :config - (mir/visual-setup) - (load-theme 'airline-ravenpower t) - :init (load-theme 'sv t)) - -;; parentheses settingses -(use-package paredit - ;; :git 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) -(use-package lispyville - :diminish - :hook (paredit-mode . lispyville-mode)) - -;; org mode and messy things -(use-package org - :git 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)))) - (make-local-variable 'completion-at-point-functions) - (add-to-list 'completion-at-point-functions #'cape-ispell) - (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'. - (defun mir/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 - #'mir/org-grayify-stars 90) - (defun mir-insert-current-datetime () - "Insert the current date and time in my preffered format, with a newline at -the end." - (interactive) - (let ((calendar-date-display-form calendar-iso-date-display-form)) - (insert - (downcase - (format "%s %s\n" (calendar-date-string (calendar-current-date)) - (format-time-string "%-l:%M %p")))))) - (defun mir-1st-heading-now () - "Insert a brand new 2nd level Org heading containing the current date/time. -Start insert mode." - (interactive) - (goto-char (point-max)) - (insert "* ") - (mir-insert-current-datetime) - (evil-insert 1)) - - :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 - :keymaps 'org-src-mode-map - "ZZ" 'org-edit-src-exit)) -(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/marq42.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)) - (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)) -(use-package ox-clip - :commands ox-clip-formatted-copy) - -;; cheaty key popups -(use-package which-key - :diminish - :defer 5 - :custom (which-key-idle-delay 2.5) - :init (which-key-mode t)) -;; (use-package which-key-posframe -;; :after which-key -;; :config (which-key-posframe-mode)) - -;; parentheses are boring -(use-package rainbow-delimiters - :diminish - :defer 1 - :custom (rainbow-delimiters-max-face-count 2) - :hook (prog-mode . rainbow-delimiters-mode)) - -;; c sharp; see 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) - :config (defun corfu/lsp-mode-setup-completion () - (setf (alist-get 'styles (alist-get 'lsp-capf completion-category-defaults)) - '(flex)))) - -;; 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 - :git (elisp-autofmt - :host "https://codeberg.org" - :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 - :custom (esup-depth 0)) -;; (esup buffer-file-name) ;useless - -;; 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 corfu - :after eldoc - :git (: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 t) - (corfu-preview-current nil) - (corfu-on-exact-match 'insert) - ;; (corfu-scroll-margin 5) - (tab-always-indent 'complete) - (tab-first-completion 'eol) - (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) - (corfu-echo-mode) - (corfu-history-mode) - :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)) -(use-package cape - :after corfu - :init - (add-to-list 'completion-at-point-functions #'cape-dabbrev) - (add-to-list 'completion-at-point-functions #'cape-file)) -(use-package pcmpl-args - :after eshell) - -(use-package popon - :git (:type git - :repo "https://codeberg.org/akib/emacs-popon") - :if (not (display-graphic-p))) -(use-package corfu-terminal - :git (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 - :after seq - :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))) -;; ;; broken bc of hl-todo version issue -;; (use-package magit-todos -;; :after magit -;; :init (magit-todos-mode)) -(use-package blamer - :git (:host github :repo "artawower/blamer.el") - :after magit - :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" - :height 140 - :italic t))) - :commands blamer-show-posframe-commit-info) -(use-package magit-stats - :git (:host github :repo "LionyxML/magit-stats") - :after magit - :commands magit-stats) -(use-package magit-pretty-graph - :git (:host github :repo "georgek/magit-pretty-graph") - :after magit - :commands magit-pg-repo) -;; (use-package transient-posframe -;; ;; :after magit -;; :if (display-graphic-p) -;; :config -;; (transient-posframe-mode) -;; ;; (add-to-list 'display-buffer-alist -;; ;; '(" *transient*" . transient-posframe--show-buffer)) -;; ) - -(use-package hyperbole - :git (: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 - :git (dconf-mode - :type git - :repo "https://git.marq42.xyz/mir/dconf-mode")) - -(use-package info-variable-pitch - :git (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 @@ -786,85 +32,6 @@ Return nil if DIR is not in a hugo project at all." ;; :repo "https://git.marq42.xyz/mir/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"))) - -;; 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) - -(use-package dwim-shell-command - :git (dwim-shell-command - :files (:defaults "dwim-shell-commands.el")) - :config (require 'dwim-shell-commands) - :commands dwim-shell-commands-kill-process) - -(use-package youtube-sub-extractor - :git (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 - :git (cheat-sh :host github :repo "davep/cheat-sh.el") - :commands cheat-sh) - -(use-package pcre2el - :git (: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 haskell-mode) -(use-package yuck-mode) - -(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 - :git (:host github :repo "vifon/fretboard.el") - :commands fretboard) - -(use-package power-mode - :commands power-mode - :custom - (power-mode-streak-shake-threshold nil)) - ;; (use-package hypop ;; :if (display-graphic-p) ;; :git (:repo "https://git.marq42.xyz/mir/hypop.el") @@ -873,13 +40,6 @@ Taken from https://howardism.org/Technical/Emacs/eshell-why.html" ;; :after vertico ;; :if (display-graphic-p) ;; :config (vertico-posframe-mode)) -(use-package notibox - :if (display-graphic-p) - :git (:host github :repo "MitchMarq42/notibox.el") - :demand t - :custom (notibox-corner 'topright) - :config (notibox/setup-timer)) - ;; (use-package hl-column ; disabled because visual yuck ;; :if (display-graphic-p) ;; :config @@ -894,74 +54,6 @@ Taken from https://howardism.org/Technical/Emacs/eshell-why.html" ;; (hl-column ;; ((t (:inherit hl-line)))) ;; :hook (prog-mode . hl-col-line-init)) - -(use-package vidframe - :if (display-graphic-p) ;we won't yet bother with - ;kitty/sixel/catimg shit - :git (:host github :repo "MitchMarq42/vidframe.el") - ) - -;; Kitty Keyboard Protocol -(use-package kkp - :git (:host github :repo "benjaminor/kkp") - :unless (display-graphic-p) - :config (global-kkp-mode)) - -;; Rubix Cube -(use-package eagle - :git (:repo "https://codeberg.org/akib/emacs-eagle")) -(use-package cube - :git (:repo "https://codeberg.org/akib/emacs-cube")) - -;; Emacs App Framework. Definitely pretty broken but it worked once -(unless (eq system-type 'windows-nt) - (use-package eaf - :git (:host github :repo "emacs-eaf/emacs-application-framework" - :files ("*.el" "*.py" "core" "app" "*.json") - :pre-build (("python" "install-eaf.py" - "--install" "pdf-viewer" "browser" - "--ignore-sys-deps"))) - :commands (eaf-open-browser eaf-open-url-at-point) - :config (add-to-list 'load-path (expand-file-name "app/" eaf-source-dir)) - (if (and (string= (getenv "XDG_CURRENT_DESKTOP") "Hyprland") - (featurep 'hypop)) - (defun eaf--get-frame-coordinate () - "We need fetch Emacs coordinate to adjust coordinate of EAF if it running on system not support cross-process reparent technology. - -Such as, wayland native, macOS etc. - -This is redefined for use with `hypop' library because multiple Emacs frames may be open." - (cond ((string-equal (getenv "XDG_CURRENT_DESKTOP") "sway") - (eaf--split-number (shell-command-to-string (concat eaf-build-dir "swaymsg-treefetch/swaymsg-rectfetcher.sh emacs")))) - ((string-equal (getenv "XDG_CURRENT_DESKTOP") "Hyprland") - (let ((clients (json-parse-string (shell-command-to-string "hyprctl -j clients"))) - (coordinate)) - (dotimes (i (length clients)) - (when (and (equal (gethash "pid" (aref clients i)) (emacs-pid)) - (not (string= (gethash "title" (aref clients i)) hypop--frame-name))) - (setq coordinate (gethash "at" (aref clients i))))) - (list (aref coordinate 0) (aref coordinate 1)))) - ((eaf-emacs-running-in-wayland-native) - (require 'dbus) - (let* ((coordinate (eaf--split-number - (dbus-call-method :session "org.gnome.Shell" "/org/eaf/wayland" "org.eaf.wayland" "get_emacs_window_coordinate" :timeout 1000) - ",")) - ;; HiDPI need except by `frame-scale-factor'. - (frame-x (truncate (/ (car coordinate) (frame-scale-factor)))) - (frame-y (truncate (/ (cadr coordinate) (frame-scale-factor))))) - (list frame-x frame-y))) - (t (list 0 0))))) - (use-package eaf-browser - :git nil - :after eaf - :custom - (eaf-browser-continue-where-left-off t) - (eaf-browser-enable-adblocker t)))) - -(use-package dtache - :git (:repo "https://gitlab.com/niklaseklund/dtache") - :hook (after-init . dtache-setup)) - ;; (if (display-graphic-p) ;; (unless (string= (getenv "XDG_SESSION_DESKTOP") "hyprland") ;; (progn @@ -984,30 +76,10 @@ This is redefined for use with `hypop' library because multiple Emacs frames may ;; :url "https://codeberg.org/gargle/tumblesocks") ;; :custom (tumblesocks-blog "mirqmarq428.tumblr.com") ;; ) - -(use-package org-modern-indent - :git (:type git :host github :repo "jdtsmith/org-modern-indent") - :hook (org-mode . org-modern-indent-mode)) - -(use-package indent-bars - :git (:type git :host github :repo "jdtsmith/indent-bars") - :custom - (indent-bars-prefer-character t) - (indent-bars-color '(highlight :face-bg t :blend 0.75)) - (indent-bars-color-by-depth '(:palette ("lime" "yellow" "pink" "cyan") :blend 1)) - (indent-bars-unspecified-fg-color "white") - (indent-bars-unspecified-bg-color "black") - (indent-bars-highlight-current-depth '(:face error :blend 0.7)) - :hook (python-mode . indent-bars-mode)) - ;;; disabled because i cant make it look good ;; (use-package prism ;; :git (:host github :repo "alphapapa/prism.el") ;; :custom (prism-colors '())) -(use-package lua-mode) - -(use-package nix-mode) - (provide 'mir-packages) ;;; mir-packages.el ends here