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..c6628121 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..22977346 --- /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$2", "}}"], + "description": "Conditional inside markup; in code, write if (c) { … }" + } +}