diff --git a/Cargo.lock b/Cargo.lock index 15707b8..dd5b071 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2558,6 +2558,7 @@ dependencies = [ "tree-sitter-cuda", "tree-sitter-go", "tree-sitter-javascript", + "tree-sitter-json", "tree-sitter-lua", "tree-sitter-make", "tree-sitter-md", @@ -2565,6 +2566,7 @@ dependencies = [ "tree-sitter-rust", "tree-sitter-toml-ng", "tree-sitter-typescript", + "tree-sitter-yaml", "tree-sitter-zig", "unicode-width", ] @@ -3807,6 +3809,16 @@ dependencies = [ "tree-sitter-language", ] +[[package]] +name = "tree-sitter-json" +version = "0.24.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d727acca406c0020cffc6cf35516764f36c8e3dc4408e5ebe2cb35a947ec471" +dependencies = [ + "cc", + "tree-sitter-language", +] + [[package]] name = "tree-sitter-language" version = "0.1.7" @@ -3883,6 +3895,16 @@ dependencies = [ "tree-sitter-language", ] +[[package]] +name = "tree-sitter-yaml" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53c223db85f05e34794f065454843b0668ebc15d240ada63e2b5939f43ce7c97" +dependencies = [ + "cc", + "tree-sitter-language", +] + [[package]] name = "tree-sitter-zig" version = "1.1.2" diff --git a/Cargo.toml b/Cargo.toml index 98fec84..c3e9ea9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -196,6 +196,13 @@ tree-sitter-javascript = "0.25" tree-sitter-typescript = "0.23" tree-sitter-toml-ng = "0.7" tree-sitter-zig = "1.1" +# JSON + YAML — config formats + the honest gate on the Jupyter path +# (JSON). Both are ABI-current (`LANGUAGE: LanguageFn` via +# `tree-sitter-language`), NOT a `tree-sitter ^0.20` fork. Registering +# yaml also lights up markdown `---` frontmatter through the #122 +# injection engine (the block injection query already sets yaml for it). +tree-sitter-json = "0.24" +tree-sitter-yaml = "0.7" # T M9.7: markdown grammar so prompt result buffers with # `_meta.format = "markdown"` get structured highlighting through the # same M4 path as rust/lua — no special-case painter in Lua. diff --git a/builtin/runtime/lsp.lua b/builtin/runtime/lsp.lua index eb4f1e4..e924a3a 100644 --- a/builtin/runtime/lsp.lua +++ b/builtin/runtime/lsp.lua @@ -200,6 +200,62 @@ pmacs.lsp.config.zig = pmacs.lsp.config.zig or { args = {}, } +-- JSON via the VS Code JSON server, binary `vscode-json-language-server`. +-- It is a PUSH-model server: it reads config from +-- `workspace/didChangeConfiguration` (the daemon now sends one after +-- `initialized`) and does NOT issue `workspace/configuration` pulls, so +-- without that push these settings would be inert. `json.validate.enable` +-- is set explicitly true — the server treats a MISSING value as false, so +-- an empty `json = {}` would silently disable validation. Schema +-- retrieval performs NETWORK ACCESS for remote `$schema` URLs (left +-- enabled; `handledSchemaProtocols = {"file"}` would disable it but break +-- remote schemas without a `vscode/content` impl). Note: the server does +-- NOT auto-associate `package.json`/`tsconfig.json` — it starts with empty +-- contributions; explicit `$schema` refs or configured `json.schemas` / +-- a `json/schemaAssociations` push (not implemented) are required. +-- Provider: pin `@t1ckbase/vscode-langservers-extracted@2.0.2` +-- (`npm install -g @t1ckbase/vscode-langservers-extracted@2.0.2`). +-- Its published payload bundles the JSON server from VS Code 1.129.0, +-- preserves this command name, and was live-smoked through initialize → +-- config push → invalid-JSON diagnostic → shutdown. The older unscoped +-- package is stale and the current `@zed-industries` payload has a broken +-- JSON launcher; neither is the recommended provider. +pmacs.lsp.config.json = pmacs.lsp.config.json or { + command = "vscode-json-language-server", + args = { "--stdio" }, + settings = { + json = { validate = { enable = true } }, + http = {}, + }, +} + +-- YAML via Red Hat `yaml-language-server`. On +-- `workspace/didChangeConfiguration` (now pushed after `initialized`) it +-- reads the `yaml`, `http`, `[yaml]`, `editor`, and `files` sections — all +-- ship present-not-null (empty ⇒ server defaults). SchemaStore / remote +-- schema retrieval performs NETWORK ACCESS by default. The standalone +-- server does not upload telemetry itself — it emits `telemetry/event` +-- notifications to its client, and pmacs has no telemetry uploader, so a +-- `redhat.telemetry` setting would be inert and is not shipped. Sections +-- live-observed with Red Hat `yaml-language-server@1.24.0`: its initial +-- pull requests exactly those five sections, and opening a YAML document +-- requests a second scoped `[yaml]` section. The standalone smoke reached +-- a real syntax diagnostic and clean shutdown. The PATH-gated pmacs +-- acceptance also proves auto-attach, initialization, config pulls, a +-- syntax diagnostic, and continued server liveness with both catalogs +-- disabled for network-free determinism. +pmacs.lsp.config.yaml = pmacs.lsp.config.yaml or { + command = "yaml-language-server", + args = { "--stdio" }, + settings = { + yaml = {}, + http = {}, + ["[yaml]"] = {}, + editor = {}, + files = {}, + }, +} + -- LSP-side extension → language map, deliberately independent of the -- tree-sitter detection in `pmacs.parse`. Consulted only when -- `pmacs.parse.language_for_path` finds nothing (an extension with a @@ -267,6 +323,11 @@ pmacs.lsp.filetypes.toml = pmacs.lsp.filetypes.toml or "toml" -- Zig (zls). `.zon` is Zig Object Notation, handled by the same server. pmacs.lsp.filetypes.zig = pmacs.lsp.filetypes.zig or "zig" pmacs.lsp.filetypes.zon = pmacs.lsp.filetypes.zon or "zig" +-- JSON / YAML. Both ship grammars, so `language_for_path` already resolves +-- these and the map is the stable-id fallback (same role as `lua`/`cuda`). +pmacs.lsp.filetypes.json = pmacs.lsp.filetypes.json or "json" +pmacs.lsp.filetypes.yaml = pmacs.lsp.filetypes.yaml or "yaml" +pmacs.lsp.filetypes.yml = pmacs.lsp.filetypes.yml or "yaml" -- Per-buffer attachment record: { language, server, uri, version }. -- Keyed by `tostring(BufferIdLua)` because BufferIdLua hands out fresh diff --git a/docs/agent-handoff.md b/docs/agent-handoff.md index d9986c7..9a090db 100644 --- a/docs/agent-handoff.md +++ b/docs/agent-handoff.md @@ -323,11 +323,18 @@ runtime/Lua-registered languages (v1 resolves only against `BUILTIN_LANGUAGES`), and the next injection *consumers* gated on new grammars — HTML/CSS/GraphQL/SQL (`