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
58 changes: 29 additions & 29 deletions lua/CopilotChat/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1100,41 +1100,41 @@ function M.setup(config)
if M.chat then
M.chat:close(state.source.bufnr)
M.chat:delete()
end

M.chat = require('CopilotChat.ui.chat')(M.config, function(bufnr)
for name, _ in pairs(M.config.mappings) do
map_key(name, bufnr)
end

require('CopilotChat.completion').enable(bufnr, M.config.chat_autocomplete)
else
M.chat = require('CopilotChat.ui.chat')(M.config, function(bufnr)
for name, _ in pairs(M.config.mappings) do
map_key(name, bufnr)
end

vim.api.nvim_create_autocmd({ 'BufEnter', 'BufLeave' }, {
buffer = bufnr,
callback = function(ev)
if ev.event == 'BufEnter' then
update_source()
end
require('CopilotChat.completion').enable(bufnr, M.config.chat_autocomplete)

vim.schedule(function()
select.highlight(state.source.bufnr, not (M.config.highlight_selection and M.chat:focused()))
end)
end,
})

if M.config.insert_at_end then
vim.api.nvim_create_autocmd({ 'InsertEnter' }, {
vim.api.nvim_create_autocmd({ 'BufEnter', 'BufLeave' }, {
buffer = bufnr,
callback = function()
vim.cmd('normal! 0')
vim.cmd('normal! G$')
vim.v.char = 'x'
callback = function(ev)
if ev.event == 'BufEnter' then
update_source()
end

vim.schedule(function()
select.highlight(state.source.bufnr, not (M.config.highlight_selection and M.chat:focused()))
end)
end,
})
end

finish(true)
end)
if M.config.insert_at_end then
vim.api.nvim_create_autocmd({ 'InsertEnter' }, {
buffer = bufnr,
callback = function()
vim.cmd('normal! 0')
vim.cmd('normal! G$')
vim.v.char = 'x'
end,
})
end

finish(true)
end)
end

for name, prompt in pairs(list_prompts()) do
if prompt.prompt then
Expand Down
2 changes: 1 addition & 1 deletion lua/CopilotChat/ui/chat.lua
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ local Chat = class(function(self, config, on_buf_create)
if not msg or msg == '' then
self.chat_overlay:restore(self.winnr, self.bufnr)
else
self:overlay({ text = msg })
self.chat_overlay:show(msg, self.winnr)
end
end)
end, Overlay)
Expand Down
Loading