That is easy: split your codebase into packages.
I did this, but code introspection was flaky across packages. Sometimes it worked, sometimes not, and I spent a lot of time trying different configurations so that symbols would be indexed properly (dev the package, e.g., using if defined include tricks). Splitting into packages creates well-defined interfaces, but you still may need to look into those packages for a variety of reasons.
Iām not a Julia guru. But I would suggest that if I canāt figure it out, then probably a lot of others are in the same situation.
But Iām glad to see the issue is being addressed as you posted above. Somehow this wasnāt on my radar, and I casually followed the discourse.
Regardless, I believe Julia has tremendous promise for scientific programming. I think one reason for the slower adoption is the legacy of tooling problems that weāre all familiar with: time to first plot, unable to edit structures, no (usable) debugger, and code introspection.
A lot of these are addressed in some way (some better than others). But I wonder if these pain points scared away a lot of potential users for good.
Sure, but the problem still remains.
So to address the original question of āwhen should you expect the language server to work?ā: The following requirements must be satisfied
- Youāve selected the correct environment (check the
Julia env:status bar item) - Said environment is fully resolved and instantiated (i.e. thereās a Manifest.toml and the referenced packages are present in the depot)
- Youāre not working on a file in the
./testdirectory (yes, this is bad, we know)
Of course, this doesnāt guarantee that the LS will work (or work well). Common issues are
- a bug in our parser/linter, which may cause e.g. stack overflows that kill the LS process
- bad performance because of large āactiveā code bases. Note that 100kloc in a project arenāt necessarily an issue ā the VS Code extension contains ~270kloc of Julia code and the LS runs fine. Note, however, that
- changes to package dependencies are not readily propagated; they only affect the currently āactive file treeā instead (which is defined by
includes, not package dependencies). Dependencies, evendeved ones, are effectively treated as immutable. - macro support is very bad
- method table merging can sometimes be wonky, which is especially notable for re-exported methods and stuff like that
Then there are some anti-patterns that are flat-out not supported:
LOAD_PATHshenanigans- dynamically computed
includes
If the requirements stated above are satisfied and the LS isnāt working for you as expected, then please open an issue and make sure it includes any errors/warnings from the Output ā Julia Language Server pane as well as as much info about your environment as you can give ā ideally, your code base and the resolved environment (Project.toml + Manifest.toml).
While this is true, many of the problems with the current LanguageServer.jl ecosystem canāt be attributed to its static nature. But yes, JETLS.jl is the future ![]()
For me, as stated above, things like āGo to Definitionā work intermittently and for a seemingly random subset of the codebase. E.g. in one package Iām currently developing, inside one module there is a symbol from a different module in the same package that canāt be resolved right now. The other symbol from a third module next to it can, and there is no obvious difference between the two symbols/modules. There are no warnings in the Language Server logs. When I switched the selected environment to a different environment and then back, the symbol that canāt be resolved now was briefly resolved, I was even able to click on it, and it went to the correct definition, but a few seconds later that stopped working.
You can try to enable the julia.trace.server setting (set it to messages) and check the Output -> Julia Language Server Trace pane for slow requests. Itās very unlikely to show any root causes though, so
I donāt see any slow responses. The response seems to be āNo Definition Foundā. I canāt share my environment unfortunately. I will try to make a MRE.
In this simple example, when looking at Module3.jl the language server does not āseeā the definitions of Type1 and Type2 in the other two modules. While I was preparing the example, intermittently it could resolve both types or only one of the two, but not the other one, but right now it canāt resolve either one. Very strange, but hopefully this helps to narrow down the issue.
I know that it may be just a poor substitute for a fully-working LS, but VSCode provides access to symbols in workspaces. I use it quite often.