feat(win): custom views

This commit is contained in:
Folke Lemaitre 2024-11-04 22:08:56 +01:00
parent dbc1521ee1
commit 12d6f863f7
No known key found for this signature in database
GPG key ID: 41F8B1FBACAE2040
5 changed files with 50 additions and 17 deletions

View file

@ -56,7 +56,7 @@ local terminals = {}
function M.open(cmd, opts)
local id = vim.v.count1
---@type snacks.terminal.Config
opts = Snacks.config.get("terminal", defaults, opts)
opts = Snacks.config.get("terminal", defaults, { win = Snacks.win.resolve(opts and opts.win) }, opts)
opts.win.position = opts.win.position or (cmd and "float" or "bottom")
opts.win.wo.winbar = opts.win.wo.winbar or (opts.win.position == "float" and "" or (id .. ": %{b:term_title}"))
@ -109,8 +109,7 @@ end
---@param cmd? string | string[]
---@param opts? snacks.terminal.Config
function M.toggle(cmd, opts)
---@type snacks.terminal.Config
opts = vim.tbl_deep_extend("force", {}, defaults, opts or {})
opts = opts or {}
local id = vim.inspect({ cmd = cmd, cwd = opts.cwd, env = opts.env, count = vim.v.count1 })