From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Danny Freeman Newsgroups: gmane.emacs.devel Subject: Re: Eglot, project.el, and python virtual environments Date: Sat, 19 Nov 2022 16:22:28 -0500 Message-ID: <877czqtyfy.fsf@dfreeman.email> References: <87zgcq68zp.fsf@ericabrahamsen.net> <878rkale3l.fsf@dfreeman.email> <4c5f4b07-3df6-d700-83f8-9a9d1b684afc@yandex.ru> <84781346-5b88-2be5-38bb-02696fcf1364@yandex.ru> <87o7t2vj19.fsf@dfreeman.email> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="5554"; mail-complaints-to="usenet@ciao.gmane.io" Cc: =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= , Eric Abrahamsen , emacs-devel To: Dmitry Gutov Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat Nov 19 22:41:16 2022 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1owVaN-0001EO-VD for ged-emacs-devel@m.gmane-mx.org; Sat, 19 Nov 2022 22:41:16 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1owVa7-0006JM-TQ; Sat, 19 Nov 2022 16:40:59 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1owVa6-0006J8-OL for emacs-devel@gnu.org; Sat, 19 Nov 2022 16:40:58 -0500 Original-Received: from out0.migadu.com ([94.23.1.103]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1owVa4-0008Iz-AO for emacs-devel@gnu.org; Sat, 19 Nov 2022 16:40:58 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dfreeman.email; s=key1; t=1668894053; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=wAZcchdPtlrpwtPZXLBKNUTHRjUnUJlWebRQ+OLetsI=; b=s9CRYME3uePxz1MADewAGMbvnYDT51vo6Q8WVHCfGXLaHtEXaHvcNhIQ5+qa/OUCE69N4n em+TZ+rOPBAkfwSVV1S/ENWCN8yC5V6kjw6qPlXSnc2x5gsh+f3QZaqlykhaFzvBJw1y57 +Mh4AJkqqBD7DTcnbMP61gRHGJEByrc= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. In-reply-to: X-Migadu-Flow: FLOW_OUT Received-SPF: pass client-ip=94.23.1.103; envelope-from=danny@dfreeman.email; helo=out0.migadu.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:300207 Archived-At: Dmitry Gutov 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