0

Company doesn't show snippets in some modes e.g. python or sh. Yet yas/describe-tables displays all snippets. In other modes e.g. org,emacs-lisp, snippets are shown as expected.

Looking at company-diag I don't see company-yasnippets loaded anywhere in python-mode.

Used backend: company-capf

While in the working org mode it returns

Used backend: (company-capf :with company-yasnippet)

Testing this variable (as proposed in spacemac docu) didn't change anything:

spacemacs-default-company-backends '(company-yasnippet)

Environment:

yas-snippet-dirs:

("/home/user/.emacs.d/private/snippets/" yasnippet-snippets-dir)

yas-global-mode t

 (auto-completion :variables
                  auto-completion-enable-snippets-in-popup t
                  auto-completion-enable-help-tooltip t)
 (python :variables
         python-backend 'lsp
         python-lsp-server 'pyright
         python-test-runner 'pytest
         python-enable-yapf-format-on-save t
         )

Where should I start looking?


Update:

Custom created snippets e.g. /private/snippets/python-mode/foo.snippet appear in a second list. In a different color and out-of-line position. It looks like multiple completion systems are interfering.

Gif: Python after enabling auto-complete-mode alongside company-mode

screenshot

Gif: Expected behavior (as in org mode and company-mode only): expected_gif

3
  • 2
    Do you have any snippet files stored in the folders (within the snippets folder) labeled python-mode and/or sh-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 enabled yasnippet globally as described in the README.md file?: github.com/joaotavora/yasnippet
    – lawlist
    Aug 6 at 7:52
  • @lawlist No parents in neither directories. Does my question update help?
    – jjk
    Aug 6 at 10:28
  • 1
    Do the snippets work correctly if you revert to the default spacemacs settings of auto-completion-enable-snippets-in-popup having a nil 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 function yas-insert-snippet ... "Prompts you for possible snippet expansion ..."
    – lawlist
    Aug 6 at 17:39
1

Remove the extension .snippet from the name of any new snippet created . No snippets have such extension.

Assuming you have some python snippets, take into account the execution order - if your python mode is enabled after yasnippets-snippets package, then at the end of your python configuration add the expression (yas-reload-all) to reload all snippets.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.