deno: wire up LSP settings (#14410)

Currently deno lsp only works because deno have a workaround when it
detects deno.json it gets activated, but without a deno.json it won't
work
With this change now it works correctly regardless of a deno.json
presence, it only require enable:true:


```json
{
  "lsp": {
    "deno": {
      "settings": {
        "deno": {
          "enable": true
        }
      }
    }
  }
}
```


Release Notes:

- Improved initial Deno set-up to enable it without explicit deno.json present in the file system
This commit is contained in:
Bedis Nbiba 2024-07-13 19:10:36 +01:00 committed by GitHub
parent 3a410942b4
commit e5dc6beace
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,6 +1,7 @@
use std::fs;
use zed::lsp::CompletionKind;
use zed::{serde_json, CodeLabel, CodeLabelSpan, LanguageServerId};
use zed_extension_api::settings::LspSettings;
use zed_extension_api::{self as zed, Result};
struct DenoExtension {
@ -117,6 +118,18 @@ impl zed::Extension for DenoExtension {
})))
}
fn language_server_workspace_configuration(
&mut self,
_language_server_id: &zed::LanguageServerId,
worktree: &zed::Worktree,
) -> Result<Option<serde_json::Value>> {
let settings = LspSettings::for_worktree("deno", worktree)
.ok()
.and_then(|lsp_settings| lsp_settings.settings.clone())
.unwrap_or_default();
Ok(Some(settings))
}
fn label_for_completion(
&self,
_language_server_id: &LanguageServerId,