Open anthony-S93 opened 2 years ago
You're using nvim-lspconfig. I use nvim-jdtls and that is not an issue. Check my config files: ftplugin/java.lua and lua/lbrayner/jdtls.lua.
I start the language server with a buffer local command JdtlsStart
, which uses some goodies from nvim-lspconfig.
I think this is a duplicate of https://github.com/eclipse/eclipse.jdt.ls/issues/1815
Hello, I'm using JDTLS on Neovim v0.7.2, mostly in single-file mode. I don't need all of JDTLS features, just the basic code completion, diagnostics, etc.
Everything works perfectly as long as I open an existing .java file with neovim:
Code completion and diagnostics work as expected whenever I open an exiting java file for editing.
However, problems emerged whenever I created new buffers in the same Neovim instance, say, by running
:e NewFile.java
After creating that new buffer, I ran
:LspInfo
to check if the server was attached:And as you can see, file detection works and the server was indeed attached and running, yet basic features like diagnostics, suggestions, and autocomplete did not work for that new buffer (
NewFile.java
)In the screenshot below, I spelled
import
halfway and waited for the floating window to appear to no avail.When I switched back to the previous file
CurrentFile.java
, the server was still functioning normally.I even tried saving the file first by running
:w
, but that didn't help also. There are only two ways to get it to function. The first is by closing that buffer and then opening it again with:e NewFile.java
(this is just the same as opening an existing file). The second way is by running theLspRestart
command followed byLspStart
. I've tested it many times, these are the only two ways to make it work.Here is what
LspLog
has to say:I'm running jdtls' latest build, which I curled from https://download.eclipse.org/jdtls/snapshots/jdt-language-server-latest.tar.gz I have not done sufficient tests to know whether other builds have the same problem.