fix/refactor(preview): Proper per-sidebar support & complete rewrite

This commit is contained in:
hedy
2023-11-27 20:08:22 +08:00
parent b6b2bf2248
commit 80f76333ba
5 changed files with 158 additions and 148 deletions

View File

@@ -154,20 +154,18 @@ end
function M.get_window_width()
if M.o.outline_window.relative_width then
return math.ceil(vim.o.columns * (M.o.outline_window.width / 100))
else
return M.o.outline_window.width
end
return M.o.outline_window.width
end
function M.get_preview_width()
if M.o.preview_window.relative_width then
local relative_width = math.ceil(vim.o.columns * (M.o.preview_window.width / 100))
local relative_width = math.max(
math.ceil(vim.o.columns * (M.o.preview_window.width / 100)),
M.o.preview_window.min_width
)
if relative_width < M.o.preview_window.min_width then
return M.o.preview_window.min_width
else
return relative_width
end
return relative_width
else
return M.o.preview_window.width
end
@@ -332,6 +330,10 @@ function M.resolve_config()
M.o.keymaps[action] = { keys }
end
end
----- PREVIEW -----
M.o.preview_window.width = M.get_preview_width()
----- WINDOW -----
M.o.outline_window.width = M.get_window_width()
end
---Ensure l is either table, false, or nil. If not, print warning using given