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

Hover help doesn't show for own modules #2719

Open
Faaziy opened this issue Feb 6, 2022 · 5 comments
Open

Hover help doesn't show for own modules #2719

Faaziy opened this issue Feb 6, 2022 · 5 comments

Comments

@Faaziy
Copy link

Faaziy commented Feb 6, 2022

Issue is as stated above. When hovering over my functions which are imported through my module the hover help doesn't show and I can't fast click towards the function itself in my module file. But when I do the same in the module file it works fine.

So for example:

using TestModule

a = TestFunction(3) # Hovering over TestFunction doesn't do anything and I can't fastclick

but

module TestModule

export TestFunction # Hovering over TestFunction shows function details and I can fastclick

function TestFunction(var)
return var
end

end

How could this be resolved?

I am using v1.5.10 of Julia for vscode
v1.6.5 of the Julia programming language

@pfitzseb
Copy link
Member

pfitzseb commented Feb 6, 2022

It seems likely that TestModule isn't in your environment (Manifest.toml) or directly reachable otherwise (via include); you may be using LOAD_PATH shenanigans to get it to load anyways.

@Faaziy
Copy link
Author

Faaziy commented Feb 6, 2022

I am indeed using the LOAD_PATH method to make use of my own module. Is there anything wrong with this? And what is the main stream method to make use of custom modules?

@pfitzseb
Copy link
Member

pfitzseb commented Feb 7, 2022

There's not really anything wrong with this per se, it's just that the extension cannot reason about LOAD_PATH modifications (currently, but there are no concrete plans either). I'd typically recommend using a local environment and add/dev local packages in there.

@jorge-brito
Copy link

One solution that i finded for getting vs-code intellisense to work for files that are in the same julia env but not directly included in the package entry point is just to add a if false statement including that file, for example:

Imagine that i created a examples/example.jl file, to get intellisense to work inside this file for my hipotetical Example package, is just to add:

# inside src/Example.jl

if (false) include("../examples/example.jl") end

If you dont like to use if statement, you can also create an @ignore macro like this:

macro ignore(args...) end

And then:

# inside src/Example.jl

@ignore include("../examples/example.jl")

This solution is not perfect, as you have to add this "false" include every time for every file you want intellisense to work, and also every symbol for your package will be visible, not just the exported ones.

Indeed, a better solution would be to the julia extension to do this automatically for every .jl file inside the package env, or only if the file has an using Example statement.

@MilesCranmer
Copy link

MilesCranmer commented Nov 2, 2022

This would be extremely useful to have. When writing tests for a module, hover help doesn't work at all, since it's not aware of the tested module.


@jorge-brito thanks for this very clever solution. This is indeed a workaround for using hover help inside tests:

# <src/MainModule.jl>
...
macro ignore(args...) end
@ignore include("../test/runtests.jl")
...

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

No branches or pull requests

5 participants