Help us learn about your current experience with the documentation. Take the survey.

支持的扩展和语言

  • Tier: Premium, Ultimate
  • Add-on: GitLab Duo Core, Pro, or Enterprise, GitLab Duo with Amazon Q
  • Offering: GitLab.com, GitLab Self-Managed, GitLab Dedicated

Code Suggestions 在以下编辑器扩展和语言中可用。

支持的编辑器扩展

要使用 Code Suggestions,请使用以下编辑器扩展之一:

IDE Extension
Visual Studio Code (VS Code) GitLab Workflow for VS Code
GitLab Web IDE (VS Code in the Cloud) 无需配置。
Microsoft Visual Studio (2022 for Windows) Visual Studio GitLab extension
JetBrains IDEs GitLab Duo Plugin for JetBrains
Neovim gitlab.vim 插件
Eclipse GitLab for Eclipse

在 VS Code、Visual Studio、Eclipse 和 Neovim 中使用 GitLab Language Server。语言服务器支持在更多平台上进行更快的迭代。您还可以配置它,以在 GitLab 未提供官方支持的 IDE 中支持 Code Suggestions。

您可以在 此问题 中表达对其他 IDE 扩展支持的兴趣。

按 IDE 支持的语言

下表提供了有关 Code Suggestions 默认支持的语言和 IDE 的更多信息。

Code Suggestions 也适用于其他语言,但您必须手动添加支持

Language Web IDE VS Code JetBrains IDEs Visual Studio 2022 for Windows Neovim Eclipse
C check-circle-filled check-circle-filled Yes dash-circle check-circle-filled check-circle-filled check-circle-filled
C++ check-circle-filled check-circle-filled Yes check-circle-filled check-circle-filled check-circle-filled check-circle-filled
C# check-circle-filled check-circle-filled Yes check-circle-filled check-circle-filled check-circle-filled check-circle-filled
CSS check-circle-filled dash-circle dash-circle dash-circle dash-circle dash-circle
Go check-circle-filled check-circle-filled Yes check-circle-filled check-circle-filled check-circle-filled check-circle-filled
Google SQL check-circle-filled check-circle-filled Yes check-circle-filled check-circle-filled check-circle-filled dash-circle
HAML check-circle-filled check-circle-filled Yes check-circle-filled check-circle-filled check-circle-filled check-circle-filled
HTML check-circle-filled dash-circle dash-circle dash-circle dash-circle dash-circle
Java check-circle-filled check-circle-filled Yes check-circle-filled check-circle-filled check-circle-filled check-circle-filled
JavaScript check-circle-filled check-circle-filled Yes check-circle-filled check-circle-filled check-circle-filled check-circle-filled
Kotlin dash-circle check-circle-filled Yes

(需要提供 Kotlin 支持的第三方扩展)
check-circle-filled check-circle-filled check-circle-filled check-circle-filled
Markdown check-circle-filled dash-circle dash-circle dash-circle dash-circle dash-circle
PHP check-circle-filled check-circle-filled Yes check-circle-filled check-circle-filled check-circle-filled check-circle-filled
Python check-circle-filled check-circle-filled Yes check-circle-filled check-circle-filled check-circle-filled check-circle-filled
Ruby check-circle-filled check-circle-filled Yes check-circle-filled check-circle-filled check-circle-filled check-circle-filled
Rust check-circle-filled check-circle-filled Yes check-circle-filled check-circle-filled check-circle-filled check-circle-filled
Scala dash-circle check-circle-filled Yes

(需要提供 Scala 支持的第三方扩展)
check-circle-filled check-circle-filled check-circle-filled check-circle-filled
Shell scripts (bash only) check-circle-filled dash-circle check-circle-filled check-circle-filled check-circle-filled check-circle-filled
Svelte check-circle-filled check-circle-filled Yes check-circle-filled check-circle-filled check-circle-filled check-circle-filled
Swift check-circle-filled check-circle-filled Yes check-circle-filled check-circle-filled check-circle-filled check-circle-filled
TypeScript (.ts and .tsx files) check-circle-filled check-circle-filled Yes check-circle-filled check-circle-filled check-circle-filled check-circle-filled
Terraform dash-circle check-circle-filled Yes

