Configure Code Suggestions

Before you can use Code Suggestions, you must set it up.

Set up Code Suggestions

Prerequisites:

  • You should have the latest version of GitLab.

To set up Code Suggestions:

  1. Configure GitLab Duo.
  2. Check that your preferred language is supported.
  3. Configure your editor extension.

Configure GitLab Duo

  1. Create a personal access token with at least the ai_features scope.
  2. Turn on GitLab Duo.
  3. Purchase the GitLab Duo Pro add-on subscription.
  4. Get a Duo Pro seat assigned to you, either individually or in bulk.
  5. For GitLab self-managed, you must:

For more information, see how to Get started with GitLab Duo.

Check language support

Code Suggestions supports a range of programming languages and development concepts.

Check that Code Suggestions supports your preferred language.

Different IDEs support different languages.

Configure editor extension

note
You might have already completed this as part of getting started with GitLab Duo.

To use Code Suggestions, if you are not using the GitLab Web IDE, you must configure one of the following editor extensions to then use an equivalent IDE:

  • GitLab Workflow for VS Code.
  • Visual Studio GitLab Extension.
  • GitLab Duo Plugin for JetBrains.
  • gitlab.vim plugin for Neovim.

Regardless of the extension you use, you must:

  1. Install the extension in your IDE.
  2. Authenticate with GitLab from the IDE. You can use either OAuth or the personal access token you created when configuring GitLab Duo.
  3. Configure the extension.

GitLab Workflow for VS Code

  1. Install the extension.
  2. Authenticate with GitLab.
  3. Configure the extension.

Visual Studio GitLab extension

  1. Install the extension.
  2. Authenticate with GitLab.
  3. Configure the extension.

GitLab Duo plugin for JetBrains IDEs

  1. Install the extension.
  2. Configure the extension.
  3. Authenticate with GitLab.

gitlab.vim plugin for Neovim

  1. Install the extension.
  2. Authenticate with GitLab.
  3. Configure the extension.
  4. Enable Omni Completion.

Turn off Code Suggestions

How you turn off Code Suggestions differs depending on which editor extension and IDE you use.

note
When turning off Code Suggestions, you cannot turn off code generation and code completion separately.

VS Code

To turn off Code Suggestions in the UI:

  1. In VS Code, go to Code > Settings > Extensions.
  2. Select Manage () > Settings.
  3. Clear the GitLab Duo Code Suggestions checkbox.

You can also set gitlab.duoCodeSuggestions.enabled to false in the VS Code settings.json file.

Visual Studio

To turn Code Suggestions on or off without uninstalling the extension, assign a keyboard shortcut to the GitLab.ToggleCodeSuggestions custom command.

To disable or uninstall the extension, see the Microsoft Visual Studio documentation on uninstalling or disabling the extension.

JetBrains IDEs

The process to disable GitLab Duo, including Code Suggestions, is the same regardless of which JetBrains IDE you use.

  1. In your JetBrains IDE, go to settings and select the plugins menu.
  2. Under the installed plugins, find the GitLab Duo plugin.
  3. Disable the plugin.

For more information, see the JetBrains product documentation.

Neovim

  1. Go to the Neovim defaults.lua settings file.
  2. Under code_suggestions, change the enabled = flag to false:

    code_suggestions = {
    ...
     enabled = false,
    

Turn off GitLab Duo

Alternatively, you can turn off GitLab Duo (which includes Code Suggestions) completely for a group, project, or instance.