maralla / completor.vim

Async completion framework made ease.
MIT License
1.31k stars 62 forks source link

Expose API method to reload completor? #156

Closed tpict closed 6 years ago

tpict commented 6 years ago

I think I should be filing this here rather than the Jedi repo, but sorry if I'm incorrect!

It seems like the modules in the path of g:completor_python_binary are cached upon entering insert mode in a Python file. It would be really nice if this could be reloaded so that one could switch to a different Python executable dynamically (my use case is switching virtualenvs without restarting Vim).

I've had a look through the code but I can't quite figure out when Jedi crawls through the path to find modules. I tried modifying the _load function in the completor module to always reload completers.python but the completion suggestions aren't updated. Please could I get some pointers?

maralla commented 6 years ago

I pushed a commit to expose the completor#daemon#kill() function which is used to kill the current running daemon. You can reload jedi daemon using the following method:

" 1. Change virtualenv.
" 2. Change python executable:
:let g:completor_python_binary = '/path/to/new/python'
" 3. Kill current running daemon:
:call completor#daemon#kill()
tpict commented 6 years ago

Perfect. Thank you so much! I've wanted something like this for a long time.