Skip to content

Commit 6bf6aa6

Browse files
deathbeamDavidyz
authored andcommitted
fix: improve project root detection for copilot chat
Use vim.fs.root to detect .vectorcode or .git directories as project roots instead of always using just the source cwd
1 parent a78ce20 commit 6bf6aa6

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

lua/vectorcode/integrations/copilotchat.lua

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,14 @@ local make_context_provider = check_cli_wrap(function(opts)
7979
"-n",
8080
tostring(opts.max_num),
8181
'"' .. input .. '"',
82-
"--project_root",
83-
source.cwd(),
8482
}
8583

84+
local cwd = source.cwd()
85+
local try_root = vim.fs.root(cwd, ".vectorcode") or vim.fs.root(cwd, ".git")
86+
if try_root ~= nil then
87+
vim.list_extend(args, { "--project_root", try_root })
88+
end
89+
8690
local result, err = run_job(args, opts.use_lsp, source.bufnr)
8791
if utils.empty(result) and err then
8892
error(utils.make_string(err))

0 commit comments

Comments
 (0)