From 2c308e5ef7bf801194db8f4e1b583d7497fc0ed3 Mon Sep 17 00:00:00 2001 From: Xavier Chanthavong Date: Sun, 3 Aug 2025 10:21:22 -0400 Subject: [PATCH 1/2] fix: functions are missing from parse_schema's return I'll use the `file` function's schema as an example of the problem: ```lua schema = { type = 'object', required = { 'path' }, properties = { path = { type = 'string', description = 'Path to file to include in chat context.', enum = function(source) local glob = utils.glob(source.cwd(), { max_count = 0, }) return glob end, }, }, } ``` At the end of `parse_schema`, the schema is filtered: ```lua if schema then schema = filter_schema(schema, true) end return schema ``` This change leaves functions as is in the results table. Prior to this, completing `#file:` in the picker would give me an input field to type my file path. This restores the behavior visible in the demo in the README where that file can be picked using `vim.ui.select`. --- lua/CopilotChat/functions.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lua/CopilotChat/functions.lua b/lua/CopilotChat/functions.lua index 6e936a3d..377f6a5e 100644 --- a/lua/CopilotChat/functions.lua +++ b/lua/CopilotChat/functions.lua @@ -56,7 +56,9 @@ local function filter_schema(tbl, root) local result = {} for k, v in pairs(tbl) do if not utils.empty(v) then - if type(v) ~= 'function' and k ~= 'examples' then + if type(v) == 'function' then + result[k] = v + elseif k ~= 'examples' then result[k] = type(v) == 'table' and filter_schema(v) or v end end From dfee352a4ef4d7fec2b3fbc87056f3c054dfab7b Mon Sep 17 00:00:00 2001 From: Xavier Chanthavong Date: Sun, 3 Aug 2025 10:27:35 -0400 Subject: [PATCH 2/2] fix: Remove redundant if --- lua/CopilotChat/functions.lua | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lua/CopilotChat/functions.lua b/lua/CopilotChat/functions.lua index 377f6a5e..080507a3 100644 --- a/lua/CopilotChat/functions.lua +++ b/lua/CopilotChat/functions.lua @@ -56,9 +56,7 @@ local function filter_schema(tbl, root) local result = {} for k, v in pairs(tbl) do if not utils.empty(v) then - if type(v) == 'function' then - result[k] = v - elseif k ~= 'examples' then + if k ~= 'examples' then result[k] = type(v) == 'table' and filter_schema(v) or v end end