Skip to content

Commit 25ec80c

Browse files
committed
If pyenv is installed, always try to get ENV by it, otherwise do nothing
1 parent 699ef49 commit 25ec80c

File tree

1 file changed

+15
-20
lines changed

1 file changed

+15
-20
lines changed

lsp-pyls.el

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -353,16 +353,10 @@ parameters referenced in config."
353353
:group 'lsp-pyls
354354
:package-version '(lsp-mode . "6.3"))
355355

356-
(defcustom lsp-pyls-plugins-jedi-use-pyenv-environment t
357-
"If enabled, pass the environment got by pyenv to jedi"
358-
:type 'boolean
359-
:group 'lsp-pyls
360-
:package-version '(lsp-mode . "6.3"))
361-
362356
(defcustom lsp-pyls-plugins-jedi-environment nil
363-
"Specify the environment that jedi runs on where <environmeent>/bin/python
364-
should be the python executable. This option will be prioritized over
365-
`lsp-pyls-plugins-jedi-use-pyenv-environment'."
357+
"Specify the environment that jedi runs on where <ENV>/bin/python should be
358+
the python executable. This option will be prioritized over the ENV got by
359+
`lsp-pyls-get-pyenv-environment'."
366360
:type 'string
367361
:group 'lsp-pyls
368362
:package-version '(lsp-mode . "6.3"))
@@ -372,20 +366,21 @@ should be the python executable. This option will be prioritized over
372366
<ENV>/bin/python is the corresponding Python executable"
373367
(if lsp-pyls-plugins-jedi-environment
374368
lsp-pyls-plugins-jedi-environment
375-
(when lsp-pyls-plugins-jedi-use-pyenv-environment
376-
(let ((pyenv-version (getenv "PYENV_VERSION"))
377-
(root (lsp-seq-first (lsp-find-roots-for-workspace lsp--cur-workspace (lsp-session)))))
378-
(when root
379-
(setenv "PYENV_VERSION" nil)
380-
(let* ((pyenv-command-path (executable-find "pyenv"))
381-
(python-env (f-parent
369+
(let ((pyenv-version (getenv "PYENV_VERSION"))
370+
(root (lsp-seq-first (lsp-find-roots-for-workspace lsp--cur-workspace (lsp-session)))))
371+
(when root
372+
(setenv "PYENV_VERSION" nil)
373+
(let* ((pyenv-command-path (executable-find "pyenv"))
374+
(python-env (when pyenv-command-path
375+
(f-parent
382376
(f-parent
383377
(shell-command-to-string
384378
(format "PYENV_DIR='%s' %s which python"
385-
root pyenv-command-path))))))
386-
(lsp--info "Configure pyls with environment: %s" python-env)
387-
(setenv "PYENV_VERSION" pyenv-version)
388-
python-env))))))
379+
root pyenv-command-path)))))))
380+
(when python-env
381+
(lsp--info "Configures pyls with environment: %s" python-env))
382+
(setenv "PYENV_VERSION" pyenv-version)
383+
python-env)))))
389384

390385
(lsp-register-custom-settings
391386
'(("pyls.rope.ropeFolder" lsp-pyls-rope-rope-folder)

0 commit comments

Comments
 (0)