Skip to content

Commit 89c5349

Browse files
committed
Fix type checks make lua_ls happy
1 parent 2d19cb7 commit 89c5349

File tree

2 files changed

+22
-11
lines changed

2 files changed

+22
-11
lines changed

lua/neogit/config.lua

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1138,6 +1138,13 @@ function M.validate_config()
11381138
validate_type(config.notification_icon, "notification_icon", "string")
11391139
validate_type(config.console_timeout, "console_timeout", "number")
11401140
validate_kind(config.kind, "kind")
1141+
if validate_type(config.floating, "floating", "table") then
1142+
validate_type(config.floating.relative, "relative", "string")
1143+
validate_type(config.floating.width, "width", "number")
1144+
validate_type(config.floating.height, "height", "number")
1145+
validate_type(config.floating.style, "style", "string")
1146+
validate_type(config.floating.border, "border", "string")
1147+
end
11411148
validate_type(config.disable_line_numbers, "disable_line_numbers", "boolean")
11421149
validate_type(config.disable_relative_line_numbers, "disable_relative_line_numbers", "boolean")
11431150
validate_type(config.auto_show_console, "auto_show_console", "boolean")

lua/neogit/lib/buffer.lua

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ local util = require("neogit.lib.util")
55

66
local signs = require("neogit.lib.signs")
77
local Ui = require("neogit.lib.ui")
8+
local config = require("neogit.config")
89

910
local Path = require("plenary.path")
1011

@@ -317,20 +318,23 @@ function Buffer:show()
317318
elseif self.kind == "vsplit_left" then
318319
win = api.nvim_open_win(self.handle, true, { split = "left", vertical = true })
319320
elseif self.kind == "floating" then
320-
local floating = require("neogit.config").values.floating
321-
322-
-- Creates the border window
321+
local width = config.values.floating.width
322+
local height = config.values.floating.height
323323
local vim_height = vim.o.lines
324324
local vim_width = vim.o.columns
325+
width = width > 1 and width or math.floor(vim_width * width)
326+
height = height > 1 and height or math.floor(vim_height * height)
325327

326-
floating.width = floating.width > 1 and floating.width or math.floor(vim_width * floating.width)
327-
floating.height = floating.height > 1 and floating.height or math.floor(vim_height * floating.height)
328-
floating.col = (vim_width - floating.width) / 2
329-
-- floating.row = (vim_height - floating.height) / 2
330-
floating.row = vim_height * 0.15
331-
floating.focusable = true
332-
333-
local content_window = api.nvim_open_win(self.handle, true, floating)
328+
local content_window = api.nvim_open_win(self.handle, true, {
329+
width = width,
330+
height = height,
331+
relative = config.values.floating.relative,
332+
border = config.values.floating.border,
333+
style = config.values.floating.style,
334+
col = config.values.floating.col or (vim_width - width) / 2,
335+
row = config.values.floating.row or (vim_height - height) / 2,
336+
focusable = true,
337+
})
334338

335339
api.nvim_win_set_cursor(content_window, { 1, 0 })
336340
win = content_window

0 commit comments

Comments
 (0)