fix(nvim): correct PIM layout to sideward-T left-column overlay
r now opens three stacked floating windows in a left column (the bar of the sideward T), leaving the document visible to the right (stem). Order top→bottom: alot 40%, calendar 30%, abook remainder. Column is min(90, 45% of screen) cols wide. All sizes are clamped to ≥1 to prevent nvim_open_win errors on small terminals. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>main
parent
96610b7ed0
commit
47b94056ac
|
|
@ -159,7 +159,7 @@ vim.keymap.set("i", "<CR>", function()
|
|||
return vim.fn["coc#pum#visible"]() == 1 and vim.fn["coc#pum#confirm"]() or "<CR>"
|
||||
end, { expr = true, silent = true })
|
||||
|
||||
-- ── PIM floating windows (calendar / alot / abook) ───────────────────────────
|
||||
-- ── PIM floating windows (sideward T: left column overlay) ───────────────────
|
||||
local function _pim_scratch(label, err)
|
||||
vim.cmd("enew")
|
||||
vim.bo.buftype = "nofile"
|
||||
|
|
@ -180,11 +180,13 @@ local function _pim_float(row, col, height, width, border)
|
|||
local buf = vim.api.nvim_create_buf(false, true)
|
||||
vim.api.nvim_open_win(buf, true, {
|
||||
relative = "editor",
|
||||
row = row, col = col,
|
||||
height = height, width = width,
|
||||
style = "minimal",
|
||||
border = border or "none",
|
||||
zindex = 50,
|
||||
row = row,
|
||||
col = col,
|
||||
height = math.max(1, height),
|
||||
width = math.max(1, width),
|
||||
style = "minimal",
|
||||
border = border or "none",
|
||||
zindex = 50,
|
||||
})
|
||||
return vim.api.nvim_get_current_win()
|
||||
end
|
||||
|
|
@ -199,21 +201,25 @@ local function toggle_solo(key, cmd, label)
|
|||
_solo[key] = nil
|
||||
return
|
||||
end
|
||||
local h = math.floor(vim.o.lines * 0.85)
|
||||
local w = math.floor(vim.o.columns * 0.85)
|
||||
local r = math.floor((vim.o.lines - h - 2) / 2)
|
||||
local c = math.floor((vim.o.columns - w - 2) / 2)
|
||||
local H = vim.o.lines - 2
|
||||
local W = vim.o.columns
|
||||
local h = math.max(1, math.floor(H * 0.85))
|
||||
local w = math.max(1, math.floor(W * 0.85))
|
||||
-- centre accounting for the 1-cell rounded border on each side
|
||||
local r = math.max(0, math.floor((H - h - 2) / 2))
|
||||
local c = math.max(0, math.floor((W - w - 2) / 2))
|
||||
local win_id = _pim_float(r, c, h, w, "rounded")
|
||||
local ok, err = pcall(vim.cmd, cmd)
|
||||
if not ok then _pim_scratch(label, err) end
|
||||
_solo[key] = win_id
|
||||
end
|
||||
|
||||
vim.keymap.set("n", "n", function() toggle_solo("n", "terminal alot", "alot") end, { silent = true })
|
||||
vim.keymap.set("n", "n", function() toggle_solo("n", "terminal alot", "alot") end, { silent = true })
|
||||
vim.keymap.set("n", "g", function() toggle_solo("g", "Calendar", "calendar.vim") end, { silent = true })
|
||||
vim.keymap.set("n", "f", function() toggle_solo("f", "terminal abook", "abook") end, { silent = true })
|
||||
|
||||
-- r: full-screen tiled overlay (mail top, calendar bottom-left, abook bottom-right)
|
||||
-- r: sideward-T overlay — left column (bar of the T) with three stacked panes,
|
||||
-- document remains visible to the right (the stem of the T)
|
||||
local _pim_wins = {}
|
||||
|
||||
local function toggle_pim()
|
||||
|
|
@ -223,21 +229,23 @@ local function toggle_pim()
|
|||
return
|
||||
end
|
||||
|
||||
local H = vim.o.lines - 2
|
||||
local W = vim.o.columns
|
||||
local mail_h = math.floor(H * 0.6)
|
||||
local bot_h = H - mail_h
|
||||
local cal_w = math.floor(W * 0.5)
|
||||
local H = vim.o.lines - 2
|
||||
local col_w = math.min(vim.o.columns, math.max(90, math.floor(vim.o.columns * 0.45)))
|
||||
|
||||
local w1 = _pim_float(0, 0, mail_h, W)
|
||||
-- divide column height: mail 40%, calendar 30%, abook remainder (≥ 10)
|
||||
local mail_h = math.max(1, math.floor(H * 0.40))
|
||||
local cal_h = math.max(1, math.floor(H * 0.30))
|
||||
local ab_h = math.max(1, H - mail_h - cal_h)
|
||||
|
||||
local w1 = _pim_float(0, 0, mail_h, col_w)
|
||||
local ok, err = pcall(vim.cmd, "terminal alot")
|
||||
if not ok then _pim_scratch("alot", err) end
|
||||
|
||||
local w2 = _pim_float(mail_h, 0, bot_h, cal_w)
|
||||
local w2 = _pim_float(mail_h, 0, cal_h, col_w)
|
||||
ok, err = pcall(vim.cmd, "Calendar")
|
||||
if not ok then _pim_scratch("calendar.vim", err) end
|
||||
|
||||
local w3 = _pim_float(mail_h, cal_w, bot_h, W - cal_w)
|
||||
local w3 = _pim_float(mail_h + cal_h, 0, ab_h, col_w)
|
||||
ok, err = pcall(vim.cmd, "terminal abook")
|
||||
if not ok then _pim_scratch("abook", err) end
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue