Clion Visual Studio

Posted onby admin

The extension allows formatting c++ files using CLion's command-line interface.https://www.jetbrains.com/help/clion/command-line-formatter.html

Q&A

Q: What was this extension developed for?

A: If you have a CLion's formatting settings file, and you need to ensure that the code formatting in visual studio code is identical to how it is done in Clion you can use this tool. CLion IDE has the feature to export clion-codestyle.xml file to .clang-format file, however, this does not provide 100% identical formatting.

Usage

  1. Install an extension from the marketplace;
  2. Set the extension settings;
  3. Open the C ++ file in the editor, select 'Format Document With ...' in the context menu, or select a code fragment and select 'Format Selection With ...' in the context menu, then select 'CLion format';
  4. Standard shortcuts can be used for formatting.

Features

  • Made in accordance with the official guidelines: https://code.visualstudio.com/blogs/2016/11/15/formatters-best-practices;
  • Allows you to edit the selected text or the whole file;
  • You will have time to make yourself a coffee because it works slightly slowly :)

Extension Settings

This extension contributes the following settings:

  • clion-formatter.executable: clion executable path
  • clion-formatter.settings: code style settings file path to use for formatting

The new CLion 2021.1 EAP build (211.6432.9) is now available. You can get it from our website, via the Toolbox App, or as a snap package (if you are using Ubuntu).Note that if you are on macOS, there is a separate build for Apple Silicon (M1 chip). Cmd.exe /k 'C: Program Files (x86) Microsoft Visual Studio 2017 Enterprise VC Auxiliary Build vcvars64.bat' However, I don't know how to get cargo to run in that command prompt. I also don't see a way to control arguments to 'cargo build'. If I could add '-features 'clion', then I could work-around the build issue for now.

Features Eclipse IntelliJ IDEA CLion Visual Studio VS Code What's New Install SonarLint in your IDE SonarLint is a free IDE extension and is available directly from your favourite IDE marketplace.

  • 从Visual Studio官网下载Visual Studio 2019 Installer,完成安装。打开Installer,从开始界面搜索Installer可以找到,桌面看不到。安装Visual Studio Community 2019社区版本,在单个组件选项页面搜索msvc,找到MSVC v142 - VS 2019 C X64/x86生成工具(v14.27)(选择最新版本就行了,具体的生成工具种类,按自己的需求选择.
  • Extension for Visual Studio Code - A CLion color theme for VSCode!

PlatformIO is an open-source ecosystem for embedded development. It allows working with various MCUs (such as ARM Cortex, AVR, MSP430), development boards, frameworks, and environments (Arduino, ESP-IDF, and many others).

CLion's integration with PlatformIO is provided by the PlatformIO for CLion plugin, created in collaboration with the PlatformIO team.

Clion Vs

Clion

The plugin is being actively developed. You can monitor the progress and leave your feedback in the tickets linked to CPP-18398: Support PlatformIO.

Installation

Install PlatformIO

  1. Refer to the official guide for details of the installation procedure.

  2. As you will be using PlatformIO in CLion, make sure to install Shell commands.

Install the PlatformIO plugin

  1. Go to Settings / Preferences Plugins and switch to Marketplace.

  2. Search for PlatformIO for CLion and click Install.

  3. You will be prompted to install the Ini plugin, which provides code insight for platformio.ini files. Click Install.

  4. After the installation is finished, click Restart IDE.

By default, CLion takes the path to PlatformIO Core CLI from system path. You can specify a custom location in Settings / Preferences Languages & Frameworks PlatformIO.

Creating a project

  1. Call File New Project from the main menu and select PlatformIO in the left-hand pane.

  2. Set the project name, choose a board or framework, and click Create.

CLion will generate a PlatformIO CMake-base project, calling the proper PlatformIO command in the background:

For Arduino-based boards, CLion generates main.cpp instead of main.c and fills it with Arduino-specific stub code:

CMake profiles

CLion automatically creates CMake profiles for the corresponding CMAKE_CONFIGURATION_TYPES entries. To configure the profiles, go to Settings / Preferences Build, Execution, Deployment CMake:

Notice that Build type corresponds to the PlatformIO environment in use.

Clion Visual Studio Debugger

The directory specified in Build directory is used for storing CMake build artifacts (in our example, it is called cmake-build-eval_l073z ). This directory is excluded from project indexing and is highlighted accordingly in the project tree:

Clion Visual Studio

Run/debug configurations

When you create or open a PlatformIO project, configurations for upload and debug are created automatically:

Add PlatformIO configurations

  1. Select Edit Configurations in the switcher or call Run Edit Configurations from the main menu.

  2. In the left-hand pane, click and select the PlatformIO node. Choose among the configuration types:

    ConfigurationDescription
    Debug

    Starts a debug session with PIO Unified Debugger by calling platformio debug.

    All the CLion debug features are available, including peripheral registers view, memory view, and disassembly.

    For Arduino (and a number of other frameworks), debugging may not be available due to hardware limitations.

    ProgramUploads the firmware using a programmer.
    TestRuns the project's unit tests by calling platformio test.
    UploadUploads the firmware by calling platformio run -t upload.
    Upload fsUploads the firmware to file system SPIFFS by calling platformio run -t uploadfs.
  3. Set the configuration name and click Apply.

Clion visual studio not found

Note that all PlatformIO configurations include Build as a pre-launch step. If you need to build the project separately, select a configuration in the Edit Configurations dialog and remove () the Build step in the Before launch area.

PlatformIO actions

Clion Visual Studio Debugger

Besides the run/debug configurations, a few PlatformIO commands are also available as IDE actions. Use Tools PlatformIO on the main menu or right-click platformio.ini in the Project tree and select the PlatformIO node:

Clion visual studio not found
  • Build Production- calls platformio run to build the project in release configuration.

  • Build- calls platformio run --target debug to build the project with debug information and all optimizations turned off.

  • Clean- calls platformio run --target clean.

  • Check- calls platformio check for static code analysis.

  • Re-Init- calls platformio init. Use this action to update your project following the changes in platformio.ini.

  • Update All- calls platformio update.

  • Monitor- calls platformio device moitor.

  • Home- calls platformio home and opens PlatformIO Home in your browser.

You can always run PlatformIO commands from CLion's built-in terminal.

Code assistance in platformio.ini

Clion Visual Studio Code

The Ini plugin, which comes in pair with the PlatformIO plugin, provides syntax highlighting, code formatting, and structure view for .ini files.

To open the structure view for platformio.ini, open it in the editor and then select View Tool Windows Structure from the main menu or press Ctrl+F12.

You can navigate to a property via Go to Symbol (Ctrl+Alt+Shift+N or Navigate Symbol on the main menu).

Also, the Ini plugin provides inspections for detecting duplicate properties and sections. You can change the severity of these inspections and turn them on/off in Settings / Preferences Editor Inspections Ini files.