From 697a0025d56d0381bfb1fd6f8eb284a1737aea59 Mon Sep 17 00:00:00 2001 From: meredith Date: Sun, 5 Mar 2023 14:00:46 -0600 Subject: [PATCH] fix(lsp): Request document sync on open/close Without sending `open_close: true` to the client, it may not issue an `textDocument/didOpen` event with document text to allow the diagnostics and text cache to be initialized after opening, but prior to editing, the document. Format requests also emit "Format request arrived before text synchronized" in this state. The didClose event probably also doesn't arrive to see cache entries removed. Observed in neovim 0.8.3 using internal client, while vim with prabirshrestha/vim-lsp sends the event regardless (but does not currently issue didClose). --- lib/standard/lsp/routes.rb | 3 ++- test/standard/runners/lsp_test.rb | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/standard/lsp/routes.rb b/lib/standard/lsp/routes.rb index b8bed922..796d5ae7 100644 --- a/lib/standard/lsp/routes.rb +++ b/lib/standard/lsp/routes.rb @@ -30,7 +30,8 @@ def for(name) diagnostic_provider: true, execute_command_provider: true, text_document_sync: Proto::Interface::TextDocumentSyncOptions.new( - change: Proto::Constant::TextDocumentSyncKind::FULL + change: Proto::Constant::TextDocumentSyncKind::FULL, + open_close: true ) ) )) diff --git a/test/standard/runners/lsp_test.rb b/test/standard/runners/lsp_test.rb index d6bf5d24..cc436280 100644 --- a/test/standard/runners/lsp_test.rb +++ b/test/standard/runners/lsp_test.rb @@ -16,7 +16,7 @@ def test_server_initializes_and_responds_with_proper_capabilities assert_equal msgs.first, { id: 2, result: {capabilities: { - textDocumentSync: {change: 1}, + textDocumentSync: {openClose: true, change: 1}, documentFormattingProvider: true, diagnosticProvider: true, executeCommandProvider: true