Skip to content

Instantly share code, notes, and snippets.

@anticomputer
Last active January 2, 2023 16:54
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anticomputer/ea71ecab639326bf540418f31c600e09 to your computer and use it in GitHub Desktop.
Save anticomputer/ea71ecab639326bf540418f31c600e09 to your computer and use it in GitHub Desktop.
ivy compliant vertico config
(use-package vertico
;; using quelpa until elpa version contains vertico-preselect
:quelpa
:ensure t
:demand
:config
(setq vertico-cycle t)
(setq vertico-preselect 'directory)
:init
(vertico-mode)
;; make things compatible with my ivy muscle memory
;; if first candidate is a directory then "/" should
;; vertico-insert, if not, then it should just do the
;; char
(defun my/vertico-insert ()
(interactive)
(let* ((mb (minibuffer-contents-no-properties))
(lc (if (string= mb "") mb (substring mb -1))))
;; make sure we can still reset to ~ and // ivy style, also consider tramp prefixes
(cond ((string-match-p "^[/~:]" lc) (self-insert-command 1 ?/))
((file-directory-p (vertico--candidate)) (vertico-insert))
(t (self-insert-command 1 ?/)))))
:bind (:map vertico-map
("/" . #'my/vertico-insert)))
;; Configure directory extension.
(use-package vertico-directory
;; using quelpa until elpa version contains vertico-preselect
:quelpa
:after vertico
:ensure t
:demand
;; More convenient directory navigation commands
:bind (:map vertico-map
("RET" . vertico-directory-enter)
("DEL" . vertico-directory-delete-char)
("M-DEL" . vertico-directory-delete-word))
;; Tidy shadowed file names
:hook (rfn-eshadow-update-overlay . vertico-directory-tidy))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment