A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://lists.gnu.org/archive/html/emacs-devel/2022-11/msg01303.html below:

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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] 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



RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4