ycm-core / YouCompleteMe

A code-completion engine for Vim
http://ycm-core.github.io/YouCompleteMe/
GNU General Public License v3.0
25.44k stars 2.81k forks source link

Python completion does not work on OS X 10.9 #1068

Closed aj8k closed 10 years ago

aj8k commented 10 years ago

It's my first day with OS X. I installed brewed python, macvim and all other things from instruction. But autocompletion still does not work for some modules.

import sys

GoToDefinition command for sys module returned such an error:

'RuntimeError: Builtin modules cannot be displayed.'

But ipython works as expected, my code run successfully. I cannot find any issue with this message in google search.

I'm stuck with setup of mac env, but on linux everything works like a charm (using it for a while). Thanx for this plugin and please help me to fix this issue.

vheon commented 10 years ago

I'm not a python developer but I think that with cpython which I believe is the default interpreter the sys module is written in C so you cannot GoToDefinition on sys at least on mac, I don't know if on linux it will get you to the C code of sys. I'm on mac and I get the same error but if I change the import like import abc which is in the standard library I get to the class just fine. So for me this is not a bug and until proven otherwise I close the issue.

ghost commented 8 years ago

I have met with similar problem. But I think in this case its the use of sys that is wrong. In my case, I have Vim 7.4+ installed in EI Capitan with latest ycm. The problem is that there's no autocompletion hint to choose. I can use GoToDefinition on os library. If I type :YcmCompleter in a python file, the result is:

ValueError: Supported commands are:
GoToDefinition
GoToDeclaration
GoTo
GetDoc
See the docs for information on what they do.

I've googled yet finding no satisfying solution. Am I missing any setup? Python autocompletion is just not working.

vheon commented 8 years ago

you have to provide a minimal test case

ghost commented 8 years ago

Sorry for being too rash. I got the problem solved after viewing Issue#1348. The autocompletion problem can be settled by let g:ycm_seed_identifiers_with_syntax = 1. I think the default value should be 1 so that ycm could seem more intelligent when opening python files the first time.

And I also find that ycm doesn't support syntastic check for python, which differs from C-family. These are the reasons why I thought ycm is not working on python.

vheon commented 8 years ago

let g:ycm_seed_identifiers_with_syntax=1 uses as candidates for the Identifier-based engine token that usually are highlighted in a python file. Not everyone want those as candidates since they could clutter real candidates from the file.

And I also find that ycm doesn't support syntastic check for python, which differs from C-family. These are the reasons why I thought ycm is not working on python.

This is because libclang gives us diagnostics for free when we try to compile the TU for giving you completion. This is not true for python even though jedi has some sort of diagnostic functionality that we might consider including; but in any case I don't think it will be in the near future since the python completer is going through some rework right now (https://github.com/Valloric/ycmd/pull/246)