all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Set eglot to use project config in subdirectory
@ 2023-08-01  8:14 Marc
  2023-08-01 19:26 ` Eric Abrahamsen
  0 siblings, 1 reply; 2+ messages in thread
From: Marc @ 2023-08-01  8:14 UTC (permalink / raw)
  To: help-gnu-emacs

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.

Thank you in advance for your help,
Marc




^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Set eglot to use project config in subdirectory
  2023-08-01  8:14 Set eglot to use project config in subdirectory Marc
@ 2023-08-01 19:26 ` Eric Abrahamsen
  0 siblings, 0 replies; 2+ messages in thread
From: Eric Abrahamsen @ 2023-08-01 19:26 UTC (permalink / raw)
  To: help-gnu-emacs

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




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-08-01 19:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-01  8:14 Set eglot to use project config in subdirectory Marc
2023-08-01 19:26 ` Eric Abrahamsen

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.