all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Eric Abrahamsen <eric@ericabrahamsen.net>
To: help-gnu-emacs@gnu.org
Subject: Re: Set eglot to use project config in subdirectory
Date: Tue, 01 Aug 2023 12:26:15 -0700	[thread overview]
Message-ID: <87o7jqtvhk.fsf@ericabrahamsen.net> (raw)
In-Reply-To: CUH1ZBFNTRIW.1SZSHF33PG07T@192.168.1.10

Marc <marcc0000@pm.me> writes:

> Hi!
>
> I am working with a typescript project with the following structure:
>
> root/package.json
> root/services/service1/package.json 
> root/services/service2/package.json
>
> Essentially, the git repo is initialized at root and then there are a
> bunch of subprojects within the repository with their own project setup.
>
> I noticed that when I edit a file in service1 for eglot, it's using the
> package.json (I.e the project config) from the root folder and therefore complaining about
> outdated dependencies and I suspect it might also have something to do
> with my emacs freezing when doing file edits.
>
> Is there any way to set so if I'm editing service1, it uses the project
> configuration for that service?
>
> I'm using eglot together with projectile if that matters.

I use project.el, not projectile, but maybe the following will help get
you started:

(defun my-find-eglot-project (dir)
  (when (and (bound-and-true-p eglot-lsp-context)
	     (string-match-p "my/special/project/" dir))
    (when-let ((root (locate-dominating-file dir ".venv")))
      (cons 'transient root))))

(add-hook 'project-find-functions #'my-find-eglot-project)

You can see this is set up for an analogous situation to yours, just
with Python subprojects instead of Node.

To be perfectly honest I've already forgotten the exact chain of events
here, I think it's something like when Eglot is trying to decide which
files "belong" to a certain LSP server, it uses project.el to collect
those files, and this function basically lies to Eglot about where the
root of the current project is. I don't know how hard this would be to
adapt to Projectile.

Good luck,
Eric




      reply	other threads:[~2023-08-01 19:26 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-01  8:14 Set eglot to use project config in subdirectory Marc
2023-08-01 19:26 ` Eric Abrahamsen [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87o7jqtvhk.fsf@ericabrahamsen.net \
    --to=eric@ericabrahamsen.net \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.