emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Eglot, project.el, and python virtual environments


From: Danny Freeman
Subject: Re: Eglot, project.el, and python virtual environments
Date: Sat, 19 Nov 2022 16:22:28 -0500

Dmitry Gutov <dgutov@yandex.ru> writes:

> Then your solution should work okay, but it also means it belongs to the 
> category of Eglot hacks (as
> opposed to project.el hacks).

It is absolutely an Eglot hack :)

> Since this issue seems to be common enough, though, we should decide on a 
> proper fix for it, too.

Maybe a description of the problem along with the example code could be
written into the eglot documentation? 

Another option might be to setup the project-find-functions in eglot for
users. Some kind of configuration would be necessary. Maybe a var with
the intention of setting it in .dir-locals.el, that would be used to
store the name of an eglot "project" root file.

```
(defvar eglot-root-marker nil
  "File name used to identify the root directory to start a LSP server
  in. When nil, the current project root is used." )

(defun eglot--find-lsp-root (dir)
  (when-let ((root (and eglot-root-marker
                        eglot-lsp-context
                        (locate-dominating-file dir eglot-root-marker))))
    (cons 'transient root)))

;; Eglot configures this somewhere, maybe when the mode is set up?
(add-hook 'project-find-functions #'eglot--find-lsp-root)
```

That makes the solutions to OP's problem setting `eglot-root-marker` to
".venv" in a .dir-locals.el file in their project. I think there is also
a better name for `eglot-root-marker` in this example.

-- 
Danny Freeman



reply via email to

[Prev in Thread] Current Thread [Next in Thread]