// Copyright (C) 2023 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only

/*!
    \previouspage creator-language-servers.html
    \page creator-copilot.html
    \nextpage creator-mime-types.html

    \title Using GitHub Copilot

    The Copilot plugin (disabled by default) integrates
    \l{https://github.com/features/copilot}{GitHub Copilot} into \QC.
    You can view suggestions from Copilot in the \uicontrol Edit mode.

    \note If you enable the Copilot plugin, you must agree with and abide by
    the GitHub terms of use. It is your responsibility to know and accept the
    requirements and parameters of using Copilot, such as ensuring you have
    the rights to grant it access to your code. Also, you must understand the
    implications of using it and the suggestions it produces, such as code
    copyright and accuracy.

    \section1 Requirements

    To use the Copilot plugin, you need:

    \list
        \li An active \l{https://docs.github.com/en/billing/managing-billing-for-github-copilot/about-billing-for-github-copilot}
            {GitHub Copilot subscription}.
        \li GitHub Copilot Neovim plugin installed (requires Node.js), as described in
            \l{https://github.com/github/copilot.vim/blob/release/README.md}
            {Copilot.vim/Readme.md}.
    \endlist

    \section1 Setting Copilot Preferences

    To set preferences for using Copilot:

    \list 1
        \li Select \preferences > \uicontrol Copilot.
            \image qtcreator-preferences-copilot.webp {Copilot tab in Preferences}
        \li Select the \uicontrol {Enable Copilot} check box to use Copilot.
        \li Select \uicontrol {Sign In} to sign into your subscription, activate
            your device, and authorize the GitHub Copilot plugin.

            The button turns into a \uicontrol {Sign Out} button.
        \li In the \uicontrol {Node.js path} field, enter the full path to the
            Node.js executable.
        \li In the \uicontrol {Path to agent.js} field, enter the path to
            agent.js in the Copilot Neovim plugin installation folder.
        \li Select the \uicontrol {Auto request} check box to receive suggestions
            for the current text cursor position when you make changes.
        \li Select the \uicontrol {Use proxy} check box to use a proxy server to
            connect to Copilot servers.
        \li In the \uicontrol {Proxy host} field, enter the host name of the
            proxy server.
        \li In the \uicontrol {Proxy port} field, enter the port number of the
            proxy server.
        \li Select the \uicontrol {Reject unauthorized} check box to prevent the
            security risk presented by accepting unauthorized certificates from
            the proxy server.
        \li In the \uicontrol {Proxy user} field, enter the user name to
            authenticate to the proxy server.
        \li Select the \uicontrol {Save proxy password} check box to save the
            password to authenticate to the proxy server.
            \note The password is saved insecurely.
        \li In the \uicontrol {Proxy password} field, enter the password to save.
            To see the password as you type, select the \inlineimage icons/original-size.png
            button.
    \endlist

    \section1 Receiving Suggestions

    When you write code in the \l {Working in Edit Mode}{Edit} mode and
    \uicontrol {Auto request} is enabled, Copilot automatically makes
    suggestions when you type.

    \image qtcreator-copilot.gif {Receiving suggestions from Copilot in the editor}

    To manually request a suggestion at the current editor's cursor position,
    select \uicontrol {Request Copilot Suggestion} in the context menu.

    Hover the mouse over a suggestion to show a toolbar with
    \inlineimage icons/prev.png
    and \inlineimage icons/next.png
    buttons for cycling between Copilot suggestions.

    To apply a suggestion as a whole, select \uicontrol Apply or press
    the \key Tab key.

    To apply a suggestion word-by-word, select \uicontrol {Apply Word}
    or press \key {Alt+Right}.

    To reject a suggestion, press \key Esc or the arrow keys.

    \section1 Enabling and Disabling Suggestions

    You can enable and disable the Copilot suggestions either globally for all
    projects or at project level for a particular project.

    To enable or disable Copilot suggestions globally, select the
    \inlineimage icons/copilot.png
    (\uicontrol {Toggle Copilot}) button. This also sets the value of the
    \uicontrol {Enable Copilot} check box in \preferences accordingly.

    To enable or disable Copilot suggestions for a particular project,
    select \uicontrol Projects > \uicontrol {Project Settings} >
    \uicontrol Copilot, and then select or deselect the
    \uicontrol {Enable Copilot} check box.

    \sa {Enable and disable plugins}
*/
