LanguageServer.jl
LanguageServer.jl copied to clipboard
Go to position where a symbol entered the namespace
When using the go-to-definition feature, the current behavior jumps to the method definition that potentially resides in another module; potentially even in another package. Instead, what I usually want is to know "where did this symbol enter my namespace"? To answer this question, it would be convenient if "go-to-definition" jumped to the associated using or import statement that brought the symbol into scope.
Example:
using Dictionaries: sortkeys # invoking "go-to-definition" on `sortkeys` here should ideally still jump to the definition in `Dictionaries.jl`
...
function foo()
...
sortkeys(d) # invoking "go-to-definition" on `sortkeys` here would jump to the `using` statement above
end
Wouldn't the hover action tell you this? Doesn't seem like a job for "go to definition" at least.
Yeah, I agree. "Go to references" already handles this case:
I guess my expectation just came from the fact that my python LS had the described behavior.
But I tested in rust and there it seems to behave as in LS.jl. In view of that and the fact that many others are probably already used to the current behavior, I'll close this issue. "Go to references" does the job for me.
FWIW, the LSP also defines the textDocument/declaration request, which could maybe do this?
Yes, at least my python language server jumps to the associated import statement upon "textDocument/declaration". In rust, however, it jumps to the definition in another crate.
I'm also not sure how e.g. VS Code shows "Go to definition" and "Go to declaration" or how the user would interact with them, FWIW.
It seems to be exposed in the right-click menu in vscode and the Go menu in the top bar. The user can also bind a key to it: