nvim: switch between light and dark theme

This commit is contained in:
nicolas 2023-12-08 08:51:28 +01:00
parent efcc4bf75c
commit ed067b2eb7
1 changed files with 22 additions and 92 deletions

View File

@ -1,93 +1,11 @@
local M = {}
local function init_solarized()
local function diagnostics_color(foreground_color)
return { fg = foreground_color, bg = '#073642', gui = 'bold' }
end
vim.o.bg = 'dark'
local new_theme = 'neosolarized'
vim.cmd.colorscheme(new_theme)
require 'neosolarized'.setup { background_set = true }
local function switch_to_theme(theme_name)
vim.cmd.colorscheme(theme_name)
require 'lualine'.setup {
options = {
theme = 'solarized'
},
sections = {
lualine_b = {
'branch',
},
lualine_c = {
{
'diagnostics',
diagnostics_color = {
error = diagnostics_color('#dc322f'),
warn = diagnostics_color('#b58900'),
info = diagnostics_color('#268bd2'),
hint = diagnostics_color('#2aa198'),
}
},
{
'diff',
diff_color = {
added = 'DiffAdd',
modified = 'DiffChange',
removed = 'DiffDelete',
},
},
{
'filename',
path = 1
}
}
}
}
local cb = require('colorbuddy.init')
local colors = cb.colors
local Group = cb.Group
local groups = cb.groups
local styles = cb.styles
local cHint = groups.Hint.fg
local cWarn = groups.Warning.fg
local cInfo = groups.Information.fg
local cError = groups.Error.fg
Group.new('NormalNC', colors.base0, colors.base03, styles.NONE)
Group.new('CursorLineNr', colors.magenta, colors.base03, styles.NONE, colors.base1)
Group.new("DiagnosticVirtualTextError", cError, cError:dark():dark():dark():dark(), styles.NONE)
Group.new("DiagnosticVirtualTextWarn", cWarn, cWarn:dark():dark():dark(), styles.NONE)
Group.new("DiagnosticVirtualTextInfo", cInfo, cInfo:dark():dark():dark(), styles.NONE)
Group.new("DiagnosticVirtualTextHint", cHint, cHint:dark():dark():dark(), styles.NONE)
Group.new("DiagnosticUnderlineError", colors.none, colors.none, styles.undercurl, cError)
Group.new("DiagnosticUnderlineWarn", colors.none, colors.none, styles.undercurl, cWarn)
Group.new("DiagnosticUnderlineInfo", colors.none, colors.none, styles.undercurl, cInfo)
Group.new("DiagnosticUnderlineHint", colors.none, colors.none, styles.undercurl, cHint)
-- vim.cmd [[highlight IndentBlanklineIndent1 guifg=#243940 gui=nocombine]]
-- color of whitespaces in the middle of lines
vim.cmd [[highlight WhiteSpace guifg=#243940 gui=nocombine]]
vim.opt.list = true
vim.opt.listchars:append "space:·,trail: "
local hooks = require "ibl.hooks"
hooks.register(hooks.type.HIGHLIGHT_SETUP, function()
vim.api.nvim_set_hl(0, "IndentGuideColor", { fg = "#243940" })
end)
require("ibl").setup {
indent = { highlight = "IndentGuideColor", char = "" },
whitespace = { highlight = "IndentGuideColor" }
}
end
local function init_dayfox()
local new_theme = 'dayfox'
vim.cmd.colorscheme(new_theme)
require 'lualine'.setup {
options = {
theme = 'dayfox'
theme = theme_name
},
sections = {
lualine_b = {
@ -103,22 +21,34 @@ local function init_dayfox()
}
}
}
local bg0 = require('nightfox.palette.dayfox').palette.bg0
vim.cmd(string.format("highlight IndentBlanklineIndent1 guifg=%s gui=nocombine", bg0))
end
local function init_catppuccin()
switch_to_theme('catppuccin-macchiato')
-- local bg0 = require('nightfox.palette.dayfox').palette.bg0
-- vim.cmd(string.format("highlight IndentBlanklineIndent1 guifg=%s gui=nocombine", bg0))
end
local function init_dayfox()
switch_to_theme('dayfox')
-- local bg0 = require('nightfox.palette.dayfox').palette.bg0
-- vim.cmd(string.format("highlight IndentBlanklineIndent1 guifg=%s gui=nocombine", bg0))
end
function M.toggle()
local current_theme = vim.g.colors_name
if current_theme == 'neosolarized' then
if current_theme == 'catppuccin-macchiato' then
init_dayfox()
else
init_solarized()
init_catppuccin()
init_catppuccin()
end
end
function M.setup()
vim.cmd.colorscheme("catppuccin-macchiato")
require 'lualine'.setup {}
local theme = "catppuccin-macchiato"
switch_to_theme(theme)
end
return M