From 04acb8fa98b822a880b6e218099c8437835b619f Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Fri, 3 May 2019 21:53:36 -0400 Subject: [PATCH] completion/company: +auto by default Questions regarding "completion not working" are very common, so the +auto flag has been removed and idle completion enabled by default. --- modules/README.org | 2 +- modules/completion/company/README.org | 25 ++----------------------- modules/completion/company/config.el | 13 +++++-------- 3 files changed, 8 insertions(+), 32 deletions(-) diff --git a/modules/README.org b/modules/README.org index 1fc00cec0..ac5f405cd 100644 --- a/modules/README.org +++ b/modules/README.org @@ -15,7 +15,7 @@ Modules that provide new interfaces or frameworks for completion, including code completion. -+ [[file:completion/company/README.org][company]] =+auto +childframe +tng=: The ultimate code completion backend ++ [[file:completion/company/README.org][company]] =+childframe +tng=: The ultimate code completion backend + helm =+fuzzy +childframe=: *Another* search engine for love and life + ido: The /other/ *other* search engine for love and life + [[file:completion/ivy/README.org][ivy]] =+fuzzy +childframe=: /The/ search engine for love and life diff --git a/modules/completion/company/README.org b/modules/completion/company/README.org index 223913178..6d796ba00 100644 --- a/modules/completion/company/README.org +++ b/modules/completion/company/README.org @@ -12,10 +12,8 @@ - [[#code-completion][Code completion]] - [[#vim-esque-omni-completion-prefix-c-x][Vim-esque omni-completion prefix (C-x)]] - [[#configuration][Configuration]] - - [[#enable-as-you-typeidle-code-completion][Enable as-you-type/idle code completion]] - [[#enable-company-backends-in-certain-modes][Enable company backend(s) in certain modes]] - [[#troubleshooting][Troubleshooting]] - - [[#code-completion-doesnt-pop-up-automatically][Code-completion doesn't pop up automatically.]] - [[#x-mode-doesnt-have-code-completion-support-or-requires-extra-setup][X-mode doesn't have code completion support or requires extra setup.]] - [[#no-backends-or-the-incorrect-ones-have-been-registered-for-x-mode][No backends (or the incorrect ones) have been registered for X-mode.]] @@ -26,7 +24,6 @@ for code completion in many of Doom's :lang modules. https://assets.doomemacs.org/completion/company/overlay.png ** Module Flags -+ =+auto= Enables as-you-type completion. + =+childframe= Enables displaying completion candidates in a child frame, rather than an overlay or tooltip (among with other UI enhancements). *This requires GUI Emacs 26.1+.* @@ -48,12 +45,11 @@ major mode's module's documentation for details. * Features ** Code completion -Ccompletion must be triggered manually with the =C-SPC= key. If you want -as-you-type code completion, the ~+auto~ module flag will enable it. +By default, completion is triggered after a short idle period or with the +=C-SPC= key. While the popup is visible, the following keys are available: | Keybind | Description | |---------+------------------------------------------| -| =C-SPC= | Invoke code completion manually | | =C-n= | Go to next candidate | | =C-p= | Go to previous candidate | | =C-j= | (evil) Go to next candidate | @@ -84,14 +80,6 @@ available to evil users to access specific company backends: | =C-x s= | Complete spelling suggestions | * Configuration -** Enable as-you-type/idle code completion -The =+auto= module flag enables this feature. - -Otherwise, ~M-x +company/toggle-auto-completion~ will toggle this interactively. - -Customize ~company-idle-delay~ to control how quickly the popup should appear. -The default is ~0.2s~. - ** Enable company backend(s) in certain modes The ~set-company-backend!~ function exists for setting ~company-backends~ buffer-locally in MODES, which is either a major-mode symbol, a minor-mode @@ -122,15 +110,6 @@ To unset the backends for a particular mode, pass ~nil~ to it: If code completion isn't working for you, consider the following common causes before you file a bug report: -** Code-completion doesn't pop up automatically. -This is by design. The expectation is that you invoke completion manually with -=C-SPC=. This was decided because code-completion backends can be slow, some -dreadfully so, and invoking them every time you move your cursor can add pauses -and delays while editing. - -If, despite that, you still want this functionality, use the =+auto= flag to -enable it. - ** X-mode doesn't have code completion support or requires extra setup. There is no guarantee your language mode will have completion support. diff --git a/modules/completion/company/config.el b/modules/completion/company/config.el index 55779bffa..3e582e242 100644 --- a/modules/completion/company/config.el +++ b/modules/completion/company/config.el @@ -2,8 +2,9 @@ (def-package! company :commands (company-complete-common company-manual-begin company-grab-line) + :after-call (evil-insert-state-entry-hook evil-emacs-state-entry-hook) :init - (setq company-idle-delay nil + (setq company-minimum-prefix-length 2 company-tooltip-limit 14 company-dabbrev-downcase nil company-dabbrev-ignore-case nil @@ -16,6 +17,9 @@ company-frontends '(company-pseudo-tooltip-frontend company-echo-metadata-frontend)) + ;; Lazy load until user starts entering text + (unless (featurep! :editor evil) + (add-transient-hook! 'post-self-insert-hook (require 'company))) :config (add-hook 'company-mode-hook #'+company|init-backends) (when (featurep! :editor evil) @@ -23,13 +27,6 @@ (global-company-mode +1)) -(def-package! company - :when (featurep! +auto) - :defer 2 - :after-call post-self-insert-hook - :config (setq company-idle-delay 0.1)) - - (def-package! company-tng :when (featurep! +tng) :defer 2