[Solved] Auto-completion support
Disclaimer: The configuration and setup mentioned in this guide are specific to Spacemacs
only. The instructions provided may not be applicable or compatible with other Emacs setups or configurations.
I have finally been able to use all sorts of completions in spacemacs
. I have tried several combinations and finally, I got it. So I put this one here in case anyone stumbled into this dilemma.
Yasnippet Auto-completion
The back-end of yasnippet
is company-yasnippet
and you can add it to your spacemacs using. There are two ways to make it works (choose only one of these two, I used the second option)
- At your
dotspacemacs-configuration-layers
add
(auto-completion :variables
auto-completion-enable-snippets-in-popup t
auto-completion-enable-help-tooltip t
auto-completion-return-key-behavior 'complete
auto-completion-tab-key-behavior 'cycle ;;'complete 'cycle
auto-completion-enable-sort-by-usage t
auto-completion-idle-delay 0.0)
:config
add-to-list 'company-backends '(company-yasnippet company-lsp company-capf company-anaconda))
- You can add to
dotspacemacs/user-config
the following
;; -------------------------------------------------------------
;; Auto-completion - Back End Support
;; -------------------------------------------------------------
(require 'company-yasnippet)
(add-to-list 'company-backends '(company-yasnippet company-lsp company-capf company-anaconda))
[Optional][bonus] Tabnine Auto-completion support
I like also to add company-tabnine
to my back-ends completions. Here is how I did it.
- Ensure you already installed the
tabnine
in dotspacemacs-additional-packages
as:
dotspacemacs-additional-packages '(
(company-tabnine) ;; for using tab-nine AI auto-assistance
)
- Put in your
dotspacemacs/user-config
(similar to before)
;; -------------------------------------------------------------
;; Auto-completion - Back End Support
;; -------------------------------------------------------------
(require 'company-yasnippet)
(require 'company-tabnine)
(add-to-list 'company-backends '(company-yasnippet company-tabnine company-lsp company-capf company-anaconda))
- Install
tabnine
binary using M-x: company-tabnine-install-binary
( twice in spacemacs
then write this command). It will be installed in your home directory (e.g. for my machine M1 macOS, it will be downloaded here ~/.TabNine/4.4.321/aarch64-apple-darwin
. Make sure it is executable by running the command below in this directory (read more here).
chmod +x ~/.TabNine/4.4.321/aarch64-apple-darwin/*
It works now as you can see

NOTE:
[I think] changing the order of the company backends in the company-backends list will affect their order in the popup menu. Make sure to set auto-completion-enable-snippets-in-popup t (read more here)
To investigate your back-end company support, you can use <space-space>
and type (M-x: describe-variable
) then search for company-backends
and you will see a doc
popup showing all back-ends supported. For me they are
Value:
((company-capf company-dabbrev-code . #1=(:with company-yasnippet))
(company-semantic company-dabbrev-code company-gtags company-etags company-keywords . #1#)
(company-files . #1#)
(company-dabbrev . #1#))
Original value was
(company-bbdb company-semantic company-cmake company-capf company-clang company-files
(company-dabbrev-code company-gtags company-etags company-keywords)
company-oddmuse company-dabbrev)
Local in buffer .spacemacs; global value is
((company-yasnippet company-tabnine company-lsp company-capf company-anaconda)
company-bbdb company-semantic company-cmake company-capf company-clang company-files
(company-dabbrev-code company-gtags company-etags company-keywords)
company-oddmuse company-dabbrev)
snippets
folder) labeledpython-mode
and/orsh-mode
, or do you have a snippet inherit file.yas-parents
in either of those folders so that snippets from other modes are inherited? Have you enabledyasnippet
globally as described in theREADME.md
file?: github.com/joaotavora/yasnippetauto-completion-enable-snippets-in-popup
having anil
value? Yasnippet comes with its own mechanism for triggering snippets when the user presses the tab key, and if more than one snippet matches the key at point, the available snippets to choose from are displayed. See the section "Multiples snippet with the same key" github.com/joaotavora/yasnippet/blob/master/doc/… See also the functionyas-insert-snippet
... "Prompts you for possible snippet expansion ..."