Closed aarondill closed 3 months ago
As a workaround, the user can set capabilities
to disable didChangeWatchedFiles
capabilities = { workspace = { didChangeWatchedFiles = { dynamicRegistration = false } } },
didChangeWatchedFiles
currently also breaks LSP formatting, since jdt will only format the file based on the state on disk, so you have to write the file before calling lsp.buf.format
or you risk improper formatting or even losing code (This has happened to me several times!)
The given example works fine for me. Diagnostics change without saving, and I have didChangeWatchedFiles
enabled. I also don't notice any difference between on/off in regards to how diagnostics update.
This also isn't really a nvim-jdtls issue as none of that is implemented in the plugin. It's either eclipse.jdt.ls or neovim core. Or you have a configuration issue, and there is something messed up with the client (not) attaching, or attaching multiple times.
I'd kinda rule out eclipse.jdt.ls itself, because vscode activates didChangeWatchedFiles
, and I'm pretty sure this also isn't an issue in vscode-java - otherwise it would've been reported and likely addressed.
didChangeWatchedFiles currently also breaks LSP formatting, since jdt will only format the file based on the state on disk, so you have to write the file before calling lsp.buf.format or you risk improper formatting or even losing code
I also can't reproduce this.
It's also not how LSP works - or is supposed to. Neovim constantly informs the server about changes in the buffer. The file changes are complementary to that, and should mostly be used by the server to deal with changes that happened outside of an editor. E.g. eclipse.jdt.ls will detect folder creation, which can then show up in move refactorings.
Using nvim -nu repro.lua File.java
and repeating the above repro directions results in all diagnostics disappearing on save.
Note that I am using nvim nightly
> nvim -V1 -v
NVIM v0.10.0-dev-2702+g0c0be09ea-dirty
Build type: RelWithDebInfo
LuaJIT 2.1.1710088188
Compilation: /usr/sbin/cc -O2 -g -Og -g -flto=auto -fno-fat-lto-objects -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wvla -Wdouble-promotion -Wmissing-noreturn -Wmissing-format-attribute -Wmissing-prototypes -fsigned-char -fstack-protector-strong -Wno-conversion -fno-common -Wno-unused-result -Wimplicit-fallthrough -fdiagnostics-color=always -DUNIT_TESTING -DHAVE_UNIBILIUM -D_GNU_SOURCE -DINCLUDE_GENERATED_DECLARATIONS -I/home/aaron/code/repos/neovim/.deps/usr/include/luajit-2.1 -I/home/aaron/code/repos/neovim/.deps/usr/include -I/home/aaron/code/repos/neovim/build/src/nvim/auto -I/home/aaron/code/repos/neovim/build/include -I/home/aaron/code/repos/neovim/build/cmake.config -I/home/aaron/code/repos/neovim/src -I/usr/include
system vimrc file: "$VIM/sysinit.vim"
fall-back for $VIM: "/usr/local/share/nvim"
Run :checkhealth for more info
Disabling didChangeWatchedFiles
fixed this issue temporarily for me, but I'm now re-encountering the issue; so it's not that. I'm closing this issue, since didChangeWatchedFiles isn't the core problem.
LSP client configuration
Eclipse.jdt.ls version
v1.33.0
Steps to Reproduce
a
tob
on line 5:w
b
toa
on line 5:w
Expected Result
The file should update in real-time as edited, not only on writes
Actual Result
The file diagnostics update only on writes. Note: using the default configuration, this is first noticeable in f3b916d6ee7bf526da78a628270a205f2ea9c32c:
because it changes capabilities to merge with
vim.lsp.protocol.make_client_capabilities()
, which includesworkspace.didChangeWatchedFiles.dynamicRegistration = true
Log file with
set_log_level(DEBUG)
(nothing looks important): https://pastebin.com/P87ftUZu