Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding yasnippet as a backend, doesn't complete when calling company-complete-selection #4

Open
jojojames opened this issue Oct 13, 2019 · 2 comments
Labels
question Further information is requested

Comments

@jojojames
Copy link

I have something like this bound to RET on the company-active-map.

(defun j-company-expand-yasnippet-or-return ()
      "Expand yas template or call RET normally.

If `yasnippet' expansion in progress, always complete selection."
      (interactive)
      (cond
       ;; `yasnippet' expansion in progress.
       ((yas-current-field)
        (call-interactively #'company-complete-selection))
       ;; Check the type of the candidate.
       ((and company-active-map
             company-selection-changed
             (car company-candidates) ;; Making sure there are candidates.
             (let ((candidate (nth company-selection
                                   company-candidates)))
               (or
                ;; This might work for `eglot'.
                ;; (get-text-property 0 :label candidate)
                ;; `company-lsp'
                (get-text-property 0 'lsp-completion-item candidate)
                ;; `company-sourcekit'
                (get-text-property 0 'sourcetext candidate)
                ;; `yasnippet'
                (get-text-property 0 'yas-template candidate))))
        (call-interactively #'company-complete-selection))
       (:default
        (when company-selection-changed
          (company-complete-selection))
        (let ((company-active-map))
          (call-interactively (key-binding (kbd "RET")))))))

Without company-fuzzy, if I'm on a snippet expansion in the company-mode popup/auto complete menu, pressing RET calls company-complete-selection which then expands the snippet.

For example, in a C file.

if| popup shows with if yasnippet selection -> press ENTER

Result:

if (/cursor/) {
}

When I pair the same setup with company-fuzzy.

Result:

if/cursor/

If I then, press TAB after that, snippet expands normally.

@jcs090218
Copy link
Member

jcs090218 commented Oct 14, 2019

Hmmm... Interesting, without any configuration with company-fuzzy and company, does it exactly do what you want? Because it does exactly the same, you describe as default? :/

Just to clarify, you want to expand snippet when the menu is still popup?

@jojojames
Copy link
Author

Yeah, I didn't emacs -Q but I stripped most of my setup away and it still works as expected.

I'd actually ask what the expected behavior of company-yasnippet would be if it didn't expand upon completion.

@jcs090218 jcs090218 added the question Further information is requested label Oct 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants