Skip to content

Commit

Permalink
feat: Add 'replace' layout that replaces current buffer in window (#295)
Browse files Browse the repository at this point in the history
  • Loading branch information
deathbeam authored May 1, 2024
1 parent 077994b commit 1a46921
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ Also see [here](/lua/CopilotChat/config.lua):

-- default window options
window = {
layout = 'vertical', -- 'vertical', 'horizontal', 'float'
layout = 'vertical', -- 'vertical', 'horizontal', 'float', 'replace'
width = 0.5, -- fractional width of parent, or absolute width in columns when > 1
height = 0.5, -- fractional height of parent, or absolute height in rows when > 1
-- Options below only apply to floating windows
Expand Down
3 changes: 3 additions & 0 deletions lua/CopilotChat/chat.lua
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,9 @@ function Chat:open(config)
self.winnr = vim.api.nvim_get_current_win()
vim.api.nvim_win_set_buf(self.winnr, self.bufnr)
vim.api.nvim_set_current_win(orig)
elseif layout == 'replace' then
self.winnr = vim.api.nvim_get_current_win()
vim.api.nvim_win_set_buf(self.winnr, self.bufnr)
end

vim.wo[self.winnr].wrap = true
Expand Down
2 changes: 1 addition & 1 deletion lua/CopilotChat/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ return {

-- default window options
window = {
layout = 'vertical', -- 'vertical', 'horizontal', 'float'
layout = 'vertical', -- 'vertical', 'horizontal', 'float', 'replace'
width = 0.5, -- fractional width of parent, or absolute width in columns when > 1
height = 0.5, -- fractional height of parent, or absolute height in rows when > 1
-- Options below only apply to floating windows
Expand Down

0 comments on commit 1a46921

Please sign in to comment.