From cc3587285dd6062094d5963e191f24a4e64764ca Mon Sep 17 00:00:00 2001 From: jao Date: Fri, 3 Jun 2022 21:46:55 +0100 Subject: in good company --- completion.org | 104 ++++++++++++++++++++++++++++----------------------------- 1 file changed, 51 insertions(+), 53 deletions(-) (limited to 'completion.org') diff --git a/completion.org b/completion.org index 8fdeb23..20460f5 100644 --- a/completion.org +++ b/completion.org @@ -111,67 +111,61 @@ (marginalia-mode 1) #+end_src -* corfu +* company #+begin_src emacs-lisp - (use-package corfu + (use-package company :ensure t - :demand 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-enable-no-auto () - (setq-local corfu-auto nil) - (corfu-mode 1)) - - (defmacro jao-corfu-no-auto (mode) - (let ((mode-name (intern (format "%s-mode" mode))) - (hook-name (intern (format "%s-mode-hook" mode)))) - `(with-eval-after-load ',mode - (add-to-list 'corfu-excluded-modes ',mode-name) - (add-hook ',hook-name #'jao-corfu-enable-no-auto)))) + :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 - (jao-corfu-no-auto eshell) - ;; (add-to-list 'corfu-excluded-modes 'notmuch-message-mode) - - (defun jao-corfu--active-p () - (and (>= corfu--index 0) (/= corfu--index corfu--preselect))) - - (defun jao-corfu-quit-or-insert () + :config + (defun jao-complete-at-point () + "Complete using company unless we're in the minibuffer." (interactive) - (if (jao-corfu--active-p) (corfu-insert) (corfu-quit))) + (if (or (not company-mode) (window-minibuffer-p)) + (completion-at-point) + (company-manual-begin))) - (defun jao-corfu-quit-or-previous () - (interactive) - (if (jao-corfu--active-p) - (corfu-previous) - (corfu-quit) - (previous-line))) + (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 corfu-map - ("C-" . corfu-insert) - ("\r" . jao-corfu-quit-or-insert) - ("C-p" . jao-corfu-quit-or-previous))) + :bind (:map company-active-map - (defun corfu-in-minibuffer () - (when (not (bound-and-true-p vertico--input)) (corfu-mode 1))) + ("" . company-complete-common-or-cycle) + ("TAB" . company-complete-common-or-cycle) - (add-hook 'minibuffer-setup-hook #'corfu-in-minibuffer 1) + ("C-h" . company-show-doc-buffer) + ("M-." . company-show-location) + ("C-" . company-complete-selection) + ([remap return] . company-abort) + ("RET" . company-abort) - (global-corfu-mode 1) + :filter (or (not (derived-mode-p 'eshell-mode)) + (company-explicit-action-p)) + ("" . company-complete-selection) + ("RET" . company-complete-selection)) + :diminish) + (unless (display-graphic-p) (global-company-mode 1)) #+end_src * vertico #+begin_src emacs-lisp @@ -616,10 +610,14 @@ (jao-recoll (format "dir:%s/doc " jao-org-dir))) (defun jao-recoll-notes () - "Use consult-recoll to search notes." (interactive) (jao-recoll (format "dir:%s " jao-org-notes-dir))) + (defun jao-recoll-consult-notes () + "Use consult-recoll to search notes." + (interactive) + (consult-recoll (format "dir:%s " jao-org-notes-dir))) + (defun jao-recoll-open-with-notmuch (fname) (let ((id (with-temp-buffer (insert-file fname) @@ -640,7 +638,7 @@ (transient-define-prefix jao-recoll-transient () [["Consult recoll queries" ("r" "consult recoll query" consult-recoll) - ("n" "consult recoll on notes" jao-org-notes-consult-recoll) + ("n" "consult recoll on notes" jao-recoll-consult-notes) ("d" "consult recoll on docs" jao-recoll-consult-docs) ("m" "consult recoll on messages" jao-recoll-consult-messages)] ["Recoll queries" -- cgit v1.2.3