Clear old config before applying a new one

Options are reseted to defaults and other sections are cleared
This commit is contained in:
shadmansaleh 2021-05-02 10:32:45 +06:00
parent f2f014e379
commit f08e8514dd
1 changed files with 8 additions and 2 deletions

View File

@ -2,11 +2,17 @@
-- MIT license, see LICENSE for more details.
local utils_section = require('lualine.utils.section')
local highlight = require('lualine.highlight')
local config = require('lualine.defaults')
local config = vim.deepcopy(require('lualine.defaults'))
local function apply_configuration(config_table)
if not config_table then return end
local function parse_sections(section_group_name)
if section_group_name ~= 'options' then
config[section_group_name] = {} -- clear old config
else
-- reset options
config.options = vim.deepcopy(require'lualine.defaults'.options)
end
if not config_table[section_group_name] then return end
for section_name, section in pairs(config_table[section_group_name]) do
config[section_group_name][section_name] =
@ -26,7 +32,7 @@ local function apply_configuration(config_table)
parse_sections('sections')
parse_sections('inactive_sections')
parse_sections('tabline')
if config_table.extensions then config.extensions = config_table.extensions end
config.extensions = config_table.extensions or {}
end
local function check_single_separator()