VSC w/ ESP-IDF: how do I configure LSP to have autocompletion for bridged headers?

Hi :wave: I wonder if it's somehow possible to have autocompletion I get for regular Swift code:

but for the C functions imported in BridgingHeader.h, like led_driver_set_brightness() or led_driver_set_saturation(). Per Using SourceKit-LSP with Embedded Projects I've attempted to specify -import-bridging-header to the LSP like so, but I couldn't get it working.

.vscode/settings.json:

"swift.buildArguments": ["-import-bridging-header", "/Users/[redacted]/swift-matter-examples/led-blink/main/BridgingHeader.h"]

or via .sourcekit-lsp/config.json:

{
  "swiftPM": {
    "swiftCompilerFlags": "-import-bridging-header", "/Users/[redacted]/swift-matter-examples/led-blink/main/BridgingHeader.h"]
  }
}

Not sure if that matters, but I am able to successfully compile and upload the blink example to my ESP32C6. As far as I remember, in Xcode the autocomplete does suggest things imported through bridging header, so my guess is that it should be possible. Any help would be greatly appraciated.

3 Likes