Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refresh workspace after poetry-add or poetry-remove on lsp-mode #28

Closed
ig-perez opened this issue Feb 6, 2021 · 2 comments
Closed

Refresh workspace after poetry-add or poetry-remove on lsp-mode #28

ig-perez opened this issue Feb 6, 2021 · 2 comments

Comments

@ig-perez
Copy link

ig-perez commented Feb 6, 2021

Hi, thanks for maintaining this package!

I'm an lsp-mode user and the snippet provided by @jidicula works great to determine the correct virtual env.

But when a dependency is added or removed you have to manually execute lsp-workspace-restart so the library changes are available to the project.

Is it possible to execute this command after every poetry-add or poetry-remove if LSP-mode is used?

Thanks!

@calebstewart
Copy link

Internally, poetryl.el uses pyvenv to manage the current virtual environment (see here). I solved this by adding the following to my Emacs configuration:

; Run lsp-restart-workspace whenever the pyvenv changes
(add-hook 'pyvenv-post-activate-hooks (lambda () (lsp-restart-workspace)))
(add-hook 'pyvenv-post-deactivate-hooks (lambda () (lsp-restart-workspace)))

On the upside, if you use pyvenv for projects that don't use Poetry, then this should also work there as well.

@ig-perez
Copy link
Author

Awesome, thanks @calebstewart , I'll give it a try.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants