zbirenbaum / copilot.lua

Fully featured & enhanced replacement for copilot.vim complete with API for interacting with Github Copilot
MIT License
2.43k stars 64 forks source link

How to accept suggestions using NvChad #257

Closed TiLopes closed 6 months ago

TiLopes commented 6 months ago

I can't accept any suggestions no matter what key I press. Here's the config

  {
    "zbirenbaum/copilot.lua",
    cmd = { "Copilot" },
    event = { "InsertEnter", "BufEnter", "BufRead" },
    config = function()
      require("copilot").setup {
        panel = {
          enabled = true,
          auto_refresh = true,
          keymap = {
            jump_prev = "[[",
            jump_next = "]]",
            accept = "<CR>",
            refresh = "gr",
            open = "<M-CR>",
          },
          layout = {
            position = "bottom", -- | top | left | right
            ratio = 0.4,
          },
        },
        suggestion = {
          enabled = true,
          auto_accept = true,
          auto_trigger = true,
          debounce = 75,
          keymap = {
            accept = "<Tab>",
            accept_word = false,
            accept_line = false,
            next = "<M-]>",
            prev = "<M-[>",
            dismiss = "<C-]>",
          },
        },
        filetypes = {
          yaml = false,
          markdown = false,
          help = false,
          gitcommit = false,
          gitrebase = false,
          hgcommit = false,
          svn = false,
          cvs = false,
          ["."] = false,
        },
        copilot_node_command = "node", -- Node.js version must be > 16.x
        server_opts_overrides = {},
      }
    end,
  },
LUSEDOU commented 6 months ago

Have you tried to do :Copilot auth?

TiLopes commented 6 months ago

The suggestions show up but I just can't accept them. Supposedly Tab is the key i should press if it behaves like in VSCode but it for me that goes to the next lsp suggestion

LUSEDOU commented 6 months ago

Well. You could do 3 things

  1. Remap your LSP or Copilot to coexist
  2. Configure the mapping to check if copilot is visible and override the LSP action
  3. Disable suggestion and configure Copilot to work in cmp

Try the first, is better to have different keymaps for copilot and lsp.

TiLopes commented 6 months ago

I remapped and everything is working fine now. Thanks @LUSEDOU.

caniko commented 6 months ago

@TiLopes can you share your config?