2021-05-09 21:11:18 +00:00
|
|
|
-- Copyright (c) 2020-2021 hoob3rt
|
|
|
|
-- MIT license, see LICENSE for more details.
|
|
|
|
local config = {
|
|
|
|
options = {
|
|
|
|
icons_enabled = true,
|
2021-08-14 06:02:30 +00:00
|
|
|
theme = 'auto',
|
2021-09-14 15:14:23 +00:00
|
|
|
component_separators = { left = '', right = '' },
|
|
|
|
section_separators = { left = '', right = '' },
|
2021-09-03 18:28:20 +00:00
|
|
|
disabled_filetypes = {},
|
2021-10-07 22:18:14 +00:00
|
|
|
always_divide_middle = true,
|
2021-05-09 21:11:18 +00:00
|
|
|
},
|
|
|
|
sections = {
|
2021-09-03 18:28:20 +00:00
|
|
|
lualine_a = { 'mode' },
|
|
|
|
lualine_b = { 'branch', 'diff', { 'diagnostics', sources = { 'nvim_lsp', 'coc' } } },
|
|
|
|
lualine_c = { 'filename' },
|
|
|
|
lualine_x = { 'encoding', 'fileformat', 'filetype' },
|
|
|
|
lualine_y = { 'progress' },
|
|
|
|
lualine_z = { 'location' },
|
2021-05-09 21:11:18 +00:00
|
|
|
},
|
|
|
|
inactive_sections = {
|
|
|
|
lualine_a = {},
|
|
|
|
lualine_b = {},
|
2021-09-03 18:28:20 +00:00
|
|
|
lualine_c = { 'filename' },
|
|
|
|
lualine_x = { 'location' },
|
2021-05-09 21:11:18 +00:00
|
|
|
lualine_y = {},
|
2021-09-03 18:28:20 +00:00
|
|
|
lualine_z = {},
|
2021-05-09 21:11:18 +00:00
|
|
|
},
|
|
|
|
tabline = {},
|
2021-09-03 18:28:20 +00:00
|
|
|
extensions = {},
|
2021-05-09 21:11:18 +00:00
|
|
|
}
|
|
|
|
|
2021-09-27 08:44:44 +00:00
|
|
|
local function check_sep_format_deprecation(sep)
|
2021-09-14 15:14:23 +00:00
|
|
|
if type(sep) == 'table' and vim.tbl_islist(sep) then
|
|
|
|
require('lualine.utils.notices').add_persistent_notice(string.format [[
|
|
|
|
### option.separator
|
2021-09-27 08:44:44 +00:00
|
|
|
Using list for configuring separators has been deprecated. Please configure it
|
2021-09-14 15:14:23 +00:00
|
|
|
with {left = left_sep, right = right_sep} like table.
|
|
|
|
]])
|
|
|
|
sep = { left = sep[1], right = sep[2] or sep[1] }
|
|
|
|
end
|
|
|
|
return sep
|
|
|
|
end
|
|
|
|
|
|
|
|
-- change separator format 'x' to {left='x', right='x'}
|
2021-05-09 21:11:18 +00:00
|
|
|
local function fix_separators(separators)
|
|
|
|
if separators ~= nil then
|
|
|
|
if type(separators) == 'string' then
|
2021-09-14 15:14:23 +00:00
|
|
|
return { left = separators, right = separators }
|
|
|
|
else
|
2021-09-27 08:44:44 +00:00
|
|
|
return check_sep_format_deprecation(separators)
|
2021-05-09 21:11:18 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
return separators
|
|
|
|
end
|
|
|
|
|
|
|
|
local function apply_configuration(config_table)
|
2021-09-03 18:28:20 +00:00
|
|
|
if not config_table then
|
|
|
|
return vim.deepcopy(config)
|
|
|
|
end
|
2021-05-09 21:11:18 +00:00
|
|
|
local function parse_sections(section_group_name)
|
2021-09-03 18:28:20 +00:00
|
|
|
if not config_table[section_group_name] then
|
|
|
|
return
|
|
|
|
end
|
2021-05-09 21:11:18 +00:00
|
|
|
for section_name, section in pairs(config_table[section_group_name]) do
|
2021-08-08 17:50:44 +00:00
|
|
|
config[section_group_name][section_name] = vim.deepcopy(section)
|
2021-05-09 21:11:18 +00:00
|
|
|
end
|
|
|
|
end
|
2021-09-03 18:28:20 +00:00
|
|
|
parse_sections 'options'
|
|
|
|
parse_sections 'sections'
|
|
|
|
parse_sections 'inactive_sections'
|
|
|
|
parse_sections 'tabline'
|
2021-08-08 17:44:03 +00:00
|
|
|
if config_table.extensions then
|
|
|
|
config.extensions = vim.deepcopy(config_table.extensions)
|
|
|
|
end
|
2021-09-03 18:28:20 +00:00
|
|
|
config.options.section_separators = fix_separators(config.options.section_separators)
|
|
|
|
config.options.component_separators = fix_separators(config.options.component_separators)
|
2021-08-02 06:40:11 +00:00
|
|
|
return vim.deepcopy(config)
|
2021-05-09 21:11:18 +00:00
|
|
|
end
|
|
|
|
|
2021-08-04 02:28:53 +00:00
|
|
|
local function get_current_config()
|
2021-08-04 01:13:37 +00:00
|
|
|
return vim.deepcopy(config)
|
|
|
|
end
|
|
|
|
|
|
|
|
return {
|
2021-08-04 02:28:53 +00:00
|
|
|
get_config = get_current_config,
|
2021-09-03 18:28:20 +00:00
|
|
|
apply_configuration = apply_configuration,
|
2021-08-04 01:13:37 +00:00
|
|
|
}
|