Skip to content

Commit 0c8d8e1

Browse files
authored
chore: add luals annotations and rename context (#2567)
Co-authored-by: Oli Morris <[email protected]>
1 parent aa3f619 commit 0c8d8e1

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

lua/codecompanion/interactions/init.lua

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ local function add_adapter(interaction, opts)
1515
end
1616

1717
---@class CodeCompanion.Interactions
18-
---@field buffer_context table
18+
---@field buffer_context CodeCompanion.BufferContext
1919
---@field selected table
2020
local Interactions = {}
2121

2222
---@class CodeCompanion.InteractionArgs
23-
---@field buffer_context table
23+
---@field buffer_context CodeCompanion.BufferContext
2424
---@field selected table
2525

2626
---@param args CodeCompanion.InteractionArgs
@@ -274,9 +274,9 @@ end
274274

275275
---Evaluate a set of prompts based on conditionals and context
276276
---@param prompts table
277-
---@param context table
277+
---@param buffer_context CodeCompanion.BufferContext
278278
---@return table
279-
function Interactions.evaluate_prompts(prompts, context)
279+
function Interactions.evaluate_prompts(prompts, buffer_context)
280280
if type(prompts) ~= "table" or vim.tbl_isempty(prompts) then
281281
return {}
282282
end
@@ -285,10 +285,10 @@ function Interactions.evaluate_prompts(prompts, context)
285285
.iter(prompts)
286286
:filter(function(prompt)
287287
return not (prompt.opts and prompt.opts.contains_code and not config.can_send_code())
288-
and not (prompt.condition and not prompt.condition(context))
288+
and not (prompt.condition and not prompt.condition(buffer_context))
289289
end)
290290
:map(function(prompt)
291-
local content = type(prompt.content) == "function" and prompt.content(context) or prompt.content
291+
local content = type(prompt.content) == "function" and prompt.content(buffer_context) or prompt.content
292292
if prompt.role == config.constants.SYSTEM_ROLE and not prompt.opts then
293293
prompt.opts = { visible = false, _meta = { tag = "from_custom_prompt" } }
294294
end

lua/codecompanion/interactions/inline/init.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ The Inline Assistant - This is where code is applied directly to a Neovim buffer
66
---@field id number The ID of the inline prompt
77
---@field adapter CodeCompanion.HTTPAdapter The adapter to use for the inline prompt
88
---@field aug number The ID for the autocmd group
9-
---@field buffer_context table The context of the buffer the inline prompt was initiated from
9+
---@field buffer_context CodeCompanion.BufferContext
1010
---@field bufnr number The buffer number to apply the inline edits to
1111
---@field chat_context? table The content from the last opened chat buffer
1212
---@field classification CodeCompanion.Inline.Classification Where to place the generated code in Neovim
@@ -18,7 +18,7 @@ The Inline Assistant - This is where code is applied directly to a Neovim buffer
1818

1919
---@class CodeCompanion.InlineArgs
2020
---@field adapter? CodeCompanion.HTTPAdapter
21-
---@field buffer_context? table The context of the buffer the inline prompt was initiated from
21+
---@field buffer_context? CodeCompanion.BufferContext
2222
---@field chat_context? table Messages from a chat buffer
2323
---@field diff? table The diff provider
2424
---@field lines? table The lines in the buffer before the inline changes

0 commit comments

Comments
 (0)