From cf9ecf766d62236c07e3e7bd29b0accabcb25fe9 Mon Sep 17 00:00:00 2001 From: Stefan Kopco Date: Sun, 22 Nov 2026 12:00:07 +0100 Subject: [PATCH 1/2] zed-rx: snippets for source, action, component, effect and friends --- tooling/zed-rx/README.md | 4 +- tooling/zed-rx/extension.toml | 1 + tooling/zed-rx/snippets/reactivescript.json | 47 +++++++++++++++++++++ 3 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 tooling/zed-rx/snippets/reactivescript.json diff --git a/tooling/zed-rx/README.md b/tooling/zed-rx/README.md index 1cf8ebc4..8846cc8c 100644 --- a/tooling/zed-rx/README.md +++ b/tooling/zed-rx/README.md @@ -5,7 +5,9 @@ Highlighting for `.rx` and `.d.rx` from a Tree-sitter grammar ([`../rx-language-server`](../rx-language-server)), TypeScript's hover, go to definition, references, rename, completion and type errors, plus the compiler's own diagnostics. ` ```rx ` and ` ```reactivescript ` blocks in -Markdown use the same language. +Markdown use the same language. Snippets (`source`, `sourceq`, `action`, +`component`, `app`, `effect`, `fn`, `for`, `if`) are in +`snippets/reactivescript.json`. The extension installs `@reactivescript/language-server` from npm (and updates it when a newer release exists; offline it keeps the installed copy) and runs it diff --git a/tooling/zed-rx/extension.toml b/tooling/zed-rx/extension.toml index 4e4d508a..183fc3fd 100644 --- a/tooling/zed-rx/extension.toml +++ b/tooling/zed-rx/extension.toml @@ -5,6 +5,7 @@ schema_version = 1 authors = ["Ryan Carniato"] description = "ReactiveScript (.rx, .d.rx): highlighting, and TypeScript's types, hover, go to definition, completion and errors through the .rx language server." repository = "https://github.com/solidjs/reactivescript" +snippets = ["./snippets/reactivescript.json"] [language_servers.rx-language-server] name = "ReactiveScript Language Server" diff --git a/tooling/zed-rx/snippets/reactivescript.json b/tooling/zed-rx/snippets/reactivescript.json new file mode 100644 index 00000000..f4bb51f1 --- /dev/null +++ b/tooling/zed-rx/snippets/reactivescript.json @@ -0,0 +1,47 @@ +{ + "source": { + "prefix": "source", + "body": "source ${1:name}: ${2:number} := ${3:0}", + "description": "State, written with :=" + }, + "source (question)": { + "prefix": "sourceq", + "body": "source ${1:user} = await ${2:fetchUser}(${3:id})", + "description": "State with a question, re-asked when its inputs change" + }, + "action": { + "prefix": "action", + "body": ["action ${1:save}(${2}) {", "\t$0", "}"], + "description": "Action: writes and awaits" + }, + "component": { + "prefix": "component", + "body": ["component ${1:Item}(props: { ${2:title}: ${3:string} }) {", "\t<${4:div}>$0", "}"], + "description": "Component" + }, + "export default component": { + "prefix": "app", + "body": ["export default component ${1:App}() {", "\t<${2:main}>$0", "}"], + "description": "Entry module's default component" + }, + "effect": { + "prefix": "effect", + "body": ["effect (${1:count}) {", "\t$0", "}"], + "description": "Runs after the listed values change; $0, $1 are their values" + }, + "fn": { + "prefix": "fn", + "body": "fn ${1:area}(${2:w}: ${3:number}, ${4:h}: ${5:number}): ${6:number} => ${7:w * h}", + "description": "Pure function" + }, + "for": { + "prefix": "for", + "body": ["{for ${1:it} in ${2:items} {", "\t$0", "}}"], + "description": "Markup loop" + }, + "if": { + "prefix": "if", + "body": ["{if ${1:cond} {", "\t$0", "} else {", "\t", "}}"], + "description": "Markup conditional" + } +} From ca3948868f9d4278d58d0b18bb101c17c5382c60 Mon Sep 17 00:00:00 2001 From: Stefan Kopco Date: Sun, 22 Nov 2026 13:13:44 +0100 Subject: [PATCH 2/2] zed-rx: snippets as a single path, and a tabstop in if's else --- tooling/zed-rx/extension.toml | 2 +- tooling/zed-rx/snippets/reactivescript.json | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tooling/zed-rx/extension.toml b/tooling/zed-rx/extension.toml index 183fc3fd..c6628121 100644 --- a/tooling/zed-rx/extension.toml +++ b/tooling/zed-rx/extension.toml @@ -5,7 +5,7 @@ schema_version = 1 authors = ["Ryan Carniato"] description = "ReactiveScript (.rx, .d.rx): highlighting, and TypeScript's types, hover, go to definition, completion and errors through the .rx language server." repository = "https://github.com/solidjs/reactivescript" -snippets = ["./snippets/reactivescript.json"] +snippets = "./snippets/reactivescript.json" [language_servers.rx-language-server] name = "ReactiveScript Language Server" diff --git a/tooling/zed-rx/snippets/reactivescript.json b/tooling/zed-rx/snippets/reactivescript.json index f4bb51f1..22977346 100644 --- a/tooling/zed-rx/snippets/reactivescript.json +++ b/tooling/zed-rx/snippets/reactivescript.json @@ -41,7 +41,7 @@ }, "if": { "prefix": "if", - "body": ["{if ${1:cond} {", "\t$0", "} else {", "\t", "}}"], - "description": "Markup conditional" + "body": ["{if ${1:cond} {", "\t$0", "} else {", "\t$2", "}}"], + "description": "Conditional inside markup; in code, write if (c) { … }" } }