From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eric Abrahamsen Newsgroups: gmane.emacs.devel Subject: Re: Eglot, project.el, and python virtual environments Date: Thu, 17 Nov 2022 10:06:48 -0800 Message-ID: <87fsehfoav.fsf@ericabrahamsen.net> References: <87zgcq68zp.fsf@ericabrahamsen.net> <878rkale3l.fsf@dfreeman.email> <87v8nezf2k.fsf@ericabrahamsen.net> <87o7t5k7sv.fsf@dfreeman.email> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="36971"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) To: emacs-devel@gnu.org Cancel-Lock: sha1:JaxfICodRuugIEXti92LXfbUr0s= Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Thu Nov 17 19:35:00 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 1ovjj1-0009I5-TX for ged-emacs-devel@m.gmane-mx.org; Thu, 17 Nov 2022 19:34:59 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ovjiV-00067U-Qa; Thu, 17 Nov 2022 13:34:27 -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 1ovjHw-0005Qf-11 for emacs-devel@gnu.org; Thu, 17 Nov 2022 13:07:01 -0500 Original-Received: from ciao.gmane.io ([116.202.254.214]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ovjHs-0005Mo-Te for emacs-devel@gnu.org; Thu, 17 Nov 2022 13:06:59 -0500 Original-Received: from list by ciao.gmane.io with local (Exim 4.92) (envelope-from ) id 1ovjHo-0001m5-Oa for emacs-devel@gnu.org; Thu, 17 Nov 2022 19:06:52 +0100 X-Injected-Via-Gmane: http://gmane.org/ Received-SPF: pass client-ip=116.202.254.214; envelope-from=ged-emacs-devel@m.gmane-mx.org; helo=ciao.gmane.io X-Spam_score_int: -15 X-Spam_score: -1.6 X-Spam_bar: - X-Spam_report: (-1.6 / 5.0 requ) BAYES_00=-1.9, HEADER_FROM_DIFFERENT_DOMAINS=0.25, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Thu, 17 Nov 2022 13:34:23 -0500 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:300062 Archived-At: Danny Freeman writes: > Eric Abrahamsen writes: > >> > > project_root >> > > ├── .git >> > > ├── src >> > > │ └── python >> > > │ ├── VeryImportantLambda >> > > │ │ └── .venv >> > > │ ├── MoreImportance >> > > │ │ └── .venv >> > > │ ├── RunInCaseOfEmergency >> > > │ │ └── .venv > > I just realized you posted information about the .venv files in your > original post and I completely overlooked that lol. > >> Thank you very much, that does help indeed! I started off down this path >> and had gotten as far as eglot-lsp-context. Then I realized I couldn't >> just return a directory, it had to be a project object, and that's when >> I decided someone else must have a better approach. But it's great to >> see all this laid out, and knowing about `(cons 'transient root)' is >> very helpful, as well. >> >> I'll play around with this a bit. It seems like a not-outlandish >> situation, and I wonder if it might not be useful to provide some >> standardized method of helping Eglot find an alternate project. >> >> Thanks again, >> Eric > > Anyways yeah, I think I've heard about someone else running into this as > well. Maybe it was on the reddit emacs forum. Either way, I do not think > you are the first. > > What might an extension for Eglot look like? Maybe a built in > `project-find-functions' implementation that does something similar > looking for a `.eglot-lsp-root` (or probably something configurable) as > a transient project root? I don't know if that would cause problems out > of the box for some people, but it seems safe. That was my first thought: a file cookie that told Eglot to consider this directory a project root. But I don't know enough about Eglot and its internals to be sure. I'm not even really sure what Eglot uses a project definition for: I guess to decide which buffers in a given major-mode should use the same invocation of a language server protocol? One process used in all those project buffers? Is that even how it groups things? I don't know. The core issue in my case is that I need to be able to tell Eglot to use a separate language server executable for all python-mode buffers within a certain directory tree. Maybe there is a simpler way of doing that that doesn't require me to trick Eglot into thinking the project is smaller than it is. All a virtual environment does, fundamentally, is munge PATH so that Python-related executables are found locally, rather than system-wide. Maybe there's a relatively simple way to explicitly tell Eglot to do that. I think the approach I'm on now can probably be made to work, but it would be nice to know if there's a simpler way. I might spend a bit of time looking at Eglot's source, and open a bug report. Thanks! Eric