# Go to definition almost never works

**URL:** <https://discourse.julialang.org/t/go-to-definition-almost-never-works/95363>\
**Category:** Tooling\
**Tags:** vscode\
**Created:** [March 1, 2023, 12:26am UTC](https://discourse.julialang.org/t/go-to-definition-almost-never-works/95363 "2023-03-01T00:26:01Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![evan-wehi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/evan-wehi/32/32692_2.png) [@evan-wehi](https://discourse.julialang.org/u/evan-wehi)\
**Post date:** [March 1, 2023, 12:26am UTC](https://discourse.julialang.org/t/go-to-definition-almost-never-works/95363/1 "2023-03-01T00:26:01Z")

</div>

I know there have been several threads on this topic already. Examples include going to definitions in packages or included definitions. Most of these threads just seem to be dangling with no resolution.

In my experience, “go to definition” almost never works.

![Screenshot 2023-03-01 at 11.03.24](https://global.discourse-cdn.com/julialang/original/3X/0/a/0afb91ad93ba163e5716430794bba590e2b13519.png)

Perhaps I’m doing something wrong or my expectations are unrealistic but pycharm has no such problems.

---

<div class="post-metadata">

**Author:** ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Post date:** [March 1, 2023, 2:45am UTC](https://discourse.julialang.org/t/go-to-definition-almost-never-works/95363/2 "2023-03-01T02:45:39Z")

</div>

When I have a package open for development, VSC does not recognize its methods, and jumping to definition does not work. I already asked about this, and I don’t think I got a definitive answer.

---

<div class="post-metadata">

**Author:** ![joa-quim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joa-quim/32/227_2.png) [@joa-quim](https://discourse.julialang.org/u/joa-quim)\
**Post date:** [March 1, 2023, 3:14am UTC](https://discourse.julialang.org/t/go-to-definition-almost-never-works/95363/3 "2023-03-01T03:14:39Z")

</div>

It does for me but I think one must have the entire directory (normally the `src` dir) loaded in the `EXPLORER` such that it can sniff in all files that may have the type/function definition.

---

<div class="post-metadata">

**Author:** ![evan-wehi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/evan-wehi/32/32692_2.png) [@evan-wehi](https://discourse.julialang.org/u/evan-wehi)\
**Post date:** [March 1, 2023, 3:43am UTC](https://discourse.julialang.org/t/go-to-definition-almost-never-works/95363/4 "2023-03-01T03:43:01Z")

</div>

What happens if you open a new file and try the example above?

---

<div class="post-metadata">

**Author:** ![jmair](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jmair/32/35117_2.png) [@jmair](https://discourse.julialang.org/u/jmair)\
**Post date:** [March 1, 2023, 8:31am UTC](https://discourse.julialang.org/t/go-to-definition-almost-never-works/95363/5 "2023-03-01T08:31:41Z")

</div>

This seems to be coming up more often (i.e. [Go To Definition (F12) does not work for functions in an included file](https://discourse.julialang.org/t/go-to-definition-f12-does-not-work-for-functions-in-an-included-file/76293)). I had a workflow that used to work okay (required a few Julia language server restarts every so often) but recently it doesn’t work and I can’t access intellisense (and hence go to definition) in most of my own files.

General advice that may or may not help:

- Open the project as a folder in VS code, instead of individual files.
- Create an environment for your project and activate that in VS code
- If you are using modules, adopt a standard package structure - e.g. using `PkgTemplates.jl`.

---

<div class="post-metadata">

**Author:** ![joa-quim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joa-quim/32/227_2.png) [@joa-quim](https://discourse.julialang.org/u/joa-quim)\
**Post date:** [March 1, 2023, 1:49pm UTC](https://discourse.julialang.org/t/go-to-definition-almost-never-works/95363/6 "2023-03-01T13:49:23Z")

</div>

Not immediately, and if fact I’m not exactly sure what made it work but I think it was the fact that I `include("testa.jl")` in the module and in the VSC repl I did a `using *package*`

 ![image](https://global.discourse-cdn.com/julialang/original/3X/b/8/b84043e188963313856929deba1f34888f8ea4e8.png)

---

<div class="post-metadata">

**Author:** ![evan-wehi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/evan-wehi/32/32692_2.png) [@evan-wehi](https://discourse.julialang.org/u/evan-wehi)\
**Post date:** [March 1, 2023, 10:32pm UTC](https://discourse.julialang.org/t/go-to-definition-almost-never-works/95363/7 "2023-03-01T22:32:11Z")

</div>

I’ll give those things a try (I already do the first one). But it seems, that is at best temperamental and unreliable.

---

<div class="post-metadata">

**Author:** ![evan-wehi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/evan-wehi/32/32692_2.png) [@evan-wehi](https://discourse.julialang.org/u/evan-wehi)\
**Post date:** [March 1, 2023, 10:32pm UTC](https://discourse.julialang.org/t/go-to-definition-almost-never-works/95363/8 "2023-03-01T22:32:59Z")

</div>

Interestingly, in my case if the change the type from an abstract type to a struct, it suddenly works.

I think I will raise an issue.

---

<div class="post-metadata">

**Author:** ![Christopher\_Fisher](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/christopher_fisher/32/26132_2.png) [@Christopher\_Fisher](https://discourse.julialang.org/u/Christopher_Fisher)\
**Post date:** [March 1, 2023, 11:45pm UTC](https://discourse.julialang.org/t/go-to-definition-almost-never-works/95363/9 "2023-03-01T23:45:32Z")

</div>

Unfortunately, this has been a longstanding issue for me. I reported this [issue](https://github.com/julia-vscode/julia-vscode/issues/2339) in 2021.

---

<div class="post-metadata">

**Author:** ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Post date:** [March 2, 2023, 9:30am UTC](https://discourse.julialang.org/t/go-to-definition-almost-never-works/95363/10 "2023-03-02T09:30:28Z")

</div>

I think the main, underlying issue is the lack of documentation of the StaticLint, see: [Request for a more specific example or documentation on StaticLint · Issue #310 · julia-vscode/StaticLint.jl · GitHub](https://github.com/julia-vscode/StaticLint.jl/issues/310)

If StaticLint would be better documented and could be used and tested stand-alone more people would test it and contribute, and these issues would get fixed faster …

---

<div class="post-metadata">

**Author:** ![evan-wehi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/evan-wehi/32/32692_2.png) [@evan-wehi](https://discourse.julialang.org/u/evan-wehi)\
**Post date:** [May 23, 2023, 3:30am UTC](https://discourse.julialang.org/t/go-to-definition-almost-never-works/95363/11 "2023-05-23T03:30:26Z")

</div>

Another very simple example - unable to find the module in the module project. It’s also unable to find the definition of `greet`.

 ![image](https://global.discourse-cdn.com/julialang/original/3X/a/1/a176eebf3504d02131a915100abb1858971050f6.png)

---

<div class="post-metadata">

**Author:** ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Post date:** [May 23, 2023, 4:52am UTC](https://discourse.julialang.org/t/go-to-definition-almost-never-works/95363/12 "2023-05-23T04:52:32Z")

</div>

> [@LSP "Missing reference" woes](https://discourse.julialang.org/t/lsp-missing-reference-woes/98231/16):
>
> First, be aware it’s very hacky and messes up a bit with inline evaluation (which I don’t use much because I actually use Emacs for my day-to-day work). But let me try and give a step-by-step procedure that demonstrates this trick on a simple package like Example.jl. You should be able to reproduce this on your system. First, git clone https://github.com/JuliaLang/Example.jl, open the project in VSCode and add a script.jl file at its root. It should look like this: Example.jl ├── Project.toml …

Possible solution…

---

<div class="post-metadata">

**Author:** ![evan-wehi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/evan-wehi/32/32692_2.png) [@evan-wehi](https://discourse.julialang.org/u/evan-wehi)\
**Post date:** [May 24, 2023, 3:02am UTC](https://discourse.julialang.org/t/go-to-definition-almost-never-works/95363/13 "2023-05-24T03:02:32Z")

</div>

Thanks - that did fix that particular issue. It’s not an obvious workaround (at least to me) and doesn’t address the bigger issue that navigation is unreliable.

---

<div class="post-metadata">

**Author:** ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Post date:** [May 24, 2023, 3:13am UTC](https://discourse.julialang.org/t/go-to-definition-almost-never-works/95363/14 "2023-05-24T03:13:02Z")

</div>

I certainly agree. I use Sublime Text with its search facilities based on indexing. That works rather well.
