fix(moonfly): override part of highlights instead of replacing them
This commit is contained in:
+14
-5
@@ -1,18 +1,27 @@
|
||||
-- https://github.com/bluz71/vim-moonfly-colors
|
||||
|
||||
local utils = require("utils")
|
||||
|
||||
local function override_hl(hl_name, opts)
|
||||
local hl = vim.api.nvim_get_hl(0, { name = hl_name, })
|
||||
utils.update_table(hl, opts)
|
||||
vim.api.nvim_set_hl(0, hl_name, hl)
|
||||
end
|
||||
|
||||
local function setup()
|
||||
vim.g.moonflyNormalFloat = true
|
||||
vim.g.moonflyCursorColor = true
|
||||
vim.g.moonflyWinSeparator = 2
|
||||
|
||||
local custom_highlight = vim.api.nvim_create_augroup("CustomMoonflyHighlight", {})
|
||||
local custom_highlight = vim.api.nvim_create_augroup(
|
||||
"CustomMoonflyHighlight", {})
|
||||
vim.api.nvim_create_autocmd("ColorScheme", {
|
||||
pattern = "moonfly",
|
||||
callback = function ()
|
||||
vim.api.nvim_set_hl(0, "DiffAdd", { bg = "#364143" })
|
||||
vim.api.nvim_set_hl(0, "DiffText", { bg = "#3e4b6b" })
|
||||
vim.api.nvim_set_hl(0, "DiffChange", { bg = "#25293c" })
|
||||
vim.api.nvim_set_hl(0, "DiffDelete", { bg = "#443244" })
|
||||
override_hl("DiffAdd", { bg = "#364143", })
|
||||
override_hl("DiffText", { bg = "#3e4b6b", })
|
||||
override_hl("DiffChange", { bg = "#25293c", })
|
||||
override_hl("DiffDelete", { bg = "#443244", })
|
||||
end,
|
||||
group = custom_highlight,
|
||||
})
|
||||
|
||||
@@ -98,4 +98,17 @@ function M.try_require(module, err_title, on_success)
|
||||
M.err(resp, err_title)
|
||||
end
|
||||
|
||||
--- Update table t1 with values in t2.
|
||||
--- @param table table: The table to update
|
||||
--- @param values table: The table with new values
|
||||
function M.update_table(table, values)
|
||||
for k, v in pairs(values) do
|
||||
if type(v) == "table" and type(table[k] or false) == "table" then
|
||||
M.update_table(table[k], values[k])
|
||||
else
|
||||
table[k] = v
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return M
|
||||
|
||||
Reference in New Issue
Block a user