petobens / poet-v Goto Github PK
View Code? Open in Web Editor NEWVim Meets Poetry and Pipenv Virtual Environments
License: MIT License
Vim Meets Poetry and Pipenv Virtual Environments
License: MIT License
I use poetry and do not have pipenv installed.
Tried adding this plugin - I use NeoVim 0.7 on macOS - I can be more specific if needed.
I use packer and installed by adding:
use "petobens/poet-v"
When opening neovim I now get this error message:
Error detected while processing /Users/xxxx/.local/share/nvim/site/pack/packer/start/poet-v/plugin/poetv.vim:
line 19:
pipenv executable not found.
When calling PoetvActivate
, paths that include spaces such as C:\Users\User Name\...
get truncated to C:\Users\User
before they're passed to poetvenv.activate
causing the following error involving activator_dir
.
Error detected while processing function poetv#activate:
line 50:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Users\User Name\vimfiles\plugged\poet-v\autoload\poetvenv.py", line 24, in activate
shutil.copy((Path(__file__).resolve().parent / activator_file).as_posix(), activator_dir.as_posix())
File "D:\Python\Python38\Lib\shutil.py", line 415, in copy
copyfile(src, dst, follow_symlinks=follow_symlinks)
File "D:\Python\Python38\Lib\shutil.py", line 261, in copyfile
with open(src, 'rb') as fsrc, open(dst, 'wb') as fdst:
FileNotFoundError: [Errno 2] No such file or directory: 'C:/Users/User/Scripts'
I cannot get this plugin to work with python3/dyn vim.
I have gVim 8.2 running on Windows 10. I have poetry
installed and am able to run it from the terminal within Vim and also from Cmder. I then have the plugin cloned into the following folder
$env:HOME\vimfiles\pack\vendor\start\peot-v
I can start up gVim and see from running :scriptnames
that it's loading. I then put in $MYVIMRC
the following snippet to have it automatically load the virtualenv so pylint stops complaining that it can't find diagrams in the load path
" poet-v
try
g:poetv_auto_activate = 1
endtry
However, when I start gVim, it says that: Pattern not found: poetv_auto_activate = 1
.
The same thing happens when using command-line vim.
Poetry Version
> poetry --version
Poetry version 1.0.10
I'm so sorry,
Where does the poetv_statusline_symbol
show? The plugin works ($ where python
after :PoetvActivate
shows exactly what I expect), but no visual trace in the status line. Curiously, the zsh console looks just like the system one, minus (venv).
BTW, I can't see the statusline symbol on your screenshot.
The following command was executed when main.py
was the current buffer.
.venv/
bottle_sample/
main.py (* current buffer)
__init__.py
tests/
README.rst
poetry.lock
pyproject.toml
Executed command:
:echo split(trim(system('poetry env list --full-path')), '\n')
['C:\Users\user1\ghq\github.com\tamago324\snippets\python\bottle_sample\.venv (Activated)']
If not on Windows, will the result be returned as follows?
:echo split(trim(system('poetry env list --full-path')), '\n')
['C:/Users/user1/ghq/github.com/tamago324/snippets/python/bottle_sample/.venv']
If not, you may need to fix the following:
diff --git a/autoload/poetv.vim b/autoload/poetv.vim
index 3039843..a177247 100644
--- a/autoload/poetv.vim
+++ b/autoload/poetv.vim
@@ -52,18 +52,15 @@ function! poetv#activate() abort
let virtual_env_cmd = s:get_venv_cmd(binary)
let poetv_out_list = split(trim(system(virtual_env_cmd)), '\n')
if v:shell_error == 0 && !empty(poetv_out_list)
- if len(poetv_out_list) == 1
- let poetv_out = poetv_out_list[0]
- endif
for i in poetv_out_list
" Only poetry allows for multiple envs and signals the active
" env with an `Activated` keyword
- if match (i, '/\S*\s\+\zs(Activated)\ze') != -1
+ if match (i, '\S*\s\+\zs(Activated)\ze') != -1
let poetv_out = i
break
endif
endfor
- let poetv_out = matchstr(poetv_out, '\zs/\S*')
+ let poetv_out = matchstr(poetv_out, '^\S*')
call setbufvar(curr_buffer_name, 'poetv_dir', poetv_out)
break
else
$ poetry env use python3.6
$ poetry env use python3.7
poetry env list output:
dial-gui-2yUC4xZS-py3.6
dial-gui-2yUC4xZS-py3.7 (Activated)
PoetvActivate
command.ERROR OUTPUT:
Error detected while processing function poetv#activate[39]..provider#python3#Call:
line 18:
Error invoking 'python_execute' on channel 4 (python3-script-host):
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/home/davafons/.vim/plugged/poet-v/autoload/poetvenv.py", line 21, in activate
shutil.copy(Path(__file__).resolve().parent / activator_file, activator_dir)
File "/usr/lib/python3.8/shutil.py", line 409, in copy
copyfile(src, dst, follow_symlinks=follow_symlinks)
File "/usr/lib/python3.8/shutil.py", line 259, in copyfile
with open(src, 'rb') as fsrc, open(dst, 'wb') as fdst:
FileNotFoundError: [Errno 2] No such file or directory: '/home/davafons/.cache/pypoetry/virtualenvs/dial-gui-2yUC4xZS-py3.6\n/home/davafons/.cache/pypoetry/virtualenvs/dial-
gui-2yUC4xZS-py3.7/bin'
In the output error you can see how the file path is actually the two venv paths joined by a \n
I'm having some issues using this plugin as well as Coc.nvim's coc-pyright plugin/extension.
More technically, I'm having some issues with :PoetvActivate
. AFAIK, :PoetvActivate
and poetry shell
should do the same behaviour?
$ vim
As you can see per my statusline, the venv has been loaded. which python
resolves to the venv. However, pyright complains that it can't find my modules. In the original thread, :!pip list
shows these packages in the vim environment.
$ poetry shell
(backend-dmp__8h8-py3.8) bash-3.2 $ vim
:e src/<file>.py
It works! All the packages are resolved! But why?
Do you have any idea what is happening here? Is this something on coc-pyright's end or should I expect something else to happen?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.