gdkrmr / lsp-julia

MIT License
71 stars 19 forks source link

Jump to definition not working between files #25

Closed prassee closed 4 years ago

prassee commented 4 years ago

I'm uisng the latest master with Julia 1.4. Basic LSP functions do work but the jumpt to definition and find references. In case of definitions, I can within the file but not to functions or variables defined in other files.

I got the following warning message

Warning (lsp-mode): Failed to process xref entry for filename ’’: Read error: Is a directory, /data/dataworkspace/vamana-ts-modelling

gdkrmr commented 4 years ago

Does it work with Julia 1.3? Julia 1.4 support does not work properly yet. How did you install lsp-julia?

prassee commented 4 years ago

I used (https://github.com/gdkrmr/lsp-julia) clone of lsp-julia to try with Julia1.4 (since gdkrmr repo seems to use the latest LangServer). OTTH, while using this repo I got the same error with Julia 1.3.

I installed lsp-julia by cloning https://github.com/non-Jedi/lsp-julia repo and adding to lsp-julia.jl to the loadpath of emacs.

prassee commented 4 years ago

just curious to know any updates about this

prassee commented 4 years ago

I have created another issue I found after updating to the latest code - https://github.com/non-Jedi/lsp-julia/issues/27

gdkrmr commented 4 years ago

For me https://github.com/non-Jedi/lsp-julia works with julia 1.3 and https://github.com/gdkrmr/lsp-julia works with 1.4 (haven't done any tests with 1.3) but flycheck integration does not work, which is why I haven't merged yet.

ghost commented 4 years ago

I'm also facing the same issue with the following

What works?

What not works

gdkrmr commented 4 years ago

what is the exact version of lsp-julia? The one from https://github.com/gdkrmr/lsp-julia currently has issues.

ghost commented 4 years ago

I'm using non-jedi version https://github.com/non-Jedi/lsp-julia

gdkrmr commented 4 years ago

that works fine for me. Sometimes LanguageServer.jl doesn't find the symbol. But seems to be a current limitation of LanguageServer.jl

ghost commented 4 years ago

I dont think so as the more specific case is let say I include utils.jl file in main.jl

util.jl


function to_upper(x::String)::String
     return uppercase(x)
end

main.jl

include("utils.jl")

lang = "julia"
lang = to_upper(lang)
to_lower(lang)

function to_lower(x::String)
    return lower_case(x)
end

In the above code, my specific issue is jump-to-definition :-

but works for

doesn't work for

and ends up with a warning

Warning (lsp-mode): Failed to process xref entry for filename ’’: Read error: Is a directory

However the same behaviour works in VSCode hence it should not be issue from LanguageServer. Based on the warning message, I guess lsp-julia could not infer the mapping between functions and the respective files where they are defined.

OTTH, jump-to-definition works for all the modules where are loaded in to LOAD_PATH.

Hope I made it clear for everyone. (Note :- I've also tried https://github.com/non-Jedi/eglot-jl and observed the same behavior as explained above.)

non-Jedi commented 4 years ago

Hi @prasannakog thanks for the good reproducer. For anyone else following along, the main.jl/utils.jl example above actually works inside a package, but it fails outside of a package because LanguageServer.jl uses a uri of "file://utils.jl" if outside of a package. I will file an issue with upstream.

prassee commented 4 years ago

Hi @prasannakog thanks for the good reproducer. For anyone else following along, the main.jl/utils.jl example above actually works inside a package, but it fails outside of a package because LanguageServer.jl uses a uri of "file://utils.jl" if outside of a package. I will file an issue with upstream.

Thanks @non-Jedi for taking this forward. I should have attached the json-log in my issue desc I would try to give as much as details if I found any in the future.

ghost commented 4 years ago

looks like the related issue on the upstream repo got fixed , just curious to know any updates.

ghost commented 4 years ago

@non-Jedi any updated on this

non-Jedi commented 4 years ago

That's up to @gdkrmr to update the versions bundled with lsp-julia. It's fixed upstream.

ghost commented 4 years ago

Thanks ... but @gdkrmr fork of lsp-julia doesn't have issues feature enabled.

non-Jedi commented 4 years ago

He maintains this repo as well

gdkrmr commented 4 years ago

I am maintaining this repository and use my fork as the development version. master on my repo is currently not working without issues. I would have merged it a long time ago. There were/are numerous open issues on lsp-mode and LanguageServer.jl to figure this out and some patches have been merged but without success. The whole thing seems to be the communication between lsp-mode and LanguageServer.jl and I am not knowledgeable in the lsp specification. If you want to contribute, @prasannakog, I suggest you start at figuring out what about the communication between eglot <-> LanguagServer.jl or vscode <-> LanguageServer.jlis different from lsp-mode <-> LanguageServer.jl.

gdkrmr commented 4 years ago

Is this working now? Please update according to https://github.com/non-Jedi/lsp-julia/issues/20#issuecomment-682031361 and report back.

spraharsh commented 4 years ago

It solved the issue for me. It might help to make lsp-julia-default-environment to "~/.julia/environments/v1.5" so that users may not need to go down the rabbit hole. Thank you!

gdkrmr commented 4 years ago

Yes, I don't really have a good solution for setting the default environment. I guess the solution is to query julia --version.