lsp: doc.language_server() is None until initialize completes

This commit is contained in:
Blaž Hrastnik 2021-09-02 13:55:55 +09:00
parent 46f3c69f06
commit 37606bad47
2 changed files with 15 additions and 2 deletions

View File

@ -93,6 +93,10 @@ fn value_into_params(value: Value) -> jsonrpc::Params {
} }
} }
pub fn is_initialized(&self) -> bool {
self.capabilities.get().is_some()
}
pub fn capabilities(&self) -> &lsp::ServerCapabilities { pub fn capabilities(&self) -> &lsp::ServerCapabilities {
self.capabilities self.capabilities
.get() .get()

View File

@ -798,9 +798,18 @@ pub fn version(&self) -> i32 {
self.version self.version
} }
#[inline]
pub fn language_server(&self) -> Option<&helix_lsp::Client> { pub fn language_server(&self) -> Option<&helix_lsp::Client> {
self.language_server.as_deref() let server = self.language_server.as_deref();
let initialized = server
.map(|server| server.is_initialized())
.unwrap_or(false);
// only resolve language_server if it's initialized
if initialized {
server
} else {
None
}
} }
#[inline] #[inline]