.emacs.d/init.d/misc/completion.el
tastytea 8f0f407ec5
completion: Defer company-quickhelp.
Has to be loaded after something, but I'm not sure what.
2021-06-28 22:58:32 +02:00

95 lines
2.8 KiB
EmacsLisp

;;; completion.el --- Completion base packages. -*- lexical-binding: t; -*-
;;; Commentary:
;; * Ivy
;; * Counsel
;;; Code:
(require 'basics/package-management)
(require 'basics/global-variables)
(require 'basics/appearance)
(require 'misc/libs)
(require 'basics/input)
;; Completion in many Emacs commands.
(use-package ivy
:demand t
:diminish ivy-mode
:custom ((ivy-use-virtual-buffers t)
(ivy-count-format "[%d/%d] ")
(ivy-wrap t))
:config (ivy-mode 1)
:bind (("C-c C-r" . ivy-resume)
(:map ivy-minibuffer-map
("M-<up>" . ivy-previous-history-element)
("M-<down>" . ivy-next-history-element)
("S-<return>" . ivy-immediate-done)))) ; Ignore completion.
;; Extensions for ivy
(use-package counsel
:demand t
:after (ivy imenu)
:bind (("C-x C-f" . counsel-find-file)
("M-x" . counsel-M-x)
("M-i" . counsel-imenu)))
;; More information in ivy mini-buffers.
(use-package ivy-rich
:demand t
:after (counsel)
:config (ivy-rich-mode 1))
;; Use icons in ivy-rich.
(use-package all-the-icons-ivy-rich
:demand t
:after (all-the-icons ivy-rich)
:config (all-the-icons-ivy-rich-mode 1))
(use-package ivy-emoji ; Insert emojis with ivy.
:after (ivy)
:bind ("C-c e" . ivy-emoji))
;; Sorting and filtering for ivy.
(use-package ivy-prescient
:after (prescient counsel)
:custom (ivy-prescient-retain-classic-highlighting t)
:hook (after-init . ivy-prescient-mode))
;; C-o shows additional options.
(use-package ivy-hydra
:after (ivy))
;; Autocompletion mode with many plugins.
(use-package company
:unless slow-computer
:diminish company-mode
:custom ((company-minimum-prefix-length 1) ; Suggestions after 1 character.
(company-selection-wrap-around t)
(company-tooltip-align-annotations t) ; Align to the right border.
(company-idle-delay 0.5))
:bind (:map company-active-map
("<return>" . nil) ; Disable completion on return.
("RET" . nil) ; https://emacs.stackexchange.com/a/13290
("<tab>" . company-complete-selection) ; Make tab work in lists.
("TAB" . company-complete-selection)) ; Tab in terminals.
:hook (after-init . global-company-mode))
;; Documentation popups for completions.
(use-package company-quickhelp
:after (company)
:defer 4
:config (company-quickhelp-mode))
;; Sorting and filtering for company.
(use-package company-prescient
:after (prescient company)
:config (defun my/company-prescient-sort-length-off ()
"Turn off length-based sorting.
Desirable when another intelligent sorting algorithm is at work."
(setq-local company-prescient-sort-length-enable nil))
:hook (company-mode . company-prescient-mode))
(provide 'misc/completion)
;;; completion.el ends here