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

Allow custom floating window style #1641

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

SheffeyG
Copy link
Contributor

This change allow users to custom floating window like #685, so we can configure it as:

floating = {
    width = 0.5, -- percentage
    height = 30, -- row
    border = "single",
    ...
}

@SheffeyG
Copy link
Contributor Author

SheffeyG commented Jan 16, 2025

@CKolkey There're some type warnings here, and I am not familiar with Lua's type system, I can resolve the type warnings by this:

modified lua/neogit/lib/buffer.lua
@@ -317,7 +317,7 @@ function Buffer:show()
     elseif self.kind == "vsplit_left" then
       win = api.nvim_open_win(self.handle, true, { split = "left", vertical = true })
     elseif self.kind == "floating" then
-      local floating = require("neogit.config").values.floating
+      local floating = require("neogit.config").values.floating or {}
 
       -- Creates the border window
       local vim_height = vim.o.lines
@@ -330,7 +330,7 @@ function Buffer:show()
       floating.row = vim_height * 0.15
       floating.focusable = true
 
-      local content_window = api.nvim_open_win(self.handle, true, floating)
+      local content_window = api.nvim_open_win(self.handle, true, vim.tbl_deep_extend("force", {}, floating))
 
       api.nvim_win_set_cursor(content_window, { 1, 0 })
       win = content_window

but in this way is kind bad since my method of reading custom configurations might be wrong, could you tell me the correct way to do it?

@SheffeyG SheffeyG force-pushed the feat-custom-float-window branch from 7b5d4bf to 2d19cb7 Compare January 16, 2025 08:21
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