zbirenbaum / copilot-cmp

Lua plugin to turn github copilot into a cmp source
MIT License
1.08k stars 39 forks source link

Copilot-cmp joins current line with previous line unexpectedly #53

Closed Bekaboo closed 10 months ago

Bekaboo commented 1 year ago

When I select the entry from copilot in the completion menu, copilot-cmp will sometimes join the current line with the previous line.

Minimal nvim-cmp config:

local cmp = require('cmp')

cmp.setup({
  mapping = {
    ['<C-n>'] = cmp.mapping(function(fallback)
      if vim.fn.mode() == 'i' then
        if cmp.visible() then
          cmp.select_next_item()
        else
          cmp.complete()
        end
      elseif vim.fn.mode() == 'c' then
        if cmp.visible() then
          cmp.select_next_item()
        else
          fallback()
        end
      end
    end, { 'i', 'c' }),
  },
  sources = {
    { name = 'copilot' },
  },
})

Copilot-cmp config:

require('copilot_cmp').setup({
  formatters = {
    label = function(item) return item.text:gsub('^%s*', '') end,
    insert_text = require('copilot_cmp.format').remove_existing
  },
})

Copilot.lua config:

vim.defer_fn(function()
  if vim.g.loaded_coplilot then
    return
  end
  vim.g.loaded_coplilot = true
  require('copilot').setup({
    suggestion = { enabled = false },
    panel = { enabled = false },
  })
end, 100)

Screen recording:

https://user-images.githubusercontent.com/76579810/226435880-4cd28a8b-3bfc-4541-8685-f2d2c284e12c.mp4

zbirenbaum commented 1 year ago

Please test #67 and see if it fixes your issue

Bekaboo commented 1 year ago

Thanks, will install and test it this weekend

zbirenbaum commented 1 year ago

I've reproduced this, it is not fixed by #67. This is probably the next big issue to tackle

zbirenbaum commented 10 months ago

This was fixed at some point and forgot to close