Open ribtoks opened 1 year ago
Hi, thanks for the issue!
What's the desired configuration / behavior you have in mind?
Does appending the virtual environment to your PATH
variable solve this, eg via let $PATH = $HOME . '/.virtualenvs/nvim/bin:' . $PATH
, or via vim.env
in Lua? Or are you saying we should auto-detect when g:python3_host_prog
is set?
To me a tricky thing with the latter is that projects can have pinned isort versions, so it doesn't necessarily make sense to prioritize a copy of isort
that's available in an nvim
environment over a copy of isort
in a project-specific environment.
As a side note, sandboxed isort
installs made via Mason should work out of the box.
Thank you for fast reply!
Desired configuration would be to have the same behavior as Black so that when I set g:python3_host_prog
, isort.vim would automatically resolve path to isort
itself (just like Black resolves path to black
). Regarding pinned isort, if there's a "local" pinned isort, it can be used - I thought this should work automatically because usually if there's a pinned isort, there's already some sort of local virtualenv?
I use Vim Plug, so Mason tip would not work for me, but thank you for the suggestion.
Ok! I'm still trying to figure out what the logic is for selecting which isort
executable to use that would result in the behavior you want.
Do you have an example from another plugin? I checked the official Black one and couldn't find anything about g:python3_host_prog
specifically. The way we do things right now also seems to match what plugins like vim-codefmt
do for black
and other formatters.
I use Vim Plug, so Mason tip would not work for me, but thank you for the suggestion.
There's not actually any incompatibility here; you would install mason.nvim
via vim-plug
. But perhaps that's separate from this particular issue.
python3_host_prog
defines Python environment for Neovim as a whole. If I run in my Neovim: :py3 print(sys.exec_prefix)
, the output is ~/.virtualenvs/my-nvim-virtualenv
. Now if you look at Black plugin for vim here, we are using this sys.exec_prefix
which just resolves to virtualenv python
(and, naturally, virtualenv pip
) and the whole other Black's logic will already use correct python binary.
It's customary to use Python tools in Neovim from their own virtualenv so that it does not clutter the main system. Currently this plugin does not allow for such customization.
e.g. Neovim allows to set Python with
let g:python3_host_prog = $HOME . '/.virtualenvs/nvim/bin/python3'
andBlack
has a proper support for this