Using LanguageServer.jl with eglot in emacs

It seems to be working,

  • but it disconnects and reconnects a lot of times,
  • doesn’t seem to understand stuff that is imported with “using
  • and keeps printing:
[eglot] (warning) Server tried to register unsupported capability `workspace/didChangeWorkspaceFolders'

But this are probably LanguageServer.jl and eglot.el issues.

This is normal, although if it prints it more than once, that means that the language server is restarting. And yes, I certainly wouldn’t call the setup stable at the moment. I’ve been in a bit of a crunch lately, so I haven’t even been using it myself as it’s been getting in the way more than helping.

When the server restarts, it would be great if you could capture the events immediately preceding the restart from the eglot events buffer and submit an issue on github. From there I can route it upstream to eglot or LanguageServer.jl as appropriate.

Sure. Thanks for your hard work!

1 Like

Julia eglot support is now available on melpa as eglot-jl.

https://melpa.org/#/eglot-jl

2 Likes

Thank you for your work!

1 Like

After installing eglot-jl, opening a julia-mode buffer, calling init-eglot-jl and eglot, I get the following error:

[jsonrpc] Server exited with status 1
error in process sentinel: eglot--error: [eglot] -1: Server died
error in process sentinel: [eglot] -1: Server died

I noticed that you initialize LanguageServerInstance with 6 arguments, but I checked the package LanguageServer,jl and the constructor for LanguageServerInstance only accepts 5 arguments. I also tried removing the last argument “Dict()” and was able to overcome this error. I still have others though.

That’s strange. The signatures of LanguageServer.jl may very well have changed, but the eglot package should have things pinned to a working version of the language server. Could you try instantiating the environment in the REPL and see if it works without modifying the arguments? Maybe using LanguageServer is picking up the wrong version despite the Manifest.toml.

In general, for troubleshooting, please post the output of the eglot stderr buffer. It’s much more useful for me to tell what’s going on.

This was an error on my end. I wasn’t testing the version that I thought I was testing. Patch release v1.1.1 should have this fixed. Thanks for bringing it to my attention. Please post or file issues for the other errors you’re running into. :slight_smile:

When you define eglot-jl-default-environment version 1.2 of Julia is assumed, but right now we are at 1.3, should I change it for the package work?

I have a problem of LanguageServer crashing soon after start, because eglot sends it nil where an array is expected.

So far, I added Base.length(::Nothing) = 0 to eglot-jl.jl as a workaround. Not sure which package is responsible for the bug - eglot-jl, eglot or LanguageServer.

Could you please give replication details? File it crashes on, versioninfo(), etc? In general, I’m happy to have bugs filed against eglot-jl and forward them upstream when necessary.

I hope that has the relevant information…

2 Likes

I’ve updated eglot-jl to use the latest release of LanguageServer.jl (so it’s now compatible with julia 1.4) and have been using it for the past 24 hours with no issues so far. I’ve also cleaned up the code for locking eglot-jl to a specific version of LanguageServer.jl so that it should get the correct version even if LanguageServer.jl is installed in your default environment.

Big kudos to @ZacLN and @davidanthoff for the work on the language server in recent months. It seems much more stable to me now. In particular, the parallel symbol server caching is a big win for usability (no longer have to wait multiple hours for the symbol server to process all dependencies before getting a usable language server).

Give it a try and let me know if any problems. If you’ve been using lsp-julia, this a great chance to give the other side of the fence a try until julia 1.4 support is ironed out. :wink: I’ve updated the LanguageServer.jl wiki with a description of the capabilities that are currently working.

1 Like

I’ve been using eglot with eglot-jl lately and it has improved a lot since I first tried it. Now it helps instead of getting in the way!

Since this thread keeps popping up (mostly my fault) and I’m unable to edit the OP anymore, would somebody with discourse moderator rights be willing to edit this link into the OP?

Glad it’s working better for you now; I’ve experienced roughly the same thing in the past month (no longer a hinderance).

2 Likes

@ffevotte has contributed tooling to make using LanguageServer.jl compiled by PackageCompiler simple with eglot. I would appreciate if anyone who is interested in the significantly alleviated startup time this gives (from 15 seconds down to less than 1) could test out his branch before I merge to master so that we can work out any bugs.

5 Likes

based on a quick test, works crazy fast for me!

1 Like

Glad to hear that! What type of system did you try this on?

I’d really like it if a MacOS user could try it, since I have not been able to test on this OS…

manjaro linux, but I’ll try it on macOS when I have the time.

This sounds all kinds of awesome… I’m a more or less old-school emacs user and haven’t kept up with newer emacs features… How do I get this installed effectively?

I installed eglot-jl from MELPA, am in a julia buffer with julia mode and company mode on, and I get:

[jsonrpc] Server exited with status 1
error in process sentinel: eglot--error: [eglot] -1: Server died
error in process sentinel: [eglot] -1: Server died

Running julia 1.4.1 and emacs-gtk 1:26.3+1-2 on Debian testing.