this post was submitted on 16 Oct 2023
1 points (66.7% liked)

Emacs

312 readers
4 users here now

A community for the timeless and infinitely powerful editor. Want to see what Emacs is capable of?!

Get Emacs

Rules

  1. Posts should be emacs related
  2. Be kind please
  3. Yes, we already know: Google results for "emacs" and "vi" link to each other. We good.

Emacs Resources

Emacs Tutorials

Useful Emacs configuration files and distributions

Quick pain-saver tip

founded 1 year ago
MODERATORS
 

I just tried out eglot today, and I must say that I am very very impressed. However, like all software, the julia language server has a few quirks that need to be worked around. Long story short, I have two folders (not nested or anything):

  • folder1 - A git repository of a large julia project that I cloned. Starting eglot here only works partially. Anything imported from other packages is a missing reference.

  • folder2 - A folder I created with various scripts that I wrote for the project in folder1. It contains a Project.toml detailing the necessary julia environment for those scripts to work. Starting eglot here works flawlessly. Both functions defined in folder1 as well as the other packages folder1 relies upon are referenced correctly.

Is there a way for me to start eglot in folder2 but have it work as if I have started it in folder1?

I believe one potential solution might be to tell Project.el that the git repository in folder1 belongs to the project in folder2, but I couldn't find a command for doing so.

Alternatively, can I tell eglot in folder1 to connect to the language server that was started by eglot in folder2?

edit: Hope the question makes sense, and apologies if not everything is phrased in the correct language. I'm pretty new to both eglot and project.el. Many thanks in advance for any help or hints!

top 2 comments
sorted by: hot top controversial new old
[–] noooit@alien.top 1 points 1 year ago

I have a similar requirement.
If folder1 and folder2 have different project root marker, it's possible to start multiple language servers via project-vc-extra-root-markers.

But the tricky part is when it's started from folder2, it needs to cd to folder1 before executing the language server.

I achieve this by creating a wrapper script for language server and create a function that sets an environment variable before executing the script and does do complex things in the script.

It'd be nice if there was a better solution without depending on .dir-locals.el and etc, like passing a function for the server program so that I don't have to use a script + environment variable.

[–] SlowAndSteady100@alien.top 1 points 1 year ago

I believe you should use project-external-roots for this.

In the context of autoconf or CMake srcdir!=builddir builds, I would suggest that you choose the builddir as the project-root based on Makefile, and use VPATH from the Makefile to get the srcdir in project-external-roots.

In your case, folder2 would be the project-root, and folder1 would be included in project-external-roots.