Skip to content
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

Merged
merged 7 commits into from
Aug 31, 2024
Merged

feat: Floating window support #4

merged 7 commits into from
Aug 31, 2024

Conversation

mikew
Copy link
Owner

@mikew mikew commented Aug 30, 2024

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

@mikew mikew mentioned this pull request Aug 30, 2024
@@ -276,6 +280,120 @@ function mod.create_drawer(opts)
instance.state.previous_bufnr = final_bufnr
end

function instance.get_win_config()
Copy link
Owner Author

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.

--- @field margin? number
--- @field width? number
--- @field height? number
--- @field anchor? 'NE' | 'NC' | 'NW' | 'CE' | 'CC' | 'CW' | 'SE' | 'SC' | 'SW'
Copy link
Owner Author

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

Comment on lines -527 to -532

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)
Copy link
Owner Author

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!

@mikew mikew changed the title feat: Add floating window support feat: Floating window support Aug 31, 2024
@mikew mikew merged commit ef5b36d into main Aug 31, 2024
@mikew mikew deleted the floating-windows branch August 31, 2024 05:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant