copilot-cmp icon indicating copy to clipboard operation
copilot-cmp copied to clipboard

I can't get a full suggestion

Open mjacobus opened this issue 2 years ago • 12 comments
trafficstars

Hey there @zbirenbaum , thank you for this awesome plugin! 🙇🏻

I have this issue. My suggestions are all one-liners.

Instead of having this:

image

I get just the first line of the suggestion:

image

Once I accept the suggestion, and start editing the next line, it offers the second line, and so on.

Could this be a miss-configuration?

This is what I had

{
    "zbirenbaum/copilot-cmp",
    event = "InsertEnter",
    dependencies = { "zbirenbaum/copilot.lua" },
    config = function()
      vim.defer_fn(function()
        require("copilot").setup()     -- https://github.com/zbirenbaum/copilot.lua/blob/master/README.md#setup-and-configuration
        require("copilot_cmp").setup() -- https://github.com/zbirenbaum/copilot-cmp/blob/master/README.md#configuration
      end, 100)
    end,
  },

And this is what I have now, but the behavior is the same:

  {
    "zbirenbaum/copilot.lua",
    cmd = "Copilot",
    event = "InsertEnter",
    config = function()
      require("copilot").setup({})
    end,
  },

  {
    "zbirenbaum/copilot-cmp",
    config = function ()
      require("copilot_cmp").setup()
    end
  },

Thank you in advance

mjacobus avatar Oct 19 '23 14:10 mjacobus

Hum... I see this is dup of https://github.com/zbirenbaum/copilot-cmp/issues/87, though I have the latest plugins, that is still a problem.

mjacobus avatar Oct 19 '23 14:10 mjacobus

Is this occurring globally or only with specific filetypes/languages? Also, have you tried using just copilot.lua and not copilot-cmp on the files where this issue is present? If the same issue persists with just copilot.lua, it is almost certainly an issue with copilot itself.

zbirenbaum avatar Oct 19 '23 18:10 zbirenbaum

I also observe this behavior. I only get one-liner suggestions. See my config here https://github.com/crzdg/dotfiles

crzdg avatar Oct 20 '23 08:10 crzdg

Is this occurring globally or only with specific filetypes/languages? Also, have you tried using just copilot.lua and not copilot-cmp on the files where this issue is present? If the same issue persists with just copilot.lua, it is almost certainly an issue with copilot itself.

That is globally, @zbirenbaum.

I haven't tried using copilot without cmp. I will try that and get back to you.

Thank you for your superfast response and follow questions, @zbirenbaum 🙇🏻

mjacobus avatar Oct 24 '23 18:10 mjacobus

Is this occurring globally or only with specific filetypes/languages? Also, have you tried using just copilot.lua and not copilot-cmp on the files where this issue is present? If the same issue persists with just copilot.lua, it is almost certainly an issue with copilot itself.

@zbirenbaum sorry for the late response.

I am actually using lunarvim, and I setup my plugins like so:

lvim.builtin.cmp.active = false 

-- plugins
  {
    "zbirenbaum/copilot.lua",
    cmd = "Copilot",
    event = "InsertEnter",
    config = function()
       require("copilot").setup({
        suggestion = {
          enabled = true,
          auto_trigger = true,
          debounce = 75,
          keymap = {
            accept = "<c-l>",
            accept_word = false,
            accept_line = false,
            next = "<M-]>",
            prev = "<M-[>",
            dismiss = "<C-]>",
          },
        },
      })

    end,
  },

  -- {
  --   "zbirenbaum/copilot-cmp",
  --   config = function ()
  --     require("copilot_cmp").setup()
  --   end
  -- },

I get multiple-line suggestions, so I believe that is actually a copilot-cmp issue.

image

mjacobus avatar Oct 26 '23 20:10 mjacobus

I'm also unable to get multi-line suggestions with copilot-cmp. Would be curious if anyone has found a fix yet. EDIT: After updating copilot-cmp to the latest commit, it's now working as expected.

