Commit ba8db69a authored by Aimé Bertrand's avatar Aimé Bertrand
Browse files

Emacs: First working code with vertico & consult

parent dd9c2974
......@@ -281,7 +281,7 @@ credit: [[https://framagit.org/gabylaunay/emacs-config/commit/b9807d33c0f9d6f6b8
(use-package recentf
:after ivy
:config
(setq recentf-max-saved-items 64)
(setq recentf-max-saved-items 20)
(setq recentf-exclude
(list "COMMIT_EDITMSG"
"~$"
......@@ -824,111 +824,74 @@ killing buffers or groups without confirmation
(define-key evil-normal-state-map (kbd "s") 'avy-goto-word-1))
#+end_src
** ivy, counsel & swiper
*** install ivy
** vertico & consult
*** install vertico & consult
#+begin_src emacs-lisp
(use-package counsel
:ensure t)
(ivy-mode 1)
#+end_src
*** ivy variables
#+begin_src emacs-lisp
(setq ivy-use-virtual-buffers t)
(setq ivy-count-format "(%d/%d) ")
(setq ivy-height 8)
(setq ivy-on-del-error-function #'ignore)
;; no `^' at the begining of the input.
(setq ivy-initial-inputs-alist
'((counsel-minor . "")
(counsel-package . "")
(counsel-org-capture . "")
(counsel-M-x . "^")
(counsel-describe-symbol . "")
(org-refile . "")
(org-agenda-refile . "")
(org-capture-refile . "")
(Man-completion-table . "")
(woman . "")))
(setq ivy-posframe-parameters
'((left-fringe . 8)
(right-fringe . 8)))
(setq mu4e-completing-read-function 'ivy-completing-read)
(setq emojify-completing-read-function 'ivy-completing-read)
(setq slack-completing-read-function 'ivy-completing-read)
(add-hook 'minibuffer-setup-hook (lambda () (setq line-spacing 0.4)))
#+end_src
*** ivy-prescient
#+begin_src emacs-lisp
(use-package ivy-prescient
(use-package vertico
:ensure t
:init
(ivy-prescient-mode))
#+end_src
(vertico-mode))
*** counsel-tramp
#+begin_src emacs-lisp
(use-package counsel-tramp
:ensure t)
(setq tramp-default-method "ssh")
#+end_src
*** ivy-posframe
#+begin_src emacs-lisp
(use-package ivy-posframe
(use-package consult
:ensure t
:init
(ivy-posframe-mode -1))
(defun ivy-posframe-display-at-frame-bottom-center (str)
(ivy-posframe--display str #'posframe-poshandler-frame-bottom-center))
;; display at `ivy-posframe-style'
(setq ivy-posframe-display-functions-alist
'((t . ivy-posframe-display-at-frame-bottom-center)))
(setq ivy-posframe-border-width 2)
(recentf-mode))
#+end_src
*** ivy-rich
*** vertico & consul config
#+begin_src emacs-lisp
(use-package all-the-icons-ivy-rich
:ensure t
:init
(all-the-icons-ivy-rich-mode 1))
(use-package orderless
:ensure t)
(use-package ivy-rich
:ensure t
:init
(ivy-rich-mode 1))
#+end_src
*** ivy, counsel & swiper keybindings
#+begin_src emacs-lisp
(global-set-key (kbd "C-s") 'swiper-isearch)
(global-set-key (kbd "M-x") 'counsel-M-x)
(global-set-key (kbd "M-o") 'counsel-find-file)
(global-set-key (kbd "M-f") 'swiper)
(global-set-key (kbd "M-b") 'ivy-switch-buffer)
(global-set-key (kbd "M-ø") 'counsel-tramp)
(global-set-key (kbd "M-∫") 'counsel-bookmark) ; (alt-cmd-b)
(define-key minibuffer-inactive-mode-map (kbd "M-v") 'yank)
(define-key minibuffer-mode-map (kbd "<escape>") 'minibuffer-keyboard-quit)
(define-key ivy-minibuffer-map (kbd "<escape>") 'minibuffer-keyboard-quit)
(define-key ivy-minibuffer-map (kbd "M-v") 'yank)
(define-key ivy-minibuffer-map (kbd "<tab>") 'ivy-alt-done)
(define-key ivy-minibuffer-map (kbd "å") 'ivy-dispatching-done)
(define-key ivy-minibuffer-map (kbd "RET") 'ivy-done)
(define-key ivy-minibuffer-map (kbd "S-RET") 'ivy-immediate-done)
(define-key ivy-minibuffer-map (kbd "C-SPC") 'ivy-mark)
(define-key ivy-minibuffer-map (kbd "C-u") 'ivy-unmark)
(setq completion-styles '(orderless))
(setq completion-category-defaults nil)
(setq completion-category-overrides '((file (styles partial-completion))))
;; https://github.com/minad/consult#live-previews:
(setq consult-preview-key 'any)
(consult-customize
consult-ripgrep consult-git-grep consult-grep consult-buffer
consult-bookmark consult-recent-file consult-xref
consult--source-file consult--source-project-file consult--source-bookmark
:preview-key (kbd "M-."))
(autoload 'projectile-project-root "projectile")
(setq consult-project-root-function #'projectile-project-root)
;; https://systemcrafters.cc/live-streams/may-21-2021/:
(defun timu/minibuffer-backward-kill (arg)
"When minibuffer is completing a file name delete up to parent
folder, otherwise delete a character backward"
(interactive "p")
(if minibuffer-completing-file-name
;; Borrowed from https://github.com/raxod502/selectrum/issues/498#issuecomment-803283608
(if (string-match-p "/." (minibuffer-contents))
(zap-up-to-char (- arg) ?/)
(delete-minibuffer-contents))
(delete-backward-char arg)))
(setq mu4e-completing-read-function 'completing-read)
#+end_src
*** vertico & consult keybindings
#+begin_src emacs-lisp
;; (global-set-key (kbd "C-s") 'swiper-isearch)
;; (global-set-key (kbd "M-x") 'counsel-M-x)
(global-set-key (kbd "M-o") 'find-file)
(global-set-key (kbd "M-f") 'consult-line)
(global-set-key (kbd "M-b") 'consult-buffer)
;; (global-set-key (kbd "M-ø") 'counsel-tramp)
(global-set-key (kbd "M-∫") 'consult-bookmark) ; (alt-cmd-b)
(define-key minibuffer-local-map (kbd "M-v") 'yank)
(define-key minibuffer-local-map (kbd "<escape>") 'minibuffer-keyboard-quit)
(define-key minibuffer-local-map (kbd "<backspace>") 'timu/minibuffer-backward-kill)
(define-key vertico-map (kbd "M-v") 'yank)
;;(define-key ivy-minibuffer-map (kbd "<tab>") 'ivy-alt-done)
;;(define-key ivy-minibuffer-map (kbd "å") 'ivy-dispatching-done)
;;(define-key ivy-minibuffer-map (kbd "RET") 'ivy-done)
;;(define-key ivy-minibuffer-map (kbd "S-RET") 'ivy-immediate-done)
;;(define-key ivy-minibuffer-map (kbd "C-SPC") 'ivy-mark)
;;(define-key ivy-minibuffer-map (kbd "C-u") 'ivy-unmark)
#+end_src
** embark
......@@ -938,7 +901,7 @@ killing buffers or groups without confirmation
:custom
(embark-prompter 'embark-completing-read-prompter))
(define-key ivy-minibuffer-map (kbd "M-e") 'embark-act)
(define-key vertico-map (kbd "M-e") 'embark-act)
#+end_src
** marginalia
......@@ -955,8 +918,8 @@ with a =.git= directory as projects and helps you manage them accordingly.
*** counsel for projectile
#+begin_src emacs-lisp
(use-package counsel-projectile
:ensure t)
;; (use-package counsel-projectile
;; :ensure t)
#+end_src
*** enable projectile globally
......
......@@ -144,15 +144,22 @@ This runs `org-babel-load-file' on `config.org'."
(evil-define-key 'normal text-mode-map (kbd "ø") 'timu/insert-line-after)
(defun timu/ivy-go-to-heading (&optional arg)
"Like `helm-org-in-buffer-headings', the preconfigured helm for org buffer headings.
This function will use `counsel-outline' and also move the heading to the top of the buffer
with the evil funtion `evil-scroll-line-to-top'"
(defun timu/org-go-to-heading (&optional arg)
"Go to an outline heading with `consult-org-heading'.
Also move the heading to the top of the buffer with `evil-scroll-line-to-top'"
(interactive)
(counsel-outline)
(consult-org-heading)
(evil-scroll-line-to-top arg))
(global-set-key (kbd "M-ª") 'timu/ivy-go-to-heading) ; (alt-cmd-h)
(defun timu/outline-go-to-heading (&optional arg)
"Go to an outline heading with `consult-outline'.
Also move the heading to the top of the buffer with `evil-scroll-line-to-top'"
(interactive)
(consult-outline)
(evil-scroll-line-to-top arg))
(define-key org-mode-map (kbd "M-ª") 'timu/org-go-to-heading) ; (alt-cmd-h)
(define-key emacs-lisp-mode-map (kbd "M-ª") 'timu/outline-go-to-heading) ; (alt-cmd-h)
;; based on infos from here https://github.com/hlissner/doom-emacs/issues/432
(defun timu/counsel-grep-and-center (&optional arg)
......
Subproject commit b09bf97673e03e307b03f33b0f063858ada83176
Subproject commit 35e33729d25d9041fe8d2bc4387c3035938c1ff1
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment