# Using LanguageServer.jl with eglot in emacs

**URL:** <https://discourse.julialang.org/t/using-languageserver-jl-with-eglot-in-emacs/23125>\
**Category:** Tooling\
**Tags:** editors, emacs\
**Created:** [April 14, 2019, 1:46am UTC](https://discourse.julialang.org/t/using-languageserver-jl-with-eglot-in-emacs/23125 "2019-04-14T01:46:19Z")\
**Posts on this page:** 20\
**Page:** 3

<div class="post-metadata">

**Author:** ![Elrod](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/elrod/32/22461_2.png) [@Elrod](https://discourse.julialang.org/u/Elrod)\
**Post date:** [November 7, 2019, 1:51pm UTC](https://discourse.julialang.org/t/using-languageserver-jl-with-eglot-in-emacs/23125/41 "2019-11-07T13:51:11Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![orialb](https://avatars.discourse-cdn.com/v4/letter/o/65b543/32.png) [@orialb](https://discourse.julialang.org/u/orialb)\
**Post date:** [November 7, 2019, 2:55pm UTC](https://discourse.julialang.org/t/using-languageserver-jl-with-eglot-in-emacs/23125/42 "2019-11-07T14:55:18Z")

</div>

> 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).

---

<div class="post-metadata">

**Author:** ![non-Jedi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/non-jedi/32/3645_2.png) [@non-Jedi](https://discourse.julialang.org/u/non-Jedi)\
**Post date:** [November 7, 2019, 2:57pm UTC](https://discourse.julialang.org/t/using-languageserver-jl-with-eglot-in-emacs/23125/43 "2019-11-07T14:57:35Z")

</div>

> [@Elrod](#):
>
> On Windows, the Emacs GUI with Julia has about 1 second of input lag per keystroke.

How did you obtain emacs? Is this from [GNU Emacs download - GNU Project](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`)?

> [@Elrod](#):
>
> Anyone also know how to set the executable path in Cygwin?

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).

---

<div class="post-metadata">

**Author:** ![4aHxKzD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/4ahxkzd/32/10833_2.png) [@4aHxKzD](https://discourse.julialang.org/u/4aHxKzD)\
**Post date:** [December 3, 2019, 11:13pm UTC](https://discourse.julialang.org/t/using-languageserver-jl-with-eglot-in-emacs/23125/44 "2019-12-03T23:13:11Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![non-Jedi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/non-jedi/32/3645_2.png) [@non-Jedi](https://discourse.julialang.org/u/non-Jedi)\
**Post date:** [December 3, 2019, 11:25pm UTC](https://discourse.julialang.org/t/using-languageserver-jl-with-eglot-in-emacs/23125/45 "2019-12-03T23:25:37Z")

</div>

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`.

---

<div class="post-metadata">

**Author:** ![4aHxKzD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/4ahxkzd/32/10833_2.png) [@4aHxKzD](https://discourse.julialang.org/u/4aHxKzD)\
**Post date:** [December 4, 2019, 12:57am UTC](https://discourse.julialang.org/t/using-languageserver-jl-with-eglot-in-emacs/23125/46 "2019-12-04T00:57:09Z")

</div>

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

```julia
(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))`

---

<div class="post-metadata">

**Author:** ![non-Jedi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/non-jedi/32/3645_2.png) [@non-Jedi](https://discourse.julialang.org/u/non-Jedi)\
**Post date:** [December 4, 2019, 12:59am UTC](https://discourse.julialang.org/t/using-languageserver-jl-with-eglot-in-emacs/23125/47 "2019-12-04T00:59:16Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![4aHxKzD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/4ahxkzd/32/10833_2.png) [@4aHxKzD](https://discourse.julialang.org/u/4aHxKzD)\
**Post date:** [December 4, 2019, 1:22am UTC](https://discourse.julialang.org/t/using-languageserver-jl-with-eglot-in-emacs/23125/48 "2019-12-04T01:22:28Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![4aHxKzD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/4ahxkzd/32/10833_2.png) [@4aHxKzD](https://discourse.julialang.org/u/4aHxKzD)\
**Post date:** [December 4, 2019, 1:41am UTC](https://discourse.julialang.org/t/using-languageserver-jl-with-eglot-in-emacs/23125/49 "2019-12-04T01:41:46Z")

</div>

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:

```julia
[eglot] (warning) Server tried to register unsupported capability `workspace/didChangeWorkspaceFolders'

```

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

---

<div class="post-metadata">

**Author:** ![non-Jedi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/non-jedi/32/3645_2.png) [@non-Jedi](https://discourse.julialang.org/u/non-Jedi)\
**Post date:** [December 4, 2019, 2:09am UTC](https://discourse.julialang.org/t/using-languageserver-jl-with-eglot-in-emacs/23125/50 "2019-12-04T02:09:10Z")

</div>

> [@4aHxKzD](#):
>
> [eglot] (warning) Server tried to register unsupported capability `workspace/didChangeWorkspaceFolders’

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.

---

<div class="post-metadata">

**Author:** ![4aHxKzD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/4ahxkzd/32/10833_2.png) [@4aHxKzD](https://discourse.julialang.org/u/4aHxKzD)\
**Post date:** [December 4, 2019, 2:12am UTC](https://discourse.julialang.org/t/using-languageserver-jl-with-eglot-in-emacs/23125/51 "2019-12-04T02:12:28Z")

</div>

Sure. Thanks for your hard work!

---

<div class="post-metadata">

**Author:** ![non-Jedi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/non-jedi/32/3645_2.png) [@non-Jedi](https://discourse.julialang.org/u/non-Jedi)\
**Post date:** [January 2, 2020, 4:31pm UTC](https://discourse.julialang.org/t/using-languageserver-jl-with-eglot-in-emacs/23125/52 "2020-01-02T16:31:57Z")

</div>

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

> **[MELPA](https://melpa.org/#/eglot-jl)**
>
> The largest and most up-to-date repository of Emacs packages.

---

<div class="post-metadata">

**Author:** ![4aHxKzD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/4ahxkzd/32/10833_2.png) [@4aHxKzD](https://discourse.julialang.org/u/4aHxKzD)\
**Post date:** [January 16, 2020, 5:45pm UTC](https://discourse.julialang.org/t/using-languageserver-jl-with-eglot-in-emacs/23125/53 "2020-01-16T17:45:58Z")

</div>

Thank you for your work!

---

<div class="post-metadata">

**Author:** ![4aHxKzD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/4ahxkzd/32/10833_2.png) [@4aHxKzD](https://discourse.julialang.org/u/4aHxKzD)\
**Post date:** [January 18, 2020, 11:20am UTC](https://discourse.julialang.org/t/using-languageserver-jl-with-eglot-in-emacs/23125/54 "2020-01-18T11:20:08Z")

</div>

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

```julia
[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.

---

<div class="post-metadata">

**Author:** ![non-Jedi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/non-jedi/32/3645_2.png) [@non-Jedi](https://discourse.julialang.org/u/non-Jedi)\
**Post date:** [January 18, 2020, 10:46pm UTC](https://discourse.julialang.org/t/using-languageserver-jl-with-eglot-in-emacs/23125/55 "2020-01-18T22:46:17Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![non-Jedi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/non-jedi/32/3645_2.png) [@non-Jedi](https://discourse.julialang.org/u/non-Jedi)\
**Post date:** [January 20, 2020, 3:00pm UTC](https://discourse.julialang.org/t/using-languageserver-jl-with-eglot-in-emacs/23125/56 "2020-01-20T15:00:45Z")

</div>

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. 🙂

---

<div class="post-metadata">

**Author:** ![4aHxKzD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/4ahxkzd/32/10833_2.png) [@4aHxKzD](https://discourse.julialang.org/u/4aHxKzD)\
**Post date:** [January 20, 2020, 4:07pm UTC](https://discourse.julialang.org/t/using-languageserver-jl-with-eglot-in-emacs/23125/57 "2020-01-20T16:07:00Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Vasily\_Pisarev](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/vasily_pisarev/32/7929_2.png) [@Vasily\_Pisarev](https://discourse.julialang.org/u/Vasily_Pisarev)\
**Post date:** [April 13, 2020, 11:40am UTC](https://discourse.julialang.org/t/using-languageserver-jl-with-eglot-in-emacs/23125/58 "2020-04-13T11:40:01Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![non-Jedi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/non-jedi/32/3645_2.png) [@non-Jedi](https://discourse.julialang.org/u/non-Jedi)\
**Post date:** [April 13, 2020, 12:00pm UTC](https://discourse.julialang.org/t/using-languageserver-jl-with-eglot-in-emacs/23125/59 "2020-04-13T12:00:02Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Vasily\_Pisarev](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/vasily_pisarev/32/7929_2.png) [@Vasily\_Pisarev](https://discourse.julialang.org/u/Vasily_Pisarev)\
**Post date:** [April 13, 2020, 12:34pm UTC](https://discourse.julialang.org/t/using-languageserver-jl-with-eglot-in-emacs/23125/60 "2020-04-13T12:34:20Z")

</div>

I hope that has the relevant information…

[https://github.com/non-Jedi/eglot-jl/issues/3](https://github.com/non-Jedi/eglot-jl/issues/3)

[Previous page](https://discourse.julialang.org/t/using-languageserver-jl-with-eglot-in-emacs/23125.md?page=2)

[Next page](https://discourse.julialang.org/t/using-languageserver-jl-with-eglot-in-emacs/23125.md?page=4)
