C++ LSP
#1
Does anyone have tips on setting up an LSP for nice editing of the C++ code?

I'm not a C++ dev, so I've just cobbled a few things together, and it's not working quite right.  I have clangd, I set my editor to use `clangd-18 --background-index --clang-tidy`, and I put `set(CMAKE_EXPORT_COMPILE_COMMANDS ON)` in CMakeLists.txt.  I don't get type hints, I get tons of type errors and undeclared identifiers that are obviously wrong because the code uses them fine, and "go to definition" only occasionally works, and seemingly only for third-party libraries.  It seems like I'm missing something that tells the LSP about the Tangara source.  I haven't had this issue with other languages before.
  Reply
#2
It can sometimes be a bit finniky, but Daniel and I both have working LSP integration. I use helix (https://helix-editor.com/), Daniel uses VS Code. I don't think either of us has had to change CMAKE_EXPORT_COMPILE_COMMANDS; my understanding is that something in esp-idf ends up enabling this for us anyway.

The main thing I had to do was pass `-query-driver=**` to clangd. My `.clangd` file in the root of the esp32 firmware directory looks like this:


Code:
CompileFlags:
  Add: [
    -D__XTENSA__,
    --target=mipsel-linux-gnu,
  ]
  Remove: [
    -fno-tree-switch-conversion,
    -mlongcalls,
    -fstrict-volatile-bitfields,
    -fno-shrink-wrap,
  ]



(this is all written up here as well: https://codeberg.org/cool-tech-zone/tang...angd-setup)

Daniel might also have things to add that he's had to do to get things working.
  Reply
#3
Sorry, I hadn't seen that section of BUILDING.md!  Honestly I think I saw the "VSCode" header and thought the LSP section was specific to it.

When you say "the esp32 firmware directory", what does that mean specifically?  The BUILDING file says it's "in the this directory", and I'm not sure what either means...

It's already way better with `-query-driver=**` though, thank you!
  Reply
#4
"the esp32 firmware directory" is the tangara-fw repo! the root of the repo!
  Reply
#5
(2025-01-07, 09:23 PM)jacqueline Wrote: "the esp32 firmware directory" is the tangara-fw repo! the root of the repo!
Oh, thanks!  Sorry, I thought it meant one of the many esp32 things inside lib/esp-idf.  I don't know hardware either.  ;(
  Reply


Forum Jump: