deno: wire up LSP settings (#14410)

Bedis Nbiba created

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

Change summary

extensions/deno/src/deno.rs | 13 +++++++++++++
1 file changed, 13 insertions(+)

Detailed changes

extensions/deno/src/deno.rs 🔗

@@ -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,