summaryrefslogtreecommitdiffhomepage
path: root/custom
diff options
context:
space:
mode:
Diffstat (limited to 'custom')
-rw-r--r--custom/jao-custom-completion.el129
1 files changed, 13 insertions, 116 deletions
diff --git a/custom/jao-custom-completion.el b/custom/jao-custom-completion.el
index 8e8e7fc..0f8b854 100644
--- a/custom/jao-custom-completion.el
+++ b/custom/jao-custom-completion.el
@@ -34,6 +34,7 @@
(defun jao-completion--crm-indicator (args)
"Add prompt indicator to `completing-read-multiple' filter ARGS."
(cons (concat "[CRM] " (car args)) (cdr args)))
+
(advice-add #'completing-read-multiple
:filter-args #'jao-completion--crm-indicator)
@@ -49,14 +50,13 @@
orderless-regexp)))
(defun jao-orderless--set-locally ()
- (setq-local completion-styles
- '(substring partial-completion orderless)
-
+ (setq-local completion-styles '(orderless basic)
completion-category-overrides
'((file (styles partial-completion orderless))
(command (styles orderless+initialism)))
orderless-matching-styles
'(orderless-literal orderless-regexp orderless-prefixes)))
+
(add-hook 'minibuffer-setup-hook #'jao-orderless--set-locally))
;;; marginalia
@@ -73,112 +73,6 @@
(marginalia-mode 1)
-;;; corfu
-(use-package corfu
- :ensure t
- :init (setq corfu-echo-documentation 0.25
- corfu-cycle t
- corfu-count 15
- corfu-quit-no-match t
- corfu-auto t
- corfu-commit-predicate nil
- corfu-preview-current nil
- corfu-preselect-first t
- corfu-min-width 20
- corfu-max-width 100)
- :config
-
- ;; show eldoc string immediately after accepted completion too
- (with-eval-after-load "eldoc"
- (eldoc-add-command-completions "corfu-"))
-
- (defun jao-corfu-no-auto () (setq-local corfu-auto nil) (corfu-mode))
-
- (add-hook 'eshell-mode-hook #'jao-corfu-no-auto)
-
- (defun jao-corfu--active-p ()
- (and (>= corfu--index 0) (/= corfu--index corfu--preselect)))
-
- (defun jao-corfu-quit-or-insert ()
- (interactive)
- (if (jao-corfu--active-p) (corfu-insert) (corfu-quit)))
-
- (defun jao-corfu-quit-or-previous ()
- (interactive)
- (if (jao-corfu--active-p)
- (corfu-previous)
- (corfu-quit)
- (previous-line)))
-
- :bind (:map corfu-map
- ("C-<return>" . corfu-insert)
- ("\r" . jao-corfu-quit-or-insert)
- ("C-p" . jao-corfu-quit-or-previous)))
-
-(defun corfu-in-minibuffer ()
- (when (not (bound-and-true-p vertico--input))
- (setq-local corfu-echo-documentation nil)
- (corfu-mode 1)))
-
-(when (display-graphic-p)
- (add-hook 'minibuffer-setup-hook #'corfu-in-minibuffer 1)
- (global-corfu-mode 1))
-
-;;; company
-(use-package company
- :ensure t
- :custom ((company-backends '(company-capf
- ;; company-bbdb
- company-files
- company-dabbrev
- company-keywords))
- (company-global-modes '(not slack-message-buffer-mode
- circe-channel-mode
- telega-chat-mode))
- (company-format-margin-function nil) ;; #'company-text-icons-margin
- (company-idle-delay 0.2)
- (company-lighter "")
- (company-lighter-base "")
- (company-show-numbers nil)
- (company-selection-wrap-around t)
- (company-tooltip-limit 15)
- (company-tooltip-align-annotations t)
- (company-tooltip-offset-display 'lines)) ;; 'scrollbar
-
- :config
- (defun jao-complete-at-point ()
- "Complete using company unless we're in the minibuffer."
- (interactive)
- (if (or (not company-mode) (window-minibuffer-p))
- (completion-at-point)
- (company-manual-begin)))
-
- (defun jao-company-use-in-tab ()
- (global-set-key [remap completion-at-point] #'jao-complete-at-point)
- (global-set-key [remap completion-symbol] #'jao-complete-at-point)
- (global-set-key (kbd "M-TAB") #'jao-complete-at-point))
-
- (jao-company-use-in-tab)
-
- :bind (:map company-active-map
-
- ("<tab>" . company-complete-common-or-cycle)
- ("TAB" . company-complete-common-or-cycle)
-
- ("C-h" . company-show-doc-buffer)
- ("M-." . company-show-location)
- ("C-<return>" . company-complete-selection)
- ([remap return] . company-abort)
- ("RET" . company-abort)
-
- :filter (or (not (derived-mode-p 'eshell-mode))
- (company-explicit-action-p))
- ("<return>" . company-complete-selection)
- ("RET" . company-complete-selection))
- :diminish)
-
-(unless (display-graphic-p) (global-company-mode 1))
-
;;; vertico
(use-package vertico
:ensure t
@@ -190,13 +84,6 @@
:config
- ;; (setq completion-in-region-function
- ;; (lambda (&rest args)
- ;; (apply (if (and (not window-system) vertico-mode)
- ;; #'consult-completion-in-region
- ;; #'completion--in-region)
- ;; args)))
-
(defun jao-vertico--display-candidates (lines)
(move-overlay vertico--candidates-ov (point-min) (point-min))
(overlay-put vertico--candidates-ov 'after-string (apply #'concat lines))
@@ -248,6 +135,16 @@
:config
+ (defun jao-consult--completion-in-region (&rest args)
+ (apply (if (and (not (bound-and-true-p corfu-mode))
+ (not (bound-and-true-p company-mode))
+ (bound-and-true-p vertico-mode))
+ #'consult-completion-in-region
+ #'completion--in-region)
+ args))
+
+ (setq completion-in-region-function #'jao-consult--completion-in-region)
+
(defun jao-find-file (arg)
(interactive "P")
(call-interactively (if arg 'consult-file-externally 'find-file)))