Skip to main content

在环境中安装 GitHub Copilot 扩展

要在你的首选编码环境中使用 Copilot,必须安装 GitHub Copilot 扩展。

关于 Azure Data Studio 中的 GitHub Copilot 扩展

在 Azure Data Studio 中安装 GitHub Copilot 扩展之后,可以在键入时收到 Copilot 的编码建议。

要查看其他常用编码环境的说明,请使用页面顶部的工具切换器。

在 Azure Data Studio 中安装 GitHub Copilot 扩展

  1. 请确保能够访问 GitHub Copilot。 如需相关信息,请参阅“关于 GitHub Copilot”。

  2. 请确保拥有 Azure Data Studio 的兼容版本。 若要在 Azure Data Studio 中使用 GitHub Copilot,必须安装 Azure Data Studio 1.44.0 或更高版本。 请参阅 Azure Data Studio 文档中的 Azure Data Studio 下载页面

  3. 在 Azure Data Studio 中安装 GitHub Copilot 扩展。 请参阅 Microsoft 文档中的安装 GitHub Copilot 扩展

  4. 如果 Azure Data Studio 中的弹出窗口提示登录,以便使用 GitHub Copilot,请按下“登录到 GitHub”并按照屏幕上的说明进行操作。****

    • 如果以前已在 GitHub 上的帐户中授权 Azure Data Studio,系统将会自动授权 GitHub Copilot。
    • 如果没有收到授权提示,可以通过单击 Azure Data Studio 窗口底部面板中的钟形图标来查看通知。
  5. 如果在浏览器中按照授权步骤进行操作,GitHub 将请求 GitHub Copilot 必需的权限。 若要批准这些权限,请单击“授权 Azure Data Studio****”。

关于 JetBrains IDE 中的 GitHub Copilot 扩展

在 JetBrains IDE 中安装 GitHub Copilot 扩展之后,可以在 IDE 中与 Copilot 聊天,并在键入时收到 Copilot 的编码建议。

要查看其他常用编码环境的说明,请使用页面顶部的工具切换器。

版本兼容性

有关 JetBrains IDE 中的 GitHub Copilot 扩展的版本兼容性的信息,请参阅 JetBrains 市场中的 GitHub Copilot 版本

在 JetBrains IDE 中安装 GitHub Copilot 插件

以下过程将指导你在 IntelliJ IDEA 中安装 GitHub Copilot 插件。 在另一个受支持的 IDE 中安装插件的步骤可能有所不同。

  1. 请确保能够访问 GitHub Copilot。 如需相关信息,请参阅“关于 GitHub Copilot”。

  2. 请确保拥有一个与 GitHub Copilot 兼容的 JetBrains IDE。 GitHub Copilot 与以下 IDE 兼容:

    • IntelliJ IDEA(旗舰版、社区版、教育版)
    • Android Studio
    • AppCode
    • CLion
    • Code With Me Guest
    • DataGrip
    • DataSpell
    • GoLand
    • JetBrains Client
    • MPS
    • PhpStorm
    • PyCharm(专业版、社区版、教育版)
    • Rider
    • RubyMine
    • RustRover
    • WebStorm

    请参阅 JetBrains IDE 工具查找器进行下载。

  3. 为 JetBrains 安装 GitHub Copilot 插件。 请参阅 JetBrains Marketplace 中的 GitHub Copilot 插件

  4. 安装 GitHub Copilot 后,单击“重启 IDE”。

  5. JetBrains IDE 重启后,单击“工具”菜单。 单击“GitHub Copilot”,然后单击“登录到 GitHub”。

    展开的“工具”菜单和“GitHub Copilot”子菜单的屏幕截图。 “登录到 GitHub”选项以蓝色突出显示。

  6. 在“登录到 GitHub”对话框中,若要复制设备代码并打开设备激活窗口,请单击“复制并打开”。

    “登录到 GitHub”对话框的屏幕截图。 设备代码显示在标记为“复制并打开”的按钮上方。

  7. 设备激活窗口将在浏览器中打开。 粘贴设备代码,然后单击“继续”。

  8. GitHub 将请求 GitHub Copilot 所需的权限。 若要批准这些权限,请单击“授权 GitHub Copilot 插件”。

  9. 权限获得批准后,JetBrains IDE 将显示确认。 要开始使用 GitHub Copilot,请单击“确定”。

关于 Vim/Neovim 中的 GitHub Copilot 扩展

在 Vim/Neovim 中安装 GitHub Copilot 扩展之后,可以在键入时收到 Copilot 的编码建议。

要查看其他常用编码环境的说明,请使用页面顶部的工具切换器。

在 Vim/Neovim 中安装 GitHub Copilot 扩展

