JuliaEditorSupport / zed-julia

Julia support for Zed.
MIT License
28 stars 3 forks source link

Language server cannot detect all packages #3

Open Zhizhou-Jia98 opened 2 months ago

Zhizhou-Jia98 commented 2 months ago

Hi, thank you for develop this amazing Julia extension for Zed! When I'm using the package "CairoMakie" the language server seems not to be able to detect this package and several other packages. However, when I ran runserver() in the "zed-julia" environment in the REPL, these packages were detected. I attached the LSP log from Zed and the output in the REPL. Can you please help me solve the problem? Thanks! zed-lsp-log.txt julia-runserver-output.txt

piechologist commented 2 months ago

Just guessing: can you check if the working directory is the same? Have a look at Zed's log (command zed: open log), you can see the working dir that's passed to the language server when it is starting.

Zhizhou-Jia98 commented 1 month ago

It might be a working directory problem? I tried to open up Zed using CLI at different directories. If I open up Zed at ~/.julia/environments/v1.10 (zed ~/.julia/environments/v1.10), the language server seems working and I can find the references for all packages. However, if I open up zed in another directory (e.g. zed ~/Research/rna-seq), it's still not working. I attached the log files for both success and failure cases, hope it helps. dir_v1.10_successful.log dir_another_failed.log

piechologist commented 1 month ago

Do you have a Project.toml that has CairoMakie somewhere in your ~/Research/... path? I think what's happening here is that the language server cannot find a reference to CairoMakie. You'd need to generate a Project.toml then.

On the other hand, CairoMakie is probably in your ~/.julia/environments/v1.10/Project.toml and that's why the language server is working there.

LanguageServer.jl is a tricky package. There are some threads over at discourse (in Tooling and Tooling/VSCode) about workarounds (and complaints 😬). TBH, I disabled the Julia LS, for me it's more trouble than help.

Zhizhou-Jia98 commented 1 month ago

Generating a Project.toml inside my working directory helped, thanks! It would be nice if the LS can look for packages in the default environment if there's no Project.toml in the working directory. Maybe disabling the Julia LS is a simpler solution :)

Thanks for your help!

piechologist commented 1 month ago

It would be nice if the LS can look for packages in the default environment if there's no Project.toml in the working directory.

I agree! Let's keep this issue open. I'm not sure if we could or should do this within the Zed extension. LanguageServer.jl would be the better place to implement this.

I'm glad it's working for you now!