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

Moves cmp popup to beginning of suggestion #89

Open
EricDriussi opened this issue Sep 1, 2023 · 9 comments
Open

Moves cmp popup to beginning of suggestion #89

EricDriussi opened this issue Sep 1, 2023 · 9 comments

Comments

@EricDriussi
Copy link

Hi there! I'm noticing a strange behavior since a couple of days ago:

If the suggestion includes the content of current line, the popup window shows up at the beginning of the content instead of staying under the cursor.

Minimal config (using lazy.nvim):

local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
	vim.fn.system({
		"git",
		"clone",
		"--filter=blob:none",
		"--single-branch",
		"https://github.com/folke/lazy.nvim.git",
		lazypath,
	})
end
vim.opt.runtimepath:prepend(lazypath)

local plugin_list = {
	{
		"hrsh7th/nvim-cmp",
		config = function()
			local cmp = require("cmp")
			cmp.setup({
				mapping = {
					["<C-Space>"] = cmp.mapping(cmp.mapping.complete(), { "i", "c" }),
				},
				sources = {
					{ name = "copilot" },
				},
			})
		end,
	},
	{
		"zbirenbaum/copilot-cmp",
		config = true,
		dependencies = {
			"zbirenbaum/copilot.lua",
			opts = {
				suggestion = { enabled = false },
				panel = { enabled = false },
			},
		},
	},
}

require("lazy").setup(plugin_list, {})

Specific commits:

{
  "copilot-cmp": { "branch": "master", "commit": "11eb015fbf9f07ad1c72dbdc9d830ebac610b5cd" },
  "copilot.lua": { "branch": "master", "commit": "0fa30d6846aae1af1c94a9ead93fa7dcf8affbe6" },
  "lazy.nvim": { "branch": "main", "commit": "dac844ed617dda4f9ec85eb88e9629ad2add5e05" },
  "nvim-cmp": { "branch": "main", "commit": "5dce1b778b85c717f6614e3f4da45e9f19f54435" }
}

Usual behavior:

image

Broken (?) behavior, notice the cursor position:

image

Mind you this is not due to the window size, the screenshot is just a portion of the window.

What makes this particularly annoying is that, since copilot takes longer to load than other cmp sources, once it does load it actually moves the window away from the cursor.

Am I missing something here?

@crzdg
Copy link

crzdg commented Oct 20, 2023

I also observe this behavior. My cmp window jumps around sometimes. But even worse, the plugin overwrites other cmp entries such as LSP. When I type the other suggestions are available, but only for a short time. So seems to be a second update happening, causing the overwrite, and certainly sometimes the jumping, I guess.

See my config here https://github.com/crzdg/dotfiles.

@xzbdmw
Copy link

xzbdmw commented Apr 7, 2024

https://github.com/hrsh7th/nvim-cmp/blob/ce16de5665c766f39c271705b17fff06f7bcb84f/lua/cmp/view.lua#L102

          for _, e in ipairs(s:get_entries(ctx)) do
            e.score = e.score + priority
            table.insert(group_entries, e)
            local is_copilot = e:get_completion_item().copilot
            if not is_copilot then
              offset = math.min(offset, e:get_offset())
            end
          end

@alwaysamer
Copy link

Any updates on this Issue ? I am encountering the same problem....

image

@xzbdmw
Copy link

xzbdmw commented Jun 10, 2024

@alwaysamer have you tried my patch above, I’m afraid there is nothing to do by copilot here

@alwaysamer
Copy link

No I did not. Wasn't sure if that was the fix since the Issue is still open. Where exactly would I put that snippet ?

@xzbdmw
Copy link

xzbdmw commented Jun 10, 2024

You need to modify cmp source code as the link points to.

@alwaysamer
Copy link

Okay I forked the repo and modified the Code. That seems to have fixed the Issue. So thanks @xzbdmw :) . It's going to be annoying to maintain the fork but I suppose there is no way around it...

@xzbdmw
Copy link

xzbdmw commented Jun 10, 2024

@alwaysamer I think
require("cmp").setup({
view = {
entries = {
follow_cursor = true
}
}
})
this can be a workaround too, but maybe what you want

@alwaysamer
Copy link

Awesome. That seems to have done it as well!

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

4 participants