GitHub 建议使用 Vim/Neovim 的内置插件管理器安装 GitHub Copilot 插件。 或者,可以使用所选的插件管理器来安装 github/copilot.vim。 有关更多信息,请参阅 copilot.vim 存储库

  1. 请确保能够访问 GitHub Copilot。 如需相关信息,请参阅“关于 GitHub Copilot”。

  2. 请确保已安装 Vim/Neovim 的兼容版本。 要在 Vim/Neovim 中使用 GitHub Copilot,必须拥有 Vim 版本 9.0.0185/Neovim 版本 0.6 或更高版本以及 Node.js 版本 18 或更高版本。 请参阅 Vim / Neovim 文档Node.js 网站

  3. 使用内置插件管理器安装 GitHub Copilot:

    • 对于 macOS 或 Linux 上的 Vim,请在终端上运行如下命令:

      Shell
      git clone https://github.com/github/copilot.vim \
      ~/.vim/pack/github/start/copilot.vim
      
    • 对于 Windows 上的 Vim,请在 Git Bash 中运行如下命令:

      Shell
      git clone https://github.com/github/copilot.vim.git \
      $HOME/vimfiles/pack/github/start/copilot.vim
      
    • 对于 macOS 或 Linux 上的 Neovim,请在终端上运行如下命令:

      Shell
      git clone https://github.com/github/copilot.vim \
      ~/.config/nvim/pack/github/start/copilot.vim
      
    • 对于 Windows 上的 Neovim,请在 Git Bash 中运行如下命令:

      Shell
      git clone https://github.com/github/copilot.vim.git \
      $HOME/AppData/Local/nvim/pack/github/start/copilot.vim
      
  4. 若要配置 GitHub Copilot,请打开 Vim/Neovim 并输入以下命令。

    Shell
    :Copilot setup
    
  5. 在 Vim/Neovim 配置中或使用 Vim/Neovim 命令启用 GitHub Copilot。

    Shell
    :Copilot enable
    

关于 Visual Studio 中的 GitHub Copilot 扩展

在 Visual Studio 中安装 GitHub Copilot 扩展之后,可以在键入时收到 Copilot 的编码建议。

要查看其他常用编码环境的说明,请使用页面顶部的工具切换器。

版本兼容性

从 Visual Studio 2022 版本 17.10 开始,统一的 Copilot 和 GitHub Copilot Chat 扩展默认作为内置组件包含。 有关详细信息,请参阅 Microsoft 文档中的“在 Visual Studio 中安装 GitHub Copilot”。

在 Visual Studio 中安装 GitHub Copilot 扩展

  1. 请确保能够访问 GitHub Copilot。 如需相关信息,请参阅“关于 GitHub Copilot”。

  2. 请确保已安装 Visual Studio 的兼容版本。 要在 Visual Studio 中使用 GitHub Copilot,必须安装 Visual Studio for Windows 版本 2022 17.8 或更高版本。 有关更多信息,请参阅 Microsoft 文档中的“安装 Visual Studio”。

  3. 在 Visual Studio 中安装 GitHub Copilot。请参阅 Microsoft 文档中的“在 Visual Studio 中安装 GitHub Copilot”。

  4. 安装 GitHub Copilot 扩展之后,要启用 GitHub Copilot,请确保已将 GitHub 帐户添加到 Visual Studio。 有关更多信息,请参阅 Microsoft 文档中的将 GitHub 帐户添加到 Visual Studio 密钥链

关于 Visual Studio Code 中的 GitHub Copilot 扩展

在 Visual Studio Code 中安装 GitHub Copilot 扩展之后,可以在键入时收到 Copilot 的编码建议。 它还会自动安装 GitHub Copilot Chat 扩展,这样就可以与 Copilot 聊天。

要查看其他常用编码环境的说明,请使用页面顶部的工具切换器。

版本兼容性

Copilot Chat 因其深度 UI 集成而与 Visual Studio Code 同步发布。 因此,Copilot Chat 的每个新版本仅与最新版本的 Visual Studio Code 兼容。 这意味着,如果使用较旧版本的 Visual Studio Code,则将无法使用最新的 Copilot Chat。

只有最新的 Copilot Chat 版本才会使用 Copilot 服务提供的最新大型语言模型,因为即使是次要模型升级也需要扩展中的提示更改和修复。 旧版 Copilot Chat 仍将使用最新版本的 Copilot 代码完成。

在 Visual Studio Code 中安装 GitHub Copilot 扩展

  1. 请确保能够访问 GitHub Copilot。 如需相关信息,请参阅“关于 GitHub Copilot”。

  2. 安装 Visual Studio Code。 请参阅 Visual Studio Code 下载页面

  3. 在 Visual Studio Code 中安装 GitHub Copilot 扩展。 有关详细说明,请参阅 Visual Studio Code 文档中的“在 Visual Studio Code 中设置 GitHub Copilot”。

后续步骤