Using LanguageServer.jl with eglot in emacs

No, I don’t have admin access and therefore cannot install/activate WSL.

EDIT:
There is a Linux cluster at work. What I normally do is ssh into it, and run emacs (in the Cygwin terminal).
There I can run Julia code, etc.

However, the master branches of many of my repos have been broken for a couple weeks, as I’m overhauling some of the internals. I have avoided updating the cluster, because I still need to get work done, and have therefore been developing the master branches locally.
This is also probably something that could be solved with Julia environments, letting me keep two separate environments on the Linux cluster. Although being able to work locally would be nice as well.

Also, a more general emacs question: how does it decide how to split the screen?
I have a relatively square monitor, and emacs always defaults to splitting side by side (equivalent to C-x 3 ), while with ultra-wide monitors, it splits them one above the other (equivalent to C-x 2 ). So it seems to be using the screen resolution to always make the opposite choice of what I want.
How can I change this default behavior?

I don’t have experience with customizing this but looking at the docs of split-window-sensibly it seems that if you set split-width-threshold to nil and split-height-threshold to 0 it will try to split the window vertically (and the other way around if you want a horizontal split).

1 Like

How did you obtain emacs? Is this from https://www.gnu.org/software/emacs/download.html or installed via cygwin? My experience has been that the perf of programs intalled via cygwin leaves a lot to be desired. What modes are enabled when you see the input lag (M-x describe-mode)?

Just modify the PATH environment variable? Note that within emacs, you can also modify the exec-path variable.

For the clipboard, try setting both select-enable-clipboard and select-enable-primary to t (just a guess on the problem).

1 Like

Hi, how does one use that recipe? I use the included package.el.

You can use straight or quelpa to install a melpa recipe. If you don’t want to use those, you can just download the package and make sure it’s on your load-path. I’m not exactly sure how you get autoloads working with this setup though, so you might just have to require it. Once the pull request to melpa is accepted you’ll be able to install with package-install if you’ve added melpa to package-archives.

1 Like

I cloned the repository, added the following line to my init:

(add-to-list 'load-path "/home/myuser/Desktop/eglot-jl-master/eglot-jl.el")
(require 'eglot-jl)

I get an error and it seems the the problem is in this line
(defconst eglot-jl-base (file-name-directory load-file-name))

Could you toggle-debug-on-error and paste the traceback either here or in a github issue, please?

Nevermind, I had to add the full directory and not just the .el file.

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