Description
When running the command Copilot version in Neovim, an error occurs due to attempting to concatenate a table value with a string using the .. operator.
Error Message
Error executing Lua callback: ...ocal/share/nvim/lazy/copilot.lua/lua/copilot/command.lua:23: ...ocal/share/nvim/lazy/copilot.lua/lua/copilot/command.lua:22: attempt to concatenate upvalue 'lines' (a table value)
stack traceback:
[builtin#36]: at 0x0100e48fc4
...ocal/share/nvim/lazy/copilot.lua/lua/copilot/command.lua:23: in function <...ocal/share/nvim/lazy/copilot.lua/lua/copilot/command.lua:8>
...ng/.local/share/nvim/lazy/copilot.lua/plugin/copilot.lua:41: in function <...ng/.local/share/nvim/lazy/copilot.lua/plugin/copilot.lua:9>
Problematic Code
In command.lua, function M.version():
function M.version()
local info = u.get_editor_info()
---@type string
local lines = {
info.editorInfo.name .. " " .. info.editorInfo.version,
"copilot language server" .. " " .. info.editorPluginInfo.version,
"copilot.lua" .. " " .. u.get_copilot_lua_version(),
}
local client = c.get()
coroutine.wrap(function()
local server_info = lsp.get_server_info(client)
logger.notify(lines .. "\n" .. server_info) -- This line causes the error
end)()
end
Root Cause
The variable lines is a table, but the code attempts to concatenate it with a string using the .. operator, which is not valid in Lua. Tables cannot be directly concatenated with strings.
Suggested Fix
Replace the problematic line with:
logger.notify(table.concat(lines, "\n") .. "\n" .. server_info)
This uses table.concat() to properly convert the table to a string before concatenation.
Environment
- Neovim version: v0.11.0
- Operating System: macOS
Additional Information
The error occurs only when trying to display version information with the Copilot version command.
Description
When running the command
Copilot versionin Neovim, an error occurs due to attempting to concatenate a table value with a string using the..operator.Error Message
Problematic Code
In
command.lua, functionM.version():Root Cause
The variable
linesis a table, but the code attempts to concatenate it with a string using the..operator, which is not valid in Lua. Tables cannot be directly concatenated with strings.Suggested Fix
Replace the problematic line with:
This uses
table.concat()to properly convert the table to a string before concatenation.Environment
Additional Information
The error occurs only when trying to display version information with the
Copilot versioncommand.