Code Monkey home page Code Monkey logo

Comments (5)

arthurl avatar arthurl commented on June 24, 2024 2

I've never had a problem with using the latter (though I recall that there was a bug with poetry in the past where poetry env info --path fails occasionally, so simply putting export PATH="$(poetry env info --path)/bin:${PATH}" in .envrc will occasionally not work). The good thing about using the direnv solution is that it sorts out the path for other tools too, e.g. black.

from emacs.d.

arthurl avatar arthurl commented on June 24, 2024

All you need to do is to make sure that the language server is launched in the correct virtualenv (in your case, the virtualenv created by poetry). Personally, I use direnv; see the comment on the top of init-python.el.

from emacs.d.

purcell avatar purcell commented on June 24, 2024

Hey! I've been playing with LSPs and this sort of setup recently.

A simple thing you can do is to install your LSP server, e.g. pyright, as a dev dependency inside the poetry project. Then you can use poetry run pyright as the LSP command for eglot.

There's a further trick you can use to make direnv (and therefore Emacs, assuming you use my envrc package, or the direnv package) "see" the inside of the virtual environment built by poetry: you can change your .envrc to

use_nix
direnv_load poetry run direnv dump

I have the impression this second trick sometimes confuses poetry, though, so I probably would recommend the first approach instead.

from emacs.d.

yszhang95 avatar yszhang95 commented on June 24, 2024

Thanks for the suggestions! I am sorry that I reply so late. It took me a long time to figure things out. Asking eglot to use poetry run pyright helps me out!

from emacs.d.

purcell avatar purcell commented on June 24, 2024

Nice, thanks for confirming.

from emacs.d.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.