Get Involved/development/IDE configuration: Difference between revisions

From KDE Community Wiki
(Create subpage for Qt Creator)
(Add page Get_Involved/development/IDE_configuration/KDevelop)
Line 8: Line 8:


* Kate - KDE's advanced text editor
* Kate - KDE's advanced text editor
* KDevelop - KDE's own IDE
* [[Get_Involved/development/IDE_configuration/KDevelop|KDevelop]] - KDE's own IDE
* [[Get_Involved/development/IDE_configuration/Qt_Creator|Qt Creator]] - By the Qt Project, strong integration with UI design and creation
* [[Get_Involved/development/IDE_configuration/Qt_Creator|Qt Creator]] - By the Qt Project, strong integration with UI design and creation
* VSCode - Popular, customizable, support for many programming languages
* VSCode - Popular, customizable, support for many programming languages

Revision as of 17:41, 31 July 2022

Setting up an IDE for KDE Development


There are many available choices for code editors and Integrated Development Environments (IDEs).

Some popular choices are (in no particular order):

  • Kate - KDE's advanced text editor
  • KDevelop - KDE's own IDE
  • Qt Creator - By the Qt Project, strong integration with UI design and creation
  • VSCode - Popular, customizable, support for many programming languages

The choice is often a personal preference, here we list some instructions and tips on getting editors and IDEs working well with KDE projects.


Visual Studio Code (VSCode)

VSCode is a very popular cross-platform, general-purpose, open source IDE. Thanks to its powerful extensions systems it supports many languages as well as deep customization options for themes, fonts, keyboard controls, and more.


Installing

VSCode is available as a deb, rpm, portable, and in the Arch User Repository.

https://code.visualstudio.com/Download


Extensions

Once VSCode is installed we need some extensions to enable support for the languages to work on KDE projects.

  1. C/C++ Extension Pack - Enables support for C++ and CMake.
  1. Qt tools - Enables some Qt support.
  1. QML - Enables syntax highlighting for QML.

Optional:

Zeal is an application that allows browsing documentation offline.

Dash is a VSCode extension that enables a hotkey (Ctrl + H) to instantly open the item under the cursor in Zeal.

These paired together make looking up documentation while working on code very quick and easy.


Configuration

VSCode holds settings related to specific projects in the top-level project directory, in a hidden .vscode folder.

We will use Dolphin as an example of where to add our project configuration files:

settings.json

This config specifies the correct build directory.

Create the file settings.json at ~/kde/src/dolphin/.vscode/settings.json

Add the following to the new file:

{
    "cmake.buildDirectory": "${workspaceFolder}/../../build/dolphin"
}

c_cpp_properties.json

This config enables the correct settings to support C++, CMake & IntelliSense.

Create the file c_cpp_properties.json at ~/kde/src/dolphin/.vscode/c_cpp_properties.json

Add the following to the new file:

{
    "configurations": [
        {
            "name": "Linux",
            "includePath": [
                "${workspaceFolder}/**"
            ],
            "defines": [],
            "compilerPath": "/usr/bin/gcc",
            "cStandard": "c17",
            "cppStandard": "c++17",
            "intelliSenseMode": "${default}",
            "compileCommands": "${workspaceFolder}/compile_commands.json"
        }
    ],
    "version": 4
}

VSCode User Settings

These settings apply once to every project

  • In VSCode open the command palette with Ctrl + Shift + P
  • Search for and open the user settings.json: "Preferences: Open Settings (JSON)"
  • Add the following block:


"cmake.environment": {
    "PATH": "~/kde/usr/bin:${env:PATH}",
    "XDG_DATA_DIRS": "~/kde/usr/share:${env:XDG_DATA_DIRS}",
    "XDG_CONFIG_DIRS": "~/kde/usr/etc/xdg:${env:XDG_CONFIG_DIRS}",
    "QT_PLUGIN_PATH": "~/kde/usr/lib/plugins:${env:QT_PLUGIN_PATH}",
    "QML2_IMPORT_PATH": "~/kde/usr/lib/qml:${env:QML2_IMPORT_PATH}",
    "QT_QUICK_CONTROLS_STYLE_PATH": "~/kde/usr/lib/qml/QtQuick/Controls.2/:${env:QT_QUICK_CONTROLS_STYLE_PATH}",
  },

.kdesrc-buildrc

Needed to enable LSP support:

In ~/.kdesrc-buildrc ensure these two options are in the global section and set to true:

    compile-commands-linking true
    compile-commands-export true

Working on a project

We work on a project in VSCode by opening it as a folder:

  • File -> Open Folder
  • Navigate to ~/kde/src/dolphin and press OK

Information

Along the bottom of the window are buttons to configure, build, run, debug, etc.