diff options
author | Blaž Hrastnik | 2021-09-02 04:55:08 +0000 |
---|---|---|
committer | Blaž Hrastnik | 2021-09-06 06:25:46 +0000 |
commit | 46f3c69f06cc55f36bcc6244a9f96c2481836dea (patch) | |
tree | 97c2a746ad1264cf171590673f14a4b8aea9672f /helix-term/src | |
parent | 2793ff383228403b1ebaf2a29c870a13ee76075a (diff) |
lsp: Don't send notifications until initialize completes
Then send open events for all documents with the LSP attached.
Diffstat (limited to 'helix-term/src')
-rw-r--r-- | helix-term/src/application.rs | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/helix-term/src/application.rs b/helix-term/src/application.rs index d3b65a4f..e21c5504 100644 --- a/helix-term/src/application.rs +++ b/helix-term/src/application.rs @@ -275,6 +275,37 @@ impl Application { }; match notification { + Notification::Initialized => { + let language_server = + match self.editor.language_servers.get_by_id(server_id) { + Some(language_server) => language_server, + None => { + warn!("can't find language server with id `{}`", server_id); + return; + } + }; + + let docs = self.editor.documents().filter(|doc| { + doc.language_server().map(|server| server.id()) == Some(server_id) + }); + + // trigger textDocument/didOpen for docs that are already open + for doc in docs { + // TODO: extract and share with editor.open + let language_id = doc + .language() + .and_then(|s| s.split('.').last()) // source.rust + .map(ToOwned::to_owned) + .unwrap_or_default(); + + tokio::spawn(language_server.text_document_did_open( + doc.url().unwrap(), + doc.version(), + doc.text(), + language_id, + )); + } + } Notification::PublishDiagnostics(params) => { let path = params.uri.to_file_path().unwrap(); let doc = self.editor.document_by_path_mut(&path); |