Skip to content

feat: allow Borders and popups to be resized #180

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

Merged
merged 25 commits into from
Sep 26, 2021

Conversation

l-kershaw
Copy link
Collaborator

Adds a function to resize a Border based on updated content_win_options and border_win_options


Initial commit is a first attempt and probably needs looking through closely to make sure I haven't missed anything.

l-kershaw added a commit to l-kershaw/popup.nvim that referenced this pull request Jul 4, 2021
- adds table to keep track of `Border`s associated to `popup`s

- adds function to resize a `popup`

- relies on nvim-lua/plenary.nvim#180
@l-kershaw
Copy link
Collaborator Author

@Conni2461 could you have a look at this and nvim-lua/popup.nvim#15 and let me know what you think.

I'm trying to set something up that would be useful for rearranging windows within telescope.nvim without breaking any of the other plugins that use either plenary.nvim or popup.nvim.

@Conni2461
Copy link
Collaborator

This looks already great. Thanks for tackling that :) (We should reduce duplication between, :new and :resize tho)

I am thinking that with a api like that we can resolve these telescope issues:

Am i missing something that you want to do ("rearranging windows")

Also we need to see that in action at the same time, interested in developing vimresize or toggle preview, while implementing this? vimresize can maybe even happen on popup.nvim level, right?

Oh and right now i do not think you break other plugins, you are only extending api :) So thanks again

@l-kershaw
Copy link
Collaborator Author

Cool, I'll refactor stuff to reduce overlap between :new and :resize.

Those were the main uses in telescope that I was thinking of, but in principle this should allow any layout changes wanted for telescope (e.g. changing layout strategy on the fly, resizing the results window to fit things in,...).

Yeh, I was working on stuff to get VimResized working with this so I'll do that at the same time. As long as the API is robust enough, implementing other stuff shouldn't be too difficult afterwards.

- rename `Border:resize` to `Border:set_size`

- allow `Border:set_size` to be passed on option to create

  a window rather than resize

- remove overlapped parts from `Border:new` and use `Border:set_size`

  with `create_window` set to `true`
l-kershaw added a commit to l-kershaw/telescope.nvim that referenced this pull request Jul 5, 2021
- implements `Picker:recalculate_layout` function

- adds an autocommand to call this function on the `VimResized` event

- relies on nvim-lua/plenary.nvim#180 and nvim-lua/popup.nvim#15

Currently has issues when the results window increases in height
@l-kershaw l-kershaw changed the title WIP: allow Borders to be resized WIP: allow Borders and popups to be resized Aug 24, 2021
@l-kershaw
Copy link
Collaborator Author

I have added the functionality from the popup PR and closed that PR.

I think this functionality is complete enough to merge now, I can't think of anything else to add.

@Conni2461 could you have a look and let me know your thoughts?

@l-kershaw l-kershaw changed the title WIP: allow Borders and popups to be resized feat: allow Borders and popups to be resized Aug 24, 2021
@fdschmidt93
Copy link
Contributor

fdschmidt93 commented Aug 30, 2021

Just 1-2 suggestions from my end but otherwise good job, looking forward for toggleable preview and VimResized :)

@l-kershaw
Copy link
Collaborator Author

I think the failed checks are due to neovim removing a "nightly" tagged release?

I still have a few things to change based on @fdschmidt93's feedback, but thought it best to mention this first as this will affect checks for any other PRs for plenary (and I think telescope too).

@l-kershaw
Copy link
Collaborator Author

I've had a bit more of a think about it and I think it would be better to factor out the posisitioning stuff from popup.create in a way that can be reused in popup.move. That way we get stuff like cursor relative positioning and pos handling for free without repeating a load of code.

I'll have a go at this today/tomorrow, and then hopefully the neovim nightly release is back available so the tests work again.


Also, once this and #227 are merged, I was thinking about refactoring popup in an object oriented way (as done with Border), which I think will make it easier to use, so you don't have to keep track of a load of win_ids everywhere.
It's not really an issue at the moment, as you currently just "set and forget" a popup, but once we're changing position and/or other config, it gets more confusing. Particularly for implementing popup_hide and popup_show this will make things a lot simpler.
I spoke with @tjdevries about this on discord a while ago, but would be good to get some other opinions too (@Conni2461 @fdschmidt93)

@fdschmidt93
Copy link
Contributor

Completely agree and also had similar things in mind. I briefly glanced at https://github.com/MunifTanjim/nui.nvim and fzf-lua's implementation which all around both look a lot more ergonomic pretty much going that route.

@l-kershaw
Copy link
Collaborator Author

Okay, from my perspective this is now ready to merge.
@Conni2461 could you let me know your thoughts?


