How to view source of import/using Package?

When I have installed some packages, then I can view docstrings of imported/using packages, by hovering over an expression or variable.

However, Go to Definition (F12) does not work for imported or using Packages. This is something that seems standard in other VSCode language extensions. Could it be there something I’m missing in my config of VSCode?

Also viewing toplevel docstrings for a module not seem to work. (Wait does Julia even have toplevel doc strings)?


I can’t answer the VSCode questions but regarding top level docstrings, if you mean a docstrings for a module itself Julia has them, but not all modules will have implemented one. You can try it with

This is a docstring
module MyModule

And see if you can view that docstring

Thanks @gustaphe for confirming that.

The gist of my question is: what is your workflow when you see import/using statements of new modules which you want to learn. What’s the fastest way to jump over to the source code of the imported model?

I like checking the GitHub repo in a browser (almost all packages are in GitHub, often as Package.jl). @edit Module should get you there too.

That’s a good tip about edit. This worked for me in the REPL:

julia> import Package
julia> edit(Package)

That opens Package.jl in the same VSCode window.
It would be nice if the VSCode extension had a shortcut for doing the same?

1 Like

I also opened an issue for an enhancement here Go to Definition (F12) for import/using statements · Issue #2860 · julia-vscode/julia-vscode · GitHub