mirror of
https://github.com/folke/snacks.nvim
synced 2025-08-04 02:38:46 +00:00
feat(config): get config for snack with defaults and custom opts
This commit is contained in:
parent
7ceeb47e54
commit
b3d08beb8c
3 changed files with 5 additions and 5 deletions
|
@ -107,7 +107,7 @@ function M.new(opts)
|
|||
local self = setmetatable({}, { __index = M })
|
||||
id = id + 1
|
||||
self.id = id
|
||||
opts = vim.tbl_deep_extend("force", {}, Snacks.config.get("float", defaults), opts or {})
|
||||
opts = Snacks.config.get("float", defaults, opts)
|
||||
opts =
|
||||
vim.tbl_deep_extend("force", {}, vim.deepcopy(opts.position == "float" and defaults_float or defaults_split), opts)
|
||||
if opts.win.style == "minimal" then
|
||||
|
|
|
@ -43,10 +43,10 @@ M.config = setmetatable({}, {
|
|||
---@generic T: table
|
||||
---@param snack string
|
||||
---@param defaults T
|
||||
---@param opts? T
|
||||
---@return T
|
||||
function M.config.get(snack, defaults)
|
||||
config[snack] = vim.tbl_deep_extend("force", {}, defaults, config[snack] or {})
|
||||
return config[snack]
|
||||
function M.config.get(snack, defaults, opts)
|
||||
return vim.tbl_deep_extend("force", {}, vim.deepcopy(defaults), vim.deepcopy(config[snack] or {}), opts or {})
|
||||
end
|
||||
|
||||
---@param opts snacks.Opts?
|
||||
|
|
|
@ -54,7 +54,7 @@ local terminals = {}
|
|||
---@param opts? snacks.terminal.Config
|
||||
function M.open(cmd, opts)
|
||||
---@type snacks.terminal.Config
|
||||
opts = vim.tbl_deep_extend("force", {}, Snacks.config.get("terminal", defaults), opts or {})
|
||||
opts = Snacks.config.get("terminal", defaults, opts)
|
||||
opts.float.position = opts.float.position or (cmd and "float" or "bottom")
|
||||
opts.float.wo.winbar = opts.float.wo.winbar
|
||||
or (opts.float.position == "float" and "" or (vim.v.count1 .. ": %{b:term_title}"))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue