mason.nvim icon indicating copy to clipboard operation
mason.nvim copied to clipboard

Responsive width and height by accepting a function in `ui.height` and `ui.width`

Open dvimaaniye opened this issue 2 months ago • 0 comments

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_width and max_height option for when the height and width is 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,
			},
		},
		...

dvimaaniye avatar Nov 21 '25 06:11 dvimaaniye

If you're enjoying Awesome-Privacy, consider dropping us a ⭐
🤖 I'm a bot, and this message was automated

liss-bot avatar Oct 24 '25 20:10 liss-bot