-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Julia LSP not working #669
Comments
The language server definition is probably wrong, the original implementer couldn't get it working in #413 Make sure you have the required binary in $PATH then try figuring out the correct LSP definition: Line 207 in d6a9c2c
|
I think you also need to have the package installed? https://github.com/julia-vscode/LanguageServer.jl |
I already installed it. Just wondering what might be causing the issue from my first post. I will try to take a look then. I will open a PR if I got it working. |
untitled.mp4it seems that julia terminates prematurely and maybe that is why no lsp was detected and the error logs shows just as in the first post of the issue. is it because julia "slow to first plot" problem is causing the issue? and the lsp plugin is trying to communicate to the lsp server but since the lsp server failed to start, nothing happens? im just guessin since i am not sure how the lsp plugin works in helix. |
Yeah I assume it's a similar crash to the original issue. You can use hx -v to increase the log level then check the LSP output in ~/.cache/helix/helix.log (I think that's the path, you can confirm under hx -h) to see what's going on. Post the whole log, if it's a timeout it should be visible in there (it'll time out after two seconds). I think the problem is with the command that's getting executed though. |
Ah so looking at the first post there's nothing reported after the "<- err"? That's weird, it would mean that we're getting a bunch of blank lines from the LSP. |
my current LSP configuration is based of nvim-lspconfig's julials, so I am sure I am doing it right in [[language]]
name = "julia"
scope = "source.julia"
injection-regex = "julia"
file-types = ["jl"]
roots = []
comment-token = "#"
language-server = { command = "julia", args = ["--startup-file=no", "--history-file=no", "-e","'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; @info \"Running language server\" VERSION pwd() project_path depot_path; server = LanguageServer.LanguageServerInstance(stdin, stdout, project_path, depot_path); server.runlinter = true; run(server)'"] }
indent = { tab-width = 2, unit = " " }
Using the working command for the julia lsp and then running ~/.cache/helix/helix.log
|
There's an error in your output:
Not sure if that's because of the LSP arguments or because of the initialize command. |
probably you are right on the arguments of the initialize command for the lsp but because of the verbosity of the arguments, i edited the toml file to launch a script [[language]]
name = "julia"
scope = "source.julia"
injection-regex = "julia"
file-types = ["jl"]
roots = []
comment-token = "#"
#language-server = { command = "julia", args = ["--startup-file=no", "--history-file=no", "-q", "-e",''''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; @info "Running language server" VERSION pwd() project_path depot_path; server = LanguageServer.LanguageServerInstance(stdin, stdout, project_path, depot_path); server.runlinter = true; run(server)''''] }
language-server = { command = "julia", args = ["--startup-file=no", "--history-file=no", "/home/uncomfy/test.jl"] }
indent = { tab-width = 2, unit = " " } The script in 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; @info "Running language server" VERSION pwd() project_path depot_path; server=LanguageServer.LanguageServerInstance(stdin,stdout,project_path,depot_path); server.runlinter = true; run(server) Syntax error is gone but problem persists. ~/.cache/helix/helix.log
|
is this for the lsp plugin of helix? julia's LanguageServer.jl usually starts at least 2 to 10 seconds in my experience (even a minute or more depending on the project). this is because of the "slow time to first plot" of julia that is also applicable to almost all packages. Not sure if this is relevant though. |
It seems to be an error before we even hit the timeout. I pushed a commit with some more logging (7eff905) can you build from master, try again and give me the |
Thanks for the assistance. It seems there is new stuff in the logs: ~/.cache/helix/helix.log
I have a guess that it is receiving the output of $ julia test.jl
┌ Info: Running language server
│ VERSION = v"1.7.0-beta3.0"
│ pwd() = "/home/uncomfy"
│ project_path = "/home/uncomfy/.julia/environments/v1.7"
└ depot_path = ""
[ Info: Couldn't retrieve cache file for FuzzyCompletions.
[ Info: Couldn't retrieve cache file for LibSSH2_jll.
[ Info: Couldn't retrieve cache file for MbedTLS_jll.
┌ Warning: LibSSH2_jll not stored on disc
└ @ SymbolServer ~/.julia/packages/SymbolServer/rrlGM/src/SymbolServer.jl:192
┌ Warning: MbedTLS_jll not stored on disc
└ @ SymbolServer ~/.julia/packages/SymbolServer/rrlGM/src/SymbolServer.jl:192
┌ Warning: FuzzyCompletions not stored on disc
└ @ SymbolServer ~/.julia/packages/SymbolServer/rrlGM/src/SymbolServer.jl:192
[ Info: Received new data from Julia Symbol Server. |
Oh yeah, definitely get rid of the Here's how the kakoune definition looks like: There seems to be further logging into stdout though so I'm checking how this is handled in other clients. |
If it still breaks I'll probably add a workaround in the client (I assume |
@archseer After trying a few things, I think its a problem on the helix side of LSP implementation |
It would be useful if you provided logs after applying the changes above and/or explained what you tried. From what I can tell the Julia LSP doesn't conform to the spec and mixes in logging output with RPC messages. We can work around this, but it really should be fixed in the server. |
The errors I got are same as @uncomfyhalomacro I'll be filing an issue on the LanguageServer.jl side of things though |
Pushed a workaround: 847d1fa |
Update First attemptConfiguration on [[language]]
name = "julia"
scope = "source.julia"
injection-regex = "julia"
file-types = ["jl"]
roots = []
comment-token = "#"
language-server = { command = "julia", args = ["--startup-file=no", "--history-file=no", "-q", "-e", "'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)'"] }
indent = { tab-width = 2, unit = " " } It is valid TOML format though no matter how I check it Helix Logs:
Second attemptConfiguration in [[language]]
name = "julia"
scope = "source.julia"
injection-regex = "julia"
file-types = ["jl"]
roots = []
comment-token = "#"
language-server = { command = "julia", args = ["--startup-file=no", "--history-file=no", "--quiet", "/home/uncomfy/julialsp.jl"] }
indent = { tab-width = 2, unit = " " } Using a script instead because I have no other ways to find out what is causing the syntax error. Helix Logs
Both attempts have problems, the second one is weird, because julia process dies. Maybe because of the timeout, it may have not let julia start the process completely. |
oh nice, going to try this one. thanks again. sorry for the bother |
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 |
Try defining it like this: language-server = { command = "julia", args = [
"--startup-file=no",
"--history-file=no",
"--quiet",
"-e",
"""
using LanguageServer;
using Pkg;
import StaticLint;
import SymbolServer;
env_path = dirname(Pkg.Types.Context().env.project_file);
server = LanguageServer.LanguageServerInstance(stdin, stdout, env_path, "");
server.runlinter = true;
run(server);
""",
] } |
That fixed the syntax literal problem. Thanks! 😃
Now it looks like the second attempt from before. I used the latest master btw with your changes 847d1fa. Hmm seems julia process still terminates prematurely. |
Can you do it with |
With
|
I'll set up julia and do some tests tomorrow morning, been meaning to tweak the highlight definitions for it a bit anyway. Is it enough for me to just add a |
It doesn't because |
Can we use something like the LSP for auto-formatting? Julia has a formatter too. |
We auto format via the LSP on save for certain languages, if the Julia formatter is good enough we could enable it: Line 7 in 7e11236
|
With With |
How is the LSP so slow :D I thought Julia was a fast language. You might want to experiment with a longer timeout here (try 60s) Line 156 in 4d98f75
|
Julia is fast but still, the "slow time to first plot" problem is a pain. I think I can try to change the commands to run it with a compiled sysimage of the server. If that works, i might add an instruction for it either in the wiki or somewhere. I will test that first and then that longer time out thingy. |
Good morning. I tested it with both a compiled sysimage with timeout of 20 seconds with the following TOML configuration language-server = { command = "julia", args = [
"--startup-file=no",
"--history-file=no",
"--sysimage=/home/uncomfy/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);
""",
] } . It currently works. If not using sysimage, it will fail because timeout already happened so i need to increase it to at least 10 seconds (currently 60 just to make sure). There is something wrong with executing |
@uncomfyhalomacro regardless of whether they want a PR, I'd be interested in getting a hold of whatever scripts you used to make this work. I use Julia myself too, and am interested in trying out Helix. |
@archseer Any update on this? |
@archseer Is there a possibility that you can somehow increase the time or add something like an exception for the Julia LSP when it comes to timeout? |
@archseer Hello! I know that this is late but currently Julia LSP is working now. I should close this :D |
Thanks again! |
So, currently Julia users need to:
pkg> add LanguageServer
pkg> add PackageCompiler
julia> using PackageCompiler
julia> create_sysimage(["LanguageServer"]; sysimage_path="julialsp.so")
# ~/.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. |
seems like we have the same idea. I do hope in the future that helix will have the ability to create envs like how kakoune does it e.g. |
any idea how I can use absolute paths in the config file? Thanks! |
Absolute paths should just work. Note that if you are facing the timeout issue, you can also fix it by increasing the max timeout in your [[language]]
name = "julia"
...
language-server.timeout = 60 # default 20 |
hmmm... weird I compiled a sysimage at ~/.julia/sysimages/julialsp.so [[language]] and i'm getting this error: This happens when i try to edit a julia file in ~/.config/helix if I edit a julia file from my home dir, everything works fine, as one would expect from a relative path |
got it to work by using -J instead of --sysimage |
This part is not really needed:
This should do the same:
|
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 :) |
|
the link of @uncomfyhalomacro is unfortunatly dead :( |
I created a new issue #10759 |
I've found the wiki page from julia-vscode/LanguageServer to be quite useful. |
Oh it was archived in my blog. i also think that i was the one that added on the wiki. you can still see the archive from my website. |
Reproduction steps
Environment
~/.cache/helix/helix.log
Is this related to #413 ?
Just to add, I wonder if it actually not start julia because in htop, no julia process is running.
The text was updated successfully, but these errors were encountered: