feat(docs): update LSP setup instructions for compile_commands.json
This commit is contained in:
21
AGENTS.md
21
AGENTS.md
@@ -254,7 +254,7 @@ The monitor daemon automatically starts after upload and is killed before upload
|
||||
|
||||
3. **No unit tests**: This is an embedded Arduino sketch — no test suite exists. Verify changes by building and deploying to hardware.
|
||||
|
||||
4. **LSP errors are expected**: The LSP cannot find `Arduino.h` because it requires arduino-cli to resolve. Ignore clangd/IntelliSense errors about missing Arduino types; builds work correctly via arduino-cli.
|
||||
4. **LSP errors are expected**: The LSP may show errors about missing Arduino types until `compile_commands.json` is generated. Run `mise run gen-compile-commands` first, then restart the LSP. The build works correctly via arduino-cli.
|
||||
|
||||
5. **Build artifacts in board dirs**: Build output goes to `boards/[board]/build/` — cleaned by `mise run clean`.
|
||||
|
||||
@@ -328,7 +328,7 @@ Track changes that were reverted to avoid flapping:
|
||||
| "Another instance is running" error | Run `mise run kill BOARD=<board>` or `FORCE=1 mise run <task> BOARD=<board>` |
|
||||
| Upload fails - port in use | Run `mise run kill` to stop monitor daemon and release port |
|
||||
| Build fails - missing libraries | Run `mise run install-libs-shared` then `BOARD=<board> mise run install` |
|
||||
| LSP shows errors but build works | LSP cannot resolve Arduino types without arduino-cli; ignore clangd errors |
|
||||
| LSP shows errors but build works | Run `mise run gen-compile-commands` to generate compile_commands.json for your BOARD |
|
||||
| No serial output | Check baud rate is set to 115200 in serial monitor |
|
||||
| State file not updating | Ensure serial output contains `[STATE]` or `[ADMIN]` tags |
|
||||
|
||||
@@ -347,21 +347,10 @@ When uncertain about CLI tool flags or argument syntax:
|
||||
|
||||
## LSP / IDE Configuration
|
||||
|
||||
The project uses clangd for C++ and arduino-language-server for Arduino. The `.crush.json` contains dynamic FQBN resolution:
|
||||
The project uses **clangd** for C++ via the `compile_commands.json` generated by arduino-cli:
|
||||
|
||||
```json
|
||||
{
|
||||
"lsp": {
|
||||
"arduino": {
|
||||
"command": "arduino-language-server",
|
||||
"args": ["-fqbn", "$(cat boards/${BOARD:-esp32-32e-4}/board-config.sh | grep '^FQBN=' | cut -d'\"' -f2)"]
|
||||
},
|
||||
"cpp": {
|
||||
"command": "clangd"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
- `mise run gen-compile-commands` regenerates the compile database (automatically run as part of `compile`)
|
||||
- The generated `compile_commands.json` includes all necessary includes, defines, and library paths for your BOARD
|
||||
|
||||
**Generate compile_commands.json** for accurate IDE diagnostics:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user