   ;; Configure a custom style dispatcher (see the Consult wiki)
   ;; (setq orderless-style-dispatchers '(+orderless-dispatch)
   ;;       orderless-component-separator #'orderless-escapable-split-on-space)
-  (setq completion-styles '(orderless)
+  (setq completion-styles '(substring orderless basic)
         completion-category-defaults nil
         completion-category-overrides '((file (styles partial-completion)))))
+
+  ;; Use `consult-completion-in-region' if Vertico is enabled.
+  ;; Otherwise use the default `completion--in-region' function.
+  (setq completion-in-region-function
+        (lambda (&rest args)
+          (apply (if vertico-mode
+                     'consult-completion-in-region
+                   #'completion--in-region)
+                 args)))
 
 ;; Persist history over Emacs restarts. Vertico sorts by history position.
 (use-package savehist

  ;;       #'command-completion-default-include-p)

  ;; Enable recursive minibuffers
  (setq enable-recursive-minibuffers t))

(provide 'setup-vertico)
;;; setup-vertico.el ends here


;;; Code
(use-package vertico

  :custom
  ;; Different scroll margin
  ;; (setq vertico-scroll-margin 0)

  ;; Show more candidates
  (vertico-count 13)

  ;; Grow and shrink the Vertico minibuffer
  (vertico-resize t)

  ;; Optionally enable cycling for `vertico-next' and `vertico-previous'.
  (vertico-cycle nil)

  :init
  (vertico-mode)
  )

;; Optionally use the `orderless' completion style. See
