Skip to content

Commit

Permalink
Merge pull request #13 from BlueDrink9/dark
Browse files Browse the repository at this point in the history
  • Loading branch information
shaunsingh authored Dec 2, 2022
2 parents 34c2245 + 9074d22 commit 36615f1
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 31 deletions.
37 changes: 32 additions & 5 deletions lua/solarized/colors.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
local bases = {
base03 = '#002b36',
base02 = '#073642',
base01 = '#586e75',
base00 = '#657b83',
base0 = '#839496',
base1 = '#93a1a1',
base2 = '#eee8d5',
base3 = '#fdf6e3',
}

local solarized = {

white = '#eee8d5',
Expand All @@ -9,14 +20,18 @@ local solarized = {
paleblue = '#586e75',
cyan = '#7d8d09',
blue = '#073642',
purple = '#b58900',
purple = '#b58900', -- why is this and purple swapped??
orange = '#cb4b16',
pink = '#073642',

bg = '#fdf6e3',
bg_alt = '#eee8d5',
fg = '#657b83',
text = '#586e75',
bg_light = bases['base3'],
bg_light_alt = bases['base2'],
bg_dark = bases['base03'],
bg_dark_alt = bases['base02'],
fg_light = bases['base0'],
text_light = bases['base1'],
fg_dark = bases['base00'],
text_dark = bases['base01'],
comments = '#657b83',
selection = '#d3cfc1',
contrast = '#002b36',
Expand All @@ -34,6 +49,18 @@ local solarized = {
none = 'NONE'
}

-- If dark mode, swap fg and bg
if vim.o.background == 'dark' then
solarized.bg = solarized.bg_dark
solarized.bg_alt = solarized.bg_dark_alt
solarized.fg = solarized.fg_dark
solarized.text = solarized.text_dark
else
solarized.bg = solarized.bg_light
solarized.bg_alt = solarized.bg_light_alt
solarized.fg = solarized.fg_light
solarized.text = solarized.text_light
end
-- Optional colors

-- Enable contrast sidebars, floating windows and popup menus
Expand Down
50 changes: 24 additions & 26 deletions lua/solarized/util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ function util.load()
-- Set the theme environment
vim.cmd("hi clear")
if vim.fn.exists("syntax_on") then vim.cmd("syntax reset") end
vim.o.background = "dark"
if not vim.o.background then
vim.o.background = "light"
end
vim.o.termguicolors = true
vim.g.colors_name = "solarized"

Expand All @@ -48,23 +50,13 @@ function util.load()
solarized.loadTerminal()

-- imort tables for plugins, treesitter and lsp
local plugins = solarized.loadPlugins()
local treesitter = solarized.loadTreeSitter()
local lsp = solarized.loadLSP()

-- loop trough the plugins table and highlight every member
for group, colors in pairs(plugins) do
util.highlight(group, colors)
end

-- loop trough the treesitter table and highlight every member
for group, colors in pairs(treesitter) do
util.highlight(group, colors)
end

-- loop trough the lsp table and highlight every member
for group, colors in pairs(lsp) do
util.highlight(group, colors)
tables = {
plugins = solarized.loadPlugins(),
treesitter = solarized.loadTreeSitter(),
lsp = solarized.loadLSP(),
}
for _, table in pairs(tables) do
util.highlight_table_members(table)
end

-- if contrast is enabled, apply it to sidebars and floating windows
Expand All @@ -79,18 +71,24 @@ function util.load()
local editor = solarized.loadEditor()
local syntax = solarized.loadSyntax()

-- load editor highlights
for group, colors in pairs(editor) do
util.highlight(group, colors)
end

-- load syntax highlights
for group, colors in pairs(syntax) do
util.highlight(group, colors)
-- imort tables for plugins, treesitter and lsp
tables = {
editor = solarized.loadEditor(),
syntax = solarized.loadSyntax(),
}
for _, table in pairs(tables) do
util.highlight_table_members(table)
end

-- load the rest later ( lsp, treesitter, plugins )
async:send()
end

function util.highlight_table_members(table)
-- loop trough the table and highlight every member
for group, colors in pairs(table) do
util.highlight(group, colors)
end
end

return util

0 comments on commit 36615f1

Please sign in to comment.