Closed wroyca closed 4 months ago
Thanks for the suggestion!
There is already a functionality for users to tweak window config to their liking, as config.window.config
can be callable.
The main it seems to be one or two really long lines which make automated width too large. Here is one approach at dynamic width that I find reasonable compromise:
local compute_dynamic_width = function(buf_id)
local max_width = 0.4 * vim.o.columns
local widths = vim.tbl_map(vim.fn.strdisplaywidth, vim.api.nvim_buf_get_lines(buf_id, 0, -1, false))
table.sort(widths)
for i = #widths, 1, -1 do
if widths[i] <= max_width then return widths[i] end
end
return max_width
end
local win_config = function(buf_id) return { width = compute_dynamic_width(buf_id) } end
local miniclue = require('mini.clue')
miniclue.setup({
-- Clues and triggers setup
window = { config = win_config },
})
It has user-defined maximum width (as a share of current Neovim instance width) and picks the window width so as to fit the largest present line below that threshold (if there is one).
My initial reaction was to leave it as possible configuration, but I think I might change my mind about somehow adding this type of behavior directly in 'mini.clue' (maybe by allowing fractional width?).
I'll think about it.
Sorry, but I think leaving it for a manual configuration is a better solution in the long term. Maybe if/when there is a wiki with all the suggested custom solutions, they will be easier to find.
Besides, all those descriptions can be adjusted manually with set_mapping_desc()
and the original culprit of those long built-in descriptions was solved before 0.10 made stable release.
Closing as not planned.
Contributing guidelines
Module(s)
clue
Description
Hello o/
When displaying clues with varying line widths, the float width is determined by the widest line, which is far too aggressive. One solution I'd like to propose here would be to calculate a width suitable to comfortably display "most" lines while truncating the excessively wide ones.
Example (late night pseudo code, don't use):
Before:
After:
And more: