mason.nvim
mason.nvim copied to clipboard
Responsive width and height by accepting a function in `ui.height` and `ui.width`
I've searched open issues for similar requests
- [x] Yes
Is your feature request related to a problem? Please describe.
Yes, I can't get the Mason UI window to be of a different size depending on height/lines and width/columns. For example, when the width is large, it should be 60% of the width, or perhaps a fixed number; when the width is smaller, it should be 80% of the width. The same goes for height.
Describe the solution you'd like
Accept a function for width and height. One possible implementation:
local function create_popup_window_opts(opts, sizes_only)
...
local height = settings.current.ui.height
local width = settings.current.ui.width
height = calc_size(type(height) == "function" and height() or height, lines)
width = calc_size(type(width) == "function" and width() or width, columns)
...
Describe potential alternatives you've considered
The idea of accepting a function is more extensible, but here's an alternative approach:
- A
max_widthandmax_heightoption for when theheightandwidthis a float in the range of 0-1.
Additional context
I have tried the proposed change locally, and it works fine.
...
-- using local fork
-- using lazy
opts = {
ui = {
...
height = function()
local rows = vim.o.lines
if rows < 40 then
return 0.9
end
return 0.8
end,
width = function()
local cols = vim.o.columns
if cols < 150 then
return 0.8
end
return 0.5
end,
},
},
...
If you're enjoying Awesome-Privacy, consider dropping us a ⭐
🤖 I'm a bot, and this message was automated