{% include “docs/reference/tools/editors/vscode/_common/_vscode_header.md” %}
The following VS Code extensions may provide a productive development environment for Fuchsia:
Fuchsia-specific extensions provide support for working with Fuchsia software and systems. These extensions are currently supported by the Fuchsia project.
The Fuchsia extension for VS Code{: .external} provides support for debugging Fuchsia devices, logging, and syntax highlighting. This extension is Fuchsia’s official extension and can be used with the source tree and the SDK. For more information see the Fuchsia developer extension page.
These extensions are developed by Fuchsia contributors. Extensions listed are unsupported and could conflict with the official Fuchsia developer extension. It is recommended to use the Fuchsia developer extension.{: .external}
Fuchsia.git Helper{: .external} adds an “Open in...”, which allows you to open a file in OSS Code Search.
To use this extension:
FuchsiAware{: .external} assists with browsing Fuchsia artifacts, such as by linking from component URLs to component manifests.
GN{: .external} adds syntax highlighting for GN files.
GNFormat{: .external} provides GN file formatting.
You may need to configure GNFormat with the file path to your GN binary and buildtools. Do the following:
CMD/CTRL + P
.settings
in the search field."gnformat.path.gn": "{{ '<var>' }}FILE_PATH{{ '</var>' }}", "gnformat.path.buildtools": "{{ '<var>' }}BUILD_TOOLS_PATH{{ '</var>' }}"
General workflow extensions provide an overall productive workflow when working with Fuchsia.
GitLens{: .external} provides highly customizable insights of git history, which allows you to see code evolution.
FIDL Language Support{: .external} provides syntax support and LSP-based language features in FIDL.
Note: You need to configure Fuchsia environment variables to run this extension. For more information, see Set up environment variables.
In some cases, you may work on Fuchsia components using a structured configuration written in JSON5. JSON5{: .external} adds syntax highlighting for JSON5 files.
Rust-analyzer{: .external} is a Language Server Protocol{: .external} (LSP) implementation for the Rust language.
Note: If your Fuchsia source is symlinked from another mountpoint, the rust-analyzer
extension may not locate the files for analysis. Instead, open the actual file path to the Fuchsia source in VS Code.
To use rust-analyzer
with VS Code, Fuchsia recommends:
Using the fuchsia.code-workspace
configuration file will set recommended defaults for using rust-analyzer on Fuchsia. If you aren't using the workspace file, here are some settings you may want to add to your settings.json
:
// disable cargo check on save "rust-analyzer.checkOnSave.enable": false, "rust-analyzer.checkOnSave.allTargets": false, // workaround for https://fxbug.dev/42053708 // needed if you see errors about extension host crashing "rust-analyzer.files.watcher": "server",
Additionally, you may want to configure smaller tooltips and hide parameter hints to optimize your workspace:
// optional: only show summary docs for functions (keeps tooltips small) "rust-analyzer.callInfo.full": false, // optional: don't activate parameterHints automatically "editor.parameterHints.enabled": false,
The rust-analyzer
extension relies on the rustup
installer to invoke rustfmt
, a tool for formatting Rust code according to style guidelines.
To configure rustup
with your Fuchsia source code, run:
Note: HOST_OS
is linux-x64
on Linux and mac-x64
on macOS.
rustup toolchain link fuchsia {{ '<var>' }}FUCHSIA_DIR{{ '</var>' }}/prebuilt/third_party/rust/{{ '<var>' }}HOST_OS{{ '</var>' }}
After configuring rustup
, the rust-analyzer
extension supports additional configuration with Fuchsia's Rust style guide, rustfmt.toml
.
Add the following snippet to your settings.json
using the same steps from Configuring workflow:
// use fuchsia toolchain and fuchsia's rules for rustfmt: "rust-analyzer.rustfmt.extraArgs": [ "+fuchsia", "--config-path={{ '<var>' }}FUCHSIA_DIR{{ '</var>' }}/rustfmt.toml" ],
The Fuchsia SDK{:.external} uses the Bazel build system. The Bazel extension{:.external} can build and run components directly from VS Code.