From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Yuan Fu Newsgroups: gmane.emacs.devel Subject: Re: Eglot, project.el, and python virtual environments Date: Thu, 17 Nov 2022 10:48:20 -0800 Message-ID: References: <87zgcq68zp.fsf@ericabrahamsen.net> <878rkale3l.fsf@dfreeman.email> <87v8nezf2k.fsf@ericabrahamsen.net> <87o7t5k7sv.fsf@dfreeman.email> <87fsehfoav.fsf@ericabrahamsen.net> Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.1.1\)) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="27300"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Eric Abrahamsen Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Thu Nov 17 19:49:02 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 1ovjwb-0006vM-L5 for ged-emacs-devel@m.gmane-mx.org; Thu, 17 Nov 2022 19:49:01 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ovjw2-0003Gv-9P; Thu, 17 Nov 2022 13:48:26 -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 1ovjw1-0003GK-2V for emacs-devel@gnu.org; Thu, 17 Nov 2022 13:48:25 -0500 Original-Received: from mail-pj1-x1031.google.com ([2607:f8b0:4864:20::1031]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ovjvz-0004nL-AI for emacs-devel@gnu.org; Thu, 17 Nov 2022 13:48:24 -0500 Original-Received: by mail-pj1-x1031.google.com with SMTP id l22-20020a17090a3f1600b00212fbbcfb78so6218224pjc.3 for ; Thu, 17 Nov 2022 10:48:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=+DHAyshQa1KvmORnADsPV5I0NvVFqY+KJyzSeYTzKnM=; b=ntIWuaWixCIVzs8OtUvtRL7mONqxrpA9f9VjGaw9Zq+gjmfS41dg9iJ8GOCYUhT5xo qA3kpMu9GZ5dYc7qnJyMP1KJ8EE0gjP2et8xGm2EUkgoAdSIXSY+hOPlMZaOKM1yrfTz xSiV2yt2oJcI/emmxy93hYdI1EwFGO4iHnjiv2LT73sbIYXmIyJ5o7X7Qe0wU0QMlYw/ gvWgIpsJVthLC3eLfJx6O8kI47kIP6smC0P1fDJlw5tiERhfvC7SYxYOazTxeC3Ej62k HbGjgkyPU/lx2O+nsoTA/NJ+c6eqPjn0abucqZ7B4aue9sw2MXD0QU6xC9QoyiqB67B2 BiKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+DHAyshQa1KvmORnADsPV5I0NvVFqY+KJyzSeYTzKnM=; b=dhAtHZ7E91X4lsxwxRo8geaCtIxfspis2BdhDk8TZw4fV/gIS9oBXMOvj/+kSNV1gV TZOmK7YkccJN1e2ljf5btBbpvAGkQyA9ZZJEOqzfChz2i+IOTgxHevVKj1avZYP6NKXy Qu4zpTN/+d1RLDE3LAZbMJGPh+87gRyTZC2XNhBASiAxh/r7V029OR5MLT2M7bfIhqBI Zf29a4aPybyATdk8W6/9o53nAQiZ70kCUUHJgV+Dc0MJ2/yPCX6uhT3Rt67lJCDfTzsK 4EJ6AK1VWVJPd1t1609vb7afl1Ku/INYd+Sf6cPJ651lMnEhf7mxvPz7kTpGbzo9/Zvj EZIQ== X-Gm-Message-State: ANoB5pkBg5u4mPQGcvZupwxbExoUqYxy0DWzqElsbvLie6sTCvvAJHix rVyVb4nGu7G5MPupsd21XT4rT/h2suc= X-Google-Smtp-Source: AA0mqf4R6PEscsR3cIFkkdLrdPi5TVI5lUHPbJoih97xhm6B/C/D6fFFkN3BBRiQ11oLCHHbURWVog== X-Received: by 2002:a17:902:9b89:b0:186:b46d:da5e with SMTP id y9-20020a1709029b8900b00186b46dda5emr4053923plp.92.1668710901691; Thu, 17 Nov 2022 10:48:21 -0800 (PST) Original-Received: from smtpclient.apple (cpe-172-117-161-177.socal.res.rr.com. [172.117.161.177]) by smtp.gmail.com with ESMTPSA id y3-20020aa79423000000b0056c058ab000sm1468968pfo.155.2022.11.17.10.48.21 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 17 Nov 2022 10:48:21 -0800 (PST) In-Reply-To: <87fsehfoav.fsf@ericabrahamsen.net> X-Mailer: Apple Mail (2.3696.120.41.1.1) Received-SPF: pass client-ip=2607:f8b0:4864:20::1031; envelope-from=casouri@gmail.com; helo=mail-pj1-x1031.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=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:300066 Archived-At: > On Nov 17, 2022, at 10:06 AM, Eric Abrahamsen = wrote: >=20 > Danny Freeman writes: >=20 >> Eric Abrahamsen writes: >>=20 >>>>> project_root >>>>> =E2=94=9C=E2=94=80=E2=94=80 .git >>>>> =E2=94=9C=E2=94=80=E2=94=80 src >>>>> =E2=94=82 =E2=94=94=E2=94=80=E2=94=80 python >>>>> =E2=94=82 =E2=94=9C=E2=94=80=E2=94=80 VeryImportantLambda >>>>> =E2=94=82 =E2=94=82 =E2=94=94=E2=94=80=E2=94=80 .venv >>>>> =E2=94=82 =E2=94=9C=E2=94=80=E2=94=80 MoreImportance >>>>> =E2=94=82 =E2=94=82 =E2=94=94=E2=94=80=E2=94=80 .venv >>>>> =E2=94=82 =E2=94=9C=E2=94=80=E2=94=80 RunInCaseOfEmergency >>>>> =E2=94=82 =E2=94=82 =E2=94=94=E2=94=80=E2=94=80 .venv >>=20 >> I just realized you posted information about the .venv files in your >> original post and I completely overlooked that lol.=20 >>=20 >>> 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. >>>=20 >>> 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. >>>=20 >>> Thanks again, >>> Eric >>=20 >> 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. >>=20 >> 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. >=20 > That was my first thought: a file cookie that told Eglot to consider > this directory a project root. >=20 > 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. AFAIK eglot uses project.el for finding projects. >=20 > 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. You can add dir-local variables and set eglot-server-programs for each = directory differently, each mapping python-mode to different server = executables. (And also use .project.el cookies to limit the scope of the = project.) >=20 > 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. >=20 > Thanks! > Eric Yuan=