partially revert f08e8514 (#209)

Deepcopying default config is not reverted . And now user config is always applied on top of default_config. Functionaly it should be same as before f98e8514
This commit is contained in:
Shadman 2021-05-04 05:03:26 +06:00 committed by GitHub
parent 4c3d76d9cf
commit 64ab49f55a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 10 deletions

View File

@ -2,17 +2,11 @@
-- MIT license, see LICENSE for more details. -- MIT license, see LICENSE for more details.
local utils_section = require('lualine.utils.section') local utils_section = require('lualine.utils.section')
local highlight = require('lualine.highlight') local highlight = require('lualine.highlight')
local config = vim.deepcopy(require('lualine.defaults')) local config = {}
local function apply_configuration(config_table) local function apply_configuration(config_table)
if not config_table then return end if not config_table then return end
local function parse_sections(section_group_name) 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 if not config_table[section_group_name] then return end
for section_name, section in pairs(config_table[section_group_name]) do for section_name, section in pairs(config_table[section_group_name]) do
config[section_group_name][section_name] = config[section_group_name][section_name] =
@ -32,7 +26,7 @@ local function apply_configuration(config_table)
parse_sections('sections') parse_sections('sections')
parse_sections('inactive_sections') parse_sections('inactive_sections')
parse_sections('tabline') parse_sections('tabline')
config.extensions = config_table.extensions or {} if config_table.extensions then config.extensions = config_table.extensions end
end end
local function check_single_separator() local function check_single_separator()
@ -285,8 +279,9 @@ local function set_statusline()
end end
local function setup(user_config) local function setup(user_config)
if not user_config then apply_configuration(vim.g.lualine) end config = vim.deepcopy(require'lualine.defaults')
apply_configuration(user_config) if user_config then apply_configuration(user_config)
elseif vim.g.lualine then apply_configuration(vim.g.lualine) end
check_single_separator() check_single_separator()
setup_theme() setup_theme()
load_components() load_components()