GitHub Copilot in Neovim: Installation and Configuration Steps
🔍 WiseChecker

GitHub Copilot in Neovim: Installation and Configuration Steps

You want to use GitHub Copilot inside Neovim to get AI-powered code suggestions as you type. GitHub Copilot requires the official Copilot plugin for Neovim and a GitHub Copilot subscription. This article explains how to install the plugin, authenticate your account, and configure key settings so Copilot works correctly in your editor.

Key Takeaways: GitHub Copilot in Neovim Setup

  • Plugin manager installation with lazy.nvim or vim-plug: The fastest way to install the copilot.lua plugin and keep it updated.
  • :Copilot auth command: Authenticates your GitHub Copilot subscription directly from Neovim.
  • vim.g.copilot_enabled = true in init.lua: Enables Copilot globally so suggestions appear in every buffer.

How GitHub Copilot Works in Neovim

GitHub Copilot is an AI code completion tool that suggests whole lines or functions as you type. In Neovim, it runs as a plugin that communicates with the GitHub Copilot service. The plugin intercepts your keystrokes, sends context to the cloud, and returns suggestions that appear inline.

Before you start, you need these prerequisites:

  • A GitHub account with an active Copilot subscription. Copilot Pro or Copilot Business both work.
  • Neovim version 0.5 or newer. The plugin uses Lua APIs available only in recent Neovim builds.
  • A plugin manager. This guide uses lazy.nvim, the most common choice for Neovim 0.8 and above.
  • Node.js version 16 or newer. The Copilot language server runs on Node.js.

The plugin itself is a Lua wrapper called copilot.lua. It replaces the older copilot.vim plugin and offers better performance and more configuration options. The official repository is github.com/zbirenbaum/copilot.lua.

Install copilot.lua with lazy.nvim

If you already use lazy.nvim, adding Copilot takes one block of code in your Neovim configuration file. The file is usually located at ~/.config/nvim/init.lua on Linux and macOS or ~/AppData/Local/nvim/init.lua on Windows.

  1. Open your Neovim configuration file
    Run nvim ~/.config/nvim/init.lua from your terminal. If the file does not exist, create it.
  2. Add the lazy.nvim plugin specification
    Insert this block inside your lazy.nvim setup function:
    {
      "zbirenbaum/copilot.lua",
      cmd = "Copilot",
      event = "InsertEnter",
      config = function()
        require("copilot").setup({})
      end,
    }

    The cmd = "Copilot" line loads the plugin only when you run a Copilot command. The event = "InsertEnter" line loads it when you enter insert mode, which is when suggestions appear.
  3. Save the file and restart Neovim
    Run :wq to save and exit. Then open Neovim again. lazy.nvim will download and compile copilot.lua automatically.
  4. Verify the plugin is loaded
    Run :Copilot status. You should see a message that Copilot is not yet authenticated. This is expected.

Authenticate GitHub Copilot in Neovim

Authentication links your Neovim instance to your GitHub Copilot subscription. The process uses a device code flow, so you do not need to paste a token manually.

  1. Run the authentication command
    In Neovim, type :Copilot auth and press Enter. The plugin will show a URL and an eight-character code in the command line area.
  2. Open the device activation page
    Copy the URL https://github.com/login/device and paste it into your browser. You can also type it manually.
  3. Enter the device code
    Type the eight-character code exactly as shown in Neovim. Click Continue or Authorize.
  4. Confirm in Neovim
    After authorization, return to Neovim. Run :Copilot status again. You should see a message like “Copilot: Online and ready”.

If you see an error about Node.js not being found, install Node.js version 16 or newer from nodejs.org and restart Neovim. Copilot will not work without the Node.js runtime.

Configure Copilot in Neovim

The default configuration works for most users. But you can customize suggestion behavior, key mappings, and panel appearance. All settings go inside the require("copilot").setup({}) call.

Enable or Disable Copilot Globally

  1. Set the global enable flag
    Add this line to your init.lua outside the setup call:
    vim.g.copilot_enabled = true
    Set it to false to disable Copilot without uninstalling the plugin.
  2. Toggle Copilot on the fly
    Run :Copilot enable or :Copilot disable to change the state for the current session.

Change Suggestion Appearance

Copilot shows suggestions as virtual text next to your cursor. You can control the delay and the suggestion format.

  1. Adjust suggestion delay
    Inside the setup call, add:
    suggestion = {
      enabled = true,
      auto_trigger = true,
      debounce = 75,
      keymap = {
        accept = "",
        next = "",
        prev = "",
      },
    }

    The debounce value is in milliseconds. Lower values make suggestions appear faster but use more CPU. The keymap entries let you accept a suggestion with Alt+L instead of Tab.
  2. Disable auto-trigger
    Set auto_trigger = false if you want to manually request suggestions with a key combination.

Use the Copilot Panel

The panel shows multiple alternative suggestions at once. You can cycle through them and accept one.

  1. Open the panel
    Run :Copilot panel. A vertical split window opens with several suggestion options.
  2. Navigate and accept
    Use j and k to move between suggestions. Press Enter to accept the highlighted one.

Common Issues After Installation

Copilot Status Shows “Offline”

This usually means the Node.js process failed to start. Check that Node.js is installed and its path is in your system PATH variable. Run node --version in your terminal to confirm. If the version is below 16, update Node.js. Restart Neovim after updating.

No Suggestions Appear in Insert Mode

Copilot needs a few seconds after you start typing to generate suggestions. If nothing appears after 5 seconds, check these settings:

  • Confirm vim.g.copilot_enabled is set to true.
  • Make sure auto_trigger is not set to false in your configuration.
  • Ensure the file type is supported. Copilot works with most programming languages but may not show suggestions in plain text files.
  • Run :Copilot status to confirm the plugin is online.

Copilot Suggests Irrelevant Code

Copilot bases suggestions on the current file and recent files you have open. If suggestions are off-target, open more context files in the same buffer. You can also clear the Copilot cache by running :Copilot detach and then :Copilot attach for the current buffer.

GitHub Copilot in Neovim: Plugin Options Comparison

Item copilot.lua (recommended) copilot.vim (older)
Description Lua-native plugin with modern Neovim API support Vimscript plugin for Vim and older Neovim versions
Installation method lazy.nvim, packer.nvim, or vim-plug vim-plug or manual Vimball install
Configuration format Lua tables in init.lua Vimscript variables in .vimrc
Performance Faster startup due to lazy loading Slower startup on large configs
Panel support Yes, built-in No, requires separate plugin

For new Neovim installations, use copilot.lua. It is actively maintained and integrates better with the Lua ecosystem. Only use copilot.vim if you are stuck on Neovim 0.4 or earlier.

You now have GitHub Copilot installed and configured in Neovim. You can accept suggestions with Alt+L, cycle through alternatives with Alt+] and Alt+[, and open the panel with :Copilot panel to see multiple options at once. For fine-tuning, experiment with the debounce value and the auto_trigger setting to match your typing speed.