Doom-emacs: snippets candidate not present in company in python-mode

Created on 10 Oct 2018  ·  3Comments  ·  Source: hlissner/doom-emacs

Observed behavior

yasnippets candidates do not present in company autocomplete.
Though I can see them from SPC s i, and expend them nicely.
the result of describe-variable for company backends is shown in the following screenshot
snipaste_2018-10-10_17-40-07

Expected behavior

when I input ifm, autocomplete should presents candidates of ifmain for me.

System information


Click to expand

- OS: darwin (x86_64-apple-darwin14.5.0)
- Emacs: 26.1 (May 31, 2018)
- Doom: 2.0.9 (develop cdf745e72a3e8bf9bef1f0fa4d051b00aab351e3)
- Graphic display: nil (daemon: nil)
- System features: NOTIFY ACL GNUTLS LIBXML2 ZLIB TOOLKIT_SCROLL_BARS NS MODULES THREADS
- Details:
  ```elisp
  elc count: 0
  uname -a:  Darwin machw 18.0.0 Darwin Kernel Version 18.0.0: Wed Aug 22 20:13:40 PDT 2018; root:xnu-4903.201.2~1/RELEASE_X86_64 x86_64 i386 MacBookPro10,1 Darwin
  modules:   (:feature (evil +everywhere) file-templates (lookup +docsets) snippets spellcheck (syntax-checker +childframe) workspaces :completion (helm +fuzzy) :ui doom-dashboard doom-modeline doom-quit evil-goggles fci hl-todo nav-flash treemacs (popup +all +defaults) unicode vc-gutter vi-tilde-fringe window-select :editor rotate-text :emacs ediff electric hideshow imenu vc :tools magit :lang emacs-lisp markdown (org +attach +babel +capture +export +present) python rust (sh +fish) :config)
  packages:  n/a
  exec-path: (/usr/local/opt/coreutils/libexec/gnubin /usr/local/opt/python/libexec/bin /usr/local/bin /usr/local/sbin /usr/bin /bin /usr/sbin /sbin ~/.cargo/bin ~/bin /usr/local/opt/fzf/bin /Applications/Emacs.app/Contents/MacOS/bin-x86_64-10_10 /Applications/Emacs.app/Contents/MacOS/libexec-x86_64-10_10 /Applications/Emacs.app/Contents/MacOS/libexec /Applications/Emacs.app/Contents/MacOS/bin)
  ```

:completion company :editor snippets :lang python question elisp resolved-elsewhere

Most helpful comment

After checking the codes of doom, I find the company backend is modified here: https://github.com/hlissner/doom-emacs/blob/develop/modules/lang/python/config.el#L64

To enable company-yasnippet by default, the following codes works.

(after! anaconda-mode
  (set-company-backend! 'anaconda-mode '(company-anaconda company-yasnippet)))

All 3 comments

This is to be expected. Company will only use company-anaconda. (:separate company-capf company-yasnippet) is a fallback, in case anaconda fails.

You can either access snippet completion through C-x C-s, or by changing python's backends:

(set-company-backend! 'anaconda-mode '(company-anaconda company-yasnippet))

This will change company-backends to be:

((company-anaconda company-yasnippet)
 (:separate company-capf company-yasnippet)
 company-capf)

In python-mode.

only works for new buffer, existing buffer is not affected.
can you help with this?

After checking the codes of doom, I find the company backend is modified here: https://github.com/hlissner/doom-emacs/blob/develop/modules/lang/python/config.el#L64

To enable company-yasnippet by default, the following codes works.

(after! anaconda-mode
  (set-company-backend! 'anaconda-mode '(company-anaconda company-yasnippet)))
Was this page helpful?
0 / 5 - 0 ratings