8

I've written the following in my custom folder, and I've run :PackerSync followed by :Copilot setup, but I get an error: E492: Not an editor command: Copilot setup.

Do I need to clone github/copilot somewhere or does Packer do it automatically? How do I configure it on NvChad?

custom/chadrc.lua

local plugin_conf = require "custom.plugins.configs"

M.plugins = {
   user = userPlugins,
   override = {
      ["hrsh7th/nvim-cmp"] = plugin_conf.cmp,
   },
}

custom/plugins.lua

return {
   ["github/copilot.vim"] = {
      config = function()
         vim.cmd [[
            let g:copilot_no_tab_map = v:true
         ]]
      end,
   },
   ["hrsh7th/cmp-copilot"] = {
      after = "nvim-cmp",
   },
}
1
  • Did you find a solution?
    – Eli Front
    Apr 3, 2023 at 11:17

1 Answer 1

7

You'll have to add copilot.lua in custom/plugins.lua using something like this:

local overrides = require("custom.configs.overrides")

local plugins = {
  ...
  {
    "zbirenbaum/copilot.lua",
    -- Lazy load when event occurs. Events are triggered
    -- as mentioned in:
    -- https://vi.stackexchange.com/a/4495/20389
    event = "InsertEnter",
    -- You can also have it load at immediately at
    -- startup by commenting above and uncommenting below:
    -- lazy = false
    opts = overrides.copilot,
  },
  ...
}
...

return plugins

Then you can override the default configuration in custom/configs/overrides.lua:

local M = {}

...

M.copilot = {
  -- Possible configurable fields can be found on:
  -- https://github.com/zbirenbaum/copilot.lua#setup-and-configuration
  suggestion = {
    auto_trigger = true,
  },
}

...

return M

You should be able to call :Copilot auth after you go into Insert mode once (since that's how we defined it to lazy load in plugins.lua in the above example).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.