-
Notifications
You must be signed in to change notification settings - Fork 73
Add Zed IDE module #179
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Add Zed IDE module #179
Changes from 3 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
11ebb4a
Add Zed IDE module
blink-so[bot] 225f180
Fix Zed module URL construction and add agent_name variable
blink-so[bot] 3cba245
Final fixes: add Zed logo and fix URL construction
blink-so[bot] 08991f2
Fix hostname logic as suggested in PR review
blink-so[bot] ec52f9f
Add important note about Zed requirements to README
blink-so[bot] ef8d732
Change display name from 'Zed IDE' to 'Zed Editor'
blink-so[bot] 9394169
Simplify display name to just 'Zed' and remove trailing period
blink-so[bot] 904159e
Remove trailing periods from all description fields
blink-so[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
--- | ||
display_name: Zed IDE | ||
description: Add a one-click button to launch Zed IDE | ||
icon: ../../../../.icons/zed.svg | ||
maintainer_github: coder | ||
verified: true | ||
tags: [ide, zed, editor] | ||
--- | ||
|
||
# Zed IDE | ||
|
||
Add a button to open any workspace with a single click in Zed IDE. | ||
|
||
Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter. | ||
|
||
```tf | ||
module "zed" { | ||
count = data.coder_workspace.me.start_count | ||
source = "registry.coder.com/coder/zed/coder" | ||
version = "1.0.0" | ||
agent_id = coder_agent.example.id | ||
} | ||
``` | ||
|
||
## Examples | ||
|
||
### Open in a specific directory | ||
|
||
```tf | ||
module "zed" { | ||
count = data.coder_workspace.me.start_count | ||
source = "registry.coder.com/coder/zed/coder" | ||
version = "1.0.0" | ||
agent_id = coder_agent.example.id | ||
folder = "/home/coder/project" | ||
} | ||
``` | ||
|
||
### Custom display name and order | ||
|
||
```tf | ||
module "zed" { | ||
count = data.coder_workspace.me.start_count | ||
source = "registry.coder.com/coder/zed/coder" | ||
version = "1.0.0" | ||
agent_id = coder_agent.example.id | ||
display_name = "Zed Editor" | ||
order = 1 | ||
} | ||
``` | ||
|
||
### With custom agent name | ||
|
||
```tf | ||
module "zed" { | ||
count = data.coder_workspace.me.start_count | ||
source = "registry.coder.com/coder/zed/coder" | ||
version = "1.0.0" | ||
agent_id = coder_agent.example.id | ||
agent_name = coder_agent.example.name | ||
} | ||
``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
import { describe, expect, it } from "bun:test"; | ||
import { | ||
runTerraformApply, | ||
runTerraformInit, | ||
testRequiredVariables, | ||
} from "~test"; | ||
|
||
describe("zed", async () => { | ||
await runTerraformInit(import.meta.dir); | ||
|
||
testRequiredVariables(import.meta.dir, { | ||
agent_id: "foo", | ||
}); | ||
|
||
it("default output", async () => { | ||
const state = await runTerraformApply(import.meta.dir, { | ||
agent_id: "foo", | ||
}); | ||
expect(state.outputs.zed_url.value).toBe( | ||
"zed://ssh/default.default.coder", | ||
); | ||
|
||
const coder_app = state.resources.find( | ||
(res) => res.type === "coder_app" && res.name === "zed", | ||
); | ||
|
||
expect(coder_app).not.toBeNull(); | ||
expect(coder_app?.instances.length).toBe(1); | ||
expect(coder_app?.instances[0].attributes.order).toBeNull(); | ||
}); | ||
|
||
it("adds folder", async () => { | ||
const state = await runTerraformApply(import.meta.dir, { | ||
agent_id: "foo", | ||
folder: "/foo/bar", | ||
}); | ||
expect(state.outputs.zed_url.value).toBe( | ||
"zed://ssh/default.default.coder/foo/bar", | ||
); | ||
}); | ||
|
||
it("expect order to be set", async () => { | ||
const state = await runTerraformApply(import.meta.dir, { | ||
agent_id: "foo", | ||
order: "22", | ||
}); | ||
|
||
const coder_app = state.resources.find( | ||
(res) => res.type === "coder_app" && res.name === "zed", | ||
); | ||
|
||
expect(coder_app).not.toBeNull(); | ||
expect(coder_app?.instances.length).toBe(1); | ||
expect(coder_app?.instances[0].attributes.order).toBe(22); | ||
}); | ||
|
||
it("expect display_name to be set", async () => { | ||
const state = await runTerraformApply(import.meta.dir, { | ||
agent_id: "foo", | ||
display_name: "Custom Zed", | ||
}); | ||
|
||
const coder_app = state.resources.find( | ||
(res) => res.type === "coder_app" && res.name === "zed", | ||
); | ||
|
||
expect(coder_app).not.toBeNull(); | ||
expect(coder_app?.instances.length).toBe(1); | ||
expect(coder_app?.instances[0].attributes.display_name).toBe("Custom Zed"); | ||
}); | ||
|
||
it("adds agent_name to hostname", async () => { | ||
const state = await runTerraformApply(import.meta.dir, { | ||
agent_id: "foo", | ||
agent_name: "myagent", | ||
}); | ||
expect(state.outputs.zed_url.value).toBe( | ||
"zed://ssh/myagent.default.me.coder", | ||
); | ||
}); | ||
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
terraform { | ||
required_version = ">= 1.0" | ||
|
||
required_providers { | ||
coder = { | ||
source = "coder/coder" | ||
version = ">= 2.5" | ||
} | ||
} | ||
} | ||
|
||
variable "agent_id" { | ||
type = string | ||
description = "The ID of a Coder agent." | ||
} | ||
|
||
variable "agent_name" { | ||
type = string | ||
description = "The name of the agent." | ||
default = "" | ||
} | ||
|
||
variable "folder" { | ||
type = string | ||
description = "The folder to open in Zed IDE." | ||
default = "" | ||
} | ||
|
||
variable "order" { | ||
type = number | ||
description = "The order determines the position of app in the UI presentation. The lowest order is shown first and apps with equal order are sorted by name (ascending order)." | ||
default = null | ||
} | ||
|
||
variable "group" { | ||
type = string | ||
description = "The name of a group that this app belongs to." | ||
default = null | ||
} | ||
|
||
variable "slug" { | ||
type = string | ||
description = "The slug of the app." | ||
default = "zed" | ||
} | ||
|
||
variable "display_name" { | ||
type = string | ||
description = "The display name of the app." | ||
default = "Zed IDE" | ||
} | ||
|
||
data "coder_workspace" "me" {} | ||
data "coder_workspace_owner" "me" {} | ||
|
||
locals { | ||
workspace_name = lower(data.coder_workspace.me.name) | ||
owner_name = lower(data.coder_workspace_owner.me.name) | ||
agent_name = lower(var.agent_name) | ||
hostname = var.agent_name != "" ? "${local.agent_name}.${local.workspace_name}.me.coder" : "${local.workspace_name}.${local.owner_name}.coder" | ||
matifali marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
} | ||
|
||
resource "coder_app" "zed" { | ||
agent_id = var.agent_id | ||
display_name = var.display_name | ||
slug = var.slug | ||
icon = "/icon/zed.svg" | ||
external = true | ||
order = var.order | ||
group = var.group | ||
url = "zed://ssh/${local.hostname}${var.folder}" | ||
} | ||
|
||
output "zed_url" { | ||
value = coder_app.zed.url | ||
description = "Zed IDE URL." | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.