Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Sep 1, 2025

Thanks for assigning this issue to me. I'm starting to work on it and will keep this PR's description up to date as I form a plan and make progress.

Original issue description:

Pre-submission checklist

  • I have read the documentation
  • I have updated the plugin and all dependencies to the latest versions
  • I have searched for existing issues and discussions
  • My issue is not a minor or cosmetic quirk (e.g., formatting, spacing, or other non-functional details)

Neovim version (nvim -v)

0.12.0 commit 3c601d02dc

Operating system/version

Arch Linux x86_64

Adapter and model

gemini_cli

Describe the bug

When I set display > chat > show_settings = true, strategies > chat > adapter = "gemini_cli" and open a sidebar chat window, It throws error message below:

Lua :command callback: ...vim/lazy/codecompanion.nvim/lua/codecompanion/schema.lua:122: bad argument #1 to 'pairs' (table expected, got nil)
stack traceback:
	[C]: in function 'pairs'
	...vim/lazy/codecompanion.nvim/lua/codecompanion/schema.lua:122: in function 'get_ordered_keys'
	...anion.nvim/lua/codecompanion/strategies/chat/ui/init.lua:322: in function 'render'
	...ompanion.nvim/lua/codecompanion/strategies/chat/init.lua:663: in function 'chat'
	...m/lazy/codecompanion.nvim/lua/codecompanion/commands.lua:131: in function <...m/lazy/codecompanion.nvim/lua/codecompanion/commands.lua:130>

Steps to reproduce

  1. Set display > chat > show_settings = true and strategies > chat > adapter = "gemini_cli"
  2. Open Nvim, then run command :CodeCompanionChat
  3. The error shows up, sidebar chat window not working.

Expected behavior

Sidebar chat window shows up without error.

Screenshots or recordings (optional)

codecompanion_error.mp4

minimal.lua file

---@diagnostic disable: missing-fields

--[[
NOTE: Set the config path to enable the copilot adapter to work.
It will search the following paths for a token:
  - "$CODECOMPANION_TOKEN_PATH/github-copilot/hosts.json"
  - "$CODECOMPANION_TOKEN_PATH/github-copilot/apps.json"
--]]
vim.env["CODECOMPANION_TOKEN_PATH"] = vim.fn.expand("~/.config")

vim.env.LAZY_STDPATH = ".repro"
load(vim.fn.system("curl -s https://raw.githubusercontent.com/folke/lazy.nvim/main/bootstrap.lua"))()

-- Your CodeCompanion setup
local plugins = {
	{
		"olimorris/codecompanion.nvim",
		dependencies = {
			{ "nvim-treesitter/nvim-treesitter", build = ":TSUpdate" },
			{ "nvim-lua/plenary.nvim" },
			-- Test with blink.cmp (delete if not required)
			{
				"saghen/blink.cmp",
				lazy = false,
				version = "*",
				opts = {
					keymap = {
						preset = "enter",
						["<S-Tab>"] = { "select_prev", "fallback" },
						["<Tab>"] = { "select_next", "fallback" },
					},
					cmdline = { sources = { "cmdline" } },
					sources = {
						default = { "lsp", "path", "buffer", "codecompanion" },
					},
				},
			},
			-- Test with nvim-cmp
			-- { "hrsh7th/nvim-cmp" },
		},
		opts = {
			adapter = {
				acp = {
					gemini_cli = function()
						return require("codecompanion.adapters").extend("gemini_cli", {
							env = {
								api_key = "GEMINI_API_KEY",
							},
						})
					end,
				},
			},
			display = {
				chat = {
					intro_message = "Welcome to CodeCompanion ✨!\n Press ? for options",
					separator = "", -- The separator between the different messages in the chat buffer
					show_context = true, -- Show context (from slash commands and variables) in the chat buffer?
					show_header_separator = false, -- Show header separators in the chat buffer? Set this to false if you're using an external markdown formatting plugin
					show_settings = true, -- Show LLM settings at the top of the chat buffer?
					show_token_count = true, -- Show the token count for each response?
					show_tools_processing = true, -- Show the loading message when tools are being executed?
					start_in_insert_mode = false, -- Open the chat buffer in insert mode?
				},
			},
			--Refer to: https://github.com/olimorris/codecompanion.nvim/blob/main/lua/codecompanion/config.lua
			strategies = {
				--NOTE: Change the adapter as required
				chat = { adapter = "gemini_cli" },
				inline = { adapter = "gemini_cli" },
			},
			opts = {
				log_level = "DEBUG",
			},
		},
	},
}

-- Leaving this comment in to see if the issue author notices ;-)
-- This is so I can tell if they've really tested with their own minimal.lua file

require("lazy.minit").repro({ spec = plugins })

-- Setup Tree-sitter
local ts_status, treesitter = pcall(require, "nvim-treesitter.configs")
if ts_status then
	treesitter.setup({
		ensure_installed = { "lua", "markdown", "markdown_inline", "yaml", "diff" },
		highlight = { enable = true },
	})
end

-- Setup nvim-cmp
-- local cmp_status, cmp = pcall(require, "cmp")
-- if cmp_status then
--   cmp.setup({
--     mapping = cmp.mapping.preset.insert({
--       ["<C-b>"] = cmp.mapping.scroll_docs(-4),
--       ["<C-f>"] = cmp.mapping.scroll_docs(4),
--       ["<C-Space>"] = cmp.mapping.complete(),
--       ["<C-e>"] = cmp.mapping.abort(),
--       ["<CR>"] = cmp.mapping.confirm({ select = true }),
--       -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
--     }),
--   })
-- end

Log output (optional)

Don't see any codecompanion.log file.

Minimal reproduction confirmation

  • Yes, I have tested and provided a minimal.lua file that reproduces the issue

Fixes #2062.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Copy link
Contributor Author

Copilot AI commented Sep 1, 2025

@olimorris 👋 This repository doesn't have Copilot instructions. With Copilot instructions, I can understand the repository better, work faster and produce higher quality PRs.

I can generate a .github/copilot-instructions.md file for you automatically. Click here to open a pre-filled issue and assign it to me. I'll write the instructions, and then tag you for review.

@cloudflare-workers-and-pages
Copy link

Deploying codecompanion with  Cloudflare Pages  Cloudflare Pages

Latest commit: 51d2ca8
Status: ✅  Deploy successful!
Preview URL: https://f0291279.codecompanion.pages.dev
Branch Preview URL: https://copilot-fix-2062.codecompanion.pages.dev

View logs

@olimorris olimorris closed this Sep 1, 2025
@olimorris olimorris deleted the copilot/fix-2062 branch November 25, 2025 22:58
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

Successfully merging this pull request may close these issues.

[Bug]: Error when set show_settings = true and adapter = "gemini_cli" (ACP adapter

2 participants