Skip to content

feature: Use espressif modified clangd tool#476

Merged
Jason2866 merged 3 commits into
developfrom
esp_clangd
Apr 14, 2026
Merged

feature: Use espressif modified clangd tool#476
Jason2866 merged 3 commits into
developfrom
esp_clangd

Conversation

@Jason2866
Copy link
Copy Markdown

@Jason2866 Jason2866 commented Apr 14, 2026

Description:

install use espressif clangd when pioarduino env var intellisense is set to clangd.
Needs not yet released pioarduino VSC extension v1.3.8

Checklist:

  • The pull request is done against the latest develop branch
  • Only relevant files were touched
  • Only one feature/fix was added per PR, more changes are allowed when changing boards.json
  • I accept the CLA

Summary by CodeRabbit

Release Notes

  • New Features
    • Added support for the clangd development tool as an optional package component.
    • Automatic provisioning of the clangd tool is now enabled when your IDE intellisense engine is configured to use clangd, streamlining the development setup process.

Jason2866 and others added 2 commits April 14, 2026 16:24
…475)

The pioarduino IDE extension now exports PLATFORMIO_IDE_INTELLISENSE_ENGINE
as an environment variable. When the value is 'clangd', the platform
automatically installs tool-clangd-esp during configure_default_packages().

Espressif's clangd has native Xtensa and ESP RISC-V ISA extension support
(xespv, xesploop, xespdsp, etc.) that the upstream clangd lacks, which
eliminates unknown-flag errors and improves IntelliSense for ESP32 targets.

Amp-Thread-ID: https://ampcode.com/threads/T-019d8c25-963a-728c-8166-76efd9747d60

Co-authored-by: Amp <amp@ampcode.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 14, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: dc6118f5-b157-4e7c-95b2-541ea3363995

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

This pull request adds support for conditional installation of the clangd-esp tool package. A new optional tool package entry is introduced in the platform definition, with corresponding logic to automatically install it when the IDE's IntelliSense engine is configured to use clangd.

Changes

Cohort / File(s) Summary
Tool Package Definition
platform.json
Added optional tool-clangd-esp package entry with version 21.1.3+20260304, owned by pioarduino, pointing to a GitHub release download URL.
Tool Installation Logic
platform.py
Added _configure_clangd_tool() helper method that checks PLATFORMIO_IDE_INTELLISENSE_ENGINE environment variable and installs tool-clangd-esp if clangd is enabled and the tool is available in the platform packages.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Poem

🐰 A clangd tool hops into the fold,
When IntelliSense whispers "please be bold!"
Platform and Python dance in sync,
Installing tools faster than a rabbit's blink! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title clearly summarizes the main change: adding support for Espressif's modified clangd tool when the IDE IntelliSense engine is set to clangd, which is directly reflected in both the platform.json and platform.py modifications.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch esp_clangd

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Jason2866
Copy link
Copy Markdown
Author

@coderabbitai full review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 14, 2026

✅ Actions performed

Full review triggered.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
platform.py (1)

808-811: Normalize engine value and log install failure for better resilience.

Line 808 currently depends on an exact env string match and Line 811 ignores install result. Normalizing and checking the return value would make this path more robust.

Proposed improvement
-        engine = os.environ.get("PLATFORMIO_IDE_INTELLISENSE_ENGINE", "")
-        if engine == "clangd" and "tool-clangd-esp" in self.packages:
+        engine = os.environ.get("PLATFORMIO_IDE_INTELLISENSE_ENGINE", "").strip().lower()
+        if engine == "clangd" and "tool-clangd-esp" in self.packages:
             logger.info("clangd IntelliSense engine detected, installing tool-clangd-esp")
-            self.install_tool("tool-clangd-esp")
+            if not self.install_tool("tool-clangd-esp"):
+                logger.warning("Failed to install tool-clangd-esp for clangd IntelliSense engine")
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@platform.py` around lines 808 - 811, The code currently checks engine via
exact match and ignores install result; update the engine check to normalize the
env var (strip and lower) before comparing to "clangd", keep the existing
package presence check ("tool-clangd-esp" in self.packages), then call
self.install_tool("tool-clangd-esp") and capture its return value; if
installation fails, emit a logger.error with a clear message including the
engine value and package name so failures are visible. Use the existing symbols
engine, self.packages, self.install_tool, and logger in the change.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@platform.py`:
- Around line 808-811: The code currently checks engine via exact match and
ignores install result; update the engine check to normalize the env var (strip
and lower) before comparing to "clangd", keep the existing package presence
check ("tool-clangd-esp" in self.packages), then call
self.install_tool("tool-clangd-esp") and capture its return value; if
installation fails, emit a logger.error with a clear message including the
engine value and package name so failures are visible. Use the existing symbols
engine, self.packages, self.install_tool, and logger in the change.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: d9741b85-e548-48e0-89a6-a49c203bbf02

📥 Commits

Reviewing files that changed from the base of the PR and between 9a92d09 and 6455529.

📒 Files selected for processing (2)
  • platform.json
  • platform.py

@Jason2866 Jason2866 merged commit fb230b1 into develop Apr 14, 2026
1 check passed
@Jason2866 Jason2866 deleted the esp_clangd branch April 14, 2026 15:48
@coderabbitai coderabbitai Bot mentioned this pull request May 5, 2026
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant