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: adjust fidget notification window offset when xcodebuild test drawer is open #207

Closed
wojciech-kulik opened this issue Jan 31, 2024 · 13 comments · Fixed by #212 or #211
Closed
Labels
enhancement New feature or request question Further information is requested

Comments

@wojciech-kulik
Copy link
Contributor

It would be great to be able to configure fidget so that it shows up on the left side

@j-hui j-hui added enhancement New feature or request question Further information is requested labels Feb 4, 2024
@j-hui j-hui changed the title Feat: show messages on the left side feat: show messages on the left side Feb 4, 2024
@j-hui
Copy link
Owner

j-hui commented Feb 4, 2024

Really? Why would you want this?

image

I am genuinely curious. Because unless I'm missing something (e.g., you often edit text that is somehow aligned to right side of your editor window), left-aligning the Fidget window is invariably going to lead to its text clashing with the text at the bottom of your buffer.

For what it's worth this is the change:

diff --git i/lua/fidget/notification/window.lua w/lua/fidget/notification/window.lua
index 3d8d7b1..80fc1c1 100644
--- i/lua/fidget/notification/window.lua
+++ w/lua/fidget/notification/window.lua
@@ -265,7 +265,7 @@ function M.get_window_position()
     row = math.min(row_max, row + M.options.y_padding)
   end

-  return row, col, (align_bottom and "S" or "N") .. "E"
+  return row, M.options.x_padding + state.x_offset, (align_bottom and "S" or "N") .. "W"
 end

 --- Set local options on a window.

The implementation is really easy, but I'm hesitant to introduce a feature that will basically render the bottom-left corner of your editor unusable. Is there a particular use case you have in mind?

(Perhaps this might look more usable when the Fidget window is given an opaque background or something. If that's what you had in mind, please let me know (: )

@wojciech-kulik
Copy link
Contributor Author

Yes, probably opaque window would be some solution. Currently, it is clashing with my right pane for unit tests:
image

(just an image of the functionality, not the issue itself. In my case tests fill the whole space and overlap with Fidget)

@j-hui
Copy link
Owner

j-hui commented Feb 4, 2024

Got it, that makes sense.

What plugin are you using for the unit tests? Another solution is to dynamically adjust the x_offset when that side tray is opened, like I do for nvim-tree.

@wojciech-kulik
Copy link
Contributor Author

It’s actually my own plugin :D it’s configurable, I can open it on the left side if needed. However, I like having it on the right side so I thought that maybe I could move Fidget on the other side where normally you see messages. Maybe I will just use changes you posted and see what works best for me. However, I think that opaque background would be useful anyway.

@j-hui
Copy link
Owner

j-hui commented Feb 4, 2024

You should already be able to make the window opaque by setting notification.window.winblend = 0.

I’ll package up the left-aligned notification window as well… I just need to figure out whether to introduce a new option or expand the align one that already exists. (Sanity check: there’s no reason to put it on the top left corner, right?)

Also, I just saw your plugin, it looks awesome! If you give Fidget a way to register a callback every time the side tray is opened or resized, and some way to query the tray width, I can write an integration to dynamically reposition the notification window, like I do for nvim-tree.

@wojciech-kulik
Copy link
Contributor Author

wojciech-kulik commented Feb 4, 2024

Dynamic repositioning could be probably the best solution, I guess just a simple API method to dynamically set the offset would be enough.

Regarding align parameter, I'm not sure how useful it would be for users, however I think in general it would be best to give users choice where they want to place it. People are very different and even if to us it doesn't make sense to put it in the top left corner I bet someone would like to have it there :D

@j-hui
Copy link
Owner

j-hui commented Feb 4, 2024

Dynamic repositioning could be probably the best solution, I guess just a simple API method to dynamically set the offset would be enough.

Ah yeah, you can check https://github.com/j-hui/fidget.nvim/blob/main/lua/fidget/integration/nvim-tree.lua for how I integrate with nvim-tree, which has a similar layout and buffer lifecycle. The only odd thing is that they have their own callback registration system. You can get away with just sending autocmd events.

Regarding align parameter, I'm not sure how useful it would be for users, however I think in general it would be best to give users choice where they want to place it. People are very different and even if to us it doesn't make sense to put it in the top left corner I bet someone would like to have it there :D

You're definitely right in general! But I want to avoid adding this feature if it's not going to be often used because (1) it adds complexity for other parts of the code that are reliant on window positioning (such as the nvim-tree integration!), and (2) it is another potential source of breaking changes, e.g., if I decide to move Fidget in some direction that is fundamentally incompatible with left-aligned notifications or something. So I don't want to give flexibility---which is why I ask whether there's a specific use case you had in mind, that can't be fixed through other features/workarounds (:

@wojciech-kulik
Copy link
Contributor Author

Ok, I was planning to add events anyway to my plugin to provide more customizability, so once it's done I can let you know if you are willing to add the integration. Or I can try creating a pull request if you prefer this way.

@j-hui
Copy link
Owner

j-hui commented Feb 4, 2024 via email

@wojciech-kulik
Copy link
Contributor Author

wojciech-kulik commented Feb 5, 2024

@j-hui I finished the integration, but I noticed that one thing is missing. Once all messages are gone and I trigger fidget again it starts again at previous offset. How can I subscribe to the event when fidget window is configured?

I guess the same problem is with nvim-tree? Unless I missed something

@wojciech-kulik
Copy link
Contributor Author

This is causing the issue, I guess. Shouldn't the offset be preserved?

@j-hui
Copy link
Owner

j-hui commented Feb 5, 2024

Ah good catch. I'll push a change that fixes that behavior.

@wojciech-kulik
Copy link
Contributor Author

It's already in my pull request, you can check it out :).

@j-hui j-hui changed the title feat: show messages on the left side feat: adjust fidget notification window offset when xcodebuild test drawer is open Feb 6, 2024
@j-hui j-hui closed this as completed in #212 Feb 6, 2024
j-hui pushed a commit that referenced this issue Feb 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request question Further information is requested
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants