maxmx03.solarized.nvim/lua/solarized/init.lua
Max Del Canto f0763424b3 refactor: Update Solarized Theme
The Solarized theme has been completely reworked to ensure it is a faithful and accurate port of the original work. All inconsistencies and issues have been resolved.

Added the option to enable or disable highlight groups, solarized now have docs and commands.

BREAKING CHANGE: The highlight and colors callbacks now accept only two parameters, colors and colorhelper table.
2023-06-29 10:28:46 -03:00

57 lines
2.1 KiB
Lua

local solarized_config = require('solarized.config')
local solarized_palette = require('solarized.palette')
local solarized_highlights = require('solarized.highlights')
local M = {}
M.is_configured = false
M.has_set_highlights = false
M.config = {}
--- Solarized setup
---
--- @param user_config? table The user-provided configuration to be merged.
--- - transparent (boolean): Specifies if transparency is enabled.
--- - styles (table): A table specifying various style options.
--- - comments (table): Specifies if comments should be styled.
--- - functions (table): Specifies if functions should be styled.
--- - variables (table): Specifies if variables should be styled.
--- - numbers (table): Specifies if numbers should be styled.
--- - constants (table): Specifies if constants should be styled.
--- - parameters (table): Specifies if parameters should be styled.
--- - conditionals (table): Specifies if conditionals should be styled.
--- - highlights (table): A table specifying custom highlight values.
--- - colors (table): A table specifying custom color values.
--- - enables (table): A table specifying plugins to be anabled or disabled
--- - theme (string): Specifies the theme to be used.
function M.setup(user_config)
if vim.g.colors_name then
vim.cmd('hi clear')
end
if vim.fn.exists('syntax_on') then
vim.cmd('syntax reset')
end
vim.o.termguicolors = true
vim.g.colors_name = 'solarized'
if not M.is_configured then
local default_config = solarized_config()
M.config = vim.tbl_deep_extend('force', default_config, user_config or {})
M.is_configured = true
end
local colors = solarized_palette.get_colors()
if type(M.config.colors) == 'table' and not vim.tbl_isempty(M.config.colors) then
colors = solarized_palette.extend_colors(colors, M.config.colors)
elseif type(M.config.colors) == 'function' then
local colorhelper = require('solarized.utils.colors')
colors = solarized_palette.extend_colors(colors, M.config.colors(colors, colorhelper))
end
solarized_highlights(colors, M.config)
end
return M