feat(completion): Allow to set min window width#2302
feat(completion): Allow to set min window width#2302gx089 wants to merge 3 commits intonvim-mini:mainfrom
Conversation
This allows the user to set a minimum width for signature and info windows.
If width_min isn't explicitly set, the default behavior is retained.
```lua
window = {
info = { width = 120, height = 120, width_min = 6 },
signature = { width = 120, height = 120, width_min = 10 },
},
```
Update doc regarding: feat(completion): Allow to set min window width #2302
|
Thanks for the PR! I am afraid, this is a bit too much for 'mini.completion'. Otherwise it opens a pass to a slippery slope of various dedicated small scoped options. Currently 'mini.completion' provides dedicated events which should be enough to customize information and signature windows in any way users prefer. Including setting minimum width. Closing as not planned. |
|
Okay, I tried to figure out how to achieve this via builtin methods like Thanks in advance @echasnovski :-)
|
|
The general idea is to create an autocommand for the local set_min_width = function(ev)
-- Ignore adjusting signature window
if ev.data.kind == 'signature' then return end
-- Get current width and possibly adjust to be at least 20
local win_id = ev.data.win_id
local config = vim.api.nvim_win_get_config(win_id)
-- Also adjust title since it might have been truncated
local config_updates = { width = math.max(config.width, 30), title = 'Info' }
vim.api.nvim_win_set_config(win_id, config_updates)
end
local pattern = { 'MiniCompletionWindowUpdate', 'MiniCompletionWindowOpen' }
vim.api.nvim_create_autocmd('User', { pattern = pattern, callback = set_min_width })One possible downside of this approach is that it might interfere with computation of which side of popup menu to use to show the info/signature window. I.e. if there is small room to the right of it and the width computed by 'mini.completion' fits while the desired minimum one does not. So I'd recommend using not too big value for minimum width. |
|
Thank you for your effort writing this snippet. It solves the problem but partially. If the width of the (float)window exceeds the rest of the space on the screen, the window is gets positioned on the left side (instead of right side) of the completion menu. This is a normal and expected behavior. Nevertheless, thank you for clarification and providing this hint. :-) Btw.: The hyperlink of "User" is referencing to a 404 Page |
As I said - not perfect. But can be adjusted and probably relatively concisely.
Thanks. This is a known neovim.io problem which broke the expected way of linking to a tag. There are solutions in pending PRs, not merged yet. |

This allows the user to set a minimum width for signature and info windows. If width_min isn't explicitly set, the default behavior is retained.