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

Copilot panel conflicts with file auto-save #325

Open
Mathieuu opened this issue Oct 6, 2024 · 0 comments
Open

Copilot panel conflicts with file auto-save #325

Mathieuu opened this issue Oct 6, 2024 · 0 comments

Comments

@Mathieuu
Copy link

Mathieuu commented Oct 6, 2024

When I open Copilot panel with meta+enter, it hangs on the loading message forever.

This is due to a conflict with the following snippet:

-- Autosave when losing focus
vim.api.nvim_create_autocmd({ "FocusLost", "BufLeave" }, {
	callback = function()
		if vim.bo.modified and not vim.bo.readonly and vim.fn.expand("%") ~= "" and vim.bo.buftype == "" then
			vim.api.nvim_command("silent! write")
		end
	end,
})

Given how frequent this kind of snippet is, I think it would be nice if they both played along.

Here's a full init.lua to reproduce the problem:

vim.g.mapleader = ","

local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not (vim.uv or vim.loop).fs_stat(lazypath) then
	local lazyrepo = "https://github.com/folke/lazy.nvim.git"
	local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath })
	if vim.v.shell_error ~= 0 then
		error("Error cloning lazy.nvim:\n" .. out)
	end
end

-- Autosave when losing focus
vim.api.nvim_create_autocmd({ "FocusLost", "BufLeave" }, {
	callback = function()
		if vim.bo.modified and not vim.bo.readonly and vim.fn.expand("%") ~= "" and vim.bo.buftype == "" then
			vim.api.nvim_command("silent! write")
		end
	end,
})

vim.opt.rtp:prepend(lazypath)

require("lazy").setup({
	{
		"zbirenbaum/copilot.lua",
		cmd = "Copilot",
		event = "InsertEnter",
		config = function()
			require("copilot").setup({})
		end,
	},
})
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

1 participant