Open SreenivasVRao opened 3 years ago
I think you just need this:
(setq lsp-pyright-venv-path "/home/sreenivas/anaconda3/envs/colorize")
I have been thinking about how this might work for some time too. I cooked up this little script that helps me (I'm not a emacs-lisp expect btw but works for me!)
(with-eval-after-load 'conda
(with-eval-after-load 'lsp-pyright
(progn
(defun autoenv-for-lsp-pyright ()
(let* ((env-name (conda--infer-env-from-buffer))
(env-path (concat conda-env-home-directory "/envs/" env-name)))
(setq-local lsp-pyright-venv-path env-path)
(setq-local mode-line-process (concat "(" env-name ")"))
(message "setting lsp-pyright-venv-path to %s" env-path))
)
(push 'autoenv-for-lsp-pyright python-mode-hook)
)))
@SreenivasVRao Have you tried the pyvenv Emacs package? Then M-x pyvenv-workon to select the conda virtual directory - this is typically how I work.
Have you tried to set python.pythonPath
(with-eval-after-load 'lsp-pyright
(progn
(lsp-register-custom-settings
`(("python.pythonPath" "D:/path/to/miniconda3/envs/stringle_pro/python.exe"))))
)
I put above code to .dir-locals.el
of my project, it's working, the content of .dir-locals.el
like below:
((python-mode . ((eval . (with-eval-after-load 'lsp-pyright
(progn
(lsp-register-custom-settings
`(("python.pythonPath" "D:/path/to/miniconda3/envs/stringle_pro/python.exe"))))
)))))
This is my
pyrightconfig.json
With doom emacs (lsp, pyright, conda, direnv), I'm running into issues getting my pyright path to work.
I think I traced this down to https://github.com/emacs-lsp/lsp-pyright/blob/master/lsp-pyright.el#L159-L176 these two functions. I don't have a
venv
in my path, I'm using anaconda3. It's on a separate partition from my project. (Project is on/media/data/....
while virtualenv is on/home/sreenivas/anaconda3
)I can override the two functions to do the job, but I would like some advice on how to do it in a neater manner.
Now it gives: