Using LanguageServer.jl with eglot in emacs

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

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

For vterm I found the following snipped on erickgnavar.github.io:

(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?

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

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.

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.

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.

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 to which the buffer belongs.

I still get linting errors that indicate Missing references. 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:

(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, but basically boils down to:

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

The linting errors appear in example.jl with contents

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.

1 Like

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:

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

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

3 Likes

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 which is discussed along with possible workarounds here:

1 Like