fix: Reloading config causing extesions to disaprear

This commit is contained in:
shadmansaleh 2021-08-13 07:25:17 +06:00
parent fcb88aebba
commit 967ddcb5ca
1 changed files with 6 additions and 5 deletions

View File

@ -47,7 +47,7 @@ end
local function load_extensions(config) local function load_extensions(config)
for index, extension in pairs(config.extensions) do for index, extension in pairs(config.extensions) do
if type(extension) == 'string' then if type(extension) == 'string' then
local local_extension = require('lualine.extensions.' .. extension) local local_extension = vim.deepcopy(require('lualine.extensions.' .. extension))
load_sections(local_extension.sections, config.options) load_sections(local_extension.sections, config.options)
if local_extension.inactive_sections then if local_extension.inactive_sections then
load_sections(local_extension.inactive_sections, config.options) load_sections(local_extension.inactive_sections, config.options)
@ -57,14 +57,15 @@ local function load_extensions(config)
end end
config.extensions[index] = local_extension config.extensions[index] = local_extension
elseif type(extension) == 'table' then elseif type(extension) == 'table' then
load_sections(extension.sections, config.options) local local_extension = vim.deepcopy(extension)
if extension.inactive_sections then load_sections(local_extension.sections, config.options)
load_sections(extension.inactive_sections, config.options) if local_extension.inactive_sections then
load_sections(local_extension.inactive_sections, config.options)
end end
if type(local_extension.init) == 'function' then if type(local_extension.init) == 'function' then
local_extension.init() local_extension.init()
end end
config.extensions[index] = extension config.extensions[index] = local_extension
end end
end end
end end