helix: Julia LSP not working

Reproduction steps

  1. Open a julia file.
  2. LSP does not work.

Environment

  • Platform: Linux
  • Helix version: v0.4.1-68-g5cee3b63 (master)
~/.cache/helix/helix.log
2021-08-28T12:29:40.183 helix_lsp::transport [ERROR] err <- 
2021-08-28T12:29:40.183 helix_lsp::transport [ERROR] err <- 
2021-08-28T12:29:40.183 helix_lsp::transport [ERROR] err <- 
2021-08-28T12:29:40.183 helix_lsp::transport [ERROR] err <- 
2021-08-28T12:29:40.183 helix_lsp::transport [ERROR] err <- 
2021-08-28T12:29:40.183 helix_lsp::transport [ERROR] err <- 
2021-08-28T12:29:40.183 helix_lsp::transport [ERROR] err <- 
2021-08-28T12:29:40.183 helix_lsp::transport [ERROR] err <- 
2021-08-28T12:29:40.183 helix_lsp::transport [ERROR] err <- 
2021-08-28T12:29:40.183 helix_lsp::transport [ERROR] err <- 
2021-08-28T12:29:40.183 helix_lsp::transport [ERROR] err <- 
2021-08-28T12:29:40.183 helix_lsp::transport [ERROR] err <- 
2021-08-28T12:29:40.183 helix_lsp::transport [ERROR] err <- 
2021-08-28T12:29:40.183 helix_lsp::transport [ERROR] err <- 
2021-08-28T12:29:40.183 helix_lsp::transport [ERROR] err <- 
2021-08-28T12:29:40.183 helix_lsp::transport [ERROR] err <- 
2021-08-28T12:29:40.183 helix_lsp::transport [ERROR] err <- 
2021-08-28T12:29:40.183 helix_lsp::transport [ERROR] err <- 
2021-08-28T12:29:40.183 helix_lsp::transport [ERROR] err <- 
2021-08-28T12:29:40.183 helix_lsp::transport [ERROR] err <- 
2021-08-28T12:29:40.183 helix_lsp::transport [ERROR] err <- 
2021-08-28T12:29:40.183 helix_lsp::transport [ERROR] err <- 
2021-08-28T12:29:40.183 helix_lsp::transport [ERROR] err <- 
2021-08-28T12:29:40.183 helix_lsp::transport [ERROR] err <- 
2021-08-28T12:29:40.183 helix_lsp::transport [ERROR] err <- 
2021-08-28T12:29:40.183 helix_lsp::transport [ERROR] err <- 
2021-08-28T12:29:40.183 helix_lsp::transport [ERROR] err <- 
2021-08-28T12:29:40.183 helix_lsp::transport [ERROR] err <- 
2021-08-28T12:29:40.183 helix_lsp::transport [ERROR] err <- 
2021-08-28T12:29:40.183 helix_lsp::transport [ERROR] err <- 
2021-08-28T12:29:40.183 helix_lsp::transport [ERROR] err <- 
2021-08-28T12:29:40.183 helix_lsp::transport [ERROR] err <- 
2021-08-28T12:29:40.183 helix_lsp::transport [ERROR] err <- 
2021-08-28T12:29:40.183 helix_lsp::transport [ERROR] err <- 
2021-08-28T12:29:40.183 helix_lsp::transport [ERROR] err <- 
2021-08-28T12:29:40.183 helix_lsp::transport [ERROR] err <- 
2021-08-28T12:29:40.183 helix_lsp::transport [ERROR] err <- 
2021-08-28T12:29:40.183 helix_lsp::transport [ERROR] err <- 
2021-08-28T12:29:40.183 helix_lsp::transport [ERROR] err <- 
2021-08-28T12:29:40.183 helix_lsp::transport [ERROR] err <- 
2021-08-28T12:29:40.183 helix_lsp::transport [ERROR] err <- 
2021-08-28T12:29:40.183 helix_lsp::transport [ERROR] err <- 
2021-08-28T12:29:40.183 helix_lsp::transport [ERROR] err <- 
2021-08-28T12:29:40.183 helix_lsp::transport [ERROR] err <- 
2021-08-28T12:29:40.183 helix_lsp::transport [ERROR] err <- 
2021-08-28T12:29:40.183 helix_lsp::transport [ERROR] err <-

Is this related to #413 ?

Just to add, I wonder if it actually not start julia because in htop, no julia process is running.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 57 (51 by maintainers)

Most upvoted comments

There are any tutorials to setup julia in helix? This seems confuse a lot.

I will write a short post soon on how to set it up 😃

There are any tutorials to setup julia in helix? This seems confuse a lot.

https://uncomfyhalomacro.pl/blog/14/

I have a set of changes here: https://github.com/helix-editor/helix/compare/lsp-async-init

(There’s still a couple of things I need to clean up but you can go ahead and test it)

It’s a bit tricky because we now need to buffer any requests sent before initialize is complete and send them at a later time. Julia is also the first LSP I tested that doesn’t support partial document updates (so you need to send the entire doc per keypress! ideally this should get addressed by the server because it’s a lot of traffic when the document is a few kilobytes in size) https://github.com/julia-vscode/LanguageServer.jl/blob/287be7f8457ad28456a390bd8ecff26919d2ee82/src/requests/init.jl#L6

I also went ahead and improved the highlighting queries a bit to match the other grammar conventions so that helix now highlights Julia a bit better 😃

Did some testing today, Helix needs some fixes regarding EOF handling, but the problem now is indeed the initial timeout being too quick. Unlike rust-analyzer, which also takes a while to analyze the code but immediately starts responding to initialize requests, LanguageServer.jl will wait until the code is fully analyzed.

I was able to get it running after increasing the timeout to 20s, but the problem is that helix initializes the LSP synchronously, blocking the UI. I’ll need to do some more changes to make this async, but it’s definitely what I’m working on this week.

got it to work by using -J instead of --sysimage

So, currently Julia users need to:

  1. Create a sysimage of the LanguageServer package:
pkg> add LanguageServer
pkg> add PackageCompiler
julia> using PackageCompiler
julia> create_sysimage(["LanguageServer"]; sysimage_path="julialsp.so")
  1. Change the default language server command:
# ~/.config/helix/languages.toml
# <...>
[[language]]
name = "julia"
language-server = { command = "julia", args = [
  "--startup-file=no",
  "--history-file=no",
  "--sysimage=/path/to/julialsp.so",
  "--sysimage-native-code=yes",
  "--quiet",
  "--eval",
  """
  using LanguageServer;
  popfirst!(LOAD_PATH);
  depot_path = get(ENV, "JULIA_DEPOT_PATH", "");
  project_path = let
      dirname(something(
          Base.load_path_expand((
              p = get(ENV, "JULIA_PROJECT", nothing);
              p === nothing ? nothing : isempty(p) ? nothing : p
          )),
          Base.current_project(),
          get(Base.load_path(), 1, nothing),
          Base.load_path_expand("@v#.#"),
      ))
  end;
  server = LanguageServer.LanguageServerInstance(stdin, stdout, project_path, depot_path);
  server.runlinter = true;
  run(server);
  """,
] }

Also, no Tab completions for writing Unicode characters easily.

I think the problem with the first command is likely the quoting around that last parameter, it might work if you remove the single quotes '. These should be automatically added by helix when executing the command.

It seems to be an error before we even hit the timeout.

I pushed a commit with some more logging (https://github.com/helix-editor/helix/commit/7eff9056802d3d4f67fbaef7ba7dc03e874564c1) can you build from master, try again and give me the hx -v -v log output again?