2019-01-03 01:29:57 -05:00
|
|
|
#+TITLE: completion/company
|
|
|
|
#+DATE: February 19, 2017
|
|
|
|
#+SINCE: v2.0
|
|
|
|
#+STARTUP: inlineimages
|
2017-05-25 20:08:50 +02:00
|
|
|
|
2019-01-03 01:29:57 -05:00
|
|
|
* Table of Contents :TOC_3:noexport:
|
2019-05-01 19:18:38 -04:00
|
|
|
- [[#description][Description]]
|
|
|
|
- [[#module-flags][Module Flags]]
|
|
|
|
- [[#plugins][Plugins]]
|
|
|
|
- [[#prerequisites][Prerequisites]]
|
|
|
|
- [[#features][Features]]
|
|
|
|
- [[#code-completion][Code completion]]
|
|
|
|
- [[#vim-esque-omni-completion-prefix-c-x][Vim-esque omni-completion prefix (C-x)]]
|
|
|
|
- [[#configuration][Configuration]]
|
|
|
|
- [[#enable-company-backends-in-certain-modes][Enable company backend(s) in certain modes]]
|
|
|
|
- [[#troubleshooting][Troubleshooting]]
|
|
|
|
- [[#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.]]
|
2017-05-25 20:08:50 +02:00
|
|
|
|
2019-01-03 01:29:57 -05:00
|
|
|
* Description
|
|
|
|
This module provides code completion, powered by [[https://github.com/company-mode/company-mode][company-mode]]. It is required
|
|
|
|
for code completion in many of Doom's :lang modules.
|
2017-05-25 20:08:50 +02:00
|
|
|
|
2019-01-03 01:29:57 -05:00
|
|
|
https://assets.doomemacs.org/completion/company/overlay.png
|
2017-05-25 20:08:50 +02:00
|
|
|
|
2019-01-03 01:29:57 -05:00
|
|
|
** Module Flags
|
|
|
|
+ =+childframe= Enables displaying completion candidates in a child frame,
|
|
|
|
rather than an overlay or tooltip (among with other UI enhancements). *This
|
2019-12-15 21:45:40 -05:00
|
|
|
requires GUI Emacs 26.1+ and is incompatible with the =+tng= flag*
|
2019-04-18 00:12:57 -03:00
|
|
|
+ =+tng= Enables completion using only ~TAB~. Pressing ~TAB~ will select the
|
2019-12-15 21:45:40 -05:00
|
|
|
next completion suggestion, while ~S-TAB~ will select the previous one. *This
|
|
|
|
is incompatible with the =+childframe= flag*
|
2017-05-25 20:08:50 +02:00
|
|
|
|
2019-01-03 01:29:57 -05:00
|
|
|
** Plugins
|
|
|
|
+ [[https://github.com/company-mode/company-mode][company-mode]]
|
|
|
|
+ [[https://github.com/hlissner/emacs-company-dict][company-dict]]
|
2019-09-26 14:22:05 -04:00
|
|
|
+ [[https://github.com/sebastiencs/company-box][company-box]]* (=+childframe=)
|
2017-05-25 20:08:50 +02:00
|
|
|
|
2019-01-03 01:29:57 -05:00
|
|
|
* Prerequisites
|
|
|
|
This module has no direct prerequisites.
|
2017-05-25 20:08:50 +02:00
|
|
|
|
2019-01-03 01:29:57 -05:00
|
|
|
However, some major modes may require additional setup for code completion to
|
|
|
|
work in them. Some major modes may have no completion support at all. Check that
|
|
|
|
major mode's module's documentation for details.
|
2017-05-25 20:08:50 +02:00
|
|
|
|
2019-01-03 01:29:57 -05:00
|
|
|
* Features
|
|
|
|
** Code completion
|
2019-05-03 21:53:36 -04:00
|
|
|
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:
|
2017-05-25 20:08:50 +02:00
|
|
|
|
2019-01-03 01:29:57 -05:00
|
|
|
| Keybind | Description |
|
|
|
|
|---------+------------------------------------------|
|
|
|
|
| =C-n= | Go to next candidate |
|
|
|
|
| =C-p= | Go to previous candidate |
|
|
|
|
| =C-j= | (evil) Go to next candidate |
|
|
|
|
| =C-k= | (evil) Go to previous candidate |
|
|
|
|
| =C-h= | Display documentation (if available) |
|
|
|
|
| =C-u= | Move to previous page of candidates |
|
|
|
|
| =C-d= | Move to next page of candidates |
|
|
|
|
| =C-s= | Filter candidates |
|
|
|
|
| =C-S-s= | Search candidates with helm/ivy |
|
|
|
|
| =C-SPC= | Complete common |
|
|
|
|
| =TAB= | Complete common or select next candidate |
|
|
|
|
| =S-TAB= | Select previous candidate |
|
2017-05-25 20:08:50 +02:00
|
|
|
|
2019-01-03 01:29:57 -05:00
|
|
|
** Vim-esque omni-completion prefix (C-x)
|
|
|
|
In the spirit of Vim's omni-completion, the following insert mode keybinds are
|
|
|
|
available to evil users to access specific company backends:
|
|
|
|
|
|
|
|
| Keybind | Description |
|
|
|
|
|-----------+-----------------------------------|
|
|
|
|
| =C-x C-]= | Complete etags |
|
|
|
|
| =C-x C-f= | Complete file path |
|
|
|
|
| =C-x C-k= | Complete from dictionary/keyword |
|
|
|
|
| =C-x C-l= | Complete full line |
|
|
|
|
| =C-x C-o= | Invoke complete-at-point function |
|
|
|
|
| =C-x C-n= | Complete next symbol at point |
|
|
|
|
| =C-x C-p= | Complete previous symbol at point |
|
|
|
|
| =C-x C-s= | Complete snippet |
|
|
|
|
| =C-x s= | Complete spelling suggestions |
|
|
|
|
|
|
|
|
* Configuration
|
|
|
|
** 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
|
|
|
|
symbol, or a list of either. BACKENDS are prepended to ~company-backends~ for
|
|
|
|
those modes.
|
|
|
|
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
|
|
|
(after! js2-mode
|
|
|
|
(set-company-backend! 'js2-mode 'company-tide 'company-yasnippet))
|
|
|
|
|
|
|
|
(after! sh-script
|
|
|
|
(set-company-backend! 'sh-mode
|
|
|
|
'(company-shell :with company-yasnippet)))
|
|
|
|
|
|
|
|
(after! cc-mode
|
|
|
|
(set-company-backend! 'c-mode
|
|
|
|
'(:separate company-irony-c-headers company-irony)))
|
|
|
|
#+END_SRC
|
|
|
|
|
|
|
|
To unset the backends for a particular mode, pass ~nil~ to it:
|
2017-05-25 20:08:50 +02:00
|
|
|
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
2019-01-03 01:29:57 -05:00
|
|
|
(after! sh-script
|
|
|
|
(set-company-backend! 'sh-mode nil))
|
2017-05-25 20:08:50 +02:00
|
|
|
#+END_SRC
|
|
|
|
|
2017-08-21 20:07:07 +02:00
|
|
|
* Troubleshooting
|
2019-01-03 01:29:57 -05:00
|
|
|
If code completion isn't working for you, consider the following common causes
|
|
|
|
before you file a bug report:
|
|
|
|
|
|
|
|
** X-mode doesn't have code completion support or requires extra setup.
|
|
|
|
There is no guarantee your language mode will have completion support.
|
|
|
|
|
|
|
|
Some, like ~lua-mode~, don't have completion support in Emacs at all. Others may
|
|
|
|
requires additional setup to get code completion working. For instance,
|
2020-03-12 11:29:54 -04:00
|
|
|
~go-mode~ requires ~guru~ to be installed on your system, and ~ruby-mode~
|
2019-01-03 01:29:57 -05:00
|
|
|
requires that you have a Robe server running (~M-x robe-start~).
|
|
|
|
|
|
|
|
Check the relevant module's documentation for this kind of information.
|
|
|
|
|
|
|
|
** No backends (or the incorrect ones) have been registered for X-mode.
|
|
|
|
Doom expects every mode to have an explicit list of company-backends (and as
|
|
|
|
short a list as possible). This may mean you aren't getting all the completion
|
|
|
|
you want or any at all.
|
2017-05-25 20:08:50 +02:00
|
|
|
|
2019-01-03 01:29:57 -05:00
|
|
|
Check the value of ~company-backends~ (=SPC h v company-backends=) from that
|
|
|
|
mode to see what backends are available. Check the [[*Assigning company backend(s) to modes][Configuration section]] for
|
|
|
|
details on changing what backends are available for that mode.
|