Skip to content

Commit 7623879

Browse files
author
Zhe Yu
committed
feat(cli, nvim): Set LSP usage and project root for VectorCode tools
1 parent 38f838c commit 7623879

4 files changed

Lines changed: 22 additions & 7 deletions

File tree

lua/codecompanion/_extensions/vectorcode/init.lua

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,15 @@
1212
local vc_config = require("vectorcode.config")
1313
local logger = vc_config.logger
1414

15+
local use_lsp = vc_config.get_user_config().async_backend == "lsp"
16+
1517
---@type VectorCode.CodeCompanion.ExtensionOpts|{}
1618
local default_extension_opts = {
17-
tool_opts = { ls = {}, query = {}, vectorise = { requires_approval = true } },
19+
tool_opts = {
20+
ls = { use_lsp = use_lsp, requires_approval = false },
21+
query = { use_lsp = use_lsp, requires_approval = false },
22+
vectorise = { use_lsp = use_lsp, requires_approval = true },
23+
},
1824
tool_group = { enabled = true, collapse = true, extras = {} },
1925
}
2026

lua/vectorcode/integrations/codecompanion/common.lua

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,15 @@ local logger = vc_config.logger
77
local default_query_options = {
88
max_num = { chunk = -1, document = -1 },
99
default_num = { chunk = 50, document = 10 },
10-
use_lsp = false,
11-
ls_on_start = false,
1210
no_duplicate = true,
1311
chunk_mode = false,
1412
}
1513

1614
---@type VectorCode.CodeCompanion.LsToolOpts
17-
local default_ls_options = { use_lsp = false }
15+
local default_ls_options = {}
1816

1917
---@type VectorCode.CodeCompanion.VectoriseToolOpts
20-
local default_vectorise_options = { use_lsp = false }
18+
local default_vectorise_options = {}
2119

2220
return {
2321
tool_result_source = "VectorCodeToolResult",

lua/vectorcode/integrations/codecompanion/vectorise_tool.lua

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ return function(opts)
6767
}
6868
end
6969
end
70+
if project_root ~= "" then
71+
action.project_root = project_root
72+
end
7073
vim.list_extend(
7174
args,
7275
vim
@@ -105,8 +108,9 @@ return function(opts)
105108
end,
106109
---@param self CodeCompanion.Agent.Tool
107110
---@param agent CodeCompanion.Agent
111+
---@param cmd VectoriseToolArgs
108112
---@param stdout VectorCode.VectoriseResult[]
109-
success = function(self, agent, _, stdout)
113+
success = function(self, agent, cmd, stdout)
110114
stdout = stdout[1]
111115
agent.chat:add_tool_output(
112116
self,
@@ -125,6 +129,13 @@ return function(opts)
125129
stdout.failed
126130
)
127131
)
132+
if cmd.project_root then
133+
agent.chat:add_tool_output(
134+
self,
135+
string.format("\nThe files were added to `%s`", cmd.project_root),
136+
""
137+
)
138+
end
128139
end,
129140
},
130141
}

src/vectorcode/lsp_main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ async def execute_command(ls: LanguageServer, args: list[str]):
159159
progress_token,
160160
types.WorkDoneProgressBegin(
161161
"VectorCode",
162-
message="Looking for other projects indexed by VectorCode",
162+
message="Looking for available projects indexed by VectorCode",
163163
),
164164
)
165165
projects: list[dict] = []

0 commit comments

Comments
 (0)