From 6faa9b7999ccf745bd7935066f1a95ac90f00d93 Mon Sep 17 00:00:00 2001
From: "blink-so[bot]" <211532188+blink-so[bot]@users.noreply.github.com>
Date: Mon, 11 Aug 2025 11:56:17 +0000
Subject: [PATCH 1/9] feat(zed): add settings input and README example for MCP
 servers

- Add optional settings input to write/merge ~/.config/zed/settings.json
- Document MCP servers example and settings.json path

Co-authored-by: Atif Ali <10648092+matifali@users.noreply.github.com>
---
 registry/coder/modules/zed/README.md | 26 +++++++++++++++++++++++
 registry/coder/modules/zed/main.tf   | 31 ++++++++++++++++++++++++++++
 2 files changed, 57 insertions(+)

diff --git a/registry/coder/modules/zed/README.md b/registry/coder/modules/zed/README.md
index 9ebf82c2..9a69cf48 100644
--- a/registry/coder/modules/zed/README.md
+++ b/registry/coder/modules/zed/README.md
@@ -62,3 +62,29 @@ module "zed" {
   agent_name = coder_agent.example.name
 }
 ```
+
+### Configure Zed settings including MCP servers
+
+Zed stores settings at `~/.config/zed/settings.json` by default. If `XDG_CONFIG_HOME` is set on Linux, settings will be at `$XDG_CONFIG_HOME/zed/settings.json`.
+
+You can declaratively set/merge settings with the `settings` input. For example, to configure MCP servers:
+
+```tf
+module "zed" {
+  count    = data.coder_workspace.me.start_count
+  source   = "registry.coder.com/coder/zed/coder"
+  version  = "1.0.1"
+  agent_id = coder_agent.example.id
+
+  settings = {
+    context_servers = {
+      your-mcp-server = {
+        source  = "custom"
+        command = "some-command"
+        args    = ["arg-1", "arg-2"]
+        env     = {}
+      }
+    }
+  }
+}
+```
diff --git a/registry/coder/modules/zed/main.tf b/registry/coder/modules/zed/main.tf
index 2f6376a4..544dab8d 100644
--- a/registry/coder/modules/zed/main.tf
+++ b/registry/coder/modules/zed/main.tf
@@ -50,7 +50,14 @@ variable "display_name" {
   default     = "Zed"
 }
 
+variable "settings" {
+  type        = any
+  description = "Optional object of Zed settings to write to settings.json (merged if jq is available)."
+  default     = {}
+}
+
 data "coder_workspace" "me" {}
+
 data "coder_workspace_owner" "me" {}
 
 locals {
@@ -60,6 +67,30 @@ locals {
   hostname       = var.agent_name != "" ? "${local.agent_name}.${local.workspace_name}.${local.owner_name}.coder" : "${local.workspace_name}.coder"
 }
 
+resource "coder_script" "zed_settings" {
+  agent_id     = var.agent_id
+  display_name = "Configure Zed settings"
+  icon         = "/icon/zed.svg"
+  run_on_start = true
+  script = <<-EOT
+    set -eu
+    SETTINGS_JSON='${replace(jsonencode(var.settings), "\"", "\\\"")}'
+    if [ "${SETTINGS_JSON}" = "{}" ] || [ -z "${SETTINGS_JSON}" ]; then
+      exit 0
+    fi
+    CONFIG_HOME="${XDG_CONFIG_HOME:-$HOME/.config}"
+    ZED_DIR="${CONFIG_HOME}/zed"
+    mkdir -p "${ZED_DIR}"
+    SETTINGS_FILE="${ZED_DIR}/settings.json"
+    if command -v jq >/dev/null 2>&1 && [ -s "${SETTINGS_FILE}" ]; then
+      tmpfile="$(mktemp)"
+      jq -s '.[0] * .[1]' "${SETTINGS_FILE}" <(printf '%s\n' "${SETTINGS_JSON}") > "${tmpfile}" && mv "${tmpfile}" "${SETTINGS_FILE}"
+    else
+      printf '%s\n' "${SETTINGS_JSON}" > "${SETTINGS_FILE}"
+    fi
+  EOT
+}
+
 resource "coder_app" "zed" {
   agent_id     = var.agent_id
   display_name = var.display_name

From 82afc43bbd7b3516480e888c0570d43fff6f1f9e Mon Sep 17 00:00:00 2001
From: "blink-so[bot]" <211532188+blink-so[bot]@users.noreply.github.com>
Date: Mon, 11 Aug 2025 12:01:36 +0000
Subject: [PATCH 2/9] fix(zed): escape shell vars in heredoc to satisfy
 terraform fmt

---
 registry/coder/modules/zed/main.tf | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/registry/coder/modules/zed/main.tf b/registry/coder/modules/zed/main.tf
index 544dab8d..e14b5ea8 100644
--- a/registry/coder/modules/zed/main.tf
+++ b/registry/coder/modules/zed/main.tf
@@ -75,18 +75,18 @@ resource "coder_script" "zed_settings" {
   script = <<-EOT
     set -eu
     SETTINGS_JSON='${replace(jsonencode(var.settings), "\"", "\\\"")}'
-    if [ "${SETTINGS_JSON}" = "{}" ] || [ -z "${SETTINGS_JSON}" ]; then
+    if [ "$${SETTINGS_JSON}" = "{}" ] || [ -z "$${SETTINGS_JSON}" ]; then
       exit 0
     fi
-    CONFIG_HOME="${XDG_CONFIG_HOME:-$HOME/.config}"
-    ZED_DIR="${CONFIG_HOME}/zed"
-    mkdir -p "${ZED_DIR}"
-    SETTINGS_FILE="${ZED_DIR}/settings.json"
-    if command -v jq >/dev/null 2>&1 && [ -s "${SETTINGS_FILE}" ]; then
+    CONFIG_HOME="$${XDG_CONFIG_HOME:-$HOME/.config}"
+    ZED_DIR="$${CONFIG_HOME}/zed"
+    mkdir -p "$${ZED_DIR}"
+    SETTINGS_FILE="$${ZED_DIR}/settings.json"
+    if command -v jq >/dev/null 2>&1 && [ -s "$${SETTINGS_FILE}" ]; then
       tmpfile="$(mktemp)"
-      jq -s '.[0] * .[1]' "${SETTINGS_FILE}" <(printf '%s\n' "${SETTINGS_JSON}") > "${tmpfile}" && mv "${tmpfile}" "${SETTINGS_FILE}"
+      jq -s '.[0] * .[1]' "$${SETTINGS_FILE}" <(printf '%s\n' "$${SETTINGS_JSON}") > "$${tmpfile}" && mv "$${tmpfile}" "$${SETTINGS_FILE}"
     else
-      printf '%s\n' "${SETTINGS_JSON}" > "${SETTINGS_FILE}"
+      printf '%s\n' "$${SETTINGS_JSON}" > "$${SETTINGS_FILE}"
     fi
   EOT
 }

From b971138e34ed14cf2f53fc99589ded4a85546198 Mon Sep 17 00:00:00 2001
From: "blink-so[bot]" <211532188+blink-so[bot]@users.noreply.github.com>
Date: Mon, 11 Aug 2025 12:02:58 +0000
Subject: [PATCH 3/9] style(zed): align heredoc assignment to satisfy terraform
 fmt

---
 registry/coder/modules/zed/main.tf | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/registry/coder/modules/zed/main.tf b/registry/coder/modules/zed/main.tf
index e14b5ea8..8ef8f538 100644
--- a/registry/coder/modules/zed/main.tf
+++ b/registry/coder/modules/zed/main.tf
@@ -72,7 +72,7 @@ resource "coder_script" "zed_settings" {
   display_name = "Configure Zed settings"
   icon         = "/icon/zed.svg"
   run_on_start = true
-  script = <<-EOT
+  script       = <<-EOT
     set -eu
     SETTINGS_JSON='${replace(jsonencode(var.settings), "\"", "\\\"")}'
     if [ "$${SETTINGS_JSON}" = "{}" ] || [ -z "$${SETTINGS_JSON}" ]; then

From 10c43e9f5d4e21612211e2de7084aed65acb94c3 Mon Sep 17 00:00:00 2001
From: "blink-so[bot]" <211532188+blink-so[bot]@users.noreply.github.com>
Date: Mon, 11 Aug 2025 12:09:56 +0000
Subject: [PATCH 4/9] chore(zed): review feedback\n\n- settings variable is a
 JSON string (use jsonencode)\n- update description per suggestion\n- README:
 link to Zed settings docs and jsonencode example

---
 registry/coder/modules/zed/README.md |  9 ++++++---
 registry/coder/modules/zed/main.tf   | 10 +++++-----
 2 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/registry/coder/modules/zed/README.md b/registry/coder/modules/zed/README.md
index 9a69cf48..32f01ea5 100644
--- a/registry/coder/modules/zed/README.md
+++ b/registry/coder/modules/zed/README.md
@@ -67,7 +67,7 @@ module "zed" {
 
 Zed stores settings at `~/.config/zed/settings.json` by default. If `XDG_CONFIG_HOME` is set on Linux, settings will be at `$XDG_CONFIG_HOME/zed/settings.json`.
 
-You can declaratively set/merge settings with the `settings` input. For example, to configure MCP servers:
+You can declaratively set/merge settings with the `settings` input. Provide a JSON string (e.g., via `jsonencode(...)`). For example, to configure MCP servers:
 
 ```tf
 module "zed" {
@@ -76,7 +76,7 @@ module "zed" {
   version  = "1.0.1"
   agent_id = coder_agent.example.id
 
-  settings = {
+  settings = jsonencode({
     context_servers = {
       your-mcp-server = {
         source  = "custom"
@@ -85,6 +85,9 @@ module "zed" {
         env     = {}
       }
     }
-  }
+  })
 }
 ```
+
+See Zed’s settings files documentation: https://zed.dev/docs/configuring-zed#settings-files
+
diff --git a/registry/coder/modules/zed/main.tf b/registry/coder/modules/zed/main.tf
index 8ef8f538..ec4fa7e3 100644
--- a/registry/coder/modules/zed/main.tf
+++ b/registry/coder/modules/zed/main.tf
@@ -51,9 +51,9 @@ variable "display_name" {
 }
 
 variable "settings" {
-  type        = any
-  description = "Optional object of Zed settings to write to settings.json (merged if jq is available)."
-  default     = {}
+  type        = string
+  description = "Optional object of Zed settings to write to settings.json"
+  default     = ""
 }
 
 data "coder_workspace" "me" {}
@@ -74,8 +74,8 @@ resource "coder_script" "zed_settings" {
   run_on_start = true
   script       = <<-EOT
     set -eu
-    SETTINGS_JSON='${replace(jsonencode(var.settings), "\"", "\\\"")}'
-    if [ "$${SETTINGS_JSON}" = "{}" ] || [ -z "$${SETTINGS_JSON}" ]; then
+    SETTINGS_JSON='${replace(var.settings, "\"", "\\\"")}'
+    if [ -z "$${SETTINGS_JSON}" ] || [ "$${SETTINGS_JSON}" = "{}" ]; then
       exit 0
     fi
     CONFIG_HOME="$${XDG_CONFIG_HOME:-$HOME/.config}"

From 02cd0ad9f7c285f86fa0795e3106ed2a0df09c91 Mon Sep 17 00:00:00 2001
From: "blink-so[bot]" <211532188+blink-so[bot]@users.noreply.github.com>
Date: Mon, 11 Aug 2025 12:11:13 +0000
Subject: [PATCH 5/9] style(zed): format README with Prettier

---
 registry/coder/modules/zed/README.md | 1 -
 1 file changed, 1 deletion(-)

diff --git a/registry/coder/modules/zed/README.md b/registry/coder/modules/zed/README.md
index 32f01ea5..104e2b1a 100644
--- a/registry/coder/modules/zed/README.md
+++ b/registry/coder/modules/zed/README.md
@@ -90,4 +90,3 @@ module "zed" {
 ```
 
 See Zed’s settings files documentation: https://zed.dev/docs/configuring-zed#settings-files
-

From 192c97261fdd3e498c40017f8d1ad20e94c798b6 Mon Sep 17 00:00:00 2001
From: "blink-so[bot]" <211532188+blink-so[bot]@users.noreply.github.com>
Date: Mon, 11 Aug 2025 13:54:04 +0000
Subject: [PATCH 6/9] chore: bump module versions (minor)

---
 registry/coder/modules/zed/README.md | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/registry/coder/modules/zed/README.md b/registry/coder/modules/zed/README.md
index 104e2b1a..13df988b 100644
--- a/registry/coder/modules/zed/README.md
+++ b/registry/coder/modules/zed/README.md
@@ -19,7 +19,7 @@ Zed is a high-performance, multiplayer code editor from the creators of Atom and
 module "zed" {
   count    = data.coder_workspace.me.start_count
   source   = "registry.coder.com/coder/zed/coder"
-  version  = "1.0.1"
+  version = "1.1.0"
   agent_id = coder_agent.example.id
 }
 ```
@@ -32,7 +32,7 @@ module "zed" {
 module "zed" {
   count    = data.coder_workspace.me.start_count
   source   = "registry.coder.com/coder/zed/coder"
-  version  = "1.0.1"
+  version = "1.1.0"
   agent_id = coder_agent.example.id
   folder   = "/home/coder/project"
 }
@@ -44,7 +44,7 @@ module "zed" {
 module "zed" {
   count        = data.coder_workspace.me.start_count
   source       = "registry.coder.com/coder/zed/coder"
-  version      = "1.0.1"
+  version = "1.1.0"
   agent_id     = coder_agent.example.id
   display_name = "Zed Editor"
   order        = 1
@@ -57,7 +57,7 @@ module "zed" {
 module "zed" {
   count      = data.coder_workspace.me.start_count
   source     = "registry.coder.com/coder/zed/coder"
-  version    = "1.0.1"
+  version = "1.1.0"
   agent_id   = coder_agent.example.id
   agent_name = coder_agent.example.name
 }
@@ -73,7 +73,7 @@ You can declaratively set/merge settings with the `settings` input. Provide a JS
 module "zed" {
   count    = data.coder_workspace.me.start_count
   source   = "registry.coder.com/coder/zed/coder"
-  version  = "1.0.1"
+  version = "1.1.0"
   agent_id = coder_agent.example.id
 
   settings = jsonencode({

From 2456ebfda5ac4a429a5d35d54c1f852d0a930f58 Mon Sep 17 00:00:00 2001
From: "blink-so[bot]" <211532188+blink-so[bot]@users.noreply.github.com>
Date: Mon, 11 Aug 2025 13:58:43 +0000
Subject: [PATCH 7/9] style(zed): format README with Prettier

---
 registry/coder/modules/zed/README.md | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/registry/coder/modules/zed/README.md b/registry/coder/modules/zed/README.md
index 13df988b..0137f879 100644
--- a/registry/coder/modules/zed/README.md
+++ b/registry/coder/modules/zed/README.md
@@ -19,7 +19,7 @@ Zed is a high-performance, multiplayer code editor from the creators of Atom and
 module "zed" {
   count    = data.coder_workspace.me.start_count
   source   = "registry.coder.com/coder/zed/coder"
-  version = "1.1.0"
+  version  = "1.1.0"
   agent_id = coder_agent.example.id
 }
 ```
@@ -32,7 +32,7 @@ module "zed" {
 module "zed" {
   count    = data.coder_workspace.me.start_count
   source   = "registry.coder.com/coder/zed/coder"
-  version = "1.1.0"
+  version  = "1.1.0"
   agent_id = coder_agent.example.id
   folder   = "/home/coder/project"
 }
@@ -44,7 +44,7 @@ module "zed" {
 module "zed" {
   count        = data.coder_workspace.me.start_count
   source       = "registry.coder.com/coder/zed/coder"
-  version = "1.1.0"
+  version  = "1.1.0"
   agent_id     = coder_agent.example.id
   display_name = "Zed Editor"
   order        = 1
@@ -57,7 +57,7 @@ module "zed" {
 module "zed" {
   count      = data.coder_workspace.me.start_count
   source     = "registry.coder.com/coder/zed/coder"
-  version = "1.1.0"
+  version  = "1.1.0"
   agent_id   = coder_agent.example.id
   agent_name = coder_agent.example.name
 }
@@ -73,7 +73,7 @@ You can declaratively set/merge settings with the `settings` input. Provide a JS
 module "zed" {
   count    = data.coder_workspace.me.start_count
   source   = "registry.coder.com/coder/zed/coder"
-  version = "1.1.0"
+  version  = "1.1.0"
   agent_id = coder_agent.example.id
 
   settings = jsonencode({

From 81613070387da3e563c0c70b041e844f022827fa Mon Sep 17 00:00:00 2001
From: "blink-so[bot]" <211532188+blink-so[bot]@users.noreply.github.com>
Date: Mon, 11 Aug 2025 14:01:08 +0000
Subject: [PATCH 8/9] style(zed): prettier README to satisfy CI

---
 registry/coder/modules/zed/README.md | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/registry/coder/modules/zed/README.md b/registry/coder/modules/zed/README.md
index 0137f879..989df54d 100644
--- a/registry/coder/modules/zed/README.md
+++ b/registry/coder/modules/zed/README.md
@@ -44,7 +44,7 @@ module "zed" {
 module "zed" {
   count        = data.coder_workspace.me.start_count
   source       = "registry.coder.com/coder/zed/coder"
-  version  = "1.1.0"
+  version      = "1.1.0"
   agent_id     = coder_agent.example.id
   display_name = "Zed Editor"
   order        = 1
@@ -57,7 +57,7 @@ module "zed" {
 module "zed" {
   count      = data.coder_workspace.me.start_count
   source     = "registry.coder.com/coder/zed/coder"
-  version  = "1.1.0"
+  version    = "1.1.0"
   agent_id   = coder_agent.example.id
   agent_name = coder_agent.example.name
 }

From 864bb01dca032b69916e918def096a8c766fe440 Mon Sep 17 00:00:00 2001
From: "blink-so[bot]" <211532188+blink-so[bot]@users.noreply.github.com>
Date: Mon, 11 Aug 2025 17:31:39 +0000
Subject: [PATCH 9/9] docs(zed): settings description -> JSON encoded
 settings.json

---
 registry/coder/modules/zed/main.tf | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/registry/coder/modules/zed/main.tf b/registry/coder/modules/zed/main.tf
index ec4fa7e3..94ec69a6 100644
--- a/registry/coder/modules/zed/main.tf
+++ b/registry/coder/modules/zed/main.tf
@@ -52,7 +52,7 @@ variable "display_name" {
 
 variable "settings" {
   type        = string
-  description = "Optional object of Zed settings to write to settings.json"
+  description = "JSON encoded settings.json"
   default     = ""
 }
 
