Repository navigation
Description
??## Context
FastLED WASM needs IntelliSense to work in a fresh desktop VS Code installation whether or not the optional clangd extension is installed. The current implementation is clangd-only and the proposed VS Code extension does not currently configure either engine:
crates/fastled-cli/src/clangd_config.rswritescompile_commands.json,.clangd, and.vscode/settings.jsononly afterfastled --clangdorfastled --write-clangd.- The generated settings explicitly set
C_Cpp.intelliSenseEngine,C_Cpp.autocomplete, andC_Cpp.errorSquigglestodisabled, so a user without clangd gets no C++ language service. vscode-plugin/src/extension.tsnever invokes either opt-in CLI path and has no configure/refresh lifecycle.vscode-plugin/package.jsondeclares neitherms-vscode.cpptoolsnorllvm-vs-code-extensions.vscode-clangdas a dependency.
The current compilation database is also not a verified representation of the real compiler invocation. A Windows Blink smoke test with the installed fastled 2.0.13 CLI generated two entries, but executing both emitted commands failed:
- the
.inoentry omitted Emscripten's compatibility include sequence and failed while resolving libc++xlocale.h; - the generated wrapper also removed the PCM/module arguments needed for
import "wasm_pch.h"; filter_compile_flags()deliberately removes every-Xclangpair and-fmodule-file=..., while the current direct-Clang build path obtains required backend flags fromem++ --cflags, including-Xclang -iwithsysroot/include\\compatand FakeSDL include paths.
The unit tests currently prove JSON shape and stable filtering, but not that a database entry matches or can successfully execute the production compile plan. This drift is especially likely after the direct-Clang changes in #191 and #192.
PlatformIO provides the relevant prior art:
- the PlatformIO VS Code extension declares
"extensionDependencies": ["ms-vscode.cpptools"], so installing PlatformIO also installs Microsoft C/C++; - PlatformIO Core first constructs engine-neutral
idedatacontaining compiler paths, C/C++ flags, defines, build/library/toolchain includes, and forced includes; pio project init --ide vscoderenders that metadata into.vscode/c_cpp_properties.jsonwithincludePath,browse.path,defines,forcedInclude,compilerPath,compilerArgs, and language standards;pio run --target compiledbemits the compilation database separately.
A real minimal PlatformIO native smoke project confirmed this behavior: project initialization generated c_cpp_properties.json backed by idedata.json, and the separate compiledb target generated an executable compiler command.
Microsoft C/C++ supports compileCommands in c_cpp_properties.json; a matching translation unit uses the database entry while includePath, defines, compilerPath, compilerArgs, forcedInclude, and browse.path remain important for standalone headers and files without a matching entry. Its public custom-configuration-provider API could avoid generated files, but the PlatformIO-style file approach is easier to inspect, reproduce, and acceptance-test for the first implementation.
Sources:
- PlatformIO VS Code manifest
- PlatformIO integration metadata builder
- PlatformIO C/C++ properties template
- PlatformIO compilation database documentation
- Microsoft C/C++ settings reference
- Microsoft C/C++ configuration-provider API
- VS Code extension manifest reference
- VS Code configuration scopes
- VS Code dependency activation implementation
- clangd extension manifest and settings
- clangd extension conflict detection and lifecycle
- Microsoft confirmation of the cpptools disable setting
Proposal
1. Derive all editor metadata from one production compile plan
Introduce one engine-neutral SketchCompilePlan (name illustrative) in the Rust build layer. It should contain the compiler executable, working directory, translation units, exact compile arguments, includes by scope, defines, forced includes/module prerequisites, language standard, and target/sysroot information.
The real direct-Clang build, compile_commands.json, clangd fallback configuration, and Microsoft C/C++ configuration must all derive from this object. Do not independently reconstruct flags in clangd_config.rs. Preserve arguments that are required to parse the source; only remove output/dependency-emission arguments when an editor-specific view genuinely requires it, and test every transformation.
2. Emit a valid compilation database
Generate entries for the sketch .ino and the generated wrapper from the same plan used by the successful build. Associate *.ino with C++ and include -x c++ where required. Generated commands must use normalized absolute paths on Windows and must be executable after the prerequisites of a successful build have been materialized.
Add a general command such as fastled --write-intellisense [DIR], retaining --write-clangd as a compatibility alias if it is already public. Generation must be deterministic and safe to repeat.
3. Generate PlatformIO-style Microsoft C/C++ configuration
Write/merge .vscode/c_cpp_properties.json with a FastLED configuration containing at least:
compileCommandspointing at${workspaceFolder}/compile_commands.json;- sketch, FastLED, compatibility, and generated include paths in
includePathandbrowse.path; - build defines;
forcedIncludewhen the compile plan uses forced headers;- the bundled direct compiler in
compilerPathplus the required target/sysroot arguments incompilerArgs; - the actual
cppStandardandcStandard.
Preserve unrelated user configurations and settings. Document which generated keys FastLED owns and update only those keys on refresh.
4. Install both extensions, but never run both language engines
Follow-up investigation confirmed that the two extensions can be installed together, but their language services must not be active for the same C/C++ documents:
- Current
vscode-clangd0.6.0 explicitly detects active cpptools and warns that Microsoft IntelliSense conflicts with clangd completion and diagnostics. - Microsoft confirms that
"C_Cpp.intelliSenseEngine": "disabled"turns off the cpptools C/C++ language service; separately disabling autocomplete and squiggles is redundant. The extension can remain installed for its non-language-service features. - VS Code activates
extensionDependenciesbefore the dependent extension. Declaring both language engines as hard dependencies therefore allows both to start before FastLED can arbitrate, and a missing, failed, or user-disabled dependency can prevent FastLED itself from activating. - The clangd extension's
clangd.enablesetting has defaultwindowscope and is only consulted while activating/restarting the client; changing it tofalsedoes not stop an already-running client. The extension exposesclangd.shutdownandclangd.restart, which FastLED must use during transitions. C_Cpp.intelliSenseEnginehasresourcescope. Because clangd's enablement is window-wide and its client selects all C/C++ files, different engines per folder in one multi-root window are not safely supported. Engine selection must be one value for the whole VS Code window, while metadata generation remains per folder.- The VS Code clangd extension does not contain the native server. When no server is found, it offers a user-confirmed download on supported x86-64 Windows, Linux, and macOS systems. The locally installed FastLED Emscripten 4.0.19 toolchain contains
clang.exe,clang++.exe, andclang-scan-deps.exe, but noclangd(.exe), so FastLED cannot currently point the extension at its own bundled server.
Use an extension pack rather than hard lifecycle dependencies for these alternative engines:
"extensionPack": [
"ms-vscode.cpptools",
"llvm-vs-code-extensions.vscode-clangd"
]VS Code installs extension-pack members together with FastLED while keeping them independently manageable. This gives a fresh supported desktop profile both editor integrations without making FastLED fail when one is disabled or unavailable. If strict extensionDependencies are nevertheless chosen, both IDs can be listed, but the activation ordering, disable semantics, remote-host placement, and failure coupling above become required acceptance risks; the extension-pack design is preferred.
Add a window/workspace-scoped setting (not folder-scoped):
fastled.intelliSenseEngine = auto | clangd | cpptools | off
Behavior and transition order:
auto(default): choose clangd only when the clangd extension is installed and the configuredclangd.pathpasses a bounded--versionprobe; otherwise select cpptools immediately. Extension presence alone is not readiness. Offer the official clangd server installer as an explicit action, and prompt before switching engines after an installation completes rather than silently changing providers mid-edit.clangd: first set workspace-levelC_Cpp.intelliSenseEngine=disabled, then setclangd.enable=true, runclangd.restart, and verify that the clangd client/provider becomes ready. Report a clear setup error with Install Server and Use Microsoft C/C++ actions if it does not.cpptools: setclangd.enable=false, runclangd.shutdownif the extension/client is already active, then set workspace-levelC_Cpp.intelliSenseEngine=defaultand wait for cpptools readiness.off: stop managing engine selection and restore/remove only FastLED-owned setting values rather than overwriting unrelated user configuration.
Perform each transition as a serialized state change and roll back or surface an actionable failure if the selected engine does not become ready. Exactly one language engine must own completion, navigation, diagnostics, formatting, and semantic highlighting throughout managed steady state. Both extensions remain installed; they are not expected to provide C++ language features simultaneously.
A guaranteed native clangd binary would require a separate packaging decision: add clangd to every FastLED toolchain archive or implement a pinned, checksummed FastLED download with platform/architecture coverage. The VS Code manifest alone cannot guarantee the server binary.
5. Configure and refresh from the VS Code extension
On activation for every FastLED workspace folder, and after a successful compile/init, invoke the IntelliSense-generation command and apply engine arbitration. Refresh when the selected engine, build mode, FastLED checkout/ref, toolchain, or workspace folders change. Handle multi-root workspaces per folder, serialize duplicate refreshes, and expose a FastLED: Refresh IntelliSense Configuration command.
Do not report compilation success until requested metadata generation has either succeeded or produced a visible, actionable warning. Log the selected engine, generated file paths, compiler path, and refresh reason to the FastLED output channel without logging sensitive environment values.
Likely implementation files:
crates/fastled-cli/src/wasm_build.rs: define/expose the canonical compile plan and reuse it for production compilation.crates/fastled-cli/src/clangd_config.rs(preferably renamed/generalized): render the compile database,.clangd,c_cpp_properties.json, and shared VS Code settings from the plan.crates/fastled-cli/src/cli.rs,lib.rs,commands.rs, andcompile_stream.rs: expose and route general IntelliSense generation while keeping compatibility.vscode-plugin/package.json: declare the cpptools dependency, setting, refresh command, and test scripts.vscode-plugin/src/extension.ts: detect engines, invoke configuration, manage per-folder settings/refresh, and surface failures.vscode-plugin/src/test/**plus Rust tests in the modules above: unit, integration, and Extension Development Host coverage.vscode-plugin/README.md,GET_STARTED.md, and root documentation: describe automatic fallback, generated files, and troubleshooting.
Acceptance criteria
- Installing FastLED in a supported fresh desktop VS Code profile installs both
ms-vscode.cpptoolsandllvm-vs-code-extensions.vscode-clangdthroughextensionPack; either engine extension can subsequently be disabled/uninstalled without disabling FastLED itself. - With both editor extensions installed but no usable native clangd server, opening Blink selects cpptools without hanging or losing IntelliSense, generates
compile_commands.json,.vscode/c_cpp_properties.json, and the.inoC++ association, and offers an explicit clangd server installation action. - With a usable clangd server,
autoselects clangd only after a bounded executable/readiness check. Finishing a clangd download does not silently switch the active provider during editing. - Explicit
clangd,cpptools, andoffselections are honored once per VS Code window. Multi-root workspaces generate independent metadata per FastLED folder but use one language engine across the window; conflicting folder-level requests are rejected with a clear explanation. - In clangd mode, workspace-level
C_Cpp.intelliSenseEngineisdisabled, the clangd client is running, and no cpptools IntelliSense provider or conflict warning remains. The cpptools extension may remain installed for non-language-service features. - In cpptools mode,
clangd.enableisfalse, any previously running clangd client has been stopped throughclangd.shutdown, cpptools is ready, and no clangd provider/process remains. - Switching in both directions is serialized and tested: disable/stop the losing engine before starting the winner, wait with a hard timeout, and either reach one-engine steady state or report/roll back an actionable failure.
- Missing/unsupported clangd downloads, a bad
clangd.path, disabled extensions, dependency/pack installation failure, and remote extension-host placement all fall back or fail visibly without preventing FastLED compilation commands from activating. - The compilation database and both editor configurations derive from the same canonical production compile plan rather than independently reconstructed flag lists.
- After a real successful Emscripten Blink build, executing every emitted
compile_commands.jsonentry from its declareddirectoryexits0, including on Windows; required Emscripten compatibility, FakeSDL, module/PCH, target, sysroot, include, and define arguments are not lost. - Rust tests compare emitted arguments field-for-field with the canonical compile plan, cover
.inolanguage forcing, normalized Windows paths, deterministic output, merge preservation, and stale config refresh. - A real VS Code Extension Development Host test with cpptools installed and clangd absent opens Blink, waits with a hard timeout for the C/C++ engine, observes no missing-
FastLED.hdiagnostics, and verifies completion plus Go to Definition into the cached FastLED headers using VS Code provider commands. - A corresponding clangd Extension Development Host test verifies completion and Go to Definition, and
clangd --check(or the configured server's equivalent check) reports no configuration errors. - An Extension Development Host test with both extensions installed covers first activation and both switch directions, asserts the losing language client/process is stopped, observes no clangd conflict warning, and produces no duplicate FastLED diagnostics, completions, definitions, formatting providers, or semantic highlighting.
- Extension tests cover activation, manual refresh, refresh after compile/init, configuration changes, window-wide multi-root arbitration, idempotence, missing CLI/toolchain/server failure, disabled extension messaging, pack installation behavior, and bounded process timeouts.
- The test matrix runs Rust unit tests, a real Emscripten compile/database replay smoke test, and VS Code extension-host tests on Windows and Linux, with at least a macOS smoke test for path/toolchain handling.
-
bash lint,soldr cargo test --workspace, the VS Code TypeScript build/tests, and the existing real WASM compile tests pass. - Documentation explains that both extensions are installed but only one language engine runs, the native clangd server prompt/platform limits, window-wide multi-root selection, generated/owned files, regeneration, switching, and troubleshooting.
Open questions
- After the file-based implementation is proven, should FastLED replace generated
c_cpp_properties.jsonwith a cpptools custom configuration provider to reduce workspace-file mutation? This should be a follow-up unless file ownership or multi-root behavior proves unacceptable. - Should the generalized CLI command be named
--write-intellisense,--write-editor-config, or remain--write-clangdwith broader behavior? Whatever name is selected, preserve compatibility for the existing public flag.
Related issues
- feat: emit clangd/VS Code config (compile_commands.json, .clangd, settings.json) so go-to-definition works for WASM sketches #177 implemented the current clangd/VS Code configuration and has the same navigation/indexing goal.
- feat(cli): make clangd/VS Code config generation opt-in instead of writing on every compile #179 made that generation opt-in, which the plugin must now invoke deliberately rather than reintroducing unconditional CLI writes.
- PR [codex] track vscode extension #183 adds the VS Code plugin surface that should own automatic setup and refresh.
- PRs perf(cli): accelerate dynamic sketch rebuilds #191 and fix(cli): filter Emscripten-only compile flags #192 changed/refined the production direct-Clang invocation that editor metadata must now follow exactly.
Activity
zackees commentedon Jul 14, 2026
Follow-up: can clangd and Microsoft C/C++ coexist?
Installed together: yes. Active as language engines for the same C/C++ files: no.
The current clangd extension explicitly detects active cpptools and warns that its IntelliSense conflicts with clangd completion and diagnostics. Microsoft confirms that
C_Cpp.intelliSenseEngine=disabledis sufficient to turn off the cpptools language service while leaving the extension installed.A hard dependency on both is technically possible, but is the wrong lifecycle for alternative engines: VS Code activates
extensionDependenciesbefore FastLED, failed/disabled dependencies can block FastLED activation, and both engines can start before FastLED applies its selection. The issue now recommends:This installs both with FastLED while allowing either to be independently disabled. FastLED must then serialize transitions:
clangd.enable=false, explicitly runclangd.shutdown, then enable/wait for cpptools;Two additional constraints are now captured in the issue:
clangd.enableis window-scoped, while the cpptools engine setting is resource-scoped, so engine selection must be one value per VS Code window; multi-root folders may have separate compile metadata but cannot safely mix engines.clangdis missing, and the observed FastLED Emscripten 4.0.19 package contains clang/clang++ but not clangd. A guaranteed native server therefore requires a separate toolchain-packaging or pinned-download decision.Primary evidence: VS Code dependency activation, extension pack/dependency semantics, configuration scopes, clangd conflict/lifecycle code, clangd manifest, and Microsoft's cpptools disable confirmation.
zackees commentedon Jul 15, 2026
Current Windows reproduction (2026-07-15)
A fresh Blink workspace demonstrates the remaining plugin integration gap:
fastled-wasm-1.0.1-win32-x64.vsix.[email protected]; its bundledclangd.exe --versionreportsclangd version 21.1.5.Blink.inoand right-clickFastLED,CRGB, orFastLED.addLeds.Observed:
.inois assigned the FastLED extension'sarduinolanguage ID.arduino.FastLED: Show Bundled clangd Diagnostics, but does not create a language client, setclangd.path, invokefastled --write-clangd/--write-intellisense, or register navigation providers.compile_commands.json,.clangd,.vscode/settings.json, or.vscode/c_cpp_properties.json.The expected semantic-navigation commands (Go to Definition/Declaration/Implementation) are consequently absent. This is not a failed native-server installation: the native server is present and executable, but no editor engine owns the Arduino document.
Manual acceptance test addition
For each selected engine, start from a clean VS Code profile and a Blink workspace with no pre-existing
.vscodeor compilation database:clangdfromPATHto prove the bundled binary is used.Blink.ino; wait for FastLED setup to finish, with a visible bounded failure if setup cannot complete..inois treated as C++ for the selected engine and FastLED-owned metadata is generated/updated without overwriting unrelated user settings.CRGB,FastLED, andFastLED.addLedsnavigate into the materialized FastLED headers..inofile and verify navigation/completion refreshes from the live generated C++ snapshot.clangdmode, explicitcpptoolsmode, andautofallback with no usable clangd; assert exactly one language engine is active and no duplicate diagnostics/completions or clangd/cpptools conflict warning appears.FastLED: Refresh IntelliSense Configuration.feat(vscode): configure FastLED IntelliSense engines (#210)