Why isn't info popping up when the mouse hovers over a function in a package

Viewed 52

When the mouse pointer hovers over the name of a function created in my code a box pops up in the editor with information about that function. However, if the function is in a package nothing happens. For example, if the mouse pointer hovers over the word "DataFrame" in the second line of the code below no box with info pops up. This is not specific to package DataFrames.

using DataFrames
DataFrame(:A => [0])

In VSCode Settings the following is set:

Editor > Hover:Delay
200
Editor > Hover:Enabled
Checked

The IDE is Visual Studio Code version 1.71.2 and the OS is Windows 11. The programming language is Julia, version 1.8.1.

It used to work, something changed, I do not know what.

Any hints on why this is happening?

1 Answers

I believe I found the solution. I created a function that adds a package to the environment. It has the package name as its single argument.

function load_package(package_name::String; used = true, report = true)
    str_ui = used ? "Using " : "Importing "

    report && println(str_ui * "package $package_name")

    if used
        eval(Meta.parse("using $package_name"))
    end

    eval(Meta.parse("import $package_name"))
end

It works fine. The package is loaded. For example,

load_package("DataFrames")

does (almost) the same thing as

using DataFrames

The only difference is that Visual Code does not seem to notice that the package was loaded when the package is loaded with the loaded_package function but it does notice it when the package is loaded with the using command.

So to fix the problem I had to load my packages with using and import comands. After doing that the tooltips became visible upon hovering over the function names.

The reason I was using the function load_packages was to load sets of packages whose names were in string vectors.

Related