(需要提供 Terraform 支持的第三方扩展)
check-circle-filled dash-circle check-circle-filled Yes

(需要提供 terraform 文件类型的第三方扩展)
check-circle-filled
Vue check-circle-filled check-circle-filled Yes check-circle-filled check-circle-filled check-circle-filled check-circle-filled

某些语言并非在所有 JetBrains IDE 中都受支持,或者可能需要额外的插件支持。请参阅 JetBrains 文档了解您 IDE 的具体信息。

对基础设施即代码 (IaC) 的支持

Code Suggestions 与基础设施即代码界面配合使用,包括:

  • Kubernetes Resource Model (KRM)
  • Google Cloud CLI
  • Terraform

管理 Code Suggestions 的语言

您可以通过启用或禁用特定支持语言的 Code Suggestions 来自定义在 VS Code 中的编码体验。 您可以通过直接编辑 settings.json 文件,或从 VS Code 用户界面执行此操作:

  1. 在 VS Code 中,打开 GitLab Workflow 的扩展设置:
    1. 在顶部栏中,转到 Code > Settings > Extensions
    2. 在列表中搜索 GitLab Workflow,然后选择 Manage ( settings )。
    3. 选择 Extension Settings
  2. 在您的 User 设置中,找到标题为 AI Assisted Code Suggestions: Enabled Supported Languages 的部分。
  3. 要为语言启用 Code Suggestions,请选择其复选框。
  4. 要为语言禁用 Code Suggestions,请清除其复选框。
  5. 您的更改会自动保存,并立即生效。

当您为语言禁用 Code Suggestions 时,Duo 图标会更改以显示该语言的建议已禁用。 悬停时,它会显示 Code Suggestions are disabled for this language

为更多语言添加支持

如果您需要的语言默认没有 Code Suggestions 可用, 您可以在本地为您的语言添加支持。 但是,Code Suggestions 可能无法按预期运行。

先决条件:

执行此操作:

  1. 语言标识符 列表中 找到您需要的语言。在后续步骤中,您需要这些语言的 标识符
  2. 在 VS Code 中,打开 GitLab Workflow 的扩展设置:
    1. 在顶部栏中,转到 Code > Settings > Extensions
    2. 在列表中搜索 GitLab Workflow,然后选择 Manage ( settings )。
    3. 选择 Extension Settings
    4. 在您的 User 设置中,找到 GitLab › Ai Assisted Code Suggestions: Additional Languages 并选择 Add Item
  3. Item 中,添加您要支持的每种语言的标识符。标识符应为 小写,如 htmlpowershell。不要在每个标识符前添加文件后缀的前导点。
  4. 选择 OK

先决条件:

执行此操作:

  1. 语言标识符 列表中 找到您需要的语言。在后续步骤中,您需要这些语言的标识符。
  2. 在您的 IDE 中,在顶部栏选择您的 IDE 名称,然后选择 Settings
  3. 在左侧边栏中,选择 Tools > GitLab Duo
  4. Code Suggestions Enabled Languages > Additional languages 下,添加您要支持的每种语言的标识符。 标识符应为小写,如 html。用逗号分隔多个标识符, 如 html,powershell,latex,不要在每个标识符前添加前导点。
  5. 选择 OK

先决条件:

执行此操作:

  1. 在您的 Eclipse 底部菜单中,选择 GitLab 图标。
  2. 选择 Show Settings
  3. 向下滚动到 Code Suggestions Enabled Languages 部分。
  4. Additional Languages 中,添加逗号分隔的语言标识符列表。不要 在标识符前添加前导点。例如,使用 htmlmdpowershell