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

Python completions not working #76

Closed
akifd opened this issue Feb 6, 2017 · 8 comments
Closed

Python completions not working #76

akifd opened this issue Feb 6, 2017 · 8 comments

Comments

@akifd
Copy link

akifd commented Feb 6, 2017

I only get normal identifier completions + UltiSnips completions and the completions show up with slight delay. Some facts:

  • Vim (8.0.311) is compiled with python3
  • Jedi is installed globally with sudo pip3 install jedi
  • Jedi is importable in python3 shell
  • In python3 shell print sys.executable gives /usr/bin/python3
  • I have let g:completor_python_binary = "/usr/bin/python3" in my .vimrc
  • :CompletorDisable makes the (identifier+UltiSnips) completions instant
  • :CompletorEnable makes the (identifier+UltiSnips) completions have slight delay
  • completor.vim version is e9897d6, latest as of writing
  • I have no other completers installed in Vim

What am I missing and how could I debug this more?

@maralla
Copy link
Owner

maralla commented Feb 7, 2017

Here is way to debug python completion:

Run:

python3 /path/to/completor.vim/pythonx/completers/python/python_jedi.py -v

then copy the following as the input to python_jedi.py:

{"filename": "/home/vagrant/test.py", "line": 1, "col": 3, "content": "import os\nos."}

then press enter to see if there has any results.

If the results is [] then open the following file to see the logs:

/path/to/completor.vim/pythonx/completers/completor.log

@akifd
Copy link
Author

akifd commented Feb 7, 2017

The result is a really long list of dicts. Should it be working then?

And is it normal that I get a lot of [ID] results with Completor/Jedi? I have used YCM before and it seemed to limit the results a lot more, giving more accurate suggestions and being more aware of class attributes. Using self. with YCM gives the class attributes/functions and parent class attributes/functions but completor doesn't. AFAIK YCM also uses Jedi, so the results should be same with YCM and completor.

Also, if I try "something".up, completor only suggests my Django UpdateView snippet from UltiSnip. YCM suggests: upper function: __builtin__.str.upper and isupper function: __builtin__.str.isupper.

The log content:

2017-02-07 09:41:50,964 [INFO][python_jedi] {"filename": "/home/vagrant/test.py", "line": 1, "col": 3, "content": "import os\nos."}

@maralla
Copy link
Owner

maralla commented Feb 7, 2017

Completor also suggests what YCM suggests:

com

Maybe you have completor.vim and YCM both installed. They can not work together.

@akifd
Copy link
Author

akifd commented Feb 7, 2017

Ok found the problem. I had autocmd Filetype python set ft=python.django. Commenting that one out made completor.vim work.

Still, my results look a bit different to yours:

completor

Why could this be? I tried removing all other plugins and cleared my .vimrc but no luck.

@ninjawithaneedle
Copy link

Unrelated. @maralla how do you have the documetation pop-up while completing? Do you use a combination of plugins? Would love to see your python dev setup. Thanks :)

@JokerQyou
Copy link

JokerQyou commented Aug 11, 2017

Just faced this problem and figured out with @maralla 's debugging tutorial. I was trying to install completor plugin as a system default for all users on a Linux box (installed to a subdirectory in /etc/vim ), and completor would like to write to a log file in the plugin directory, which is obviously impossible because normal users have no permission to write to /etc/vim.

vim-plug seems to provide an option named dir for plugins, I wonder if completor could use that directory to store log files instead?

Update: python_jedi seems to be the only completer with this issue.

Update 2: please ignore my previous advice of using dir option of vim-plug to determine the log file location, I misunderstood the use of that option.

@abidibo
Copy link

abidibo commented Oct 20, 2017

About @decent1 problem,
I find convenient to set autocmd Filetype python set ft=python.django in my local vimrc for django projects, also because ultisnips will load the django snippets. Many other plugins (I think) work by matching with regexp, or perhaps dot separated words the filetype, in other words, I would expect to have python semantic completion available with a filetype which is python.django.

I've currenlty forced this behavior editing the pythonx/completor/__init__.py file, and adding a map item

 _type_map = {
     b'c': b'cpp',
     b'python.django': b'python',
     b'javascript.jsx': b'javascript'
}

at line72.

@maralla is there a better way to support this behavior?

Thanks for this great plugin!

@maralla
Copy link
Owner

maralla commented Oct 23, 2017

You can add this config:

let g:completor_filetype_map = {'python.django': 'python'}

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

5 participants