Skip to content
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

Go to definition (M-.) #50

Open
cstjean opened this issue Jan 9, 2019 · 7 comments
Open

Go to definition (M-.) #50

cstjean opened this issue Jan 9, 2019 · 7 comments

Comments

@cstjean
Copy link

cstjean commented Jan 9, 2019

Thank you for this package! Is there something like M-. (aka go-to-defintion) in this package? I find that C-c C-e is not too useful when editing module code, because of course, the arguments can't be evaluated.

@cstjean cstjean changed the title M-. Go to definition (M-.) Jan 9, 2019
@tpapp
Copy link
Owner

tpapp commented Jan 9, 2019

Not at the moment, as it would have to query the Julia process in the background for the relevant information. PRs and suggestions are welcome, eventually I guess this should be possible with LanguageServer.

@gdkrmr
Copy link

gdkrmr commented Jan 9, 2019

This works with lsp-julia.

@cstjean
Copy link
Author

cstjean commented Jan 9, 2019

Thank you for the link to lsp-julia

Here's a suggestion in line with this package's philosophy. Send this command to julia:

julia> println(methods(findfirst)); edit(methods(findfirst).ms[parse(Int, readline())])
# 7 methods for generic function "findfirst":
[1] findfirst(A::Union{AbstractString, AbstractArray}) in Base at array.jl:1661
[2] findfirst(pred::Base.Fix2{#s57,#s56} where #s56<:Union{Int8, UInt8} where #s57<:Union{typeof(==), typeof(isequal)}, a::Union{Array{Int8,1}, Array{UInt8,1}}) in Base at strings/search.jl:22
[3] findfirst(testf::Function, A::Union{AbstractString, AbstractArray}) in Base at array.jl:1742
[4] findfirst(testf::Function, A) in Base at array.jl:1735
[5] findfirst(pattern::AbstractString, string::AbstractString) in Base at strings/search.jl:104
[6] findfirst(r::Regex, s::AbstractString) in Base at regex.jl:243
[7] findfirst(A) in Base at array.jl:1652
6   # user input

If you can get the method number from emacs and send it to the julia process, then it should work.

@gdkrmr
Copy link

gdkrmr commented Jan 10, 2019

Here's a suggestion in line with this package's philosophy. Send this command to julia:

julia> println(methods(findfirst)); edit(methods(findfirst).ms[parse(Int, readline())])
# 7 methods for generic function "findfirst":
[1] findfirst(A::Union{AbstractString, AbstractArray}) in Base at array.jl:1661
[2] findfirst(pred::Base.Fix2{#s57,#s56} where #s56<:Union{Int8, UInt8} where #s57<:Union{typeof(==), typeof(isequal)}, a::Union{Array{Int8,1}, Array{UInt8,1}}) in Base at strings/search.jl:22
[3] findfirst(testf::Function, A::Union{AbstractString, AbstractArray}) in Base at array.jl:1742
[4] findfirst(testf::Function, A) in Base at array.jl:1735
[5] findfirst(pattern::AbstractString, string::AbstractString) in Base at strings/search.jl:104
[6] findfirst(r::Regex, s::AbstractString) in Base at regex.jl:243
[7] findfirst(A) in Base at array.jl:1652
6   # user input

If you can get the method number from emacs and send it to the julia process, then it should work.

That would be great to integrate with lsp-julia, so you get a list of definitions to jump to. I have no idea how to integrate this in with the different autocompletion systems such as helm and ivy.

@PetrKryslUCSD
Copy link

Why not ctags?

@tpapp
Copy link
Owner

tpapp commented Nov 27, 2019

AFAIK ctags would require that index files are pre-generated (and updated when necessary). At the same time, this information is available in the Julia image, so @gdkrmr's suggestion would be easier to do.

LSP support developed quite a bit since this issue was opened, perhaps it is time to revisit the implementation.

@PetrKryslUCSD
Copy link

This, presumably, might work also with the user's own files?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants