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: allow term window_options to be a function #188

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions lua/alpha/term.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,18 @@ local alpha = require("alpha")
local M = {}

function M.open_window(el)
local width = el.width
local height = el.height
local window_config = el.opts and el.opts.window_config or {}
if type(window_config) == 'function' then
window_config = window_config()
end

local width = window_config.width or el.width
local height = window_config.height or el.height

local row = math.floor(height / 5)
local col = math.floor((vim.o.columns - width) / 2)

local opts = vim.tbl_extend("keep", (el.opts and el.opts.window_config) or {}, {
local opts = vim.tbl_extend("keep", window_config, {
relative = "editor",
row = row,
col = col,
Expand Down