Open sbruder opened 4 years ago
I get the same error on Arch Linux.
It's not perfect, but this workaround works for me. It just ignores the extension entirely and invokes the black cli against the current file on save.
home.packages = with pkgs; [
neovim
black
]
programs.neovim = {
extraConfig = ''
autocmd BufWritePost *.py execute '! black %'
''
}
Thanks, that looks like a reasonable alternative. However, I have switched to formatting with pylsp’s black plugin instead, which does not require this plugin to be installed.
Describe the bug
When opening vim with black installed for the first time, black tries to create the virtualenv. On my system it fails with the following error:
When uncommenting
shutil.rmtree(virtualenv_path)
(line 128) and running/home/simon/.local/share/nvim/black/bin/python3 -Im ensurepip --upgrade --default-pip
, the following error is shown:To Reproduce
vim-plug
on neovim on NixOSExpected behavior
The plugin creates the virtualenv in the specified location.
Environment
Does this bug also happen on master? Yes
Additional context
When installing neovim on NixOS, the python module in neovim includes
pynvim
andmsgpack
for which nix creates an own python installation (in my case/nix/store/x718m62fiyfx6xfqrv2f33i7m3pfbrmi-python3-3.8.5-env/bin/python3.8
). The normal python installation without any modules in my case is/nix/store/z65l1jqvxa58zzwwa3bvglb6asj4y8cv-python3-3.8.5/bin/python3.8
). Thepython3.8
executable in vim’s python environment is just a shell script wrapper that sets environment variables and then calls the normal python executable.This leads to
sys._base_executable
(pointing to normal python) being different fromsys.executable
(pointing to vim’s python) in vim’s python environment. Since the plugin sets both to the same executable (vim’s python’s), creating the virtualenv fails.I’m not sure how to fix this without reintroducing #1379.