Skip to content

Commit 21b2adc

Browse files
authored
chore: rename references in chat (#715)
Co-authored-by: Oli Morris <[email protected]>
1 parent 2c6e51d commit 21b2adc

File tree

11 files changed

+29
-29
lines changed

11 files changed

+29
-29
lines changed

lua/codecompanion/strategies/chat/init.lua

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ function Chat.new(args)
196196
end
197197
self.parser = parser
198198

199-
self.References = require("codecompanion.strategies.chat.references").new({ chat = self })
199+
self.references = require("codecompanion.strategies.chat.references").new({ chat = self })
200200
self.watchers = require("codecompanion.strategies.chat.watchers").new()
201201
self.tools = require("codecompanion.strategies.chat.tools").new({ bufnr = self.bufnr, messages = self.messages })
202202
self.variables = require("codecompanion.strategies.chat.variables").new()
@@ -502,7 +502,7 @@ function Chat:add_tool(tool, tool_config)
502502
end
503503

504504
local id = "<tool>" .. tool .. "</tool>"
505-
self.References:add({
505+
self.references:add({
506506
source = "tool",
507507
name = "tool",
508508
id = id,
@@ -602,7 +602,7 @@ function Chat:submit(opts)
602602
if not opts.regenerate and not vim.tbl_isempty(message) then
603603
self:add_message({ role = config.constants.USER_ROLE, content = message.content })
604604
end
605-
message = self.References:clear(self.messages[#self.messages])
605+
message = self.references:clear(self.messages[#self.messages])
606606

607607
self:apply_tools_and_variables(message)
608608
self:check_references()
@@ -697,7 +697,7 @@ function Chat:done(output)
697697
local assistant_range = self.header_line
698698
self:set_range(-2)
699699
self.ui:display_tokens(self.parser, self.header_line)
700-
self.References:render()
700+
self.references:render()
701701

702702
if self.status == CONSTANTS.STATUS_SUCCESS and self:has_tools() then
703703
self.tools:parse_buffer(self, assistant_range, self.header_line - 1)
@@ -727,7 +727,7 @@ end
727727
---Reconcile the references table to the references in the chat buffer
728728
---@return nil
729729
function Chat:check_references()
730-
local refs = self.References:get_from_chat()
730+
local refs = self.references:get_from_chat()
731731
if vim.tbl_isempty(refs) and vim.tbl_isempty(self.refs) then
732732
return
733733
end

lua/codecompanion/strategies/chat/keymaps.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ M.pin_reference = {
327327
local icon = config.display.chat.icons.pinned_buffer
328328
local id = line:gsub("^> %- ", "")
329329

330-
if not chat.References:can_be_pinned(id) then
330+
if not chat.references:can_be_pinned(id) then
331331
return util.notify("This reference type cannot be pinned", vim.log.levels.WARN)
332332
end
333333

@@ -366,7 +366,7 @@ M.toggle_watch = {
366366

367367
local icons = config.display.chat.icons
368368
local id = line:gsub("^> %- ", "")
369-
if not chat.References:can_be_watched(id) then
369+
if not chat.references:can_be_watched(id) then
370370
return util.notify("This reference type cannot be watched", vim.log.levels.WARN)
371371
end
372372

lua/codecompanion/strategies/chat/slash_commands/buffer.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ function SlashCommand:read(selected)
146146
content = buf.format_with_line_numbers(selected.bufnr)
147147
end
148148

149-
local id = "<buf>" .. self.Chat.References:make_id_from_buf(selected.bufnr) .. "</buf>"
149+
local id = "<buf>" .. self.Chat.references:make_id_from_buf(selected.bufnr) .. "</buf>"
150150

151151
return content, filename, id
152152
end
@@ -186,7 +186,7 @@ function SlashCommand:output(selected, opts)
186186
return
187187
end
188188

189-
self.Chat.References:add({
189+
self.Chat.references:add({
190190
bufnr = selected.bufnr,
191191
id = id,
192192
path = selected.path,

lua/codecompanion/strategies/chat/slash_commands/fetch.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ local function output(chat, data, opts)
4343
content = format_output(data.url, data.content),
4444
}, { reference = id, visible = false })
4545

46-
chat.References:add({
46+
chat.references:add({
4747
source = "slash_command",
4848
name = "fetch",
4949
id = id,

lua/codecompanion/strategies/chat/slash_commands/file.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ function SlashCommand:output(selected, opts)
186186
return
187187
end
188188

189-
self.Chat.References:add({
189+
self.Chat.references:add({
190190
id = id or "",
191191
path = selected.path,
192192
source = "codecompanion.strategies.chat.slash_commands.file",

lua/codecompanion/strategies/chat/slash_commands/help.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ Note the path to the help file is `%s`.
8888
),
8989
}, { reference = id, visible = false })
9090

91-
Chat.References:add({
91+
Chat.references:add({
9292
source = "slash_command",
9393
name = "help",
9494
id = id,

lua/codecompanion/strategies/chat/slash_commands/symbols.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ Prompt the user if you need to see more than the symbolic outline.
265265
content = description,
266266
}, { reference = id, visible = false })
267267

268-
self.Chat.References:add({
268+
self.Chat.references:add({
269269
source = "slash_command",
270270
name = "symbols",
271271
id = id,

lua/codecompanion/strategies/chat/variables/buffer.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ function Variable:read(bufnr, range)
2626
local content = buf_utils.format_with_line_numbers(bufnr, range)
2727
log:trace("Buffer Variable:\n---\n%s", content)
2828

29-
local name = self.Chat.References:make_id_from_buf(bufnr)
29+
local name = self.Chat.references:make_id_from_buf(bufnr)
3030
if name == "" then
3131
name = "Buffer " .. bufnr
3232
end
@@ -76,7 +76,7 @@ function Variable:output(selected, opts)
7676
return
7777
end
7878

79-
self.Chat.References:add({
79+
self.Chat.references:add({
8080
bufnr = bufnr,
8181
params = params,
8282
id = id,

lua/codecompanion/strategies/chat/variables/user.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ function Variable:output()
2525
content = self.config.callback(),
2626
}, { reference = id, tag = "variable", visible = false })
2727

28-
self.Chat.References:add({
28+
self.Chat.references:add({
2929
bufnr = self.Chat.bufnr,
3030
id = id,
3131
source = "codecompanion.strategies.chat.variables.user",

lua/codecompanion/types.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
---@field intro_message? boolean Whether the welcome message has been shown
7979
---@field messages? table The messages in the chat buffer
8080
---@field parser vim.treesitter.LanguageTree The Tree-sitter parser for the chat buffer
81-
---@field References CodeCompanion.Chat.References
81+
---@field references CodeCompanion.Chat.References
8282
---@field refs? table<CodeCompanion.Chat.Ref> References which are sent to the LLM e.g. buffers, slash command output
8383
---@field settings? table The settings that are used in the adapter of the chat buffer
8484
---@field subscribers table The subscribers to the chat buffer

0 commit comments

Comments
 (0)