-
Notifications
You must be signed in to change notification settings - Fork 220
Description
@Zentrik @pfitzseb I am thinking about the best way to get continual feedback with more detailed type hints in VSCode. Similar to how it is done with rust-analyzer.
Since Julia is very dynamic, this is obviously a bit trickier. Right now the mechanism for this is to connect a REPL, and run Cthulhu descend (thanks to @Zentrik’s PR and @timholy’s Cthulhu).
This is awesome but I am wondering if we can do even better. I want type information to automatically show up while I am typing out the function, so I can immediately spot type indtability, rather than needing to manually descend to find it.
Here’s one idea: could we have a special comment that tells Julia LSP to run Cthulhu for the function with a given input?
For example:
function foo(x)
out = []
for xi in x
push!(out, xi)
end
push!(out, "bar")
out
end
# descend: ([1, 2, 3],)This "descend" would tell the Julia language server to continually run Cthulhu.descend(foo, ([1, 2, 3],)) whenever the code is changed. (Or just @code_warntype, but I feel like multiple levels could be useful)
In the future you could also specify multiple descend. In VSCode I believe there is the ability to cycle between code warnings for a given function (?) which would let you quickly switch between seeing the warnings for different example inputs.
The descend could also be more complex to allow different input types. For example,
# descend: begin
# using MyPkg
# (MyPkg.MyStruct(), "foobar")
# endI think the comments are the right place to put this because this is where you control linters and formatters.
Edit: I'm going to cross-post this on the discourse as I think wider input might be useful too!