Skip to content

Commit e2502c4

Browse files
authored
feat: resize popup on VimResized (#36)
* feat: resize popup on VimResized * style: format code with stylua and add minor inline comment
1 parent 8720e99 commit e2502c4

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

lua/scissors/3-edit-popup.lua

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,22 @@ function M.editInPopup(snip, mode)
324324
end,
325325
})
326326

327+
-- Adjusts the popup size when the Neovim window is resized
328+
vim.api.nvim_create_autocmd("VimResized", {
329+
group = vim.api.nvim_create_augroup("scissors-resized", { clear = true }),
330+
callback = function()
331+
if not vim.api.nvim_win_is_valid(winnr) then return end
332+
333+
vim.api.nvim_win_set_config(winnr, {
334+
relative = "editor",
335+
width = math.floor(conf.width * vim.o.columns),
336+
height = math.floor(conf.height * vim.o.lines),
337+
row = math.floor((1 - conf.height) * vim.o.lines / 2),
338+
col = math.floor((1 - conf.width) * vim.o.columns / 2),
339+
})
340+
end,
341+
})
342+
327343
-- MISC
328344
setupPopupKeymaps(bufnr, winnr, mode, snip, prefixBodySep)
329345
u.tokenHighlight(bufnr)

0 commit comments

Comments
 (0)