CharlesARoy avatar Oct 26 '23 22:10 CharlesARoy

Same thing happening to me on latest version of both plugins, but only with TS/JS https://github.com/zbirenbaum/copilot.lua/issues/229

dseravalli avatar Oct 31 '23 22:10 dseravalli

Same here, I've noticed this long thread here with a potential solution for vscode https://github.com/orgs/community/discussions/40522#discussioncomment-6350781

dgmora avatar Nov 10 '23 16:11 dgmora

I'm observing a quite bizarre behaviour. Not sure what's the origin. Right now I'm checking with Ruby.

If I take an existing class with any method and type def fibon I get as suggestion def fibonnaci(n) or similar as a 1-liner. However, if I type this as the last method of the class, I get a full suggestion. Same if I do it before the end word of a method definition(which is syntactically incorrect, but anyway)

class Foo
  # here wouldn't work
  def bar
    # here wouldn't work
    puts "hi"
    # here it works
  end
   # here it works
end

If I create a new file, set the syntax to Ruby and start typing, I get multi-line suggestions all the time, wherever I try to write the method. However, if I save this file as test.rb and start editing , I only get a suggestions as explained before.

dgmora avatar Nov 10 '23 19:11 dgmora

Hum, that is good input, @dgmora

I opened a new buffer did class Fib

This was the first suggestion, which I accepted:

# fibonacci method
class Fibonacci
  def self.fib(n)
    return 0 if n == 0
    return 1 if n == 1
    fib(n - 1) + fib(n - 2)
  end
end
# Path: tmp/copilot.rb
# fibonacci method
class Fibonacci
  def self.fib(n)
    return 0 if n == 0
    return 1 if n == 1
    fib(n - 1) + fib(n - 2)
  end
end
# Path: tmp/copilot.rb
# fibonacci method
class Fibonacci
  def self.fib(n)
    return 0 if n == 0
    return 1 if n == 1
    fib(n - 1) + fib(n - 2)
  end
end
# Path: tmp/copilot.rb
# fibonacci method
class Fibonacci
  def self.fib(n)
    return 0 if n == 0
    return 1 if n == 1
    fib(n - 1) + fib(n - 2)
  end
end
# Path: tmp/copilot.rb
# fibonacci method
class Fibonacci
  def self.fib(n)
    return 0 if n == 0
    return 1 if n == 1
    fib(n - 1) + fib(n - 2)
  end
end
# Path: tmp/copilot.rb
# fibonacci method
class Fibonacci
  def self.fib(n)
    return 0 if n == 0
    return 1 if n == 1
    fib(n - 1) + fib(n - 2)
  end
end
# Path: tmp/copilot.rb
# fibonacci method
class Fibonacci
  def self.fib(n)
    return 0 if n == 0
    return 1 if n == 1
    fib(n - 1) + fib(n - 2)
  end
end
# Path: tmp/copilot.rb
# fibonacci method
class Fibonacci
  def self.fib(n)
    return 0 if n == 0
    return 1 if n == 1
    fib(n - 1) + fib(n - 2)
  end
end

I tried again, and then:

# fibonacci method
class Fibonacci
  def self.fibonacci(n)
    return 0 if n == 0
    return 1 if n == 1
    fibonacci(n - 1) + fibonacci(n - 2)
  end
end
 
# then I tried def fib...
def fibonacci(n)
  Fibonacci.fibonacci(n)
end

I saved and it kept working...

def sqrt(n)
  Math.sqrt(n)
end

def camelize(string)
  string.split('_').map(&:capitalize).join
end

I closed nvim, reopened it, and now it works for that file 🤷🏻

Then I closed vim, opened an existing file in the project, and now it is back to one-liners.

Then I tried your workaround, adding an "end", without a def. I typed def resolve(number) and tada!

image

mjacobus avatar Nov 13 '23 14:11 mjacobus

This got fixed for me as soon as I updated to new version of copilot-cmp as suggested here

palcalde avatar Jan 23 '24 08:01 palcalde