mirror of
https://github.com/ViViDboarder/vim-settings.git
synced 2024-12-23 04:27:36 +00:00
Improve color setting in nvim
This commit is contained in:
parent
6b8a4d39db
commit
eca001d4d7
@ -2,12 +2,15 @@
|
|||||||
function _G.update_colors()
|
function _G.update_colors()
|
||||||
local function maybe_set(scope, name, val, force)
|
local function maybe_set(scope, name, val, force)
|
||||||
force = force or false
|
force = force or false
|
||||||
if vim[scope][name] ~= val then
|
local changed = vim[scope][name] ~= val
|
||||||
|
if changed or force then
|
||||||
|
if scope == "g" and name == "colors_name" then
|
||||||
|
-- Colorscheme is different. Use this instead of setting colors_name directly
|
||||||
|
vim.cmd("colorscheme "..val)
|
||||||
|
else
|
||||||
vim[scope][name] = val
|
vim[scope][name] = val
|
||||||
return true
|
|
||||||
end
|
end
|
||||||
if force then
|
return changed
|
||||||
vim[scope][name] = val
|
|
||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
@ -31,12 +34,12 @@ function _G.update_colors()
|
|||||||
env_color = utils.env_default("VIM_COLOR_DARK", env_color)
|
env_color = utils.env_default("VIM_COLOR_DARK", env_color)
|
||||||
env_color = utils.env_default("NVIM_COLOR_DARK", env_color)
|
env_color = utils.env_default("NVIM_COLOR_DARK", env_color)
|
||||||
change = maybe_set("o", "background", "dark")
|
change = maybe_set("o", "background", "dark")
|
||||||
change = maybe_set("g", "colors_name", env_color, true) or change
|
change = maybe_set("g", "colors_name", env_color, false) or change
|
||||||
elseif mode == "light" then
|
elseif mode == "light" then
|
||||||
env_color = utils.env_default("VIM_COLOR_LIGHT", env_color)
|
env_color = utils.env_default("VIM_COLOR_LIGHT", env_color)
|
||||||
env_color = utils.env_default("NVIM_COLOR_LIGHT", env_color)
|
env_color = utils.env_default("NVIM_COLOR_LIGHT", env_color)
|
||||||
change = maybe_set("o", "background", "light")
|
change = maybe_set("o", "background", "light")
|
||||||
change = maybe_set("g", "colors_name", env_color, true) or change
|
change = maybe_set("g", "colors_name", env_color, false) or change
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Update status line theme
|
-- Update status line theme
|
||||||
|
Loading…
Reference in New Issue
Block a user