fwcd / kotlin-language-server

Kotlin code completion, diagnostics and more for any editor/IDE using the Language Server Protocol
MIT License
1.68k stars 212 forks source link

Bazel support #199

Open igorgatis opened 4 years ago

igorgatis commented 4 years ago

Any thoughts on Bazel support?

igorgatis commented 4 years ago

If I understood the code correctly, KotlinLanguageServer keeps a single compiler instance which has a global view of sources and classpaths. That is, two independent kotlin/java modules will see symbols from each other as if they were part of the same module or classpath. Is this correct? Also, I'm guessing that the Koltin compiler instance is resource expensive. Right?

One possible approach is to add each Bazel target as a workspace root. In fact, that's the approach I invested some time so far.

Another approach avoid "symbol leak" by creating separated "Compilation Environments", one for each independent module (e.g. one for each Bazel Target). To lower resource consumption, Language Server could keep a handful of compiler instances up and assign Compilation Environments as needed in a LRU fashion. Does that make sense?

refi64 commented 4 years ago

In fact, that's the approach I invested some time so far.

Out of curiosity, do you have anything publicly available, or was it just more planning / very early work?

igorgatis commented 4 years ago

Very early work and unfinished. Nothing published yet.

pierreis commented 4 years ago

@Igorgatis Pinging on this topic. Is there anything we can do to help posting this forward?

igorgatis commented 4 years ago

Sorry, no progress made. My company ended up using Intellij with Bazel plugin which is still far from a good IDE experience with Bazel.

chipsenkbeil commented 3 years ago

Bummer, was hoping there was some progress here or a magical way for bazel to generate something to help this language server work. As of now, I have a variety of dependencies that aren't detecting when starting this language server, presumably because it is not aware of the needed dependencies since it does not process bazel BUILD files among other configs.

cwlbraa commented 1 year ago

bit of a dead thread, but just confirming this is still desirable and missing in late 2023 if somebody wants to figure it out

smocherla-brex commented 7 months ago

I have somewhat of a working prototype that has Bazel support. The thoughts behind my approach are:

It's not perfect at this point and some details still need to be resolved but it is moderately usable at this point. If anyone else has thoughts or there's interest in taking a look at a PR, I'd be happy to bring it forward.