# 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:** 5

<div class="post-metadata">

**Author:** ![ellocco](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ellocco/32/31331_2.png) [@ellocco](https://discourse.julialang.org/u/ellocco)\
**Post date:** [December 1, 2022, 9:38pm UTC](https://discourse.julialang.org/t/using-languageserver-jl-with-eglot-in-emacs/23125/81 "2022-12-01T21:38:16Z")

</div>

I have an issue to install `vterm`, the problem is the same for Ubunutu 22.02 as well as for MS-Windows 10:

```julia
Error (use-package): vterm/:catch: Cannot open load file: No such file or directory, vterm-module

```

---

<div class="post-metadata">

**Author:** ![ellocco](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ellocco/32/31331_2.png) [@ellocco](https://discourse.julialang.org/u/ellocco)\
**Post date:** [December 1, 2022, 9:45pm UTC](https://discourse.julialang.org/t/using-languageserver-jl-with-eglot-in-emacs/23125/82 "2022-12-01T21:45:21Z")

</div>

> [@tom-plaa](#):
>
> `(use-package vterm :ensure t)`

For `vterm` I found the following snipped on [erickgnavar.github.io](https://erickgnavar.github.io/emacs-config/):

```julia
(use-package vterm
  :ensure t
  :defer t
  :hook
  (vterm-mode . (lambda ()
                  (setq-local show-trailing-whitespace nil)))
  :custom
  (vterm-module-cmake-args "-DUSE_SYSTEM_LIBVTERM=yes")
  (vterm-always-compile-module t))

```

Does this make sense?

---

<div class="post-metadata">

**Author:** ![tom-plaa](https://avatars.discourse-cdn.com/v4/letter/t/d26b3c/32.png) [@tom-plaa](https://discourse.julialang.org/u/tom-plaa)\
**Post date:** [December 2, 2022, 12:03pm UTC](https://discourse.julialang.org/t/using-languageserver-jl-with-eglot-in-emacs/23125/83 "2022-12-02T12:03:33Z")

</div>

Sorry, @ellocco, I had forgotten that using vterm wasn’t as plug-and-play as it seemed.  
I forgot to mention that we need to compile vterm on our machine. And I believe that emacs must be compiled with the “with modules” option. I’m not sure if the version you have is compiled like that, but I thought it had become standard starting with 28 or similar.  
Here’s a thread that mentions it, and where I based myself when I had exactly the same issue as yourself : [Cannot open load file: No such file or directory, vterm-module · Issue #113 · akermu/emacs-libvterm · GitHub](https://github.com/akermu/emacs-libvterm/issues/113)  
I ended up compiling my own version of emacs, I’m on ubuntu 20.

For using vterm in general, check the readme of the repository for the installation procedure steps, minding what I said above about emacs: [GitHub - akermu/emacs-libvterm: Emacs libvterm integration](https://github.com/akermu/emacs-libvterm)

If I remember correctly, we need to have all the dependencies needed for compilation, and then emacs itself will compile vterm for us on startup if we call the associated package in the config.  
The configuration you posted seems to have an option for forcing recompilation everytime you startup - I personally would not include it, I don’t see the point. Once it compiled correctly for me, I never had any problems again. It also defers loading the package, I’m not sure if that is useful but it may be.

---

<div class="post-metadata">

**Author:** ![ellocco](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ellocco/32/31331_2.png) [@ellocco](https://discourse.julialang.org/u/ellocco)\
**Post date:** [December 2, 2022, 2:59pm UTC](https://discourse.julialang.org/t/using-languageserver-jl-with-eglot-in-emacs/23125/84 "2022-12-02T14:59:56Z")

</div>

My problem was the missing package `libtool-bin`, the compiler complains about the missing package `libtool` even, if it is installed, but the error message does not mention the missing `libtool-bin`.  
The current emacs was sufficient, it was not necessary to compile it myself.  
MS-Windows:  
I wonder if the `eshell` is an alternative to `vterm` on MS-Window OS.

---

<div class="post-metadata">

**Author:** ![tom-plaa](https://avatars.discourse-cdn.com/v4/letter/t/d26b3c/32.png) [@tom-plaa](https://discourse.julialang.org/u/tom-plaa)\
**Post date:** [December 2, 2022, 3:08pm UTC](https://discourse.julialang.org/t/using-languageserver-jl-with-eglot-in-emacs/23125/85 "2022-12-02T15:08:38Z")

</div>

I’m glad you managed to solve it nonetheless. I have no experience with using these in Windows so I can’t comment on that.

---

<div class="post-metadata">

**Author:** ![johannesnauta](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/johannesnauta/32/47434_2.png) [@johannesnauta](https://discourse.julialang.org/u/johannesnauta)\
**Post date:** [March 7, 2023, 4:48pm UTC](https://discourse.julialang.org/t/using-languageserver-jl-with-eglot-in-emacs/23125/86 "2023-03-07T16:48:34Z")

</div>

I am not sure if this is correct thread to post, but here goes:

I am switching from `lsp-mode` to using `eglot` and `eglot-jl` because I could not correctly configure `lsp-mode` with my current Julia project (e.g. using `Pkg.activate("path/to/project")`). While the `README.md` on the `eglot-jl` clearly states:

> After installation, `eglot-jl-init` will load support for the Julia language server into eglot and project.el. If `eglot-jl-init` has been run in your emacs session, running `eglot` in a `julia-mode` buffer will start a language server for the [Julia project](https://docs.julialang.org/en/v1.1/manual/code-loading/#Project-environments-1) to which the buffer belongs.

I still get linting errors that indicate `Missing reference`s. Does someone maybe have an idea why this is the case? If I look into the `*EGLOT` message buffer it appears to have chosen the correct project, but it still cannot find the modules in my `/src/` directory.

Here is the relevant elisp:

```elisp
(use-package eglot
    :ensure t)

(use-package eglot-jl
    :ensure t)

(use-package julia-mode
    :ensure t
    :mode "\\.jl\\'"
    :interpreter "julia"
    :config
    (eglot-jl-init)
    ;; Specify the hook that connects =eglot=
    :hook (julia-mode . eglot-ensure))

```

And, perhaps useful, an overview of my `tree` can be checked in [this question](https://discourse.julialang.org/t/revise-pkg-pkgtemplates-pkgskeleton-and-smooth-julia-package-development/95608), but basically boils down to:

```bash
Project.toml
|- src/
|--- Main.jl
|- examples/
|--- example.jl

```

The linting errors appear in `example.jl` with contents

```julia
using Main
Main.someFunction()

```

Note that the code does work inside a Julia REPL, so I believe it is not an issue of a wrong `import`/`using` statement.

---

<div class="post-metadata">

**Author:** ![johannesnauta](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/johannesnauta/32/47434_2.png) [@johannesnauta](https://discourse.julialang.org/u/johannesnauta)\
**Post date:** [March 9, 2023, 3:00pm UTC](https://discourse.julialang.org/t/using-languageserver-jl-with-eglot-in-emacs/23125/87 "2023-03-09T15:00:29Z")

</div>

For those in the future that have the same problem, I solved it by making another `Project.toml` in the `examples/` directory that contains the `Main` package, e.g.

`examples/Projects.toml`:

```toml
[deps]
Main = "whatever-hash-is-generated-by-julia"

```

and the `Missing reference` errors raised by `flymake` (or `flycheck`) disappear.

---

<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:** [June 1, 2023, 1:45pm UTC](https://discourse.julialang.org/t/using-languageserver-jl-with-eglot-in-emacs/23125/88 "2023-06-01T13:45:52Z")

</div>

I try to go through discourse every few months and see if there’s any `eglot-jl`-related questions I missed. Apologies for not replying here sooner. This is a [limitation of LanguageServer.jl](https://github.com/julia-vscode/LanguageServer.jl/issues/988) which is discussed along with possible workarounds here:

> [@LSP "Missing reference" woes](https://discourse.julialang.org/t/lsp-missing-reference-woes/98231/16):
>
> First, be aware it’s very hacky and messes up a bit with inline evaluation (which I don’t use much because I actually use Emacs for my day-to-day work). But let me try and give a step-by-step procedure that demonstrates this trick on a simple package like Example.jl. You should be able to reproduce this on your system. First, git clone https://github.com/JuliaLang/Example.jl, open the project in VSCode and add a script.jl file at its root. It should look like this: Example.jl ├── Project.toml …

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [July 31, 2024, 10:33am UTC](https://discourse.julialang.org/t/using-languageserver-jl-with-eglot-in-emacs/23125/89 "2024-07-31T10:33:44Z")

</div>

I recently started using `eglot-jl` again, and it works great, but there are some annotations I would like to disable. Specifically,

argument names like this:

![screenshot_2024-07-31-123012](https://global.discourse-cdn.com/julialang/original/3X/1/6/160e8d585cde5f8914fb87c96c977efafcfcb40c.png)

and inferred types like this (note `Int64`, `Set{T}`; also argument names `x:` and `B:`):

![screenshot_2024-07-31-123031](https://global.discourse-cdn.com/julialang/original/3X/4/1/415bb4a16665b62be0ca23c772e36e1a85240de8.png)

I am currently digging into the manuals of eglot but I could figure this out.

---

<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:** [August 1, 2024, 3:10am UTC](https://discourse.julialang.org/t/using-languageserver-jl-with-eglot-in-emacs/23125/90 "2024-08-01T03:10:48Z")

</div>

Glad it’s generally working well for you. I believe `eglot-inlay-hints-mode` is the invocation you’re looking for, but I’m not near a ~~computer~~ emacs right now, so I can’t confirm this. It’s a relatively new feature in either eglot or the language server, and I tend to agree that it’s quite annoying.

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [August 1, 2024, 7:02am UTC](https://discourse.julialang.org/t/using-languageserver-jl-with-eglot-in-emacs/23125/91 "2024-08-01T07:02:18Z")

</div>

> [@non-Jedi](#):
>
> `eglot-inlay-hints-mode` is the invocation you’re looking for

Indeed it is! Disabling it solves my problem. Thanks for the super-quick reply and your continued maintenance of `eglot-jl`!

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [August 1, 2024, 12:33pm UTC](https://discourse.julialang.org/t/using-languageserver-jl-with-eglot-in-emacs/23125/92 "2024-08-01T12:33:44Z")

</div>

I just learned that the [correct solution](https://github.com/joaotavora/eglot/discussions/1191) is something along the lines of

```julia
(setq eglot-ignored-server-capabilites '(:inlayHintProvider))

```

(explanation: `eglot-ensure` does not hold up the execution of your customization hook, so if you so something like `(eglot-inlay-hints-mode -1)` after, it may be reset when the mode actually finishes initialization).

---

<div class="post-metadata">

**Author:** ![pfitzseb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pfitzseb/32/45566_2.png) [@pfitzseb](https://discourse.julialang.org/u/pfitzseb)\
**Post date:** [August 1, 2024, 1:12pm UTC](https://discourse.julialang.org/t/using-languageserver-jl-with-eglot-in-emacs/23125/93 "2024-08-01T13:12:56Z")

</div>

I assume that eglot has a way to set LS settings somewhere, in which case you should be able to disable `julia.inlayHints.static.enabled` (useful if you want inlay hints in other languages, for example).

---

<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:** [August 1, 2024, 2:03pm UTC](https://discourse.julialang.org/t/using-languageserver-jl-with-eglot-in-emacs/23125/94 "2024-08-01T14:03:11Z")

</div>

[It does](https://www.gnu.org/software/emacs/manual/html_node/eglot/Advanced-server-configuration.html)! I think I’ve used that functionality in the past to turn off certain lints, but I don’t see any sign of it in my config at the moment.

Is there a documented list of the available configuration options somewhere? It would be good to include a link to it in the eglot-jl README.

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [August 7, 2024, 8:23am UTC](https://discourse.julialang.org/t/using-languageserver-jl-with-eglot-in-emacs/23125/95 "2024-08-07T08:23:14Z")

</div>

Another question: for the code

```julia
using DocStringExtensions

"""
$(SIGNATURES)

This is a 100% bug-free function.
"""
foo() = nothing

```

when I put the point in a `foo()` (before the `(`), I get the documentation hint in the minibuffer, but

1. it does not resolve `$(SIGNATURES)` and
2. new lines appear as `n`, see screenshot:

 ![screenshot_2024-08-07-101928](https://global.discourse-cdn.com/julialang/original/3X/6/0/60e747a9a22ccef3881702a2239ad7923318450a.png)

I thought asking here before opening an issue, because I am not sure which part of the toolchain is responsible for this.

---

<div class="post-metadata">

**Author:** ![pfitzseb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pfitzseb/32/45566_2.png) [@pfitzseb](https://discourse.julialang.org/u/pfitzseb)\
**Post date:** [August 7, 2024, 8:55am UTC](https://discourse.julialang.org/t/using-languageserver-jl-with-eglot-in-emacs/23125/96 "2024-08-07T08:55:05Z")

</div>

1 is expected, the language server can’t currently deal with DocStringExtensions. 2 is happening somewhere inside of emacs/eglot though, I think – I’ve never seen that before in any other context.

---

<div class="post-metadata">

**Author:** ![tom-plaa](https://avatars.discourse-cdn.com/v4/letter/t/d26b3c/32.png) [@tom-plaa](https://discourse.julialang.org/u/tom-plaa)\
**Post date:** [August 8, 2024, 8:23am UTC](https://discourse.julialang.org/t/using-languageserver-jl-with-eglot-in-emacs/23125/97 "2024-08-08T08:23:20Z")

</div>

Has anyone successfully gotten eglot and julia-ts-mode to work together? If try to use julia-ts-mode instead of julia-mode eglot seems to go crazy and flag every single thing as a missing reference, and none of the functionalities work at all.

---

<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:** [August 8, 2024, 12:36pm UTC](https://discourse.julialang.org/t/using-languageserver-jl-with-eglot-in-emacs/23125/98 "2024-08-08T12:36:24Z")

</div>

> [@Tamas\_Papp](#):
>
> 1. new lines appear as `n`, see screenshot:
> 
> ![screenshot_2024-08-07-101928](https://global.discourse-cdn.com/julialang/original/3X/6/0/60e747a9a22ccef3881702a2239ad7923318450a.png)
> 
> I thought asking here before opening an issue, because I am not sure which part of the toolchain is responsible for this.

Could you please open an issue against eglot-jl for this? I’m having an unrelated issue with eglot at the moment, so I can’t try to replicate right now. There’s a chance that this is an active choice of eglot to display docstrings with “\n”, and the backslash is just getting swallowed up accidentally as emacs likes to do, but I’ll need to dig a bit before I can say.

> [@tom-plaa](#):
>
> Has anyone successfully gotten eglot and julia-ts-mode to work together? If try to use julia-ts-mode instead of julia-mode eglot seems to go crazy and flag every single thing as a missing reference, and none of the functionalities work at all.

I just fired up eglot in a `julia-ts-mode` buffer, and it’s working no differently for me than in a `julia-mode` buffer. Could you please double-check you’re not getting the same result with plain `julia-mode` buffers? After that, try to create as minimal of a reproduction as possible and file an issue against eglot-jl?

Thanks!

---

<div class="post-metadata">

**Author:** ![tom-plaa](https://avatars.discourse-cdn.com/v4/letter/t/d26b3c/32.png) [@tom-plaa](https://discourse.julialang.org/u/tom-plaa)\
**Post date:** [August 8, 2024, 3:37pm UTC](https://discourse.julialang.org/t/using-languageserver-jl-with-eglot-in-emacs/23125/99 "2024-08-08T15:37:18Z")

</div>

I reverted back to julia-mode so I definitely have different behaviour. I’ll try to get a MWE and report back on the repo like you asked.

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [August 13, 2024, 11:38am UTC](https://discourse.julialang.org/t/using-languageserver-jl-with-eglot-in-emacs/23125/100 "2024-08-13T11:38:18Z")

</div>

> [@non-Jedi](#):
>
> Could you please open an issue against eglot-jl for this?

I tried to replicate it to file an issue but now I don’t get docstrings shown at all. (I had updated my emacs packages a few times in between).

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

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