diff --git a/lua/CopilotChat/config/mappings.lua b/lua/CopilotChat/config/mappings.lua index fb4b6388..96e15656 100644 --- a/lua/CopilotChat/config/mappings.lua +++ b/lua/CopilotChat/config/mappings.lua @@ -75,22 +75,33 @@ return { normal = 'q', insert = '', callback = function() - require('CopilotChat').close() + local function get_project_name() + local cwd = vim.fn.getcwd() + return cwd:match('([^/]+)$') + end + local chat = require('CopilotChat') + print('Saving chat session...' .. get_project_name()) + chat.save(get_project_name()) + chat.close() end, }, - reset = { - normal = '', - insert = '', - callback = function() - require('CopilotChat').reset() - end, - }, + -- reset = { + -- normal = '', + -- insert = '', + -- callback = function() + -- require('CopilotChat').reset() + -- end, + -- }, submit_prompt = { normal = '', insert = '', callback = function() + local function get_project_name() + local cwd = vim.fn.getcwd() + return cwd:match('([^/]+)$') + end local copilot = require('CopilotChat') local message = copilot.chat:get_message(constants.ROLE.USER, true) if not message then