Files
dotfiles/thoom-emacs/modules/thoom-completion.el
2024-09-23 09:53:07 -07:00

125 lines
3.9 KiB
EmacsLisp

(provide 'thoom-completion)
;; VMOCE
(use-package vertico
:ensure t
:init
(vertico-mode))
(use-package vertico-directory
:after vertico
:bind (:map vertico-map
("C-h" . vertico-directory-delete-word)
("C-l" . vertico-directory-enter)))
(use-package marginalia
:ensure t
;; Either bind `marginalia-cycle' globally or only in the minibuffer
:bind (:map minibuffer-local-map
("M-A" . marginalia-cycle))
:init
(marginalia-mode))
(use-package orderless
:ensure t
:init
(setq completion-ignore-case t)
(setq completion-styles '(orderless basic)
completion-category-defaults nil
completion-category-overrides '((file (styles partial-completion)))))
(use-package consult
:ensure t
;; Replace bindings. Lazily loaded due by `use-package'.
:bind (("C-x b" . consult-buffer)
("C-x C-b" . consult-buffer)
("C-x p g" . consult-ripgrep)
("M-i" . consult-imenu))
;; Enable automatic preview at point in the *Completions* buffer. This is
;; relevant when you use the default completion UI.
;; :hook (completion-list-mode . consult-preview-at-point-mode)
:init
;; Optionally configure the register formatting. This improves the register
;; preview for `consult-register', `consult-register-load',
;; `consult-register-store' and the Emacs built-ins.
(setq register-preview-delay 0.5
register-preview-function #'consult-register-format)
;; Optionally tweak the register preview window.
;; This adds thin lines, sorting and hides the mode line of the window.
(advice-add #'register-preview :override #'consult-register-window)
;; Use Consult to select xref locations with preview
(setq xref-show-xrefs-function #'consult-xref
xref-show-definitions-function #'consult-xref)
:config
;; For some commands and buffer sources it is useful to configure the
;; :preview-key on a per-command basis using the `consult-customize' macro.
(consult-customize
consult-theme
:preview-key '(:debounce 0.5 any)
consult-ripgrep consult-git-grep consult-grep
consult-bookmark consult-recent-file consult-xref
consult--source-bookmark consult--source-recent-file
consult--source-project-recent-file))
(use-package consult-dir
:ensure t
:bind (("C-x C-d" . consult-dir)
:map vertico-map
("C-x C-d" . consult-dir)
("C-x C-j" . consult-dir-jump-file)))
(use-package embark
:ensure t
:bind
(("C-;" . embark-act) ;; pick some comfortable binding
("C-:" . embark-dwim) ;; good alternative: M-.
("C-h B" . embark-bindings)) ;; alternative for `describe-bindings'
:init
;; Optionally replace the key help with a completing-read interface
(setq prefix-help-command #'embark-prefix-help-command)
:config
;; Hide the mode line of the Embark live/completions buffers
(add-to-list 'display-buffer-alist
'("\\`\\*Embark Collect \\(Live\\|Completions\\)\\*"
nil
(window-parameters (mode-line-format . none)))))
;; Consult users will also want the embark-consult package.
(use-package embark-consult
:ensure t
:after (embark consult)
:demand t ; only necessary if you have the hook below
;; if you want to have consult previews as you move around an
;; auto-updating embark collect buffer
:hook
(embark-collect-mode . consult-preview-at-point-mode))
(use-package corfu
:ensure t
:bind
(("C-'" . completion-at-point))
:init
(global-corfu-mode))
(use-package cape
:ensure t
;; Bind prefix keymap providing all Cape commands under a mnemonic key.
:bind ("C-c p" . cape-prefix-map) ;; Alternative keys: M-p, M-+, ...
:custom
(cape-dabbrev-check-other-buffers nil)
(cape-file-directory-must-exist nil)
:init
(add-hook 'completion-at-point-functions #'cape-dabbrev)
(add-hook 'completion-at-point-functions #'cape-file)
(add-hook 'completion-at-point-functions #'cape-elisp-block))