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:
- GitLab Duo Chat: Interact with an AI assistant directly in VS Code. See how to set up GitLab Duo Chat.
- GitLab Duo Code Suggestions: Suggest completions to your current line of code, or write natural-language code comments to get more substantive suggestions.
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:
- 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.
- To sign in to your GitLab instance, run the command GitLab: Authenticate in VS Code.
- Open the command palette by pressing Command + Shift + P.
- In the command palette, search for GitLab: Authenticate and press Enter.
- 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://
orhttps://
. Press Enter to confirm.
- When manually adding an instance to URL to GitLab instance, paste the full URL to your
GitLab instance, including the
- For
GitLab.com
, you can use the OAuth authentication method. - 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.
- If you have an existing personal access token with
- Copy the token. For security reasons, this value is never displayed again, so you must copy this value now.
- 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:
- GitLab Duo Chat.
- Features to display or hide.
- Self-signed certificate information.
- Code Suggestions.
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:
- In VS Code, run the
Preferences: Open Keyboard Shortcuts
command. - Find the shortcut you want to edit, and select Change keybinding ({pencil}).
- Assign your preferred shortcuts to Accept Inline Suggestion, Accept Next Word Of Inline Suggestion, or Accept Next Line Of Inline Suggestion.
- Press Enter to save your changes.
Configure more languages for Code Suggestions
To add more languages to Code Suggestions:
- Find your desired language in the list of language identifiers for VS Code. You need the Identifier for a later step.
- In VS Code, open the extension settings for GitLab Workflow:
- On the top bar, go to Code > Settings > Extensions.
- Search for GitLab Workflow in the list, then select Manage ({settings}) > Extension Settings.
- In your User settings, find GitLab › Ai Assisted Code Suggestions: Additional Languages and select Add Item.
- 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:
- View issues and merge requests.
- Run common commands from the Visual Studio Code command palette.
- Create and review merge requests.
- Validate your GitLab CI/CD configuration.
- View pipeline status and job outputs.
- Create and manage snippets.
- Browse repositories without cloning them.
- View security findings.
For detailed information on these features, refer to the GitLab Workflow extension documentation.
Troubleshooting
If you encounter any issues or have feature requests:
- Check the extension documentation for known issues and solutions.
- Report bugs or request features in the
gitlab-vscode-extension
issue queue.