summaryrefslogtreecommitdiffstats
path: root/lisp/init-vertico.el
blob: b3266f7a8ac71b0c0e8faf5275b8f53f13647cc4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
;;; init-vertico.el --- a better completion ui  -*- lexical-binding:t -*-
;;; Commentary:
;;; Code:

(defun mpolden/consult-project-function (may-prompt)
  "Return project root directory.
When no project is found and MAY-PROMPT is non-nil ask the user.

This wraps `consult--default-project-function', but ignores
remote projects."
  ;; https://github.com/minad/consult/issues/792
  (unless (file-remote-p default-directory)
    (consult--default-project-function may-prompt)))

;; save minibuffer history so that vertico can use it for sorting
(use-package savehist
  :config
  (savehist-mode 1))

;; enhanced search and navigation commands
(use-package consult
  :ensure t
  :init
  (setq consult-project-function #'mpolden/consult-project-function)
  (setq xref-show-xrefs-function #'consult-xref)
  (setq completion-in-region-function #'consult-completion-in-region)
  :bind (("C-x b" . consult-buffer)
         ("C-c i" . consult-imenu)
         ("C-c m" . consult-flymake)
         ("M-g M-g" . consult-goto-line)))

;; show rich annotations in the minibuffer
(use-package marginalia
  :ensure t
  :config
  (marginalia-mode 1))

;; a better completion ui
(use-package vertico
  :ensure t
  :init
  ;; enable fuzzy matching
  ;; https://github.com/minad/vertico/#completion-styles-and-tab-completion
  (setq completion-styles '(flex))
  :config
  (vertico-mode 1))

;; make directory navigation behave like ido
;; https://github.com/minad/vertico/#extensions
(use-package vertico-directory
  :ensure nil
  :after vertico
  :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))

(provide 'init-vertico)

;;; init-vertico.el ends here