-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Floating window support #4
Conversation
lua/nvim-drawer/init.lua
Outdated
@@ -276,6 +280,120 @@ function mod.create_drawer(opts) | |||
instance.state.previous_bufnr = final_bufnr | |||
end | |||
|
|||
function instance.get_win_config() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function + nvim_win_set_config
kind of makes set_size
moot, it does the same thing.
lua/nvim-drawer/init.lua
Outdated
--- @field margin? number | ||
--- @field width? number | ||
--- @field height? number | ||
--- @field anchor? 'NE' | 'NC' | 'NW' | 'CE' | 'CC' | 'CW' | 'SE' | 'SC' | 'SW' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add N | E | S | W | C
since they're more ergonomic, but they should just resolve to NC / CE / SC / CW / CC
since those make the code much cleaner
|
||
local winid = instance.get_winid() | ||
instance.set_size(instance.state.size) | ||
|
||
local bufnr = instance.state.previous_bufnr | ||
vim.api.nvim_win_set_buf(winid, bufnr) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Personal milestone!
It always irked me that the restore logic here was so involved, even going back to vim-drawer: https://github.com/mikew/vim-drawer/blob/38c760debb0e85a3586878ea40ff6cc978fea054/autoload/drawer.vim#L290-L300
Really, .open
and .close
should suss themselves out correctly without having to account for any weird side effects, and finally they do!
Since there's no easy way to resize floating windows with a mouse, I've also added a
toggle_zoom()
function. This also works on splits.Preview
Screen.Recording.2024-08-30.at.3.44.03.AM.mov.mp4