Closed peterzky closed 4 months ago
Hi @peterzky, thanks for your PR. I have never used direnv before, so I'll learn what it is and how to use it first.
Direnv sets up environment variables when you cd
into directories.
Thanks.
So how do you use direnv with Emacs? I mean do you cd
some dir, then start Emacs there, and then do you development?
You said you use eglot
, so eglot works well with direnv, right? Do you have any special config when using eglot + direnv? (such as .dir-locals.el or something else). I ask because I didn't find anything related to exec-path in eglot's code.
The emacs-direnv
package sets up the environment variables for an open file or project if direnv
is already set up in the project/directory. When using eglot
, it inherits the exec-path
in Emacs. However, it seems that lspce
does not function in the same way.
For additional information, the following shows how eglot
starts the process:
(make-process
:name readable-name
:command (setq server-info (eglot--cmd contact))
:connection-type 'pipe
:coding 'utf-8-emacs-unix
:noquery t
:stderr (get-buffer-create (format "*%s stderr*" readable-name))
:file-handler t)
The make-process
function will inherit the 'exec-path' from Emacs.
Sorry for late reply, I need more time to get familiar with it, maybe test it too. Once I'm done, I'll merge it or talk about it with you. Thanks. Also thanks for expaining what direnv is and how it works.
Hi @peterzky , I finally merged your PR. Thanks again.
And I also made addtional changes:
lspce-inherit-exec-path
(means passing exec-path or not) and its default value is nil, so people who don't need this feature won't be affected.emacs_exec_path
is not empty, it will be used as PATH.So it you use the new code, you should set lspce-inherit-exec-path
to t in your config.
Thanks, great job!
I have been using
direnv
to manage my development environment and I'd like to switch tolspce
fromeglot
. However, when spawning the LSP server, it ignores thePATH
thatdirenv
provides, preventing me from accessing the proper development environment, likepython virtualenv
.I made a few changes to
lspce.el
to make it pass theexec-path
when spawning the LSP server. It's now working, but I'm not sure if this is the correct approach. Do you have any suggestions?