Skip to content

Commit 2a47aaa

Browse files
authored
feat: make floating window zindex configurable (#104)
1 parent 39647f5 commit 2a47aaa

3 files changed

Lines changed: 9 additions & 3 deletions

File tree

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ Also see [here](/lua/CopilotChat/config.lua):
194194
-- default window options
195195
window = {
196196
layout = 'vertical', -- 'vertical', 'horizontal', 'float'
197+
-- Options below only apply to floating windows
197198
relative = 'editor', -- 'editor', 'win', 'cursor', 'mouse'
198199
border = 'single', -- 'none', single', 'double', 'rounded', 'solid', 'shadow'
199200
width = 0.8, -- fractional width of parent
@@ -202,6 +203,7 @@ Also see [here](/lua/CopilotChat/config.lua):
202203
col = nil, -- column position of the window, default is centered
203204
title = 'Copilot Chat', -- title of chat window
204205
footer = nil, -- footer of chat window
206+
zindex = 1, -- determines if window is on top or below other floating windows
205207
},
206208
-- default mappings
207209
mappings = {

lua/CopilotChat/config.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ local select = require('CopilotChat.select')
2727
---@field col number?
2828
---@field title string?
2929
---@field footer string?
30+
---@field zindex number?
3031

3132
---@class CopilotChat.config.mappings
3233
---@field close string?
@@ -95,6 +96,7 @@ return {
9596
-- default window options
9697
window = {
9798
layout = 'vertical', -- 'vertical', 'horizontal', 'float'
99+
-- Options below only apply to floating windows
98100
relative = 'editor', -- 'editor', 'win', 'cursor', 'mouse'
99101
border = 'single', -- 'none', single', 'double', 'rounded', 'solid', 'shadow'
100102
width = 0.8, -- fractional width of parent
@@ -103,6 +105,7 @@ return {
103105
col = nil, -- column position of the window, default is centered
104106
title = 'Copilot Chat', -- title of chat window
105107
footer = nil, -- footer of chat window
108+
zindex = 1, -- determines if window is on top or below other floating windows
106109
},
107110
-- default mappings
108111
mappings = {

lua/CopilotChat/init.lua

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ local function show_diff_between_selection_and_copilot()
8484
row = 0,
8585
col = 0,
8686
width = vim.api.nvim_win_get_width(0) - 3,
87+
zindex = M.config.window.zindex + 1,
8788
})
8889
end
8990
end
@@ -317,7 +318,7 @@ function M.open(config)
317318
local layout = config.window.layout
318319

319320
if layout == 'float' then
320-
win_opts.zindex = 1
321+
win_opts.zindex = config.window.zindex
321322
win_opts.relative = config.window.relative
322323
win_opts.border = config.window.border
323324
win_opts.title = config.window.title
@@ -329,7 +330,7 @@ function M.open(config)
329330
win_opts.height = math.floor(vim.o.lines * config.window.height)
330331
elseif layout == 'vertical' then
331332
if is_stable() then
332-
win_opts.zindex = 1
333+
win_opts.zindex = config.window.zindex
333334
win_opts.relative = 'editor'
334335
win_opts.width = math.floor(vim.o.columns * 0.5) -- 50% width
335336
win_opts.height = vim.o.lines -- full height
@@ -343,7 +344,7 @@ function M.open(config)
343344
end
344345
elseif layout == 'horizontal' then
345346
if is_stable() then
346-
win_opts.zindex = 1
347+
win_opts.zindex = config.window.zindex
347348
win_opts.relative = 'editor'
348349
win_opts.height = math.floor(vim.o.lines * 0.5) -- 50% height
349350
win_opts.width = vim.o.columns -- full width

0 commit comments

Comments
 (0)