Remove vertico and magit

This commit is contained in:
Alexander Rosenberg 2023-12-27 22:43:15 -08:00
parent b930f3072d
commit 0de0f8ebab
Signed by: Zander671
GPG Key ID: 5FD0394ADBD72730

349
init.el
View File

@ -168,9 +168,11 @@
;; recentf ;; recentf
(use-package recentf (use-package recentf
:init :init
(setq recentf-exclude '("^/tmp/.*" (setq recentf-exclude `("^/tmp/.*"
"^~/.mail/[^/]/Drafts/.*" "^~/.mail/[^/]/Drafts/.*"
(format "^%svar/elpa/.*" user-emacs-directory))) ,(format "^%svar/elpa/.*" user-emacs-directory)
,(format "^%svar/gnus/.*" user-emacs-directory)
,(format "^%setc/gnus/.*" user-emacs-directory)))
:bind ("C-c r" . recentf) :bind ("C-c r" . recentf)
:config :config
(recentf-mode 1)) (recentf-mode 1))
@ -243,7 +245,8 @@ visual states."
:predicate '((not magit-mode dired-mode :predicate '((not magit-mode dired-mode
proced-mode mu4e-main-mode proced-mode mu4e-main-mode
mu4e-view-mode mu4e-headers-mode mu4e-view-mode mu4e-headers-mode
ibuffer-mode calc-mode calc-trail-mode) t)) ibuffer-mode calc-mode calc-trail-mode
gnus-group-mode) t))
(my/evil-avy-global-mode 1) (my/evil-avy-global-mode 1)
:config :config
(avy-setup-default)) (avy-setup-default))
@ -288,20 +291,51 @@ visual states."
;; face minibuffer-prompt)) ;; face minibuffer-prompt))
;; (vertico-mode 1)) ;; (vertico-mode 1))
;; icomplete
(use-package icomplete (use-package icomplete
:ensure nil :ensure nil
:demand t
:bind (:map icomplete-minibuffer-map :bind (:map icomplete-minibuffer-map
("C-S-s" . kill-line) ("C-S-s" . kill-line)
("C-j" . icomplete-forward-completions) ("C-j" . icomplete-forward-completions)
("C-k" . icomplete-backward-completions) ("C-k" . icomplete-backward-completions)
("DEL" . icomplete-fido-backward-updir) ("DEL" . icomplete-fido-backward-updir)
("M-DEL". delete-backward-char)) ("M-DEL". delete-backward-char)
("M-RET" . icomplete-force-complete-and-exit)
("TAB" . icomplete-force-complete)
("<escape>" . abort-recursive-edit)
("C-;" . embark-dwim)
("C-." . embark-act)
("<left>" . backward-char)
("<right>" . forward-char))
:hook (icomplete-minibuffer-setup . my/icomplete-setup-hook-func)
:init :init
(defun my/icomplete-setup-hook-func ()
(setq truncate-lines t))
(setq completion-ignore-case t (setq completion-ignore-case t
read-file-name-completion-ignore-case t read-file-name-completion-ignore-case t
read-buffer-completion-ignore-case t read-buffer-completion-ignore-case t
enable-recursive-minibuffers t
minibuffer-prompt-properties '(read-only t
cursor-intangible t
face minibuffer-prompt)
;;completions-detailed t
icomplete-compute-delay 0
icomplete-scroll t) icomplete-scroll t)
(defun my/crm-indicator (args)
(cons (format "[CRM%s] %s"
(replace-regexp-in-string
"\\`\\[.*?]\\*\\|\\[.*?]\\*\\'" ""
crm-separator)
(car args))
(cdr args)))
(advice-add #'completing-read-multiple :filter-args #'my/crm-indicator)
(defun my/marginalia-trim-right (list)
(cl-loop for (cand prefix suffix) in list collect
(list cand prefix (string-trim-right suffix))))
(advice-add #'marginalia--align :filter-return #'my/marginalia-trim-right)
:config :config
(set-face-attribute 'icomplete-selected-match nil :inherit 'region)
(fido-mode 1) (fido-mode 1)
(fido-vertical-mode 1)) (fido-vertical-mode 1))
@ -464,11 +498,6 @@ visual states."
:init :init
(setq-default eldoc-echo-area-use-multiline-p 'truncate-sym-name-if-fit)) (setq-default eldoc-echo-area-use-multiline-p 'truncate-sym-name-if-fit))
;; dumb-jump
(use-package dumb-jump
:init
(add-hook 'xref-backend-functions #'dumb-jump-xref-activate))
;; eglot ;; eglot
(use-package eglot (use-package eglot
:demand t :demand t
@ -770,35 +799,61 @@ Take directly from doom-modeline."
(doom-modeline-spc) (doom-modeline-spc)
"IAlg")))))))) "IAlg"))))))))
(use-package with-editor)
;; vterm ;; vterm
(use-package vterm ;; (use-package vterm
:hook (vterm-mode . with-editor-export-editor) ;; :hook (vterm-mode . with-editor-export-editor)
:init ;; :init
(defvar my/project-vterm-hash-table (make-hash-table :test 'equal) ;; (defvar my/project-vterm-hash-table (make-hash-table :test 'equal)
"Hash table that maps project root dirs to vterm buffers.") ;; "Hash table that maps project root dirs to vterm buffers.")
(defun my/project-vterm (prompt) ;; (defun my/project-vterm (prompt)
"Switch to or create a vterm buffer in the current projects root." ;; "Switch to or create a vterm buffer in the current projects root."
;; (interactive (list t))
;; (if-let ((proj (project-current prompt))
;; (default-directory (project-root proj)))
;; (if-let ((vterm-buff (gethash default-directory
;; my/project-vterm-hash-table))
;; ((buffer-live-p vterm-buff)))
;; (switch-to-buffer vterm-buff)
;; (puthash default-directory
;; (vterm (concat "*vterm for project " default-directory "*"))
;; my/project-vterm-hash-table))))
;; (defun my/project-vterm-or-default ()
;; "Open a vterm for the current project, otherwise, open a normal vterm."
;; (interactive)
;; (unless (my/project-vterm nil)
;; (if-let ((vterm-buff (gethash nil my/project-vterm-hash-table))
;; ((buffer-live-p vterm-buff)))
;; (switch-to-buffer vterm-buff)
;; (puthash nil (vterm vterm-buffer-name) my/project-vterm-hash-table)))))
;; eat
(use-package eat
:config
(defvar my/project-eat-hash-table (make-hash-table :test 'equal)
"Hash table that maps project root dirs to eat buffers.")
(defun my/project-eat (prompt)
"Switch to or create a eat buffer in the current projects root."
(interactive (list t)) (interactive (list t))
(if-let ((proj (project-current prompt)) (if-let ((proj (project-current prompt))
(default-directory (project-root proj))) (default-directory (project-root proj)))
(if-let ((vterm-buff (gethash default-directory (if-let ((eat-buff (gethash default-directory
my/project-vterm-hash-table)) my/project-eat-hash-table))
((buffer-live-p vterm-buff))) ((buffer-live-p eat-buff)))
(switch-to-buffer vterm-buff) (switch-to-buffer eat-buff)
(puthash default-directory (let ((eat-buffer-name (concat "*eat for project " default-directory "*")))
(vterm (concat "*vterm for project " default-directory "*")) (puthash default-directory
my/project-vterm-hash-table)))) (eat)
(defun my/project-vterm-or-default () my/project-vterm-hash-table)))))
"Open a vterm for the current project, otherwise, open a normal vterm." (defun my/project-eat-or-default ()
"Open an eat for the current project, otherwise, open a normal eat."
(interactive) (interactive)
(unless (my/project-vterm nil) (unless (my/project-eat nil)
(if-let ((vterm-buff (gethash nil my/project-vterm-hash-table)) (if-let ((eat-buff (gethash nil my/project-eat-hash-table))
((buffer-live-p vterm-buff))) ((buffer-live-p eat-buff)))
(switch-to-buffer vterm-buff) (switch-to-buffer eat-buff)
(puthash nil (vterm vterm-buffer-name) my/project-vterm-hash-table))))) (puthash nil (eat) my/project-eat-hash-table)))))
;; eat (mostly for eshell purposes)
(use-package eat)
;; eshell stuff ;; eshell stuff
(use-package eshell (use-package eshell
@ -860,11 +915,11 @@ If no name is given, list all bookmarks instead."
(string-join (last parts num) "/")))) (string-join (last parts num) "/"))))
(defun my/-eshell-prompt-get-dir () (defun my/-eshell-prompt-get-dir ()
"Get dir for `my/-eshell-prompt-function'" "Get dir for `my/-eshell-prompt-function'"
(my/-eshell-prompt-cut-path (my/-eshell-prompt-cut-path 3
3 (if-let ((worktree (car-safe (car-safe (magit-list-worktrees)))) (if-let ((worktree (vc-root-dir))
(parent (file-name-parent-directory worktree))) (parent (file-name-parent-directory worktree)))
(file-relative-name default-directory parent) (file-relative-name default-directory parent)
(my/-replace-home-with-tilda default-directory)))) (my/-replace-home-with-tilda default-directory))))
(defun my/-eshell-prompt-status-char-for-branch (branch remote) (defun my/-eshell-prompt-status-char-for-branch (branch remote)
"Get the status char representing the relation between BRANCH and REMOTE." "Get the status char representing the relation between BRANCH and REMOTE."
(let ((lines (process-lines vc-git-program (let ((lines (process-lines vc-git-program
@ -883,109 +938,109 @@ If no name is given, list all bookmarks instead."
((and to-remote to-local) ?󰹺) ((and to-remote to-local) ?󰹺)
(to-remote ?󰜷) (to-remote ?󰜷)
(to-local ?󰜮)))) (to-local ?󰜮))))
(defun my/-eshell-prompt-current-branch-status () (defun my/-eshell-prompt-current-branch-status ()
"Get the status char for the current branch and its remote." "Get the status char for the current branch and its remote."
(let ((refs (process-lines vc-git-program (let ((refs (process-lines vc-git-program
"for-each-ref" "for-each-ref"
"--format=%(HEAD)%00%(refname:short)%00%(upstream:short)" "--format=%(HEAD)%00%(refname:short)%00%(upstream:short)"
"refs/heads"))) "refs/heads")))
(catch 'break (catch 'break
(dolist (ref refs) (dolist (ref refs)
(if-let ((split-ref (split-string ref "\0" nil nil)) (if-let ((split-ref (split-string ref "\0" nil nil))
((equal (car split-ref) "*"))) ((equal (car split-ref) "*")))
(throw 'break (my/-eshell-prompt-status-char-for-branch (throw 'break (my/-eshell-prompt-status-char-for-branch
(cadr split-ref) (cadr split-ref)
(caddr split-ref)))))))) (caddr split-ref))))))))
(defun my/-eshell-prompt-git-state-chars () (defun my/-eshell-prompt-git-state-chars ()
"Get chars, like + and ✘ for `my/-eshell-prompt-function'." "Get chars, like + and ✘ for `my/-eshell-prompt-function'."
(let ((lines (process-lines vc-git-program "status" "--porcelain=v1")) (let ((lines (process-lines vc-git-program "status" "--porcelain=v1"))
(branch-status (my/-eshell-prompt-current-branch-status)) (branch-status (my/-eshell-prompt-current-branch-status))
(status-arr)) (status-arr))
(dolist (line lines) (dolist (line lines)
(cl-loop with fields = (string-split line " " t " *") (cl-loop with fields = (string-split line " " t " *")
with status-str = (car-safe fields) with status-str = (car-safe fields)
for status-char across status-str for status-char across status-str
do do
(cond ((or (= status-char ?M) (= status-char ?T)) (cond ((or (= status-char ?M) (= status-char ?T))
(add-to-list 'status-arr ?!)) (add-to-list 'status-arr ?!))
((= status-char ??) ((= status-char ??)
(add-to-list 'status-arr ??)) (add-to-list 'status-arr ??))
((or (= status-char ?A) (= status-char ?C)) ((or (= status-char ?A) (= status-char ?C))
(add-to-list 'status-arr ?+)) (add-to-list 'status-arr ?+))
((= status-char ?D) ((= status-char ?D)
(add-to-list 'status-arr ?)) (add-to-list 'status-arr ?))
((= status-char ?R) ((= status-char ?R)
(add-to-list 'status-arr ))))) (add-to-list 'status-arr )))))
(sort status-arr #'<) (sort status-arr #'<)
(when branch-status (when branch-status
(push branch-status status-arr)) (push branch-status status-arr))
(apply 'string status-arr))) (apply 'string status-arr)))
(defun my/-eshell-prompt-git-status () (defun my/-eshell-prompt-git-status ()
"Get git status for `my/-eshell-prompt-function'" "Get git status for `my/-eshell-prompt-function'"
(let ((branch (car (vc-git-branches))) (let ((branch (car (vc-git-branches)))
(state (my/-eshell-prompt-git-state-chars))) (state (my/-eshell-prompt-git-state-chars)))
(concat (concat
(propertize (concat " 󰊢 " branch) 'face '(:foreground "medium purple")) (propertize (concat " 󰊢 " branch) 'face '(:foreground "medium purple"))
(unless (string-empty-p state) (unless (string-empty-p state)
(propertize (concat " [" state "]") 'face '(:foreground "red")))))) (propertize (concat " [" state "]") 'face '(:foreground "red"))))))
(defun my/-eshell-prompt-vc-status () (defun my/-eshell-prompt-vc-status ()
"Get vc status for `my/-eshell-prompt-function'." "Get vc status for `my/-eshell-prompt-function'."
(if-let (backend (vc-responsible-backend default-directory t)) (if-let (backend (vc-responsible-backend default-directory t))
(if (eq backend 'Git) (if (eq backend 'Git)
(my/-eshell-prompt-git-status) (my/-eshell-prompt-git-status)
(my/-eshell-prompt-set-face-color (my/-eshell-prompt-set-face-color
(concat "" (downcase (symbol-name backend))) (concat "" (downcase (symbol-name backend)))
"purple")))) "purple"))))
(defvar-local my/-eshell-prompt-last-start-time nil (defvar-local my/-eshell-prompt-last-start-time nil
"Start time of last eshell command.") "Start time of last eshell command.")
(defun my/-eshell-prompt-timer-pre-cmd () (defun my/-eshell-prompt-timer-pre-cmd ()
"Command run before each eshell program to record the time." "Command run before each eshell program to record the time."
(setq my/-eshell-prompt-last-start-time (current-time))) (setq my/-eshell-prompt-last-start-time (current-time)))
(add-hook 'eshell-pre-command-hook #'my/-eshell-prompt-timer-pre-cmd) (add-hook 'eshell-pre-command-hook #'my/-eshell-prompt-timer-pre-cmd)
(defun my/-eshell-prompt-format-span (span) (defun my/-eshell-prompt-format-span (span)
"Format SPAN as \"XhXms.\"" "Format SPAN as \"XhXms.\""
(let* ((hours (/ span 3600)) (let* ((hours (/ span 3600))
(mins (% (/ span 60) 60)) (mins (% (/ span 60) 60))
(secs (% span 60))) (secs (% span 60)))
(concat (unless (= hours 0) (concat (unless (= hours 0)
(format "%dh" hours)) (format "%dh" hours))
(unless (= mins 0) (unless (= mins 0)
(format "%dm" mins)) (format "%dm" mins))
(format "%ds" secs)))) (format "%ds" secs))))
(defun my/-eshell-prompt-last-command-time (end-time) (defun my/-eshell-prompt-last-command-time (end-time)
"Return the prompt component for the time of the last command." "Return the prompt component for the time of the last command."
(if-let ((my/-eshell-prompt-last-start-time) (if-let ((my/-eshell-prompt-last-start-time)
(len (time-subtract end-time (len (time-subtract end-time
my/-eshell-prompt-last-start-time)) my/-eshell-prompt-last-start-time))
(float-len (float-time len)) (float-len (float-time len))
((< 3 float-len)) ((< 3 float-len))
(int-len (round float-len))) (int-len (round float-len)))
(concat " time " (concat " time "
(propertize (my/-eshell-prompt-format-span int-len) (propertize (my/-eshell-prompt-format-span int-len)
'face '(:foreground "gold1"))))) 'face '(:foreground "gold1")))))
(defun my/-eshell-prompt-function () (defun my/-eshell-prompt-function ()
"Function for `eshell-prompt-function'" "Function for `eshell-prompt-function'"
(let* ((end-time (current-time)) (let* ((end-time (current-time))
(dir (my/-eshell-prompt-get-dir)) (dir (my/-eshell-prompt-get-dir))
(prompt (concat (prompt (concat
"\n" "\n"
(propertize dir 'face '(:foreground "dark turquoise")) (propertize dir 'face '(:foreground "dark turquoise"))
(unless (file-writable-p dir) (unless (file-writable-p dir)
"") "")
(my/-eshell-prompt-vc-status) (my/-eshell-prompt-vc-status)
(my/-eshell-prompt-last-command-time end-time) (my/-eshell-prompt-last-command-time end-time)
(propertize "\n" 'read-only t 'rear-nonsticky t) (propertize "\n" 'read-only t 'rear-nonsticky t)
(propertize (propertize
" " 'face `(:foreground " " 'face `(:foreground
,(if (= eshell-last-command-status 0) ,(if (= eshell-last-command-status 0)
"lime green" "lime green"
"red")) "red"))
'rear-nonsticky t)))) 'rear-nonsticky t))))
(setq my/-eshell-prompt-last-start-time nil) (setq my/-eshell-prompt-last-start-time nil)
prompt)) prompt))
(setq eshell-prompt-function #'my/-eshell-prompt-function (setq eshell-prompt-function #'my/-eshell-prompt-function
eshell-prompt-regexp "^ " eshell-prompt-regexp "^ "
eshell-highlight-prompt nil)) eshell-highlight-prompt nil))
(use-package esh-help (use-package esh-help
:hook (eshell-mode . my/-setup-eshell-help-func) :hook (eshell-mode . my/-setup-eshell-help-func)
:init :init
@ -1021,11 +1076,11 @@ If no name is given, list all bookmarks instead."
:bind ("C-x C-b" . ibuffer)) :bind ("C-x C-b" . ibuffer))
;; magit ;; magit
(use-package magit ;; (use-package magit
:init ;; :init
(evil-define-key '(normal visual motion) magit-mode-map ;; (evil-define-key '(normal visual motion) magit-mode-map
"s" #'magit-stage-file ;; "s" #'magit-stage-file
"S" #'magit-stage-modified)) ;; "S" #'magit-stage-modified))
;; org-mode ;; org-mode
(use-package org (use-package org
@ -1121,7 +1176,7 @@ If no name is given, list all bookmarks instead."
(mu4e t) (mu4e t)
(mu4e-context-switch nil "Personal") (mu4e-context-switch nil "Personal")
;; rainbow-delimiters ;; RAINBOW-delimiters
(use-package rainbow-delimiters (use-package rainbow-delimiters
:hook (prog-mode . rainbow-delimiters-mode)) :hook (prog-mode . rainbow-delimiters-mode))