Skip to content

Extension settings overview

When you start working with the extension, you only need to set up the SDK and toolchain versions.

After some time, you might need to modify other configuration options of the nRF Connect for VS Code extension to meet your needs. Make sure to have a good understanding of the nRF Connect SDK, the extension, and the workspaces when you do this.

Sources of settings

The extension uses the following patterns for gathering information about its settings:

Setting Source
VS Code settings VS Code setting files.
nRF Connect SDK and toolchain version Values set when setting up the SDK and the toolchain, stored in the VS Code workspace settings.
nRF Connect SDK application Contents of the build folders (for example, CMakeCache.txt and .config files).

The extension also uses the bash terminal settings, with the following exceptions:

  • VS Code picks up environment variables set in .profile. To disable this option while still being compatible with the bash terminal, move the nRF Connect SDK-specific environment variables (such as ZEPHYR_TOOLCHAIN_VARIANT or GNUARMEMB_TOOLCHAIN_PATH) to .profile.
  • On macOS and Linux, the extension queries bash for its environment on Linux and macOS, which executes the ~/.bashrc file. This file is used for storing environment variables on these operating systems. For more information, see West environment on macOS and Linux.

nRF Connect SDK and toolchain versions

By default, the nRF Connect SDK and toolchain versions are determined by the paths you selected when setting up the extension in the Quick Setup section:

  • nRF Connect SDK - This option sets the path to the nRF Connect SDK installation. The SDK can be installed either through the Toolchain Manager or manually.

  • nRF Connect Toolchain - This option sets the path to the nRF Connect Toolchain. The nRF Connect Toolchain is a set of development tools including west, CMake, and the GNU Arm Embedded Toolchain, among others. You can either set this option to the toolchain path installed with the SDK or select PATH (if the toolchain is installed on the system PATH).

If you want to compile your application against a different version, install that version from the Toolchain Manager and complete the related migration steps.

Configuration scopes

The configuration settings in the extension's Quick Setup are scope-aware and related to workspaces:

  • If a VS Code workspace is open, the settings affect the workspace configuration.
  • If there is no VS Code workspace open, the configuration settings affect the User Settings (nRF Connect > Toolchain: Path and nRF Connect: Topdir). User Settings act as a fallback if the current workspace does not override them. You can access them from File > Preferences > Settings > Extensions > nRF Connect.

Workspace settings in the extension

The extension stores information such as the nRF Connect SDK version, the nRF Connect SDK toolchain, and the application list in the VS Code workspace settings. While storing the settings, it uses built-in and custom variables to replace local system paths. This makes the workspace file suitable for checking in to version control and sharing between developers.

The following variables are used:

  • nrf-connect.applications
  • nrf-connect.topdir
  • nrf-connect.toolchain.path
  • nrf-connect.west.env

You can read more about variable substitution in Additional settings information.

Storing of the application and its settings

Based on the type of your current workspace, an application and its settings are saved in one of the following files:

  • Single-root workspace: .vscode/settings.json
  • Multi-root workspaces: <workspace_name>.code-workspace.json

To learn more about general VS Code workspace mechanisms, see the workspace documentation.

Caution

If you have not saved the current workspace you are working in, the file containing information about your application and its settings is saved in a temporary location. This temporary file is not meant to be interacted with directly. It is deleted at the end of the session, unless you save the workspace. When saving the workspace, you are asked for a location to save it in.

If you have not saved your current workspace, but want to recover your applications and their configurations, see the How to recover unsaved applications section.

Application sources

When you add an application, it is automatically added to the Applications View list. The list of applications there can be populated from the following sources:

All folders found within one of these sources are checked. If a folder turns out to be a valid nRF Connect SDK application, it will show up in the Applications View.

The source of the application affects how the application can be removed.

nRF Connect Toolchain path resolution

The extension resolves paths to the build tools, such as west or CMake, using the nrf-connect.toolchain.path setting. These paths are then set in the PATH environment variable in the environment that is used to call west for actions such as building or flashing.

To allow for this, the CMake NCS_TOOLCHAIN_VERSION variable is set to NONE when calling west. This instructs the build system to look for the necessary tools on PATH rather than resolve the paths internally.

When pasting command line invocations of west from the integrated terminal to an external terminal, make sure that the tools available on PATH in the external terminal are the same as the tools indicated by nrf-connect.toolchain.path.

nRF Connect terminal profile

The extension includes an nRF Connect terminal profile that is configured to work with west and the rest of the nRF Connect Toolchain and nRF Connect SDK environment. The version of the nRF Connect SDK used depends on the value of the nrf-connect.toolchain.path setting at the time the terminal is created.

To access the terminal profile, see the section about Profile actions in the Panel View.

Shell initialization conflicts

You may receive a warning message in the extension about shell initialization conflicts when opening the internal terminal with the nRF Connect profile. The internal terminal sets the shell environment for the configured SDK and toolchain, but the shell initialization script (for example, .bashrc) overrides the environment. This can happen if the ZEPHYR_BASE environment variable is set in .bashrc.

Note

To fix this issue, if there is no need for external terminals to use the ZEPHYR_BASE variable, you can remove this variable from .bashrc. Alternatively, you can move it to .bash_profile or an equivalent script that is only loaded by login shells.

Automatic IntelliSense configuration

The extension automatically configures IntelliSense in the C/C++ for Visual Studio Code extension. The extension checks the current file in the editor against the build configuration and source tree it belongs to. It then parses the build configuration, collects all the relevant compiler options, and configures IntelliSense for the current file.

You can simultaneously open source files that are shared by different build configurations. This is due to the structure and dependencies of an application source tree and the fact that you can work with multiple applications and build configurations in your workspace, for example nRF Connect SDK source files. In such cases, the extension tries to match the compiler options to the selected active application and build configuration.

If your settings contain C/C++ extension configurations (C_Cpp.defaults.<file-name> files), these might conflict or override the autoconfigured settings. To check which settings are applied, use the C/C++: Log Diagnostics command from the Command Palette.