@@ -18,6 +18,7 @@ local plugin_name = 'CopilotChat.nvim'
1818--- @field config CopilotChat.config ?
1919--- @field last_system_prompt string ?
2020--- @field last_code_output string ?
21+ --- @field response string ?
2122--- @field diff CopilotChat.Overlay ?
2223--- @field system_prompt CopilotChat.Overlay ?
2324--- @field user_selection CopilotChat.Overlay ?
@@ -31,6 +32,9 @@ local state = {
3132 last_system_prompt = nil ,
3233 last_code_output = nil ,
3334
35+ -- Response for mappings
36+ response = nil ,
37+
3438 -- Overlays
3539 diff = nil ,
3640 system_prompt = nil ,
@@ -268,6 +272,11 @@ function M.toggle(config, source)
268272 end
269273end
270274
275+ -- @returns string
276+ function M .response ()
277+ return state .response
278+ end
279+
271280--- Ask a question to the Copilot model.
272281--- @param prompt string
273282--- @param config CopilotChat.config | nil
@@ -342,6 +351,7 @@ function M.ask(prompt, config, source)
342351 on_done = function (response , token_count )
343352 vim .schedule (function ()
344353 append (' \n\n ' .. config .separator .. ' \n\n ' )
354+ state .response = response
345355 if tiktoken .available () and token_count and token_count > 0 then
346356 state .chat :finish (token_count .. ' tokens used' )
347357 else
364374
365375--- Reset the chat window and show the help message.
366376function M .reset ()
377+ state .response = nil
367378 state .copilot :reset ()
368379 vim .schedule (function ()
369380 state .chat :clear ()
0 commit comments