Tidy up LSP (#17973)

Release Notes:

- N/A
This commit is contained in:
Conrad Irwin 2024-09-18 11:15:46 -06:00 committed by GitHub
parent eda7e88fd4
commit 826777a257
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 14 additions and 27 deletions

View file

@ -38,7 +38,7 @@ impl LspAdapter for ExtensionLspAdapter {
fn get_language_server_command<'a>(
self: Arc<Self>,
_: Arc<Path>,
_: Option<Arc<Path>>,
delegate: Arc<dyn LspAdapterDelegate>,
_: futures::lock::MutexGuard<'a, Option<LanguageServerBinary>>,
_: &'a mut AsyncAppContext,

View file

@ -208,7 +208,7 @@ impl CachedLspAdapter {
pub async fn get_language_server_command(
self: Arc<Self>,
container_dir: Arc<Path>,
container_dir: Option<Arc<Path>>,
delegate: Arc<dyn LspAdapterDelegate>,
cx: &mut AsyncAppContext,
) -> Result<LanguageServerBinary> {
@ -294,7 +294,7 @@ pub trait LspAdapter: 'static + Send + Sync {
fn get_language_server_command<'a>(
self: Arc<Self>,
container_dir: Arc<Path>,
container_dir: Option<Arc<Path>>,
delegate: Arc<dyn LspAdapterDelegate>,
mut cached_binary: futures::lock::MutexGuard<'a, Option<LanguageServerBinary>>,
cx: &'a mut AsyncAppContext,
@ -325,6 +325,10 @@ pub trait LspAdapter: 'static + Send + Sync {
return Ok(cached_binary.clone());
}
let Some(container_dir) = container_dir else {
anyhow::bail!("cannot download language servers for remotes (yet)")
};
if !container_dir.exists() {
smol::fs::create_dir_all(&container_dir)
.await
@ -1664,7 +1668,7 @@ impl LspAdapter for FakeLspAdapter {
fn get_language_server_command<'a>(
self: Arc<Self>,
_: Arc<Path>,
_: Option<Arc<Path>>,
_: Arc<dyn LspAdapterDelegate>,
_: futures::lock::MutexGuard<'a, Option<LanguageServerBinary>>,
_: &'a mut AsyncAppContext,

View file

@ -869,12 +869,10 @@ impl LanguageRegistry {
adapter.name.0
);
let download_dir = &self
.language_server_download_dir
.clone()
.ok_or_else(|| anyhow!("language server download directory has not been assigned before starting server"))
.log_err()?;
let container_dir: Arc<Path> = Arc::from(download_dir.join(adapter.name.0.as_ref()));
let container_dir: Option<Arc<Path>> = self
.language_server_download_dir
.as_ref()
.map(|dir| Arc::from(dir.join(adapter.name.0.as_ref())));
let root_path = root_path.clone();
let this = Arc::downgrade(self);
@ -969,7 +967,7 @@ impl LanguageRegistry {
Some(PendingLanguageServer {
server_id,
task,
container_dir: Some(container_dir),
container_dir,
})
}

View file

@ -4742,17 +4742,6 @@ impl LspStore {
.reorder_language_servers(&language, enabled_lsp_adapters);
}
/*
ssh client owns the lifecycle of the language servers
ssh host actually runs the binaries
in the future: ssh client will use the local extensions to get the downloads etc.
and send them up over the ssh connection (but today) we'll just the static config
languages::() <-- registers lsp adapters
on the ssh host we won't have adapters for the LSPs
*/
fn start_language_server_on_ssh_host(
&mut self,
worktree: &Model<Worktree>,

View file

@ -42,11 +42,7 @@ impl HeadlessProject {
}
pub fn new(session: Arc<SshSession>, fs: Arc<dyn Fs>, cx: &mut ModelContext<Self>) -> Self {
let mut languages = LanguageRegistry::new(cx.background_executor().clone());
languages
.set_language_server_download_dir(PathBuf::from("/Users/conrad/what-could-go-wrong"));
let languages = Arc::new(languages);
let languages = Arc::new(LanguageRegistry::new(cx.background_executor().clone()));
let worktree_store = cx.new_model(|_| WorktreeStore::new(true, fs.clone()));
let buffer_store = cx.new_model(|cx| {