lsp: Add support for workspace/workspaceFolders request (#17639)
Related to: #17574 Release Notes: - N/A
This commit is contained in:
parent
56bc3c36ad
commit
75256bdfe1
1 changed files with 25 additions and 1 deletions
|
@ -40,7 +40,7 @@ use lsp::{
|
||||||
CompletionContext, DiagnosticSeverity, DiagnosticTag, DidChangeWatchedFilesRegistrationOptions,
|
CompletionContext, DiagnosticSeverity, DiagnosticTag, DidChangeWatchedFilesRegistrationOptions,
|
||||||
Edit, FileSystemWatcher, InsertTextFormat, LanguageServer, LanguageServerBinary,
|
Edit, FileSystemWatcher, InsertTextFormat, LanguageServer, LanguageServerBinary,
|
||||||
LanguageServerId, LspRequestFuture, MessageActionItem, MessageType, OneOf, ServerHealthStatus,
|
LanguageServerId, LspRequestFuture, MessageActionItem, MessageType, OneOf, ServerHealthStatus,
|
||||||
ServerStatus, SymbolKind, TextEdit, WorkDoneProgressCancelParams,
|
ServerStatus, SymbolKind, TextEdit, Url, WorkDoneProgressCancelParams, WorkspaceFolder,
|
||||||
};
|
};
|
||||||
use parking_lot::{Mutex, RwLock};
|
use parking_lot::{Mutex, RwLock};
|
||||||
use postage::watch;
|
use postage::watch;
|
||||||
|
@ -4774,6 +4774,30 @@ impl LspStore {
|
||||||
})
|
})
|
||||||
.detach();
|
.detach();
|
||||||
|
|
||||||
|
let id = language_server.server_id();
|
||||||
|
language_server
|
||||||
|
.on_request::<lsp::request::WorkspaceFoldersRequest, _, _>({
|
||||||
|
let this = this.clone();
|
||||||
|
move |_, mut cx| {
|
||||||
|
let this = this.clone();
|
||||||
|
async move {
|
||||||
|
let Some(server) =
|
||||||
|
this.update(&mut cx, |this, _| this.language_server_for_id(id))?
|
||||||
|
else {
|
||||||
|
return Ok(None);
|
||||||
|
};
|
||||||
|
let root = server.root_path();
|
||||||
|
let Ok(uri) = Url::from_file_path(&root) else {
|
||||||
|
return Ok(None);
|
||||||
|
};
|
||||||
|
Ok(Some(vec![WorkspaceFolder {
|
||||||
|
uri,
|
||||||
|
name: Default::default(),
|
||||||
|
}]))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.detach();
|
||||||
// Even though we don't have handling for these requests, respond to them to
|
// Even though we don't have handling for these requests, respond to them to
|
||||||
// avoid stalling any language server like `gopls` which waits for a response
|
// avoid stalling any language server like `gopls` which waits for a response
|
||||||
// to these requests when initializing.
|
// to these requests when initializing.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue