JetBrains Fleet 1.42 Help

Getting started with C++

This tutorial gets you up to speed with C++ development in JetBrains Fleet. It covers the installation, project setup, and working with code.

Install Fleet

  1. Install JetBrains Toolbox 1.22.10970 or later: the Download page.

  2. Download and install JetBrains Toolbox.

  3. In JetBrains Toolbox, click Install near the JetBrains Fleet icon.

    Download and install Fleet

Set up a workspace

Prepare a compilation database for your project

JetBrains Fleet supports C++ projects with compilation databases.

A compilation database is a JSON file named compile_commands.json, which contains structured data about every compilation unit in the project.

Open a project

  1. Press ⌘ O or select File | Open from the menu.

  2. Select your project root folder and click Open:

    Opening a folder containing the project's compilation database
  3. The opened directory becomes the root of your workspace:

    Project opening

Switch to smart mode

Enable Smart mode

Smart Mode turns on code insight features for your C++ code.

  • Click the Smart Mode Status icon in the top-right corner. In the popup that appears, click Enable.

    Enabling Smart Mode

Troubleshooting Smart mode: LSP can't start

Smart mode can't start

This message indicates that Fleet might not have been able to download Clangd because of a firewall. Follow the steps below for a workaround.

  1. Download Clangd using the following links:

  2. Put the downloaded file into the ~/.fleet/ directory.

  3. Restart Fleet.

Here's what you can do in Smart Mode. The below is not an exhaustive list of Smart Mode features, rather a couple of examples that'll help you to get the feel of how it works in Fleet.

Spot syntax errors

  • All the errors in your code are highlighted red:

    Error highlighting for C++

Complete code automatically

  • Context-aware completion gives a list of suggestions for names, types, and keywords:

    Code completion for C++
  • Among the completion suggestions, you can find templates for common code constructs. Select one from the list, and then use Tab to move the caret between stubs:

    Inserting a live template

    Available code snippets:

    • typedef [type] [name];

    • using [name] [type];

    • namespace [name] = [namespace];

    • using namespace [identifier];

    • using [qualifier]::[name];

    • using typename [qualifier]::[name];

    • template<class [name]>

    • template<typename [name]>

    • switch ([condition]) { [cases] }

    • case [expression]:

    • goto [label];

    • dynamic_cast<[type]>([expression])

    • static_cast<[type]>([expression])

    • reinterpret_cast<[type]>([expression])

    • const_cast<[type]>([expression])

    • catch ([declaration]) { [statements] }

    • concept [name] = [constraint];

    • #define [macro]([args])

Reduce caret jumps

  • To transform an already typed expression into a different one without moving the caret, add a dot at the end. You will see postfix completion options among the list of suggestions:

    Postfix completion suggestions

    For example, you can choose if, and the initial expression will get wrapped into an if statement:

    Postfix completion result

View parameter information

  • Press ⌘ I to get the list of parameter names in a function call:

    Parameter info for C++

    Click Show all to view all the usages.

Check documentation in a popup

  • Hover over a class, function, field, or another element to see where and how it is defined:

    Quick definition popup

Rename code items

  • Select an item to be renamed, press ⌃ R, and enter the new name:

    Renaming a symbol
  • Navigate to the declaration of a symbol with ⌘ B.

  • Find usages of a symbol with ⌘ U:

    Find Usages results
  • Skim over the errors with ⌘ E and ⌘ ⇧ E.

Build and run your program

Fleet does not provide automation for the process of building a running C/C++ applications.

However, you can use Fleet's language-agnostic run configurations for that. Find below an example for the case of CMake:

{ "configurations": [ { "type": "command", "name": "Build", "program": "cmake", "args": ["--build", "$PROJECT_DIR$/cmake-build-debug", "--target", "program_name"], }, { "type": "command", "name": "Run", "program": "$PROJECT_DIR$/cmake-build-debug/program_name", }, ] }
    Last modified: 11 February 2024