Skip to content

Commit

Permalink
fix(config): rebase on default config after changes from cli (#53)
Browse files Browse the repository at this point in the history
  • Loading branch information
ramojus committed Aug 10, 2024
1 parent 96058d5 commit c0b966d
Showing 1 changed file with 69 additions and 64 deletions.
133 changes: 69 additions & 64 deletions lua/mellifluous/config.lua
Original file line number Diff line number Diff line change
@@ -1,64 +1,68 @@
local M = {}

local config = {
colorset = "mellifluous",
plugins = {
cmp = true,
indent_blankline = true,
nvim_tree = {
enabled = true,
show_root = false,
local config = {}
local saved_user_config = {}

local function get_default_config()
return {
colorset = "mellifluous",
plugins = {
cmp = true,
indent_blankline = true,
nvim_tree = {
enabled = true,
show_root = false,
},
neo_tree = {
enabled = true,
},
telescope = {
enabled = true,
nvchad_like = true,
},
startify = true,
gitsigns = true,
neorg = true,
nvim_notify = true,
aerial = true,
neotest = true,
lazy = true,
mason = true,
},
neo_tree = {
enabled = true,
dim_inactive = false,
styles = {
comments = { italic = true },
conditionals = {},
folds = {},
loops = {},
functions = {},
keywords = {},
strings = {},
variables = {},
numbers = {},
booleans = {},
properties = {},
types = {},
operators = {},
markup = {
headings = { bold = true },
},
},
telescope = {
enabled = true,
nvchad_like = true,
transparent_background = {
enabled = false,
floating_windows = true,
telescope = true,
file_tree = true,
cursor_line = true,
status_line = false,
},
startify = true,
gitsigns = true,
neorg = true,
nvim_notify = true,
aerial = true,
neotest = true,
lazy = true,
mason = true,
},
dim_inactive = false,
styles = {
comments = { italic = true },
conditionals = {},
folds = {},
loops = {},
functions = {},
keywords = {},
strings = {},
variables = {},
numbers = {},
booleans = {},
properties = {},
types = {},
operators = {},
markup = {
headings = { bold = true },
flat_background = {
line_numbers = false,
floating_windows = false,
file_tree = false,
cursor_line_number = false,
},
},
transparent_background = {
enabled = false,
floating_windows = true,
telescope = true,
file_tree = true,
cursor_line = true,
status_line = false,
},
flat_background = {
line_numbers = false,
floating_windows = false,
file_tree = false,
cursor_line_number = false,
},
}
}
end

local function disable_disabled()
for _, v in pairs(config) do
Expand All @@ -76,27 +80,25 @@ end

local are_colorset_defaults_merged = false

local function merge_colorset_defaults()
local function merge_colorset_defaults(colorset)
if are_colorset_defaults_merged then
return
end
are_colorset_defaults_merged = true

local colorset = require("mellifluous.colors.colorsets." .. config.colorset)
local colorset_module = require("mellifluous.colors.colorsets." .. colorset)

if not colorset.get_config then
if not colorset_module.get_config then
return
end

config[config.colorset] = vim.tbl_deep_extend("force", config[config.colorset] or {}, colorset.get_config())
config[colorset] = vim.tbl_deep_extend("force", config[colorset] or {}, colorset_module.get_config())
end

local function process_colorset()
config.is_bg_dark = require("mellifluous.colors").get_is_bg_dark(config.colorset)
config.ui_color_base_lightness =
require("mellifluous.colors").get_ui_color_base_lightness(config.colorset, config.is_bg_dark)

merge_colorset_defaults()
end

-- https://www.lua.org/pil/13.4.5.html
Expand All @@ -113,11 +115,14 @@ local function read_only(table)
end

function M.setup(user_config)
merge_colorset_defaults()
config = vim.tbl_deep_extend("force", config, user_config or {})
saved_user_config = vim.tbl_deep_extend("force", saved_user_config, user_config)
end

function M.prepare()
config = get_default_config()
merge_colorset_defaults(vim.tbl_get(saved_user_config, "colorset") or config.colorset)
config = vim.tbl_deep_extend("force", config, saved_user_config or {})

process_colorset()
disable_disabled()

Expand Down

0 comments on commit c0b966d

Please sign in to comment.