Missing references when working on include-files (e.g. in Emacs via julia-mode)

I finally switched to Emacs after being a hardcore Vim user for more than 23 years… and yes, I admit, Emacs is a better software (but I am still evil). I am using the Doom Emacs configuration and quite happy with the Julia support which works out of the box (https://github.com/hlissner/doom-emacs/tree/develop/modules/lang/julia)
The LSP server works more or less fine (I still experience some lags here and there) and it’s way better than any other setup I hacked together in the past in Vim. That’s also true for other languages I work with.

…but one thing is still annoying: missing references when I work on Julia packages which spread over multiple include files, mainly caused by not having activated the right project.

For example, most of my packages have some main entry point in src/PackageName.jl where I define the module and include() different sources – that seems to be a nice pattern and is used all over the place. When I however open those includes, the LSP does not find any references which are defined in other files. It seems to only care about the file I am working on and shows tons of Missing reference errors.

In Python for example I usually call M-x pyvenv-activate with the virtual environment which is located inside each projects folder and from the context is correct and the references are found.

In Julia I only found these settings:

(setq lsp-julia-default-environment "~/.julia/environments/v1.0")
(setq lsp-julia-package-dir nil)

but they do not play a role when already working inside Emacs, so I cannot switch between projects. Btw. I also did not manage to get it working with my own LanguageServer installation due to several dependency limitations (it only supports v1 and some other dependencies needs to be downgraded as well etc.).

My question is, how did you set this up? Is there a setting I miss or how do you activate the Projects so that LSP can deal with it?

I have the feeling I am a bit cursed with this IDE stuff in whatever editor I work with :wink:

EDIT: I am aware that one can also run the LanguageServer manually, pointing it to the project but I don’t understand how to set this up in Emacs:

using LanguageServer

server = LanguageServerInstance(stdin, stdout, false, "/path/to/environment")

I already raised a issue here https://github.com/non-Jedi/lsp-julia/issues/25.

1 Like