From dafb4c0d47ab0e938363d56950dce7c3b0e6d502 Mon Sep 17 00:00:00 2001 From: Tom Baldwin Date: Thu, 2 Jul 2026 18:34:37 +0100 Subject: [PATCH] Add Candor Language Server template MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit candor (https://candor.poly.io) renders a per-function side-effect map in the editor — CodeLens (effects + blast radius), architecture-policy diagnostics, and effect-provenance hover — from a precomputed report covering JVM/TS/Rust/Swift code. The server ships in the candor-ts npm package as `candor-lsp`; the installer follows the typescript-language-server pattern. --- .../templates/lsp/candor-lsp/README.md | 25 +++++++ .../templates/lsp/candor-lsp/installer.json | 36 ++++++++++ .../templates/lsp/candor-lsp/template.json | 67 +++++++++++++++++++ 3 files changed, 128 insertions(+) create mode 100644 src/main/resources/templates/lsp/candor-lsp/README.md create mode 100644 src/main/resources/templates/lsp/candor-lsp/installer.json create mode 100644 src/main/resources/templates/lsp/candor-lsp/template.json diff --git a/src/main/resources/templates/lsp/candor-lsp/README.md b/src/main/resources/templates/lsp/candor-lsp/README.md new file mode 100644 index 000000000..dc2ac5a40 --- /dev/null +++ b/src/main/resources/templates/lsp/candor-lsp/README.md @@ -0,0 +1,25 @@ +You can use the [candor language server](https://candor.poly.io) to see each function's **side-effect +map** where the code is: + + * **CodeLens** on every effectful function: `⚡ Db, Net · blast radius 12` — the effects it (transitively) + performs and how many functions are affected if it changes; + * **Diagnostics**: the repo's architecture policy (e.g. "the domain layer does no I/O") checked live — + a violation is a squiggle at the offending function; + * **Hover**: effect provenance — the call chain through which an inherited effect reaches its source. + +The server renders a **candor report** — it does not analyse source itself. Produce one with any candor +engine (JVM bytecode / TypeScript / Rust / Swift; see [candor.poly.io](https://candor.poly.io)), e.g.: + +**jbang candor@tombaldwin/candor-java target/classes --json .candor/report.json** (JVM) + +**npx -y candor-ts src --out .candor/report** (TypeScript/JavaScript) + +Setup: +* [Install Node.js](https://nodejs.org/en/download) +* Open a terminal and execute: + +**npm install -g candor-ts** + +It will install the `candor-lsp` executable (the language server ships in the candor-ts package). The +server resolves the report at `/.candor/report` and the policy from the checked-in +`.candor/config` — no per-project server configuration is needed. diff --git a/src/main/resources/templates/lsp/candor-lsp/installer.json b/src/main/resources/templates/lsp/candor-lsp/installer.json new file mode 100644 index 000000000..558aea12d --- /dev/null +++ b/src/main/resources/templates/lsp/candor-lsp/installer.json @@ -0,0 +1,36 @@ +{ + "id": "candor-lsp", + "name": "Candor Language Server", + "executeOnStartServer": false, + "properties": { + "workingDir" : "$USER_HOME$/.lsp4ij/lsp/candor-lsp/node_modules" + }, + "check": { + "exec": { + "name": "Trying current command", + "command": "${server.command}", + "timeout": 2000 + } + }, + "run": { + "exec": { + "name": "Install Candor Language Server", + "workingDir": "${workingDir}", + "ignoreStderr": true, + "command": { + "windows": "npm.cmd install candor-ts --force", + "default": "npm install candor-ts --force" + }, + "onSuccess": { + "configureServer": { + "name": "Configure Candor Language Server command", + "command": { + "windows": "${workingDir}/.bin/candor-lsp.cmd", + "default": "${workingDir}/.bin/candor-lsp" + }, + "update": true + } + } + } + } +} diff --git a/src/main/resources/templates/lsp/candor-lsp/template.json b/src/main/resources/templates/lsp/candor-lsp/template.json new file mode 100644 index 000000000..1e191bdf5 --- /dev/null +++ b/src/main/resources/templates/lsp/candor-lsp/template.json @@ -0,0 +1,67 @@ +{ + "id": "candor-lsp", + "name": "Candor Language Server", + "programArgs": { + "windows": "cmd /C candor-lsp.cmd", + "default": "candor-lsp" + }, + "fileTypeMappings": [ + { + "fileType": { + "name": "JAVA", + "patterns": [ + "*.java" + ] + }, + "languageId": "java" + }, + { + "fileType": { + "name": "Kotlin", + "patterns": [ + "*.kt", + "*.kts" + ] + }, + "languageId": "kotlin" + }, + { + "fileType": { + "name": "TypeScript", + "patterns": [ + "*.ts", + "*.tsx" + ] + }, + "languageId": "typescript" + }, + { + "fileType": { + "name": "JavaScript", + "patterns": [ + "*.js", + "*.jsx", + "*.mjs" + ] + }, + "languageId": "javascript" + }, + { + "fileType": { + "name": "Rust", + "patterns": [ + "*.rs" + ] + }, + "languageId": "rust" + }, + { + "fileType": { + "patterns": [ + "*.swift" + ] + }, + "languageId": "swift" + } + ] +}