From ff2ce0f197601b19fda9a19cbbe06228deb3ee1d Mon Sep 17 00:00:00 2001 From: Levi Neuwirth Date: Tue, 14 Jul 2026 17:03:05 +0100 Subject: [PATCH] =?UTF-8?q?fix(lsp):=20PR=20#117=20round=201=20=E2=80=94?= =?UTF-8?q?=20CMake=20config=20via=20initializationOptions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit cmake-language-server does NOT pull a `workspace/configuration` section: it reads `buildDirectory` from the `initialize` request's `initializationOptions`, and drives its project model off CMake's File API under `/.cmake/api/` (not `compile_commands.json`). The `settings = { cmake = {} }` block — and the documented `settings.cmake.buildDirectory` override — were therefore inert, leaving conventional out-of-source project data unavailable. Replace it with `init_options = { buildDirectory = "build" }` (the conventional out-of-source dir; users override `init_options.buildDirectory` from init.lua), and correct the comment. The wiring test now asserts `config.cmake.init_options.buildDirectory == "build"` — bite-verified against the pre-fix lsp.lua. Gates: fmt; clippy -D warnings; --features crdt (1720); m4_acceptance --skip basedpyright (109); GPU (59); full workspace sweep (zero failures); git diff --check — all green. One `--lib` run flaked on process::m6_1_pty_mode_lifecycle_started_then_exited (PTY-lifecycle timing, the m6/m8 daemon-timing family); it passed in the crdt run, the full sweep, and 4/4 isolated — unrelated to this Lua config change. Change is Lua config + the acceptance assertion. Co-Authored-By: Claude Opus 4.8 (1M context) Claude-Session: https://claude.ai/code/session_01YJ9FQ832QwftJXCD9LeFan --- builtin/runtime/lsp.lua | 14 ++++++++------ tests/m4_acceptance.rs | 10 ++++++++++ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/builtin/runtime/lsp.lua b/builtin/runtime/lsp.lua index c0efb03..befc3ad 100644 --- a/builtin/runtime/lsp.lua +++ b/builtin/runtime/lsp.lua @@ -168,15 +168,17 @@ pmacs.lsp.config.dockerfile = pmacs.lsp.config.dockerfile or { } -- CMake via cmake-language-server (the Python server). It speaks LSP over --- stdio with no transport flag and pulls configuration via --- `workspace/configuration` under the `cmake` section (empty ⇒ defaults, --- present not null — same rationale as gopls). It reads --- `build/compile_commands.json` for the project model. Users populate --- `settings.cmake` (buildDirectory, …) from init.lua. +-- stdio with no transport flag. Unlike gopls/taplo it does NOT pull a +-- `workspace/configuration` section: it reads `buildDirectory` from the +-- `initialize` request's `initializationOptions`, and drives its project +-- model off CMake's File API under `/.cmake/api/` (not +-- `compile_commands.json`). So the config is an `init_options`, defaulting +-- to the conventional out-of-source `build/`; users override +-- `init_options.buildDirectory` from init.lua. pmacs.lsp.config.cmake = pmacs.lsp.config.cmake or { command = "cmake-language-server", args = {}, - settings = { cmake = {} }, + init_options = { buildDirectory = "build" }, } -- TOML via taplo. `taplo lsp stdio` serves LSP over stdio. taplo diff --git a/tests/m4_acceptance.rs b/tests/m4_acceptance.rs index 9eecb53..3cc0462 100644 --- a/tests/m4_acceptance.rs +++ b/tests/m4_acceptance.rs @@ -6154,6 +6154,11 @@ fn m4_filename_map_resolves_special_files() { out.plain_is_nil = f('notes.txt') == nil out.cfg_docker = pmacs.lsp.config.dockerfile and pmacs.lsp.config.dockerfile.command out.cfg_cmake = pmacs.lsp.config.cmake and pmacs.lsp.config.cmake.command + -- cmake-language-server reads buildDirectory from + -- initializationOptions, not workspace/configuration. + out.cmake_builddir = pmacs.lsp.config.cmake + and pmacs.lsp.config.cmake.init_options + and pmacs.lsp.config.cmake.init_options.buildDirectory out.has_make_cfg = pmacs.lsp.config.make ~= nil return out ", @@ -6181,6 +6186,11 @@ fn m4_filename_map_resolves_special_files() { probe.get::("cfg_cmake").unwrap(), "cmake-language-server" ); + assert_eq!( + probe.get::("cmake_builddir").unwrap(), + "build", + "cmake config passes buildDirectory via init_options (not a workspace/configuration section)" + ); assert!( !probe.get::("has_make_cfg").unwrap(), "Make has no language server, so no config.make"