@fdschmidt93 yes, nui.nvim was part of what inspired the discussion for using an object based model for popups. It's been a while since I looked at it, but from memory there were a few parts of the API that looked a lot easier to use than our current setup.

@Conni2461
Copy link
Collaborator

Also, once this and #227 are merged, I was thinking about refactoring popup in an object oriented way (as done with Border), which I think will make it easier to use, so you don't have to keep track of a load of win_ids everywhere.

tj said exactly the same thing to me a month ago 🤣 i just quote him
image

my answer was kinda like that. Good idea we should focus on building what works on us and we can always build the popup_* interface on top of that object oriented implementation later.

Copy link
Collaborator

@Conni2461 Conni2461 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this looks good. Thanks :)

I'll run it for the day and maybe do some popup_move this evening, after that i would merge

@Conni2461
Copy link
Collaborator

Oh also. If you do that popup refactor, do you want "access", permissions to merge stuff. I havent talked with tj about that (just came to my mind) but i hardly think he will have a issue with that 😆

If you want i can give you permissions later. Maybe that easier than always waiting for me 🤣

@Conni2461
Copy link
Collaborator

I actually have issues with telescope, do we need some adjustments their?

Screenshots to demonstrate this behavior (i need to censor stuff that i am not allowed to share, sorry) but long story short i only see one result. But both show 132/132 results found
This PR
image
Master
image

@l-kershaw
Copy link
Collaborator Author

@Conni2461

If you want i can give you permissions later. Maybe that easier than always waiting for me 🤣

I'm happy to write the PR either way. If it makes it easier to have an extra person who can merge stuff for plenary, then I'm happy to help out with reviewing stuff over here.

I actually have issues with telescope, do we need some adjustments their?

Ah, that's weird. I hadn't had any issues, but was working with my layout refactor branch for telescope (see here).
When I switched to master, I had the same issue as you.
I don't really know how the PR branch would change this behaviour, but will have a dig through to see what I can figure out.

@Conni2461
Copy link
Collaborator

Hmm maybe that would solve the CI in telescope 🤔 You could try switching the branch ci pulls in your telescope branch, maybe that fixes ci then could merge both at the same time.

I could run both PRs for the rest of the week. I think is super busy lately (i have caught him playing dota 🤣) the stuff i saw from that pr looked good i just also didnt understand the failing ci.

@l-kershaw
Copy link
Collaborator Author

@Conni2461 as suggested I tried switching the branch for ci in the telescope PR, but it doesn't fix the issues over there
Also, it set off merge conflicts, and after the merge, the issue is now present with that PR as well as master 😅

Don't really know what's going on now 🤣 Will see if I can figure stuff out

@l-kershaw
Copy link
Collaborator Author

@Conni2461 I've tried to find the point in the commit history for telescope where stuff diverged enough to cause this issue and it is before we move popup into plenary, so I can't find the root cause.
I think it is probably best to wait for the layout refactor branch to be merged into telescope, and then we can decipher the cause of this issue and probably write a fix within telescope for it. Until then, I think this PR is blocked 😢

@l-kershaw
Copy link
Collaborator Author

@Conni2461 I think I have fixed the stuff in this PR that was breaking telescope. So I think this PR could be merged without negatively affecting anything in telescope.

I don't think there is anything more to do on the plenary side in terms of moving popups around, but for resizing layouts in telescope there is still some work to do in terms of handling the results buffer. I'm happy to hold off on merging this in case we need some extra changes in plenary to get stuff to work, but it does seem like more of a telescope issue causing problems over there now.

@Conni2461
Copy link
Collaborator

I tested it and i havent seen any regressions for telescope, so i dont see any reason why not merging right now :)

Thanks for all the hard work :)

@Conni2461 Conni2461 merged commit 8c6cc07 into nvim-lua:master Sep 26, 2021
@l-kershaw l-kershaw deleted the feat/border_resize branch September 26, 2021 14:14
l-kershaw added a commit to l-kershaw/telescope.nvim that referenced this pull request Oct 10, 2021
- implements `Picker:recalculate_layout` function

- adds an autocommand to call this function on the `VimResized` event

- relies on nvim-lua/plenary.nvim#180 and nvim-lua/popup.nvim#15

Currently has issues when the results window increases in height
l-kershaw added a commit to l-kershaw/telescope.nvim that referenced this pull request Oct 18, 2021
- implements `Picker:recalculate_layout` function

- adds an autocommand to call this function on the `VimResized` event

- relies on nvim-lua/plenary.nvim#180 and nvim-lua/popup.nvim#15

Currently has issues when the results window increases in height

lint
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.

3 participants