Closed utilyre closed 4 months ago
Same request as you (Sadly that the issue is still opened after one year 😂).
I've tried to pass a function to window.position
param in setup{}
but it seems to only accept string type.
-- lua/plugins/whichkey.lua
require('whichkey').setup{
window = {
border = "none", -- none, single, double, shadow
position = function() -- dynamic position
return require("core.utils").curor_lower_win() and "top" or "bottom"
end, -- bottom, top
}
}
-- lua/core/utils.lua
curor_lower_win = function()
local top = vim.fn.line("w0", 0)
local h = vim.api.nvim_win_get_height(0)
local cur = vim.api.nvim_win_get_cursor(0)
return (cur[1] - top) > (h / 2)
end
Expecting for any hook to controll this measure.
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.
It'd be cool if we had a smart window positioning kind of thing which would show the popup menu on top if the cursor is on the bottom split of the screen and vise versa.
There has been many times that I was editing a file with my cursor on the bottom of screen and I pressed leader key to do something which brought up the popup menu on the line I was editing.
Thanks for the fantastic plugin