mirror of
https://github.com/LazyVim/LazyVim.git
synced 2026-03-10 09:27:25 +00:00
fix(options): set_default option
This commit is contained in:
@@ -310,21 +310,21 @@ local _defaults = {} ---@type table<string, boolean>
|
||||
--
|
||||
-- It will only set the option if:
|
||||
-- * it is the same as the global value
|
||||
-- * it is the same as a previously set default value
|
||||
-- * it's current value is a default value
|
||||
-- * it was last set by a script in $VIMRUNTIME
|
||||
---@param option string
|
||||
---@param value string|number|boolean
|
||||
---@return boolean was_set
|
||||
function M.set_default(option, value)
|
||||
local key = ("%s=%s"):format(option, value)
|
||||
_defaults[key] = true
|
||||
|
||||
if not _defaults[key] then
|
||||
local l = vim.api.nvim_get_option_value(option, { scope = "local" })
|
||||
local g = vim.api.nvim_get_option_value(option, { scope = "global" })
|
||||
|
||||
if l ~= g then
|
||||
-- Option changed, so check if it was set by an ft plugin
|
||||
_defaults[("%s=%s"):format(option, value)] = true
|
||||
local key = ("%s=%s"):format(option, l)
|
||||
|
||||
if l ~= g and not _defaults[key] then
|
||||
-- Option does not match global and is not a default value
|
||||
-- Check if it was set by a script in $VIMRUNTIME
|
||||
local info = vim.api.nvim_get_option_info2(option, { scope = "local" })
|
||||
---@param e vim.fn.getscriptinfo.ret
|
||||
local scriptinfo = vim.tbl_filter(function(e)
|
||||
@@ -341,7 +341,6 @@ function M.set_default(option, value)
|
||||
return false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if vim.g.lazyvim_debug_set_default then
|
||||
LazyVim.info(("Setting option `%s` to `%s`"):format(option, value), { title = "LazyVim", once = true })
|
||||
|
||||
Reference in New Issue
Block a user