kakoune-lsp / kakoune-lsp

Kakoune Language Server Protocol Client
The Unlicense
601 stars 114 forks source link

Java Eclipse LSP stops responding to kak-lsp command after enter insert mode. #700

Closed yuan-kuan closed 10 months ago

yuan-kuan commented 10 months ago

Hello!

Just yesterday, I am starting to learn Java for a new project, thus setting up my Kakoune for Java development. So, I never run any Java LSP before and I am installing everything latest:

I have managed to run the Java-lsp with both the jdtls script and the recommended way of doing java with a bunch of arguments. Both gave me the same issue. I will list out my observations. Note that I have been observing the kak-lsp log and the .log file spawned by jdtls in the data folder.

  1. From a freshly started Kakoune. I open a .java file from a Java project.
  2. LSP runs. I can do the following without issue: check capabilities, go to definition, hover, view diagnostic, view references.
  3. Once I enter insert mode. Things got silent:
  4. no new event was observed in the kak-lsp log (the enter insert mode did not fire anything?)
  5. java LSP is running without error or freezing. It did not get any new event from the insert mode, and everything after.
  6. When I exit insert mode and try to do all the stuff I did in point 2, nothing show up in the IDE. kak-lsp still sent out the event, but Java LSP does not seemed to receiving any.
  7. The only command that work? Quit the Java LSP. That works. Java LSP will respond to that.
  8. When I trigger any LSP action in Kakoune again, the whole process repeat. from point 1.

With the same session of Kakoune, my Dart LSP is working flawlessly. I can enter insert mode, come out and continue working with Dart files. One thing I observed from Dart LSP is, whenever I enter insert mode, kak-LSP will create a new event. I did not observe this with Java LSP.

I hope I have provided enough information here. Please tell me if anything else is needed. Or this is an issue with jdtls instead? I have tried the older version but still seeing the same issue.

krobelus commented 10 months ago

Using the same versions, I can't reproduce on a Java project that contains only one file test.java:

class test {
  public static void main(String[] args) {
    foo();
  }

  static void foo() {}
}

I get completions in insert mode and everything still works fine after insert mode.

  1. no new event was observed in the kak-lsp log (the enter insert mode did not fire anything?)

On i, the only thing that should be sent is signatureHelp. But every subsequent key should (after 50ms) send a didChange notification to the server. If that doesn't happen there is something seriously wrong that should show up in the kak-lsp log, so if none of the below helps please include the log.

  1. The only command that work? Quit the Java LSP. That works. Java LSP will respond to that.

Quit as in pkill -f jdtls? Could also run lsp-disable, wait a few milliseconds, then run lsp-enable to restart it.

Couple things to try:

  1. Can you repro with an empty config with this command -- I just pushed a commit to use the jdtls wrapper script by default, so pull first.
HOME=$(mktemp -d) kak -e '
    eval %sh{kak-lsp --kakoune -s $kak_session}
    set global lsp_cmd "kak-lsp -s %val{session} -vvvv --log /tmp/kak-lsp.log"
    lsp-enable'
  1. Can you send me a project where I can repro?

  2. After the bug happens, is there anything in the *debug* buffer.

  3. Figure out how to access the jdtls log file. If it logs to stderr that should show up in kak-lsp's log but most servers use a file.


The only things that don't work for me are code actions/code lenses because this server doesn't implement the workspace/executeCommand interface..

yuan-kuan commented 10 months ago

My problem is solved. @krobelus, thank you for the quick assist and your detailed reply. I am sure you are wondering what could have solved my case, I was surprised too. All I did is to include lsp-enable into my kakrc, after learning the way you started Kakoune and kak-lsp:

# LSP enabling
eval %sh{kak-lsp --kakoune -s $kak_session}
# set global lsp_cmd "kak-lsp -s %val{session} -vvv --log /tmp/kak-lsp.log"
lsp-enable   # <--- I just added this

I realized my Java LSP kept working after I tried to restart it with :lsp-enable instead of doing my usual :lsp-capacities via user mode. Which led me to add this lsp-enable into my kakrc.

How I survived without lsp-enable with my Dart development is the story of another day. But with it now, I can have my Java LSP running without becoming unresponsive.