Skip to content

Commit 6dca8ea

Browse files
committed
feat: configurable zindex with default to 49 (resolve: #132)
1 parent 78888b1 commit 6dca8ea

File tree

3 files changed

+26
-13
lines changed

3 files changed

+26
-13
lines changed

lua/gp/config.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,9 @@ local config = {
338338
style_popup_margin_top = 2,
339339
style_popup_max_width = 160,
340340

341+
-- in case of visibility colisions with other plugins, you can increase/decrease zindex
342+
zindex = 49,
343+
341344
-- command config and templates below are used by commands like GpRewrite, GpEnew, etc.
342345
-- command prompt prefix for asking user for input (supports {{agent}} template variable)
343346
command_prompt_prefix_template = "🤖 {{agent}} ~ ",

lua/gp/init.lua

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -629,6 +629,7 @@ M.open_buf = function(file_name, target, kind, toggle)
629629
return ww, wh, top, (w - ww) / 2
630630
end, { on_leave = false, escape = false, persist = true }, {
631631
border = M.config.style_popup_border or "single",
632+
zindex = M.config.zindex,
632633
})
633634

634635
if not toggle then
@@ -1157,6 +1158,7 @@ M.cmd.ChatFinder = function()
11571158
local gid = M.helpers.create_augroup("GpChatFinder", { clear = true })
11581159

11591160
-- prepare three popup buffers and windows
1161+
local style = { border = M.config.style_chat_finder_border or "single", zindex = M.config.zindex }
11601162
local ratio = M.config.style_chat_finder_preview_ratio or 0.5
11611163
local top = M.config.style_chat_finder_margin_top or 2
11621164
local bottom = M.config.style_chat_finder_margin_bottom or 8
@@ -1171,7 +1173,7 @@ M.cmd.ChatFinder = function()
11711173
return math.floor(ww * (1 - ratio)), wh, top, left
11721174
end,
11731175
{ gid = gid },
1174-
{ border = M.config.style_chat_finder_border or "single" }
1176+
style
11751177
)
11761178

11771179
local preview_buf, preview_win, preview_close, preview_resize = M.render.popup(
@@ -1183,7 +1185,7 @@ M.cmd.ChatFinder = function()
11831185
return ww * ratio, wh, top, left + math.ceil(ww * (1 - ratio)) + 2
11841186
end,
11851187
{ gid = gid },
1186-
{ border = M.config.style_chat_finder_border or "single" }
1188+
style
11871189
)
11881190

11891191
vim.api.nvim_set_option_value("filetype", "markdown", { buf = preview_buf })
@@ -1196,7 +1198,7 @@ M.cmd.ChatFinder = function()
11961198
return w - left - right, 1, h - bottom, left
11971199
end,
11981200
{ gid = gid },
1199-
{ border = M.config.style_chat_finder_border or "single" }
1201+
style
12001202
)
12011203
-- set initial content of command buffer
12021204
vim.api.nvim_buf_set_lines(command_buf, 0, -1, false, { M.config.chat_finder_pattern })
@@ -1841,16 +1843,22 @@ M.Prompt = function(params, target, agent, template, prompt, whisper, callback)
18411843
M._toggle_close(M._toggle_kind.popup)
18421844
-- create a new buffer
18431845
local popup_close = nil
1844-
buf, win, popup_close, _ = M.render.popup(nil, M._Name .. " popup (close with <esc>/<C-c>)", function(w, h)
1845-
local top = M.config.style_popup_margin_top or 2
1846-
local bottom = M.config.style_popup_margin_bottom or 8
1847-
local left = M.config.style_popup_margin_left or 1
1848-
local right = M.config.style_popup_margin_right or 1
1849-
local max_width = M.config.style_popup_max_width or 160
1850-
local ww = math.min(w - (left + right), max_width)
1851-
local wh = h - (top + bottom)
1852-
return ww, wh, top, (w - ww) / 2
1853-
end, { on_leave = true, escape = true }, { border = M.config.style_popup_border or "single" })
1846+
buf, win, popup_close, _ = M.render.popup(
1847+
nil,
1848+
M._Name .. " popup (close with <esc>/<C-c>)",
1849+
function(w, h)
1850+
local top = M.config.style_popup_margin_top or 2
1851+
local bottom = M.config.style_popup_margin_bottom or 8
1852+
local left = M.config.style_popup_margin_left or 1
1853+
local right = M.config.style_popup_margin_right or 1
1854+
local max_width = M.config.style_popup_max_width or 160
1855+
local ww = math.min(w - (left + right), max_width)
1856+
local wh = h - (top + bottom)
1857+
return ww, wh, top, (w - ww) / 2
1858+
end,
1859+
{ on_leave = true, escape = true },
1860+
{ border = M.config.style_popup_border or "single", zindex = M.config.zindex }
1861+
)
18541862
-- set the created buffer as the current buffer
18551863
vim.api.nvim_set_current_buf(buf)
18561864
-- set the filetype to markdown

lua/gp/render.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ M.popup = function(buf, title, size_func, opts, style)
9696
opts = opts or {}
9797
style = style or {}
9898
local border = style.border or "single"
99+
local zindex = style.zindex or 49
99100

100101
-- create buffer
101102
buf = buf or vim.api.nvim_create_buf(false, not opts.persist)
@@ -112,6 +113,7 @@ M.popup = function(buf, title, size_func, opts, style)
112113
border = border,
113114
title = title,
114115
title_pos = "center",
116+
zindex = zindex,
115117
}
116118

117119
-- open the window and return the buffer

0 commit comments

Comments
 (0)