Closed dycw closed 3 years ago
Ah, I believe you're running into a jedi limitation. Jedi does not support autoimport, nor will it in the future. https://github.com/davidhalter/jedi-vim/issues/736 . Since you are trying to automatically insert an import statement, it appears this is not currently possible and never will be possible with Jedi (I assume for a combination of performance and generalization reasons).
Please let me know if this adequately answers your question; if yes, feel free to close the issue. If not, let me know what else you might be having trouble replicating.
Also, just found this tool, maybe you can experiment with it and let me know how it goes for you! https://pypi.org/project/autoimport/
Hi @pappasam, thanks for dropping by.
I understand the issue of this being a jedi limitation now, thank you. However, allow me to expand on my query. If I am to write imports by hand, am I right in expecting my interpreter to understand what's been installed into my environment? Viz.:
from numpy import <CURSOR>
should start showing me members of __all__
, like arange
, ones
, etc?
Whilst unable to get this working straight up, I can't be sure where to start debugging because there appears to be many places to set "interpreter path" (using PyCharm terminology) like:
~/.config/nvim/init.vim
which has python3_host_prog
,~/.config/nvim/coc-settings.json
which has both python.pythonPath
and python.venvPath
, and jedi
has jedi.executable.command
(I have read this).I don't mind installing pynvim
and jedi-language-server
in each of my conda
/poetry
environments wasteful as that might sound - I'm just trying to get started!
Further, it's unclear if I need to install jedi
by hand? Can I just leave
let g:coc_global_extensions = ['coc-jedi']
in my init.vim
and have coc.nvim
do the rest?
P.S. Thanks for introducing me to autoimport.
I believe you'll need to install pynvim
everywhere (that's a Neovim requirement), but coc-jedi
manages the installation of jedi-language-server
in one place if you configure it appropriately. Everything's documented in the readme, but the relevant section is here.
And yes, Neovim + coc-jedi can discover what's been installed in your environment if you've installed pynvim. See the following screencast for what you should be able to do with proper configuration:
If you're looking for overall configuration recommendations, my vimrc is a gem: https://github.com/pappasam/dotfiles/blob/master/dotfiles/.config/nvim/init.vim
Additionally, I use the function ve
from my zshrc to create a virtualenv for Python. This automatically installs all the necessary software to make Vim behave. See: https://github.com/pappasam/dotfiles/blob/master/dotfiles/.zshrc#L981
Good luck on your configuration journey, there are no right answers in the Vim world, part of the fun is figuring out the exact setup that works for you. Soon you'll be able to do with every language what you used to do with Python in PyCharm!
Thanks for stopping by again - I will have a good look! (Not sure why I didn't think of going through your dotfiles!)
Allow me to close this for now. Cheers!
Hi, I am considering moving from PyCharm, and thought this would be a great place to start.
I am running a setup of the following form:
I have
conda
:where I've put
pynvim
in theneovim
environment.In PyCharm, if I have an environment called
work
withpytest
(for example) installed, then setting the project interpreter to the said environment would allow me to autocomplete & auto-import from:to:
I cannot seem to recreate this.
In my
init.vim
I have:which allows me to use different
python
s as I switch around projects, as well asalong with the rest of the stuff from here.
I haven't configured
coc-settings.json
besides setting its entirety to this.Any assistance please?
FWIW, I am able to do the symbol rename and other things: