mirror of
https://github.com/LazyVim/LazyVim.git
synced 2026-07-25 14:01:06 +00:00
fix(util): attempt to concatenate a boolean
If you passed a table of values { false, true } for example, then the
code would attempt to concatenate the raw boolean in Util.info()
Additionally, honor the silent option when explicit values are passed,
and allow passing a single value and don't do anything if already set.
This commit is contained in:
parent
abaa6d90e4
commit
7ae136d07e
1 changed files with 15 additions and 9 deletions
|
|
@ -166,22 +166,28 @@ function M.float_term(cmd, opts)
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param silent boolean?
|
---@param silent boolean?
|
||||||
---@param values? {[1]:any, [2]:any}
|
---@param values? {[1]:any, [2]?:any}
|
||||||
function M.toggle(option, silent, values)
|
function M.toggle(option, silent, values)
|
||||||
if values then
|
if values then
|
||||||
if vim.opt_local[option]:get() == values[1] then
|
if vim.opt_local[option]:get() == values[1] then
|
||||||
|
if values[2] == values[1] or values[2] == nil then
|
||||||
|
return -- Nothing to do
|
||||||
|
end
|
||||||
vim.opt_local[option] = values[2]
|
vim.opt_local[option] = values[2]
|
||||||
else
|
else
|
||||||
vim.opt_local[option] = values[1]
|
vim.opt_local[option] = values[1]
|
||||||
end
|
end
|
||||||
return Util.info("Set " .. option .. " to " .. vim.opt_local[option]:get(), { title = "Option" })
|
if not silent then
|
||||||
end
|
Util.info("Set " .. option .. " to " .. tostring(vim.opt_local[option]:get()), { title = "Option" })
|
||||||
vim.opt_local[option] = not vim.opt_local[option]:get()
|
end
|
||||||
if not silent then
|
else
|
||||||
if vim.opt_local[option]:get() then
|
vim.opt_local[option] = not vim.opt_local[option]:get()
|
||||||
Util.info("Enabled " .. option, { title = "Option" })
|
if not silent then
|
||||||
else
|
if vim.opt_local[option]:get() then
|
||||||
Util.warn("Disabled " .. option, { title = "Option" })
|
Util.info("Enabled " .. option, { title = "Option" })
|
||||||
|
else
|
||||||
|
Util.warn("Disabled " .. option, { title = "Option" })
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue