Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I can't get a full suggestion #96

Open
mjacobus opened this issue Oct 19, 2023 · 11 comments
Open

I can't get a full suggestion #96

mjacobus opened this issue Oct 19, 2023 · 11 comments

Comments

@mjacobus
Copy link

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
Copy link
Author

Hum... I see this is dup of #87, though I have the latest plugins, that is still a problem.

@zbirenbaum
Copy link
Owner

zbirenbaum commented Oct 19, 2023

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
Copy link

crzdg commented Oct 20, 2023

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

@mjacobus
Copy link
Author

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
Copy link
Author

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
Copy link

CharlesARoy commented Oct 26, 2023

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
Copy link

dseravalli commented Oct 31, 2023

Same thing happening to me on latest version of both plugins, but only with TS/JS
zbirenbaum/copilot.lua#229

@dgmora
Copy link

dgmora commented Nov 10, 2023

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
Copy link

dgmora commented Nov 10, 2023

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
Copy link
Author

mjacobus commented Nov 13, 2023

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
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants