fix(edgy): improve edgy.lua bufferline offset logic

Use already defined Bufferline offsets or use Edgy offset if none are found.

Properly set offset separator position depending on offset location.
This commit is contained in:
Gobinda Goshwami 2024-06-24 14:39:22 +06:00 committed by GitHub
parent 2a7ba6d09c
commit 087dccf2f3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -152,14 +152,17 @@ return {
local get = Offset.get
Offset.get = function()
if package.loaded.edgy then
local old_offset = get()
local layout = require("edgy.config").layout
local ret = { left = "", left_size = 0, right = "", right_size = 0 }
for _, pos in ipairs({ "left", "right" }) do
local sb = layout[pos]
if sb and #sb.wins > 0 then
local title = " Sidebar" .. string.rep(" ", sb.bounds.width - 8)
ret[pos] = "%#EdgyTitle#" .. title .. "%*" .. "%#WinSeparator#│%*"
ret[pos .. "_size"] = sb.bounds.width
if sb and #sb.wins > 0 then
ret[pos] = old_offset[pos .. "_size"] > 0 and old_offset[pos]
or pos == "left" and ("%#Bold#" .. title .. "%*" .. "%#BufferLineOffsetSeparator#│%*")
or pos == "right" and ("%#BufferLineOffsetSeparator#│%*" .. "%#Bold#" .. title .. "%*")
ret[pos .. "_size"] = old_offset[pos .. "_size"] > 0 and old_offset[pos .. "_size"] or sb.bounds.width
end
end
ret.total_size = ret.left_size + ret.right_size