zbirenbaum / copilot-cmp

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

I can't get a full suggestion #96

Open mjacobus opened 1 year ago

mjacobus commented 1 year ago

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 commented 1 year ago

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.

zbirenbaum commented 1 year ago

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.

crzdg commented 1 year ago

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

mjacobus commented 1 year ago

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 commented 1 year ago

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

CharlesARoy commented 1 year ago

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.

dseravalli commented 1 year ago

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

dgmora commented 1 year ago

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 commented 1 year ago

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.

mjacobus commented 1 year ago

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

palcalde commented 10 months ago

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