Google is committed to advancing racial equity for Black communities. See how.

Installing extensions

The following VS Code extensions may provide a productive development environment for Fuchsia:

Fuchsia-specific extensions

Fuchsia-specific extensions provide support with custom Fuchsia files.

FIDL Language Support

FIDL Language Support provides syntax support and LSP-based language features in FIDL.

This figure shows syntax highlighting for FIDL files in VS Code.

Fuchsia.git Helper

Fuchsia.git Helper adds an "Open in...", which allows you to open a file in OSS Code Search.

To use this extension:

  1. Right click a file in the file editor.
  2. Select Open in OSS Code Search.

This figure shows the VS Code menu to open a file in OSS code search.

FuchsiAware

FuchsiAware assists with browsing Fuchsia artifacts, such as by linking from component URLs to component manifests.

This figure shows hyperlinks to fuchsia-pkg urls in VS Code.

zxdb for VS Code

The VS Code zxdb extension provides IDE based zxdb debugger support.

This gif shows a demo of the features.

General workflow extensions

General workflow extensions provide an overall productive workflow when working with Fuchsia.

GitLens

GitLens provides highly customizable insights of git history, which allows you to see code evolution.

This figure shows an overlay of git commit history in VS Code.

GN

GN adds syntax highlighting for GN files.

This figure shows syntax highlighting for GN files in VS Code.

GNFormat

GNFormat provides GN file formatting.

You may need to configure GNFormat with the file path to your GN binary and buildtools. Do the following:

  1. In VS Code, launch Quick Open by running CMD/CTRL + P.
  2. Type settings in the search field.
  3. Click Preferences: Open Settings (JSON).
  4. Add the following configuration and restart VS Code:
"gnformat.path.gn": "FILE_PATH",
"gnformat.path.buildtools": "BUILD_TOOLS_PATH"

JSON5

JSON5 adds syntax highlighting for JSON5 files.

This figure shows syntax highlighting for JSON5 files in VS Code.

Rust-analyzer

Rust-analyzer is a Language Server Protocol (LSP) implementation for the Rust language.

To use rust-analyzer with VS Code, Fuchsia recommends:

Configure workflow

After installing rust-analyzer, modify your VS Code's settings.json file:

  1. Press CMD/CTRL + SHIFT + P to open Command Palette.
  2. Type settings in the search field.
  3. Click Preferences: Open Settings (JSON).
  4. In settings.json, paste the following snippets:

  // disable cargo check on save
  "rust-analyzer.checkOnSave.enable": false,
  "rust-analyzer.checkOnSave.allTargets": false,

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,

Enable rustfmt

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:

rustup toolchain link fuchsia FUCHSIA_DIR/prebuilt/third_party/rust/HOST_OS

After configuring rustup, the rust-analyzer extension supports additional configuration with Fuchisa'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= FUCHSIA_DIR/rustfmt.toml"
    ],