From f08e8514ddbe73cb02644cbd7b4b98e3681a7f9d Mon Sep 17 00:00:00 2001 From: shadmansaleh Date: Sun, 2 May 2021 10:32:45 +0600 Subject: [PATCH 1/2] Clear old config before applying a new one Options are reseted to defaults and other sections are cleared --- lua/lualine/init.lua | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lua/lualine/init.lua b/lua/lualine/init.lua index aeca8b8..f6376f5 100644 --- a/lua/lualine/init.lua +++ b/lua/lualine/init.lua @@ -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() From 39102109b80b77ed43036401bbf39c9016c373a9 Mon Sep 17 00:00:00 2001 From: shadmansaleh Date: Sun, 2 May 2021 10:33:25 +0600 Subject: [PATCH 2/2] Don't apply `g:lualine` config if config given to setup function --- lua/lualine/init.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lua/lualine/init.lua b/lua/lualine/init.lua index f6376f5..1d76875 100644 --- a/lua/lualine/init.lua +++ b/lua/lualine/init.lua @@ -273,7 +273,9 @@ local function set_statusline() end local function setup(user_config) - apply_configuration(vim.g.lualine) + if not user_config then + apply_configuration(vim.g.lualine) + end apply_configuration(user_config) check_single_separator() setup_theme()