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

Autocomplete in prelude #293

Closed
ahonnecke opened this issue May 30, 2018 · 5 comments
Closed

Autocomplete in prelude #293

ahonnecke opened this issue May 30, 2018 · 5 comments

Comments

@ahonnecke
Copy link

ahonnecke commented May 30, 2018

I'm currently attempting to set up anaconda-mode through prelude in an environment that uses pipenv, I've

  1. installed a fresh install of prelude
  2. installed company-anaconda
  3. activated my pipenv venv with pythonic-activate

created a company anaconda init file

(use-package company-anaconda)
(use-package company)

(eval-after-load "company"
  '(add-to-list 'company-backends 'company-anaconda))

(add-hook 'after-init-hook 'global-company-mode)

I can get anaconda-mode-find-definitions to follow definitions into files that are in my pipenv venv (so it seems that emacs has found the venv), but can't get anaconda-mode-complete to do suggest any context aware matches (like the methods of an object). (ie type in model_name.sa and no list appears, when I run C-M-i, the mini buffer prints "no matches")

I am seeing suggestions of python built in methods
builtins
So autocomplete seems to be working, just not the contextual part.

Maybe I'm just not setting it up right?

I'm happy to check out dev, debug, qa, help however I can.

anaconda-mode

anaconda_mode port 60260

Process anaconda-mode killed: 9
anaconda_mode port 60359

I don't have anaconda-response or anaconda-socat

@proofit404
Copy link
Contributor

Hi, thanks for giving anaconda-mode a try.

Probably method search of the models isn't supported because the model itself was built with tricky metaclass magic? What library do you use to work with the model?

Regards, Artem.

@ahonnecke
Copy link
Author

Hi, thanks for writing it!

The object that's not suggesting is from

from django_otp.plugins.otp_totp.models import TOTPDevice

and the code where it's not suggesting (although it's happening everywhere in the file):

def create_device(user, confirmed=False):
    key = default_key()
    device = TOTPDevice.objects.create(
        key=key,
        user=user,
        name='Default',
        tolerance=10,
        digits=6,
        Confirmed=confirmed
    )
    device.<no methods suggested here>
    return device

Thanks!

@valignatev
Copy link
Contributor

@ahonnecke Thing is - Django models are created with dark metaclass magic, that's why Jedi (completion library anaconda-mode uses under the hood) can't work with them properly.
I'd suggest you try (just for the experiment) to create device with TOTPDevice initializer like this:

device = TOTPDevice(
    key=key,
    user=user,
    name='Default',
    tolerance=10,
    digits=6,
    Confirmed=confirmed
)

and then try if anaconda-mode suggests any completions.
You can also check this jedi long-awaited feature for reference: davidhalter/jedi#626

@ahonnecke
Copy link
Author

That did not change the behavior, however, I think that I wasn't activating the pipenv virtual environment correctly (and honestly, I'm not entirely sure what I did that fixed it) as after getting that fixed it's working now.

Thank you!

@proofit404
Copy link
Contributor

Ok, closing then.

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