You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If a file changes on disk/outside of neovim, it seems like neovim's buffers or "view" of the file becomes out of sync with the new content. The LSP client reports inaccurate diagnostics, semantic highlighting, completion, etc.
Furthermore, reloading the file (e.g. through :e) doesn't resolve the problem. It's like the buffer or lsp state becomes "stuck" at where it was before the file was changed outside of neovim.
I haven't found a workaround aside from restarting neovim.
Although I only have encountered this with the tsserver LSP, I believe it is a neovim client bug since even restarting the tsserver LSP does not fix the inaccurate diagnostics until neovim itself is restarted.
Steps to reproduce using "nvim -u minimal_init.lua"
Make sure you have typescript-language-server installed globally
clone the repro: git clone git@github.com:jacksonludwig/nvimlsprepro.git
cd nvimlsprepro
run npm i to install typescript locally
use the minimal config to open the typescript file: nvim -u minimal_init.lua index.ts
move to line 8
copy/paste the line (e.g. yyp)
delete one of the quotes in the console.log('stuff') so you're left with console.log(stuff'). Notice the errors reported here so far are accurate and expected.
save the file with :w
open a terminal and stash your changes: :sp | term, then git stash
go back to the buffer with the index.ts file
run :e to re-read from disk and update the buffer contents
Notice that the diagnostics are no longer accurate. Making other changes results in continued inaccurate diagnostics.
Expected behavior
LSP client should report diagnostics consistent with the current buffer contents.
jacksonludwig
changed the title
Buffer becomes out of sync with LSP if file changes outside of neovim
Buffer becomes out of sync with language server if file changes outside of neovim
Dec 9, 2023
In 0.9 neovim doesn't enable the lsp file watching mechanism by default, so the language server doesn't get notified about changes happening outside of neovim.
You can enable the mechanism by setting the following client capabilities:
For 0.10/nightly it's currently enabled by default, but that may still change before the release - depending on #23291
Furthermore, reloading the file (e.g. through :e) doesn't resolve the problem. It's like the buffer or lsp state becomes "stuck" at where it was before the file was changed outside of neovim.
This sounds a bit more like a language server problem, and related to #26131
Most other servers do re-publish diagnostics on :e.
Uh oh!
There was an error while loading. Please reload this page.
Problem
If a file changes on disk/outside of neovim, it seems like neovim's buffers or "view" of the file becomes out of sync with the new content. The LSP client reports inaccurate diagnostics, semantic highlighting, completion, etc.
Furthermore, reloading the file (e.g. through
:e
) doesn't resolve the problem. It's like the buffer or lsp state becomes "stuck" at where it was before the file was changed outside of neovim.I haven't found a workaround aside from restarting neovim.
Although I only have encountered this with the
tsserver
LSP, I believe it is a neovim client bug since even restarting thetsserver
LSP does not fix the inaccurate diagnostics until neovim itself is restarted.Steps to reproduce using "nvim -u minimal_init.lua"
typescript-language-server
installed globallygit clone git@github.com:jacksonludwig/nvimlsprepro.git
nvimlsprepro
npm i
to install typescript locallynvim -u minimal_init.lua index.ts
yyp
)console.log('stuff')
so you're left withconsole.log(stuff')
. Notice the errors reported here so far are accurate and expected.:w
:sp | term
, thengit stash
index.ts
file:e
to re-read from disk and update the buffer contentsExpected behavior
LSP client should report diagnostics consistent with the current buffer contents.
Neovim version (nvim -v)
stable 0.9.4
Language server name/version
typscript-language-server 4.1.3
Operating system/version
ubuntu 20.04
Log file
https://gist.github.com/jacksonludwig/227a4f33cceeb67624e474b837bf98aa
The text was updated successfully, but these errors were encountered: