Created
August 27, 2025 17:30
-
-
Save rakotomandimby/64e722bcce20e435436b9d3b53661b9f to your computer and use it in GitHub Desktop.
Add file_glob function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| local functions = { | |
| file_glob = { | |
| group = 'copilot', | |
| uri = 'files://glob_contents/{pattern}', | |
| description = 'Includes the full contents of every file matching a specified glob pattern.', | |
| schema = { | |
| type = 'object', | |
| required = { 'pattern' }, | |
| properties = { | |
| pattern = { | |
| type = 'string', | |
| description = 'Glob pattern to match files.', | |
| default = '**/*', | |
| }, | |
| }, | |
| }, | |
| resolve = function(input, source) | |
| local files = require('CopilotChat.utils.files').glob(source.cwd(), { | |
| pattern = input.pattern, | |
| }) | |
| local resources = {} | |
| for _, file_path in ipairs(files) do | |
| local data, mimetype = require('CopilotChat.resources').get_file(file_path) | |
| if data then | |
| table.insert(resources, { | |
| uri = 'file://' .. file_path, | |
| name = file_path, | |
| mimetype = mimetype, | |
| data = data, | |
| }) | |
| end | |
| end | |
| return resources | |
| end, | |
| }, | |
| } | |
| require("CopilotChat").setup({ | |
| functions = vim.tbl_deep_extend('force', require("CopilotChat.config.functions"), functions) | |
| }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment