Comments (6)
Can I only add a new workspace-folder without removing the old one, as shown below?
Is there anything preventing you from testing this on your side?
from lsp-pyright.
make sure that your project root is the correct one. Use M-x lsp-describe-session
from lsp-pyright.
How to know whether the project root directory is correct or not? For example, the following one:
from lsp-pyright.
Project root is the folder that contains the files that you want to work on. It is usually git repository. In your case you have selected your home folder which is wrong. As a result the language server is scanning all files in your home folder and that's why it is crashing.
Use M-x lsp-workspace-folders-add/remove to fix the project root.
from lsp-pyright.
Can I only add a new workspace-folder without removing the old one, as shown below?
from lsp-pyright.
Thank you, I reinstalled pyrigt
as follows, according to the commented here:
$ yarn global add pyright
$ export PATH=$HOME/.yarn/bin:$PATH
Then I use pyvenv to automatically set the current workspace-folder as follows:
(use-package pyvenv
:init
(setenv "WORKON_HOME" "~/.pyenv/versions")
;;https://lists.gnu.org/archive/html/help-gnu-emacs/2021-09/msg00535.html
(defun try/pyvenv-workon ()
(when (buffer-file-name)
(let* ((python-version ".python-version")
(project-dir (locate-dominating-file (buffer-file-name) python-version)))
(when project-dir
(progn
;; https://github.com/emacs-lsp/lsp-pyright/issues/62#issuecomment-942845406
(lsp-workspace-folders-add project-dir)
(pyvenv-workon
(with-temp-buffer
(insert-file-contents (expand-file-name python-version project-dir))
(car (split-string (buffer-string))))))
))))
:config
(pyvenv-mode 1)
(setq pyvenv-post-activate-hooks
(list (lambda ()
(when (executable-find "ipython3")
(setq python-shell-interpreter "ipython3"
python-shell-interpreter-args "-i --matplotlib=inline --automagic --simple-prompt --pprint"
;; https://gitlab.com/python-mode-devs/python-mode/-/issues/112#note_699461188
py-ipython-command "ipython3"
py-ipython-command-args '("-i" "--matplotlib=inline" "--automagic" "--simple-prompt" "--pprint")
)))))
(setq pyvenv-post-deactivate-hooks
(list (lambda ()
(setq python-shell-interpreter "python3"))))
)
The above method will fix the problem discussed here. See the info given by M-x lsp-describe-session
:
from lsp-pyright.
Related Issues (20)
- How specify Python interpreter with elisp HOT 3
- Documentation not working HOT 5
- How can I change the pyright's initialized folder path? HOT 4
- How to unimport or remove an imported folder? HOT 1
- Is it possible to expose reveal_type on selection?
- wrong-type-argument hash-table-p on pyright startup HOT 5
- _T@abs error
- How to turn on foldingRange HOT 1
- lsp-mode doesn't seem to try to load pyright when opening python file HOT 4
- Request: Support for `python-ts-mode` HOT 1
- Auto import not working anymore HOT 2
- Inconsistent/random/non-deterministic choice of variable faces
- stub file not read when checking buffer HOT 1
- [Bug] lsp-request: Timeout while waiting for response HOT 1
- Emacs lsp-pyright can not complete print function HOT 2
- support multiple venvs in a monorepo
- Why is textDocument/implementation not implemented?
- How to set PYTHONPATH for python shell based on project root?
- (🎁) Support basedpyright
- lsp-pyright server crashes HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lsp-pyright.