Code Monkey home page Code Monkey logo

Comments (4)

deifactor avatar deifactor commented on June 4, 2024 4

As a workaround, if you set (setq lsp-pyright-multi-root nil) then it'll run separate processes. You need to set that before you (require 'lsp-pyright), and may need to lsp-workspace-folders-remove your existing folders. You can check whether this is working if lsp-describe-session shows different port numbers for the different pyright instances.

from lsp-pyright.

vakker avatar vakker commented on June 4, 2024

I'm having the exact same issue using pyenv-mode. Did you find a solution?
After some digging and trying to manually set lsp-pyright-venv-path that is used in lsp-pyright-locate-python I still can't make it work.

It seems like there's only 1 workspace created, e.g. if I open a file then LSP reports that:

LSP :: pyright:972173 initialized successfully in folders: (/home/user/project1 /home/user/project2 /home/user/.pyenv)

then if I open another file from the other project:

LSP :: Connected to [pyright:972173]

Is that correct?

Here it says that the server will ask for configs for each workspace, but that doesn't seem to happen.

from lsp-pyright.

erikcw avatar erikcw commented on June 4, 2024

I'm running into the same issue. Setting (setq lsp-pyright-multi-root nil) early in my config does not seem to help. I removed all workspace folders as started from scratch. Looks like each time I switch into a new project, it gets "appended" to the session from the first virtual environment.

from lsp-pyright.

vljosa-vivodyne avatar vljosa-vivodyne commented on June 4, 2024

Hope this helps someone:

I don't fully understand why, but I found that I had to set the python.pythonPath setting of pyright correctly for each project (virtualenv):

(setq lsp-pyright-multi-root nil) ; Must be set before lsp-pyright is loaded. https://github.com/emacs-lsp/lsp-pyright/issues/19#issuecomment-930596080

(defvar lsp-client-settings (make-hash-table :test 'equal)) ; Original does not set :test, so values with string keys cannot be replaced.

(use-package lsp-pyright
  :ensure t
  :config
  (lsp-register-custom-settings
   '(("python.pythonPath" ljosa-lsp-pyright-locate-python)))

  (define-key lsp-mode-map (kbd "C-c C-l") lsp-command-map)
  :hook (python-mode . (lambda ()
                         (require 'lsp-pyright)
                          (lsp))))

I also had to make sure that projectile understood that the virutalenv were in diferent projects. (This was relevant because they were in the same git repo.) I did this by creating empty .projectile files in the root of each project.

After this, it still doesn't work at first: I have to do M-x lsp-reload-session the first time I open a file in a new project (virtualenv).

from lsp-pyright.

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.