Skip to content

Commit e98ef13

Browse files
committed
Use relative paths for file references in contexts
Makes data smaller and faster Signed-off-by: Tomas Slusny <[email protected]>
1 parent 5236f0e commit e98ef13

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

lua/CopilotChat/config.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ return {
141141
vim.ui.select(
142142
vim.tbl_map(
143143
function(buf)
144-
return { id = buf, name = vim.api.nvim_buf_get_name(buf) }
144+
return { id = buf, name = vim.fn.fnamemodify(vim.api.nvim_buf_get_name(buf), ':p:.') }
145145
end,
146146
vim.tbl_filter(function(buf)
147147
return vim.api.nvim_buf_is_loaded(buf) and vim.fn.buflisted(buf) == 1

lua/CopilotChat/context.lua

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ function M.files(pattern)
8585
return {}
8686
end
8787

88+
files = vim.tbl_map(function(file)
89+
return vim.fn.fnamemodify(file, ':p:.')
90+
end, files)
91+
8892
local out = {}
8993

9094
-- Create embeddings in chunks
@@ -116,7 +120,7 @@ function M.file(filename)
116120

117121
return {
118122
content = table.concat(content, '\n'),
119-
filename = filename,
123+
filename = vim.fn.fnamemodify(filename, ':p:.'),
120124
filetype = vim.filetype.match({ filename = filename }),
121125
}
122126
end
@@ -127,6 +131,7 @@ end
127131
---@return CopilotChat.copilot.embed?
128132
function M.outline(bufnr)
129133
local name = vim.api.nvim_buf_get_name(bufnr)
134+
name = vim.fn.fnamemodify(name, ':p:.')
130135
local ft = vim.bo[bufnr].filetype
131136

132137
-- If buffer is not too big, just return the content

0 commit comments

Comments
 (0)