Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -408,10 +408,6 @@ chat.toggle(config) -- Toggle chat window visibility with optional con
chat.reset() -- Reset the chat
chat.stop() -- Stop current output

-- Source Management
chat.get_source() -- Get the current source buffer and window
chat.set_source(winnr) -- Set the source window

-- Prompt & Model Management
chat.select_prompt(config) -- Open prompt selector with optional config
chat.select_model() -- Open model selector
Expand Down Expand Up @@ -441,14 +437,17 @@ window:get_message(role, cursor) -- Get chat message by role, eith
window:add_message({ role, content }, replace) -- Add or replace a message in chat
window:remove_message(role, cursor) -- Remove chat message by role, either last or closest to cursor
window:get_block(role, cursor) -- Get code block by role, either last or closest to cursor
window:add_sticky(sticky) -- Add sticky prompt to chat message

-- Content Management
window:append(text) -- Append text to chat window
window:clear() -- Clear chat window content
window:start() -- Start writing to chat window
window:finish() -- Finish writing to chat window

-- Source Management
window.get_source() -- Get the current source buffer and window
window.set_source(winnr) -- Set the source window

-- Navigation
window:follow() -- Move cursor to end of chat content
window:focus() -- Focus the chat window
Expand Down
2 changes: 1 addition & 1 deletion lua/CopilotChat/completion.lua
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ end
--- Trigger the completion for the chat window.
---@param without_input boolean?
function M.complete(without_input)
local source = require('CopilotChat').get_source()
local source = require('CopilotChat').chat:get_source()
local info = M.info()
local bufnr = vim.api.nvim_get_current_buf()
local line = vim.api.nvim_get_current_line()
Expand Down
2 changes: 1 addition & 1 deletion lua/CopilotChat/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
---@field language string?
---@field temperature number?
---@field headless boolean?
---@field callback nil|fun(response: CopilotChat.client.Message, source: CopilotChat.source)
---@field callback nil|fun(response: CopilotChat.client.Message, source: CopilotChat.ui.chat.Source)
---@field remember_as_sticky boolean?
---@field window CopilotChat.config.Window?
---@field show_help boolean?
Expand Down
2 changes: 1 addition & 1 deletion lua/CopilotChat/config/functions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ end
---@field schema table?
---@field group string?
---@field uri string?
---@field resolve fun(input: table, source: CopilotChat.source):CopilotChat.client.Resource[]
---@field resolve fun(input: table, source: CopilotChat.ui.chat.Source):CopilotChat.client.Resource[]

---@type table<string, CopilotChat.config.functions.Function>
return {
Expand Down
36 changes: 2 additions & 34 deletions lua/CopilotChat/config/mappings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ local files = require('CopilotChat.utils.files')

--- Prepare a buffer for applying a diff
---@param filename string?
---@param source CopilotChat.source
---@param source CopilotChat.ui.chat.Source
---@return integer
local function prepare_diff_buffer(filename, source)
if not filename then
Expand Down Expand Up @@ -47,7 +47,7 @@ end
---@class CopilotChat.config.mapping
---@field normal string?
---@field insert string?
---@field callback fun(source: CopilotChat.source)
---@field callback fun(source: CopilotChat.ui.chat.Source)

---@class CopilotChat.config.mapping.yank_diff : CopilotChat.config.mapping
---@field register string?
Expand All @@ -57,7 +57,6 @@ end
---@field close CopilotChat.config.mapping|false|nil
---@field reset CopilotChat.config.mapping|false|nil
---@field submit_prompt CopilotChat.config.mapping|false|nil
---@field toggle_sticky CopilotChat.config.mapping|false|nil
---@field accept_diff CopilotChat.config.mapping|false|nil
---@field jump_to_diff CopilotChat.config.mapping|false|nil
---@field quickfix_diffs CopilotChat.config.mapping|false|nil
Expand Down Expand Up @@ -103,37 +102,6 @@ return {
end,
},

toggle_sticky = {
normal = 'grr',
callback = function()
local message = copilot.chat:get_message(constants.ROLE.USER)
local section = message and message.section
if not section then
return
end

local cursor = vim.api.nvim_win_get_cursor(copilot.chat.winnr)
if cursor[1] < section.start_line or cursor[1] > section.end_line then
return
end

local current_line = vim.trim(vim.api.nvim_get_current_line())
if current_line == '' then
return
end

local cur_line = cursor[1]
vim.api.nvim_buf_set_lines(copilot.chat.bufnr, cur_line - 1, cur_line, false, {})

if vim.startswith(current_line, '> ') then
return
end

copilot.chat:add_sticky(current_line)
vim.api.nvim_win_set_cursor(copilot.chat.winnr, cursor)
end,
},

accept_diff = {
normal = '<C-y>',
insert = '<C-y>',
Expand Down
2 changes: 1 addition & 1 deletion lua/CopilotChat/functions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ end

--- Get input from the user based on the schema
---@param schema table?
---@param source CopilotChat.source
---@param source CopilotChat.ui.chat.Source
---@return string?
function M.enter_input(schema, source)
if not schema or not schema.properties then
Expand Down
Loading
Loading