From 4252faee429a01c7b6d2ce3d8c75dda9a93857e6 Mon Sep 17 00:00:00 2001 From: Joseph Ferano Date: Fri, 21 Apr 2023 15:24:34 +0700 Subject: [PATCH] Skip to first and last candidate in vertico --- .config/emacs/init.org | 115 +++++++++++++++++++++++++---------------- 1 file changed, 71 insertions(+), 44 deletions(-) diff --git a/.config/emacs/init.org b/.config/emacs/init.org index 6017928..b2fd152 100644 --- a/.config/emacs/init.org +++ b/.config/emacs/init.org @@ -929,13 +929,16 @@ Ace Window will show a hint if there are more than 2 windows, but I don't really #+end_src #+begin_src emacs-lisp +;; TODO Prot help improving workflow. There's a bug where sometimes this doesn't work anymore +;; Is there a way to detect if the current window is a side window? (global-set-key (kbd "C-`") #'window-toggle-side-windows) (defvar joe/side-window-buffers '("^\\*Flycheck errors\\*$" "^\\*Completions\\*$" + "^\\*Occur\\*$" "^\\*Help\\*$" "^\\*Embark.*" - "^\\*helpful.*" + "^\\*helpful .*" "^\\*Compilation\\*$" "^\\*SQL.*" "^\\*HTTP Response\\*$" @@ -963,6 +966,12 @@ Ace Window will show a hint if there are more than 2 windows, but I don't really '((t :inherit font-lock-string-face)) "Face for `consult' framed buffers.") + ;; If you want to filter the current buffer you can use this and replace :items in the + ;; beframe-consult-source var + ;; (defun joe/consult-beframe-names-minus-current () + ;; (delete (buffer-name) (beframe-buffer-names))) +;; :items ,#'joe/consult-beframe-names-minus-current + (defvar beframe-consult-source `( :name "Frame-specific buffers (current frame)" :narrow ?F @@ -977,8 +986,6 @@ Ace Window will show a hint if there are more than 2 windows, but I don't really (beframe-mode +1) -(global-set-key (kbd "s-n") #'joe/consult-buffer-vertico) -(global-set-key (kbd "s-p") #'joe/consult-buffer-vertico) #+end_src *** COMMENT Popper @@ -1287,44 +1294,60 @@ Ace Window will show a hint if there are more than 2 windows, but I don't really ** VEMCO *** Vertico #+begin_src emacs-lisp - (require 'all-the-icons-completion) - ;; (require '(vertico :files (:defaults "extensions/*") - ;; :includes (vertico-indexed - ;; vertico-repeat - ;; vertico-directory)) +(require 'all-the-icons-completion) +;; (require '(vertico :files (:defaults "extensions/*") +;; :includes (vertico-indexed +;; vertico-repeat +;; vertico-directory)) (require 'vertico) - (vertico-mode) - ;; (elpaca 'vertico-posframe) +(vertico-mode) +;; (elpaca 'vertico-posframe) - ;; (define-key vertico-map (kbd "C-w") #'vertico-directory-delete-word) - ;; (define-key vertico-map (kbd "C-r") #'vertico-repeat-) +;; (define-key vertico-map (kbd "C-w") #'vertico-directory-delete-word) +;; (define-key vertico-map (kbd "C-r") #'vertico-repeat-) - ;; (vertico-posframe-mode t) - ;; (vertico-indexed-mode) - ;; (setq vertico-posframe-parameters - ;; '((left-fringe . 100) - ;; (right-fringe . 100))) +;; (vertico-posframe-mode t) +;; (vertico-indexed-mode) +;; (setq vertico-posframe-parameters +;; '((left-fringe . 100) +;; (right-fringe . 100))) - ;; (setq vertico-posframe-border-width 5) - ;; (setq vertico-posframe-min-height 20) - ;; (defun posframe-poshandler-slightly-below-top (info) - ;; (cons (/ (- (plist-get info :parent-frame-width) - ;; (plist-get info :posframe-width)) - ;; 2) - ;; 150)) - ;; (setq vertico-posframe-poshandler #'posframe-poshandler-slightly-below-top) +;; (setq vertico-posframe-border-width 5) +;; (setq vertico-posframe-min-height 20) +(defun posframe-poshandler-slightly-below-top (info) + (cons (/ (- (plist-get info :parent-frame-width) + (plist-get info :posframe-width)) + 2) + 180)) -(defun joe/consult-buffer-vertico () +;; (setq vertico-posframe-poshandler #'posframe-poshandler-frame-center) +(setq vertico-posframe-poshandler #'posframe-poshandler-slightly-below-top) + +(defun joe/consult-buffer-vertico-indexed (start-index) (interactive) (let ((vertico-count 12) (vertico-posframe-width 110) - (vertico-posframe-height 20)) - (consult-buffer))) + (vertico-posframe-height 20) + (vertico-group-format nil) + (vertico-indexed-start 1) + (vertico--index start-index) + (consult-buffer-sources '(beframe-consult-source))) + (consult-buffer))) - (setq vertico-count 20 - vertico-resize nil - vertico-cycle t) +(defun joe/consult-buffer-vertico-next () + (interactive) + (joe/consult-buffer-vertico-indexed 1)) +(defun joe/consult-buffer-vertico-last () + (interactive) + (joe/consult-buffer-vertico-indexed (1- (length (beframe-buffer-names))))) + +(global-set-key (kbd "s-n") #'joe/consult-buffer-vertico-next) +(global-set-key (kbd "s-p") #'joe/consult-buffer-vertico-last) + +(setq vertico-count 20 + vertico-resize nil + vertico-cycle t) (setq vertico-posframe-width 130) (setq vertico-posframe-height 30) (setq vertico-posframe-parameters @@ -1332,29 +1355,32 @@ Ace Window will show a hint if there are more than 2 windows, but I don't really (left-fringe . 30) (right-fringe . 30))) - (require 'savehist) - (savehist-mode) - (add-hook 'minibuffer-setup-hook #'vertico-repeat-save) - (add-to-list 'savehist-additional-variables 'vertico-repeat-history) +(require 'savehist) +(savehist-mode) +(add-hook 'minibuffer-setup-hook #'vertico-repeat-save) +(add-to-list 'savehist-additional-variables 'vertico-repeat-history) - (define-key vertico-map (kbd "C-M-n") #'vertico-next-group) - (define-key vertico-map (kbd "s-p") #'vertico-previous) - (define-key vertico-map (kbd "s-n") #'vertico-next) - ;; #' "C-M-p" #'vertico-previous-group) +(define-key vertico-map (kbd "C-M-n") #'vertico-next-group) +(define-key vertico-map (kbd "s-p") #'vertico-previous) +(define-key vertico-map (kbd "s-n") #'vertico-next) +;; #' "C-M-p" #'vertico-previous-group) ;; (elpaca 'vertico-directory) - ;; :bind (:map vertico-map - ;; ("RET" . vertico-directory-enter) - ;; ("DEL" . vertico-directory-delete-char) - ;; ("M-DEL" . vertico-directory-delete-word)) - ;; :hook (rfn-eshadow-update-overlay . vertico-directory-tidy)) +;; :bind (:map vertico-map +;; ("RET" . vertico-directory-enter) +;; ("DEL" . vertico-directory-delete-char) +;; ("M-DEL" . vertico-directory-delete-word)) +;; :hook (rfn-eshadow-update-overlay . vertico-directory-tidy)) #+end_src *** Embark #+begin_src emacs-lisp (require 'embark) +;; TODO Prot +;; 1.) Cannot quickly deleete buffers from the mini buffer with emark +;; 2.) switch-to-buffer-other-frame is not working (setq embark-quit-after-action '((kill-buffer . nil))) (defun embark-which-key-indicator () @@ -1639,6 +1665,7 @@ startup. Reason we have to call this is so the vterm fucntion can call `vterm--i (setq mono-complete-backend-capf-complete-fn #'eglot-completion-at-point) (setq mono-complete-preview-delay 0.1) +;; TODO Prot This setting gets lost when creating a new frame (add-to-list 'face-remapping-alist '(mono-complete-preview-face . shadow)) (mono-complete-mode +1) #+end_src