diff options
| author | tslil clingman <tslil@posteo.de> | 2023-11-02 15:48:21 +0100 |
|---|---|---|
| committer | tslil clingman <tslil@posteo.de> | 2023-11-02 16:49:32 +0100 |
| commit | 9bc372625e1fdafa50d44dcb9a8070ecdfc01b38 (patch) | |
| tree | bd53e8672dceb8e504f8bb3f2d881d832dd36e30 /emacs | |
| parent | f33d50a49fae314f098f63c5aa14911624588ce1 (diff) | |
[emacs] switch back to vertico/selectrum/marginalia
icomplete is too slow on large lists
Diffstat (limited to 'emacs')
| -rw-r--r-- | emacs/inits/11-completion.el | 128 |
1 files changed, 125 insertions, 3 deletions
diff --git a/emacs/inits/11-completion.el b/emacs/inits/11-completion.el index b995ded..00bc708 100644 --- a/emacs/inits/11-completion.el +++ b/emacs/inits/11-completion.el @@ -1,4 +1,4 @@ -;; Time-stamp: <2023-10-24 19h06 CEST (anker)> +;; Time-stamp: <2023-11-02 16h49 CET (anker)> (use-package savehist :ensure t @@ -23,6 +23,128 @@ (add-hook 'minibuffer-setup-hook #'cursor-intangible-mode) ;; Enable recursive minibuffers - (setq enable-recursive-minibuffers t) + (setq enable-recursive-minibuffers t)) - (fido-vertical-mode t)) +;; ----------------------------------------------------------------------------- +;; Vertico + +(use-package vertico + :ensure t + :bind (:map vertico-map + ("<tab>" . vertico-insert) + ("DEL" . vertico-directory-delete-char)) + :init + (vertico-mode) + (setq vertico-cycle t) + (setq completion-styles '(substring))) + +;; ----------------------------------------------------------------------------- +;; Orderless + +(use-package orderless + :ensure t + :config + (setq orderless-component-separator 'orderless-escapable-split-on-space + completion-styles '(orderless basic) + completion-category-overrides '((file (styles basic))))) + +;; ----------------------------------------------------------------------------- +;; Consult + +(use-package consult + :ensure t + :bind (;; C-c bindings (mode-specific-map) + ("C-c h" . consult-history) + ("C-c m" . consult-mode-command) + ("C-c b" . consult-bookmark) + ("C-c k" . consult-kmacro) + ;; C-x bindings (ctl-x-map) + ("C-x M-:" . consult-complex-command) ;; orig. repeat-complex-command + ("C-x b" . consult-buffer) ;; orig. switch-to-buffer + ("C-x 4 b" . consult-buffer-other-window) ;; orig. switch-to-buffer-other-window + ("C-x 5 b" . consult-buffer-other-frame) ;; orig. switch-to-buffer-other-frame + ;; Custom M-# bindings for fast register access + ("M-#" . consult-register-load) + ("M-'" . consult-register-store) ;; orig. abbrev-prefix-mark (unrelated) + ("C-M-#" . consult-register) + ;; Other custom bindings + ("M-y" . consult-yank-pop) ;; orig. yank-pop + ("<help> a" . consult-apropos) ;; orig. apropos-command + ;; M-g bindings (goto-map) + ("M-g e" . consult-compile-error) + ("M-g f" . consult-flymake) ;; Alternative: consult-flycheck + ("M-g M-g" . consult-goto-line) ;; orig. goto-line + ("M-g o" . consult-outline) ;; Alternative: consult-org-heading + ("M-g m" . consult-mark) + ("M-g k" . consult-global-mark) + ("M-g i" . consult-imenu) + ("M-g I" . consult-project-imenu) + ;; M-s bindings (search-map) + ("M-s f" . consult-find) + ("M-s L" . consult-locate) + ("C-c g" . consult-ripgrep) + ("C-c G" . consult-git-grep) + ("M-s l" . consult-line) + ("M-s m" . consult-multi-occur) + ("M-s k" . consult-keep-lines) + ("M-s u" . consult-focus-lines) + ;; Isearch integration + ("M-s e" . consult-isearch) + :map isearch-mode-map + ("M-e" . consult-isearch) ;; orig. isearch-edit-string + ("M-s e" . consult-isearch) ;; orig. isearch-edit-string + ("M-s l" . consult-line)) ;; needed by consult-line to detect isearch + + :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 + 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 + (defun previous-history-or-next () + (interactive) + (if (string= "" (minibuffer-contents-no-properties)) + (progn + (previous-history-element 1) + (end-of-line)) + (vertico-next))) + + (defvar my-consult-line-map + (let ((map (make-sparse-keymap))) + (define-key map "\C-s" #'previous-history-or-next) + map)) + + (consult-customize consult-line :keymap my-consult-line-map) + + ;; Optionally configure the narrowing key. + ;; Both < and C-+ work reasonably well. + (setq consult-narrow-key "<") ;; (kbd "C-+") + + ;; Optionally make narrowing help available in the minibuffer. + ;; You may want to use `embark-prefix-help-command' or which-key instead. + ;; (define-key consult-narrow-map (vconcat consult-narrow-key "?") #'consult-narrow-help) + + ;; Projectile integration + (autoload 'projectile-project-root "projectile") + (setq consult-project-function #'projectile-project-root) + + ;; Ues consult for capfs + (setq completion-in-region-function #'consult-completion-in-region)) + +;; ----------------------------------------------------------------------------- +;; Marginalia + +(use-package marginalia + :ensure t + :bind (:map minibuffer-local-map ("M-A" . marginalia-cycle)) + :init (marginalia-mode)) |
