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

Add some way to extend the python path in ycmd #609

Closed kovidgoyal closed 8 years ago

kovidgoyal commented 10 years ago

When editing certain projects, I change the python path in vim so the jedi works with those projects. There needs to be some way to manipulate the python path in ycmd.py.

The simplest would be just a config variable that is loaded on server startup. In which case I can set that config variable and restart ycmd when editing a project that needs a custom path.

A nicer, though somewhat hacky approach would be to monkey patch the insert, remove and append methods of sys.path in vim and pass in modifications to ycmd automatically. Of course, this will break if the user does assignment to sys.path or slicing instead of insert or append, but that is hopefully relative rare.

Valloric commented 10 years ago

The simplest would be just a config variable that is loaded on server startup. In which case I can set that config variable and restart ycmd when editing a project that needs a custom path.

That sounds reasonable. YCM already has problems with detecting the path to the Python interpreter on some Windows machines so that option would be a good last-resort for such a use case as well.

Valloric commented 10 years ago

Note to self: we'll need to reload user options from Vim to support changing the path to python while Vim is running.

kovidgoyal commented 10 years ago

It occurs to me that probably, there is no need for a separate config variable, the vim client could just send sys.path to ycmd when ycmd starts. This would mean that things will "just work" provided sys.path is setup before the first completion is triggered.

However, if there are some problems with this, I have no objection to a separate config variable, as my project env is setup automatically anyway, so adding support forconfiguring ycm is no problem.

phmarek commented 10 years ago

I'd like (need) autocompletion for python3 scripts as well.

Would the 'ycmd' process have to be running python3 to do completion for python3 scripts? I thought that the completion data came from LLVM, so it shouldn't matter what the script driving LLVM is running, right?

phmarek commented 10 years ago

Ie. would it be sufficient to set 'ft=python3' (or, perhaps better because of syntax HL, some YCM-variable instead) and have that filetype sent to ycmd so that this can use a different completion database?

davidjb commented 10 years ago

+1, having an option like this would be excellent. The way that I've had to run and configure the ycm server at present is fairly tedious. For Python projects, I use Buildout (somewhat similar to Virtualenv), and because that uses local modifications to the sys.path to include packages, it doesn't play well with ycm. Being able to configure things at the Vim configuration level would be a real help.

papa-agoo commented 10 years ago

+1

languitar commented 10 years ago

+1

laishulu commented 10 years ago

+1

mfussenegger commented 10 years ago

+1

Doubanma commented 9 years ago

+1

Congee commented 9 years ago

+1

blueyed commented 9 years ago

For related issues in Jedi, which YouCompleteMe uses, see: https://github.com/davidhalter/jedi/issues/385, https://github.com/davidhalter/jedi/pull/539, https://github.com/davidhalter/jedi/issues/535 and https://github.com/davidhalter/jedi/pull/534.

timofurrer commented 9 years ago

How is state? Was there something implemented? I have the same problem: If I would like to jump to the definition of a method from an external module in my project it is not found.

micbou commented 8 years ago

Closed by PR #2205. See the Python Semantic Completion section from the documentation for details.