GitLab Workflow extension for VS Code

The GitLab Workflow extension for Visual Studio Code integrates GitLab Duo and other GitLab features directly into your IDE.

The GitLab Workflow extension streamlines your VS Code workflow with AI-assisted features:

Code Suggestions features

GitLab Duo provides AI-powered code suggestions as you type in VS Code, helping you write code more efficiently. To interact with a code suggestion on the current line:

  • To accept the entire suggestion, press Tab.
  • To accept the suggestion word-by-word, press Command + (right arrow).
  • To accept an entire line, right-click and select Accept Line.

GitLab Duo can also generate code based on comments in the file you’re editing in VS Code. When you write comments in a supported file type, use natural language to describe what you want the code to do. Press Enter to see suggestions from GitLab Duo inline in your current file.

To learn more, see the documentation for Code Suggestions.

Set up the GitLab Workflow extension

This extension requires you to create a GitLab personal access token, and assign it to the extension:

  1. Install the extension from the Visual Studio Marketplace and enable it. If you use an unofficial version of VS Code, install the extension from the Open VSX Registry.
  2. To sign in to your GitLab instance, run the command GitLab: Authenticate in VS Code.
    1. Open the command palette by pressing Command + Shift + P.
    2. In the command palette, search for GitLab: Authenticate and press Enter.
    3. Select your GitLab instance URL from the offered options, or enter one manually.
      • When manually adding an instance to URL to GitLab instance, paste the full URL to your GitLab instance, including the http:// or https://. Press Enter to confirm.
    4. For GitLab.com, you can use the OAuth authentication method.
    5. If you don’t use OAuth, use a personal access token to log in.
      • If you have an existing personal access token with api scope, select Enter an existing token to enter it.
      • If you don’t, select Create a token first, and the extension opens the token settings page for you. If this method fails, follow the instructions to create a personal access token.
    6. Copy the token. For security reasons, this value is never displayed again, so you must copy this value now.
    7. Paste in your GitLab personal access token and press Enter. The token is not displayed, nor is it accessible to others.

The extension matches your Git repository remote URL with the GitLab instance URL you specified for your token. If you have multiple accounts or projects, you can choose the one you want to use. For more details, see Account management.

The extension shows information in the VS Code status bar if both:

  • Your project has a pipeline for the last commit.
  • Your current branch is associated with a merge request.

Configure extension settings

After you install GitLab Workflow, go to Settings > Extensions > GitLab Workflow in VS Code to configure its settings:

Customize keyboard shortcuts

You can assign different keyboard shortcuts for Accept Inline Suggestion, Accept Next Word Of Inline Suggestion, or Accept Next Line Of Inline Suggestion:

  1. In VS Code, run the Preferences: Open Keyboard Shortcuts command.
  2. Find the shortcut you want to edit, and select Change keybinding ().
  3. Assign your preferred shortcuts to Accept Inline Suggestion, Accept Next Word Of Inline Suggestion, or Accept Next Line Of Inline Suggestion.
  4. Press Enter to save your changes.

Configure more languages for Code Suggestions

To add more languages to Code Suggestions:

  1. Find your desired language in the list of language identifiers for VS Code. You need the Identifier for a later step.
  2. In VS Code, open the extension settings for GitLab Workflow:
    1. On the top bar, go to Code > Settings > Extensions.
    2. Search for GitLab Workflow in the list, then select Manage () > Extension Settings.
    3. In your User settings, find GitLab › Ai Assisted Code Suggestions: Additional Languages and select Add Item.
  3. In Item, add the language identifier, and select OK.

Integrate with GitLab

This extension brings the GitLab features you use every day directly into your VS Code environment:

For detailed information on these features, refer to the GitLab Workflow extension documentation.

Troubleshooting

If you encounter any issues or have feature requests:

  1. Check the extension documentation for known issues and solutions.
  2. Report bugs or request features in the gitlab-vscode-extension issue queue.