Skip to content

Commit 190d3be

Browse files
authored
Update how to use VSCode with clangd after the monorepo merge (flutter#163671)
1 parent 178749b commit 190d3be

File tree

1 file changed

+27
-7
lines changed

1 file changed

+27
-7
lines changed

engine/src/flutter/docs/contributing/Setting-up-the-Engine-development-environment.md

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -90,25 +90,45 @@ VSCode can provide some IDE features using the [C/C++ extension](https://marketp
9090

9191
Intellisense can also use our `compile_commands.json` for more robust functionality. Either symlink `src/out/compile_commands.json` to the project root at `src` or provide an absolute path to it in the `c_cpp_properties.json` config file. See ["compile commands" in the c_cpp_properties.json reference](https://code.visualstudio.com/docs/cpp/c-cpp-properties-schema-reference). This will likely resolve the basic issues mentioned above.
9292

93-
For example, in `src/.vscode/settings.json`:
93+
The easiest way to do this is create a [multi-root workspace](https://code.visualstudio.com/docs/editor/workspaces/workspaces#_multiroot-workspaces) that includes the Flutter SDK. For example, something like this:
9494

9595
```json
96+
# flutter.code-workspace
9697
{
97-
"clangd.path": "buildtools/mac-arm64/clang/bin/clangd",
98-
"clangd.arguments": [
99-
"--compile-commands-dir=out/host_debug_unopt_arm64"
100-
],
101-
"clang-format.executable": "buildtools/mac-arm64/clang/bin/clang-format"
98+
"folders": [
99+
{
100+
"path": "path/to/the/flutter/sdk"
101+
}
102+
],
103+
"settings": {}
104+
}
105+
```
106+
107+
Then, edit the `"settings"` key:
108+
109+
```json
110+
"settings": {
111+
"html.format.enable": false,
112+
"githubPullRequests.ignoredPullRequestBranches": [
113+
"master"
114+
],
115+
"clangd.path": "engine/src/flutter/buildtools/mac-arm64/clang/bin/clangd",
116+
"clangd.arguments": [
117+
"--compile-commands-dir=engine/src/out/host_debug_unopt_arm64"
118+
],
119+
"clang-format.executable": "engine/src/flutter/buildtools/mac-arm64/clang/bin/clang-format"
102120
}
103121
```
104122

105123
... which is built with:
106124

107125
```shell
108126
# M1 Mac (host_debug_unopt_arm64)
109-
./tools/gn --unopt --mac-cpu arm64 --enable-impeller-vulkan --enable-impeller-opengles --enable-unittests
127+
et build -c host_debug_unopt_arm64
110128
```
111129

130+
Some files (such as the Android embedder) will require an Android `clangd` configuration.
131+
112132
For adding IDE support to the Java code in the engine with VSCode, see ["Using VSCode as an IDE for the Android Embedding"](#using-vscode-as-an-ide-for-the-android-embedding-java).
113133

114134
### Zed Editor

0 commit comments

Comments
 (0)