How to auto-size the popup? #108
Answered
by
MunifTanjim
bennypowers
asked this question in
Q&A
-
Hello! local buffer = require'nui.popup' {
position = 1,
relative = 'cursor',
enter = false,
focusable = false,
size = {
width = '75%',
height = 5,
},
border = {
padding = { 1, 2 },
style = 'shadow',
},
buf_options = {
readonly = false,
modifiable = true,
},
win_options = {
wrap = true,
},
}
function set_lines(buf, components)
end
-- an arbitrary string, may or may not contain newlines
local text = get_narrative_lines(get_components())
vim.api.nvim_buf_call(buf.bufnr, function()
vim.lsp.util.stylize_markdown(buf.bufnr, text)
end)
-- TODO: adjust popup size In that scenario, how would I automatically adjust the popup window size, based on the initial defaults, and according to the text size? For example, if the text is shorter than some configured min (e.g. 50 chars), make the popup smaller, if it's above some configured max (e.g. 300 chars), increase the popup size, otherwise, keep the defaults as above. |
Beta Was this translation helpful? Give feedback.
Answered by
MunifTanjim
Feb 18, 2022
Replies: 1 comment 1 reply
-
Have you tried |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
bennypowers
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Have you tried
popup:set_size
method?