Set up Code Suggestions

You can use Code Suggestions in several different IDEs. To set up Code Suggestions, follow the instructions for your IDE.

Prerequisites

To use Code Suggestions, you need:

  • A GitLab Duo add-on subscription and an assigned seat.
  • To confirm that Code Suggestions supports your preferred language. Different IDEs support different languages.

Configure editor extension

Code Suggestions is part of an editor extension. To use Code Suggestions, you will:

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

Follow these steps for your IDE:

Turn on Code Suggestions

If you are assigned a seat, GitLab Duo AI-powered features are turned on by default. However, you can confirm that Code Suggestions is turned on.

VS Code

To verify that Code Suggestions is turned on in VS Code:

  1. In VS Code, go to Settings > Extensions > GitLab Workflow.
  2. Select Manage ().
  3. Ensure that GitLab › Duo Code Suggestions: Enabled is selected.
  4. Optional. For GitLab › Duo Code Suggestions: Enabled Supported Languages, select the languages you want to suggest or generate code for.
  5. Optional. For GitLab › Duo Code Suggestions: Additional Languages, add other languages you’d like to use.

Visual Studio

To verify that Code Suggestions is turned on in Visual Studio:

  1. In Visual Studio, on the bottom status bar, point to the GitLab icon.
  2. When Code Suggestions is enabled, the icon tooltip shows GitLab code suggestions are enabled.
  3. If Code Suggestions are not enabled, on the top bar select Extensions > GitLab > Toggle Code Suggestions to enable it.

JetBrains IDEs

To verify that Code Suggestions is turned on in JetBrains IDEs:

  1. In your IDE, on the top bar, select your IDE’s name, then select Settings.
  2. On the left sidebar, expand Tools, then select GitLab Duo.
  3. In the Features section, ensure that Enable Code Suggestions and Enable GitLab Duo Chat are selected.
  4. Select OK or Save.

Add a custom certificate for Code Suggestions

History

GitLab Duo attempts to detect trusted root certificates without configuration on your part. If needed, configure your JetBrains IDE to allow the GitLab Duo plugin to use a custom SSL certificate when connecting to your GitLab instance.

To use a custom SSL certificate with GitLab Duo:

  1. In your IDE, on the top bar, select your IDE name, then select Settings.
  2. On the left sidebar, expand Tools, then select GitLab Duo.
  3. Under Connection, enter the URL to GitLab instance.
  4. To verify your connection, select Verify setup.
  5. Select OK or Save.

If your IDE detects a non-trusted SSL certificate:

  1. The GitLab Duo plugin displays a confirmation dialog.
  2. Review the SSL certificate details shown.
    • Confirm the certificate details match the certificate shown when you connect to GitLab in your browser.
  3. If the certificate matches your expectations, select Accept.

To review certificates you’ve already accepted:

  1. In your IDE, on the top bar, select your IDE name, then select Settings.
  2. On the left sidebar, select Tools > Server Certificates.
  3. Select Server Certificates.
  4. Select a certificate to view it.

Neovim

Code Suggestions provides a LSP (Language Server Protocol) server, to support the built-in Control+x, Control+o Omni Completion key mapping:

Mode Key mappings Type Description
INSERT Control+x, Control+o Built-in Requests completions from GitLab Duo Code Suggestions through the language server.
NORMAL <Plug>(GitLabToggleCodeSuggestions) <Plug> Toggles Code Suggestions on or off for the current buffer. Requires configuration.

Verify that Code Suggestions is on

All editor extensions from GitLab, except Neovim, add an icon to your IDE’s status bar. For example, in Visual Studio:

The status bar in Visual Studio.

Icon Status Meaning
Ready You’ve configured and enabled GitLab Duo, and you’re using a language that supports Code Suggestions.
Not configured You haven’t entered a personal access token, or you’re using a language that Code Suggestions doesn’t support.
The status icon for fetching Code Suggestions. Loading suggestion GitLab Duo is fetching Code Suggestions for you.
The status icon for a Code Suggestions error. Error GitLab Duo has encountered an error.

Turn off Code Suggestions

The process for turning off Code Suggestions is different for each IDE.

note
You cannot turn off code generation and code completion separately.

VS Code

To turn off Code Suggestions in VS Code:

  1. Go to Code > Settings > Extensions.
  2. Select Manage () > Settings.
  3. Clear the GitLab Duo Code Suggestions checkbox.

Instead, you can 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.