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

ac-source-nrepl-vars conflict with yasnippet? #34

Open
BlanceXR opened this issue Jun 1, 2013 · 3 comments
Open

ac-source-nrepl-vars conflict with yasnippet? #34

BlanceXR opened this issue Jun 1, 2013 · 3 comments

Comments

@BlanceXR
Copy link

BlanceXR commented Jun 1, 2013

I am using yasnippet along with auto complete and ac-nrepl.

When I start a fresh emacs session, open my .clj file, type something like def, I see bunch of normal candidates and highlighted yasnippet's target. I can then tab to complete or ret to call yas-expand.

However, I noticed that after I start nrepl, and evaluate the (ns ...) form of my clj file, I can no longer see yasnippet's target in auto-complete lists.

I than found out that if I comment out (add-to-list 'ac-sources 'ac-source-nrepl-vars)
in ac-nrepl-setup , the yasnippet's target appears again.

@purcell
Copy link
Member

purcell commented Jun 2, 2013

Presumably you just need to make sure that yasnippet's completion source appears earlier in the ac-sources list. Since ac-nrepl-setup uses (add-to-list ...), the ac-nrepl sources will be added at the beginning of ac-sources. To override this, which I believe is a reasonable default behaviour, you can write code something like this:

(defun ensure-yasnippet-is-first-ac-source ()
  (when (memq 'ac-source-yasnippet ac-sources)
    (setq ac-sources
          (cons 'ac-source-yasnippet
                (remove 'ac-source-yasnippet ac-sources)))))
(add-hook 'nrepl-interaction-mode-hook 'ac-nrepl-setup)
(add-hook 'nrepl-interaction-mode-hook 'ensure-yasnippet-is-first-ac-source)
(add-hook 'nrepl-mode-hook 'ac-nrepl-setup)
(add-hook 'nrepl-mode-hook 'ensure-yasnippet-is-first-ac-source)

I haven't tested that code directly, but you get the general idea. :-)

@BlanceXR
Copy link
Author

BlanceXR commented Jun 2, 2013

Thanks! I changed add-hook's order and It works great!

@MalloZup
Copy link

MalloZup commented Aug 5, 2019

autogenerated with https://github.com/MalloZup/doghub: issue inactive since 450 days. Please update the issue or close it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants