zed-extensions / java

Extension for Zed to support Java
40 stars 6 forks source link

Not working -> auto imports, completion, documentation on linux #20

Open SaiKamalP opened 3 days ago

SaiKamalP commented 3 days ago
  1. Suggestions are shown, but nothing is added as import on hitting enter, only the word is completed.

https://github.com/user-attachments/assets/5baffcdc-fab0-460b-8fdd-60559462c448

  1. There is no documentation being shown on side for the Completion list.

See VS Code for example shows it.

https://github.com/user-attachments/assets/93d891bd-b13c-4a76-85ec-10bc2d67102e

  1. No auto completion of any kind.

refer this -> https://github.com/ABckh/zed-java-eclipse-jdtls/issues/35 (same issue with this extension)

both of these (this and https://github.com/ABckh/zed-java-eclipse-jdtls) seem to use jdtls which is the same as what VS Code/ eclipse is using.

I see that this problem is not there in zed for C++ with clang, everything above is working as expected.

Observation from LSP logs:

  1. I see that eclipse.jdtls lsp didn't return additionalTextEdits, documentation, editText on completionItem/resolve request.
  2. From Zed source code I see
    image

These properties are marked for lazy evaluation and hence must be resolved lazily with completionItem/resolve request instead of textDocument/completion. Which didn't happen, (They are present in neither of those responses).

On changing commenting out the additionalTextEdits line (marking it not for lazy resolve), I managed to get additionalTextEdits in both completionItem/resolve and textDocument/completion, which made auto import work.

But I am not able to make any progress on documentation. (because documentation is by default lazy evaluated?!)

for textEditTexts they seem to be provided in textDocument/completion but not in completionItem/resolve.

I am not sure is this an issue with JDTLS or Zed. Knowing that many editors using JDTLS work fine, I suspect the issue has to be from Zed side.

my system details

OS: Fedora release 41 (Forty One) x86_64 Kernel: 6.11.6-300.fc41.x86_64 openjdk 23.0.1 2024-10-15 OpenJDK Runtime Environment (Red_Hat-23.0.1.0.11-1) (build 23.0.1+11) OpenJDK 64-Bit Server VM (Red_Hat-23.0.1.0.11-1) (build 23.0.1+11, mixed mode, sharing)

I also have src, devel packages installed. and JAVA_HOME variable set.

valentinegb commented 3 days ago

Thanks very much for looking into this! I am aware that JDTLS doesn't exactly use normal LSP, it uses its own extension of it, so I think you could blame JDTLS for weirdness. However, it's unlikely they would consider this a bug and change the behavior. The VSCode extension, for example, works because it implements LSP and the JDTLS extension of LSP completely from the ground up, specifically tailored to JDTLS. Zed, meanwhile, uses standard LSP, and is not implemented per extension. Zed may allow its extensions to implement LSP extensions in the future I think, but it doesn't right now, so probably the only way to fix these issues soon would be to handle JDTLS specifically in Zed itself (kinda like how Rust isn't an extension, it's handled by Zed itself). I'm not sure if the Zed maintainers would want to do that, but you could open an issue and pitch the idea if you'd like!