mirror of
https://github.com/maxmx03/solarized.nvim.git
synced 2026-09-10 07:26:26 -04:00
refactor: setup,highlights,commands
This commit is contained in:
parent
279107c61d
commit
f9dc2d64c7
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
lua/solarized/utils/test.lua
|
||||
103
README.md
103
README.md
|
|
@ -71,13 +71,13 @@ To manually install Solarized, follow these steps:
|
|||
`lua`, `plugin`.
|
||||
4. Copy these folders to the `~/.config/nvim` directory.
|
||||
|
||||
## Get some help
|
||||
## Help
|
||||
|
||||
Use `:h solarized.nvim.txt` to get some help
|
||||
|
||||
## Commands
|
||||
|
||||
`:SolarizedColors` - Display the Solarized palette in a new buffer
|
||||
`:Solarized colors` - Display the Solarized palette in a new buffer
|
||||
|
||||
## Default Config
|
||||
|
||||
|
|
@ -130,7 +130,7 @@ vim.cmd.colorscheme = 'solarized'
|
|||
|
||||
## Config Themes
|
||||
|
||||
Solarized offers two themes: the default Solarized theme and Neosolarized.
|
||||
Solarized offers two themes: the default Solarized theme and Neo.
|
||||
These themes provide different visual styles to enhance your experience.
|
||||
|
||||
```lua
|
||||
|
|
@ -253,6 +253,18 @@ require('lualine').setup {
|
|||
}
|
||||
```
|
||||
|
||||
Alternatively, to utilize Lualine's Solarized theme:
|
||||
|
||||
```lua
|
||||
require('lualine').setup {
|
||||
options = {
|
||||
theme = require('lualine.themes.solarized')
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
To use the Solarized theme showcased in the screenshot for Lualine [click here](https://github.com/maxmx03/solarized.nvim/discussions/50)
|
||||
|
||||
## Api
|
||||
|
||||
You can utilize useful functions to customize your Neovim plugins.
|
||||
|
|
@ -290,27 +302,65 @@ colorhelper.blend('#ffffff', '#000000', 0.15)
|
|||
|
||||
## Contributing
|
||||
|
||||
Thank you for your interest in contributing to this project!
|
||||
To ensure a smooth collaboration, please follow the guidelines below:
|
||||
Thank you for your interest in contributing to this project! To ensure a smooth
|
||||
collaboration, please follow the guidelines below:
|
||||
|
||||
1. Open a discussion to propose and discuss the changes you
|
||||
intend to make. This step allows for valuable input and
|
||||
feedback from the project maintainers and the community.
|
||||
2. Ensure you have the latest changes from the `dev` branch by pulling the
|
||||
latest updates.
|
||||
3. Make your changes on the `dev` branch. Avoid making direct changes to
|
||||
the `main` branch.
|
||||
4. Before submitting a pull request, run the `./test.py` script to ensure that
|
||||
your changes pass all the necessary tests. This step helps maintain the
|
||||
quality and stability of the project.
|
||||
5. When submitting a pull request, make sure to select the `dev`
|
||||
branch as the target branch. This ensures that your changes will be merged
|
||||
into the `dev` branch for further review and integration.
|
||||
6. Provide a clear and descriptive title and description for your pull request,
|
||||
explaining the purpose and scope of your changes.
|
||||
7. Wait for the maintainer to review your pull request.
|
||||
8. Once your changes have been reviewed and approved, the project maintainer
|
||||
will handle merging your changes into the `main` branch.
|
||||
1. **Branching**: Make your changes on the `dev` branch. Avoid making direct
|
||||
changes to the `main` branch.
|
||||
2. **Testing**: Before submitting a pull request, run the `./test.py` script
|
||||
to ensure that your changes pass all necessary tests. This step helps maintain
|
||||
the quality and stability of the project. Ensure that the following dependencies
|
||||
are installed for running tests:
|
||||
|
||||
```bash
|
||||
sudo apt install luarocks
|
||||
sudo luarocks install luacheck
|
||||
sudo luarocks install vusted
|
||||
cargo install stylua
|
||||
```
|
||||
|
||||
```bash
|
||||
./test.py
|
||||
```
|
||||
|
||||
```bash
|
||||
ok 1 - Color Conversions Convert hex to RGB
|
||||
ok 2 - Color Conversions Convert RGB to hex
|
||||
ok 3 - Color Conversions Convert RGB to HSL
|
||||
ok 4 - Color Conversions Convert HSL to RGB
|
||||
ok 5 - Color Conversions Darken the color by percentage
|
||||
ok 6 - Color Conversions Lighten the color by percentage
|
||||
ok 7 - Color Conversions Blend colors
|
||||
ok 8 - Configuration Default configuration
|
||||
ok 9 - Configuration Unique configuration table instances
|
||||
ok 10 - Configuration Extend default configuration
|
||||
ok 11 - Initialization Loads without encountering any errors
|
||||
ok 12 - Initialization Background is set to light
|
||||
ok 13 - Math Round to the nearest integer
|
||||
ok 14 - Math Return the value of the first parameter and the sign of the second parameter
|
||||
ok 15 - Palette Extend solarized color palette
|
||||
ok 16 - Palette Correct any invalid colors when extending the solarized palette
|
||||
ok 17 - Setup Customizing Highlight Groups
|
||||
ok 18 - Setup Changing Comment Style
|
||||
ok 19 - Setup Changing Function Style
|
||||
ok 20 - Setup Customizable Highlight Groups Without Losing Previous Configuration
|
||||
ok 21 - Setup Ability to Change the Default Theme
|
||||
|
||||
# Success: 21
|
||||
```
|
||||
|
||||
3. **Pull Request**: When submitting a pull request, select the `dev` branch
|
||||
as the target branch. This ensures that your changes will be merged into the
|
||||
`dev` branch for further review and integration.
|
||||
|
||||
4. **Provide Details**: Provide a clear and descriptive title and description
|
||||
for your pull request, explaining the purpose and scope of your changes.
|
||||
|
||||
5. **Review Process**: Wait for the maintainer to review your pull request.
|
||||
The maintainers will review your changes before merging.
|
||||
|
||||
6. **Final Approval**: Once your changes have been reviewed and approved, the
|
||||
project maintainer will handle merging your changes into the `main` branch.
|
||||
|
||||
## Designed by
|
||||
|
||||
|
|
@ -320,9 +370,8 @@ Ethan Schoonover
|
|||
|
||||
## Credits and Reference 🎉
|
||||
|
||||
[](https://github.com/glepnir)
|
||||
|
||||
Raphael
|
||||
|
||||
- [onedarkpro](https://github.com/olimorris/onedarkpro.nvim)
|
||||
- [solarized-vim](https://github.com/altercation/vim-colors-solarized)
|
||||
- [tokyonight](https://github.com/folke/tokyonight.nvim)
|
||||
|
||||
[](https://github.com/glepnir)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
lua << EOF
|
||||
local solarized = require('solarized')
|
||||
|
||||
solarized.setup()
|
||||
require('solarized.config').load()
|
||||
EOF
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
*solarized.nvim.txt* For NVIM v0.9.1 Last change: 2023 December 06
|
||||
*solarized.nvim.txt* For NVIM v0.9.1 Last change: 2023 December 09
|
||||
|
||||
==============================================================================
|
||||
Table of Contents *solarized.nvim-table-of-contents*
|
||||
|
|
@ -7,7 +7,7 @@ Table of Contents *solarized.nvim-table-of-contents*
|
|||
- Requirements |solarized.nvim-requirements|
|
||||
- Install from package manager |solarized.nvim-install-from-package-manager|
|
||||
- Manual Installation |solarized.nvim-manual-installation|
|
||||
- Get some help |solarized.nvim-get-some-help|
|
||||
- Help |solarized.nvim-help|
|
||||
- Commands |solarized.nvim-commands|
|
||||
- Default Config |solarized.nvim-default-config|
|
||||
- Config Themes |solarized.nvim-config-themes|
|
||||
|
|
@ -88,14 +88,14 @@ To manually install Solarized, follow these steps:
|
|||
4. Copy these folders to the `~/.config/nvim` directory.
|
||||
|
||||
|
||||
GET SOME HELP *solarized.nvim-get-some-help*
|
||||
HELP *solarized.nvim-help*
|
||||
|
||||
Use |solarized.nvim.txt| to get some help
|
||||
|
||||
|
||||
COMMANDS *solarized.nvim-commands*
|
||||
|
||||
`:SolarizedColors` - Display the Solarized palette in a new buffer
|
||||
`:Solarized colors` - Display the Solarized palette in a new buffer
|
||||
|
||||
|
||||
DEFAULT CONFIG *solarized.nvim-default-config*
|
||||
|
|
@ -150,8 +150,8 @@ DEFAULT CONFIG *solarized.nvim-default-config*
|
|||
|
||||
CONFIG THEMES *solarized.nvim-config-themes*
|
||||
|
||||
Solarized offers two themes: the default Solarized theme and Neosolarized.
|
||||
These themes provide different visual styles to enhance your experience.
|
||||
Solarized offers two themes: the default Solarized theme and Neo. These themes
|
||||
provide different visual styles to enhance your experience.
|
||||
|
||||
>lua
|
||||
require('solarized').setup({
|
||||
|
|
@ -277,6 +277,19 @@ LUALINE *solarized.nvim-lualine*
|
|||
}
|
||||
<
|
||||
|
||||
Alternatively, to utilize Lualine’s Solarized theme:
|
||||
|
||||
>lua
|
||||
require('lualine').setup {
|
||||
options = {
|
||||
theme = require('lualine.themes.solarized')
|
||||
}
|
||||
}
|
||||
<
|
||||
|
||||
To use the Solarized theme showcased in the screenshot for Lualine click here
|
||||
<https://github.com/maxmx03/solarized.nvim/discussions/50>
|
||||
|
||||
|
||||
API *solarized.nvim-api*
|
||||
|
||||
|
|
@ -321,24 +334,70 @@ CONTRIBUTING *solarized.nvim-contributing*
|
|||
Thank you for your interest in contributing to this project! To ensure a smooth
|
||||
collaboration, please follow the guidelines below:
|
||||
|
||||
1. Open a discussion to propose and discuss the changes you
|
||||
intend to make. This step allows for valuable input and
|
||||
feedback from the project maintainers and the community.
|
||||
2. Ensure you have the latest changes from the `dev` branch by pulling the
|
||||
latest updates.
|
||||
3. Make your changes on the `dev` branch. Avoid making direct changes to
|
||||
the `main` branch.
|
||||
4. Before submitting a pull request, run the `./test.py` script to ensure that
|
||||
your changes pass all the necessary tests. This step helps maintain the
|
||||
quality and stability of the project.
|
||||
5. When submitting a pull request, make sure to select the `dev`
|
||||
branch as the target branch. This ensures that your changes will be merged
|
||||
into the `dev` branch for further review and integration.
|
||||
6. Provide a clear and descriptive title and description for your pull request,
|
||||
explaining the purpose and scope of your changes.
|
||||
7. Wait for the maintainer to review your pull request.
|
||||
8. Once your changes have been reviewed and approved, the project maintainer
|
||||
will handle merging your changes into the `main` branch.
|
||||
1. **Branching**: Make your changes on the `dev` branch. Avoid making direct
|
||||
changes to the `main` branch.
|
||||
|
||||
|
||||
2. **Testing**: Before submitting a pull request, run the `./test.py` script to
|
||||
ensure that your changes pass all necessary tests. This step helps maintain the
|
||||
quality and stability of the project. Ensure that the following dependencies
|
||||
are installed for running tests:
|
||||
|
||||
>bash
|
||||
sudo apt install luarocks
|
||||
sudo luarocks install luacheck
|
||||
sudo luarocks install vusted
|
||||
cargo install stylua
|
||||
<
|
||||
|
||||
>bash
|
||||
./test.py
|
||||
<
|
||||
|
||||
>bash
|
||||
ok 1 - Color Conversions Convert hex to RGB
|
||||
ok 2 - Color Conversions Convert RGB to hex
|
||||
ok 3 - Color Conversions Convert RGB to HSL
|
||||
ok 4 - Color Conversions Convert HSL to RGB
|
||||
ok 5 - Color Conversions Darken the color by percentage
|
||||
ok 6 - Color Conversions Lighten the color by percentage
|
||||
ok 7 - Color Conversions Blend colors
|
||||
ok 8 - Configuration Default configuration
|
||||
ok 9 - Configuration Unique configuration table instances
|
||||
ok 10 - Configuration Extend default configuration
|
||||
ok 11 - Initialization Loads without encountering any errors
|
||||
ok 12 - Initialization Background is set to light
|
||||
ok 13 - Math Round to the nearest integer
|
||||
ok 14 - Math Return the value of the first parameter and the sign of the second parameter
|
||||
ok 15 - Palette Extend solarized color palette
|
||||
ok 16 - Palette Correct any invalid colors when extending the solarized palette
|
||||
ok 17 - Setup Customizing Highlight Groups
|
||||
ok 18 - Setup Changing Comment Style
|
||||
ok 19 - Setup Changing Function Style
|
||||
ok 20 - Setup Customizable Highlight Groups Without Losing Previous Configuration
|
||||
ok 21 - Setup Ability to Change the Default Theme
|
||||
|
||||
# Success: 21
|
||||
<
|
||||
|
||||
|
||||
3. **Pull Request**: When submitting a pull request, select the `dev` branch as
|
||||
the target branch. This ensures that your changes will be merged into the `dev`
|
||||
branch for further review and integration.
|
||||
|
||||
|
||||
4. **Provide Details**: Provide a clear and descriptive title and description for
|
||||
your pull request, explaining the purpose and scope of your changes.
|
||||
|
||||
|
||||
5. **Review Process**: Wait for the maintainer to review your pull request. The
|
||||
maintainers will review your changes before merging.
|
||||
|
||||
|
||||
6. **Final Approval**: Once your changes have been reviewed and approved, the
|
||||
project maintainer will handle merging your changes into the `main` branch.
|
||||
|
||||
|
||||
|
||||
|
||||
DESIGNED BY *solarized.nvim-designed-by*
|
||||
|
|
@ -350,12 +409,11 @@ Ethan Schoonover
|
|||
|
||||
CREDITS AND REFERENCE 🎉 *solarized.nvim-credits-and-reference-🎉*
|
||||
|
||||
<https://github.com/glepnir>
|
||||
|
||||
Raphael
|
||||
|
||||
- onedarkpro <https://github.com/olimorris/onedarkpro.nvim>
|
||||
- solarized-vim <https://github.com/altercation/vim-colors-solarized>
|
||||
- tokyonight <https://github.com/folke/tokyonight.nvim>
|
||||
|
||||
<https://github.com/glepnir>
|
||||
|
||||
==============================================================================
|
||||
1. Links *solarized.nvim-links*
|
||||
|
|
|
|||
63
lua/solarized/command.lua
Normal file
63
lua/solarized/command.lua
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
local command = {}
|
||||
|
||||
local subcommands = {
|
||||
colors = function(arg)
|
||||
local colors = require('solarized.palette').get_colors()
|
||||
local buf = vim.api.nvim_create_buf(true, true)
|
||||
local max_length = vim.tbl_count(colors)
|
||||
|
||||
local function color_desc(color)
|
||||
local colors_desc = {
|
||||
base04 = 'background tone (column/nvim-tree)',
|
||||
base03 = 'background tone (main)',
|
||||
base02 = 'background tone (highlight/menu/LineNr)',
|
||||
base01 = 'content tone (comment)',
|
||||
base00 = 'content tone (winseparator)',
|
||||
base0 = 'content tone (foreground)',
|
||||
base1 = 'content tone (statusline/tabline)',
|
||||
base2 = 'background tone (highlight)',
|
||||
base3 = 'background tone (main)',
|
||||
}
|
||||
local desc = colors_desc[color]
|
||||
|
||||
if not desc then
|
||||
return ''
|
||||
end
|
||||
|
||||
return desc
|
||||
end
|
||||
|
||||
local function set_lines(color, hex, line)
|
||||
vim.api.nvim_buf_set_lines(buf, line, (line + 1), false, {
|
||||
color .. string.rep('.', max_length - #color) .. ' = "' .. tostring(hex) .. '" ' .. color_desc(color),
|
||||
})
|
||||
return line + 1
|
||||
end
|
||||
|
||||
local line = 0
|
||||
for color, hex in pairs(colors) do
|
||||
if type(hex) == 'table' then
|
||||
for c, h in pairs(hex) do
|
||||
line = set_lines(c, h, line)
|
||||
end
|
||||
else
|
||||
line = set_lines(color, hex, line)
|
||||
end
|
||||
end
|
||||
|
||||
vim.api.nvim_set_option_value('modifiable', false, { buf = buf })
|
||||
vim.api.nvim_set_option_value('filetype', 'Solarized', { buf = buf })
|
||||
vim.api.nvim_buf_set_name(buf, 'Solarized Colors')
|
||||
vim.api.nvim_win_set_buf(0, buf)
|
||||
end,
|
||||
}
|
||||
|
||||
function command.list()
|
||||
return vim.tbl_keys(subcommands)
|
||||
end
|
||||
|
||||
function command.load(cmd, arg)
|
||||
subcommands[cmd](arg)
|
||||
end
|
||||
|
||||
return command
|
||||
|
|
@ -1,6 +1,16 @@
|
|||
local palette = require('solarized.palette')
|
||||
local solarized = require('solarized.highlights')
|
||||
local colorhelper = require('solarized.utils.colors')
|
||||
local utils = require('solarized.utils')
|
||||
|
||||
local M = {}
|
||||
|
||||
M.config = nil
|
||||
M.colors = nil
|
||||
|
||||
--- Define and return default config
|
||||
---@return table default_config
|
||||
local function default_config()
|
||||
function M.default_config()
|
||||
return {
|
||||
transparent = false,
|
||||
styles = {
|
||||
|
|
@ -42,4 +52,51 @@ local function default_config()
|
|||
}
|
||||
end
|
||||
|
||||
return default_config
|
||||
function M.load(background)
|
||||
background = background or 'dark'
|
||||
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'
|
||||
|
||||
local colors = palette.get_colors()
|
||||
solarized.highlights(M.colors or colors, M.config or M.default_config())
|
||||
end
|
||||
|
||||
--- Solarized setup
|
||||
---
|
||||
--- @param opts? 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 enabled or disabled
|
||||
--- - theme (string): Specifies the theme to be used.
|
||||
function M.setup(opts)
|
||||
M.config = vim.tbl_deep_extend('force', M.default_config(), opts or {})
|
||||
local colors = palette.get_colors()
|
||||
|
||||
utils.on_config({
|
||||
tbl = function()
|
||||
M.colors = palette.extend_colors(colors, M.config.colors)
|
||||
end,
|
||||
fnc = function()
|
||||
M.colors = palette.extend_colors(colors, M.config.colors(colors, colorhelper))
|
||||
end,
|
||||
}, M.config.colors)
|
||||
end
|
||||
|
||||
return M
|
||||
|
|
|
|||
|
|
@ -1,8 +1,12 @@
|
|||
local utils = require('solarized.utils')
|
||||
local colorhelper = require('solarized.utils.colors')
|
||||
|
||||
local M = {}
|
||||
|
||||
--- Update or override highlights defined by the user
|
||||
---
|
||||
--- @param highlights table A table containing highlight names as keys and their updated values as values
|
||||
local function custom_hl(highlights)
|
||||
local utils = require('solarized.utils')
|
||||
function M.custom_hl(highlights)
|
||||
local get_hl = utils.get_hl
|
||||
|
||||
for highlight_name, highlight_value in pairs(highlights) do
|
||||
|
|
@ -18,12 +22,12 @@ end
|
|||
---
|
||||
--- @param colors table A table containing color values
|
||||
--- @param config table A table containing configuration options, including the enabled highlights and theme
|
||||
local function load_highlights(colors, config)
|
||||
for highlight, enabled in pairs(config.enables) do
|
||||
function M.load_plugins(colors, config)
|
||||
for plugin, enabled in pairs(config.enables) do
|
||||
if enabled then
|
||||
local highlights = require(string.format('solarized.themes.%s.%s', config.theme, highlight))
|
||||
local highlight_groups = require(string.format('solarized.themes.%s.%s', config.theme, plugin))
|
||||
|
||||
highlights(colors, config)
|
||||
highlight_groups(colors, config)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -32,18 +36,22 @@ end
|
|||
---
|
||||
--- @param colors table A table containing color values
|
||||
--- @param config table A table containing configuration options
|
||||
return function(colors, config)
|
||||
function M.highlights(colors, config)
|
||||
if config.theme == 'neo' or config.theme == 'default' then
|
||||
load_highlights(colors, config)
|
||||
M.load_plugins(colors, config)
|
||||
else
|
||||
config.theme = 'default'
|
||||
load_highlights(colors, config)
|
||||
M.load_plugins(colors, config)
|
||||
end
|
||||
|
||||
if type(config.highlights) == 'table' and not vim.tbl_isempty(config.highlights) then
|
||||
custom_hl(config.highlights)
|
||||
elseif type(config.highlights) == 'function' then
|
||||
local colorhelper = require('solarized.utils.colors')
|
||||
custom_hl(config.highlights(colors, colorhelper))
|
||||
end
|
||||
utils.on_config({
|
||||
tbl = function()
|
||||
M.custom_hl(config.highlights)
|
||||
end,
|
||||
fnc = function()
|
||||
M.custom_hl(config.highlights(colors, colorhelper))
|
||||
end,
|
||||
}, config.highlights)
|
||||
end
|
||||
|
||||
return M
|
||||
|
|
|
|||
|
|
@ -1,56 +1,7 @@
|
|||
local solarized_config = require('solarized.config')
|
||||
local solarized_palette = require('solarized.palette')
|
||||
local solarized_highlights = require('solarized.highlights')
|
||||
local config = require('solarized.config')
|
||||
|
||||
local M = {}
|
||||
M.is_configured = false
|
||||
M.has_set_highlights = false
|
||||
M.config = {}
|
||||
|
||||
--- Solarized setup
|
||||
---
|
||||
--- @param opts? 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 enabled or disabled
|
||||
--- - theme (string): Specifies the theme to be used.
|
||||
function M.setup(opts)
|
||||
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, opts 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
|
||||
M.setup = config.setup
|
||||
|
||||
return M
|
||||
|
|
|
|||
|
|
@ -4,71 +4,68 @@ local M = {}
|
|||
---
|
||||
--- @return table colors A table containing the solarized colors
|
||||
function M.get_colors()
|
||||
local dark = {
|
||||
base04 = '#00222b', -- background tone darker (column/nvim-tree)
|
||||
base03 = '#002b36', -- background tone dark (main)
|
||||
base02 = '#073642', -- background tone (highlight/menu/LineNr)
|
||||
base01 = '#586e75', -- content tone (comment)
|
||||
base00 = '#657b83', -- content tone (winseparator)
|
||||
base0 = '#839496', -- content tone (foreground)
|
||||
base1 = '#93a1a1', -- content tone (statusline/tabline)
|
||||
base2 = '#eee8d5', -- background tone light (highlight)
|
||||
base3 = '#fdf6e3', -- background tone lighter (main)
|
||||
-- accent
|
||||
yellow = '#b58900',
|
||||
orange = '#cb4b16',
|
||||
red = '#dc322f',
|
||||
magenta = '#d33682',
|
||||
violet = '#6c71c4',
|
||||
blue = '#268bd2',
|
||||
cyan = '#2aa198',
|
||||
green = '#859900',
|
||||
-- git
|
||||
add = '#859900',
|
||||
change = '#b58900',
|
||||
delete = '#dc322f',
|
||||
-- diagnostic
|
||||
info = '#268bd2',
|
||||
hint = '#859900',
|
||||
warning = '#b58900',
|
||||
error = '#dc322f',
|
||||
local colors = {
|
||||
dark = {
|
||||
base04 = '#00222b', -- background tone darker (column/nvim-tree)
|
||||
base03 = '#002b36', -- background tone dark (main)
|
||||
base02 = '#073642', -- background tone (highlight/menu/LineNr)
|
||||
base01 = '#586e75', -- content tone (comment)
|
||||
base00 = '#657b83', -- content tone (winseparator)
|
||||
base0 = '#839496', -- content tone (foreground)
|
||||
base1 = '#93a1a1', -- content tone (statusline/tabline)
|
||||
base2 = '#eee8d5', -- background tone light (highlight)
|
||||
base3 = '#fdf6e3', -- background tone lighter (main)
|
||||
-- accent
|
||||
yellow = '#b58900',
|
||||
orange = '#cb4b16',
|
||||
red = '#dc322f',
|
||||
magenta = '#d33682',
|
||||
violet = '#6c71c4',
|
||||
blue = '#268bd2',
|
||||
cyan = '#2aa198',
|
||||
green = '#859900',
|
||||
-- git
|
||||
add = '#859900',
|
||||
change = '#b58900',
|
||||
delete = '#dc322f',
|
||||
-- diagnostic
|
||||
info = '#268bd2',
|
||||
hint = '#859900',
|
||||
warning = '#b58900',
|
||||
error = '#dc322f',
|
||||
},
|
||||
light = {
|
||||
base3 = '#002b36', -- background tone darker (main)
|
||||
base2 = '#073642', -- background tone dark (highlight)
|
||||
base1 = '#586e75', -- content tone (statusline/tabline)
|
||||
base0 = '#657b83', -- content tone (foreground)
|
||||
base00 = '#839496', -- content tone (winseparator)
|
||||
base01 = '#93a1a1', -- content tone (comment)
|
||||
base02 = '#eee8d5', -- background tone (highlight/menu/LineNr)
|
||||
base03 = '#fdf6e3', -- background tone lighter (main)
|
||||
base04 = '#fcf2d8', -- background tone (column/nvim-tree)
|
||||
-- accent
|
||||
yellow = '#b58900',
|
||||
orange = '#cb4b16',
|
||||
red = '#dc322f',
|
||||
magenta = '#d33682',
|
||||
violet = '#6c71c4',
|
||||
blue = '#268bd2',
|
||||
cyan = '#2aa198',
|
||||
green = '#859900',
|
||||
-- git
|
||||
add = '#859900',
|
||||
change = '#b58900',
|
||||
delete = '#dc322f',
|
||||
-- diagnostic
|
||||
info = '#268bd2',
|
||||
hint = '#859900',
|
||||
warning = '#b58900',
|
||||
error = '#dc322f',
|
||||
},
|
||||
}
|
||||
|
||||
local light = {
|
||||
base3 = '#002b36', -- background tone darker (main)
|
||||
base2 = '#073642', -- background tone dark (highlight)
|
||||
base1 = '#586e75', -- content tone (statusline/tabline)
|
||||
base0 = '#657b83', -- content tone (foreground)
|
||||
base00 = '#839496', -- content tone (winseparator)
|
||||
base01 = '#93a1a1', -- content tone (comment)
|
||||
base02 = '#eee8d5', -- background tone (highlight/menu/LineNr)
|
||||
base03 = '#fdf6e3', -- background tone lighter (main)
|
||||
base04 = '#fcf2d8', -- background tone (column/nvim-tree)
|
||||
-- accent
|
||||
yellow = '#b58900',
|
||||
orange = '#cb4b16',
|
||||
red = '#dc322f',
|
||||
magenta = '#d33682',
|
||||
violet = '#6c71c4',
|
||||
blue = '#268bd2',
|
||||
cyan = '#2aa198',
|
||||
green = '#859900',
|
||||
-- git
|
||||
add = '#859900',
|
||||
change = '#b58900',
|
||||
delete = '#dc322f',
|
||||
-- diagnostic
|
||||
info = '#268bd2',
|
||||
hint = '#859900',
|
||||
warning = '#b58900',
|
||||
error = '#dc322f',
|
||||
}
|
||||
|
||||
if vim.o.background == 'dark' then
|
||||
return dark
|
||||
end
|
||||
|
||||
return light
|
||||
return colors[vim.o.background]
|
||||
end
|
||||
|
||||
--- Filter colors by selecting valid hexadecimal color values.
|
||||
|
|
|
|||
|
|
@ -1,18 +1,13 @@
|
|||
return function(c, config)
|
||||
return function(c)
|
||||
local utils = require('solarized.utils')
|
||||
local set_hl = utils.set_hl
|
||||
|
||||
if vim.o.background == 'dark' then
|
||||
set_hl('IndentBlanklineChar', { fg = '#475252' }) -- Highlight of indent character. Default: Whitespace
|
||||
set_hl('IndentBlanklineSpaceChar', { link = 'IndentBlanklineChar' }) -- Highlight of space character. Default: Whitespace
|
||||
set_hl('IndentBlanklineContextChar', { fg = '#647373' }) -- Highlight of indent character when base of current context. Default: Label
|
||||
set_hl('IndentBlanklineContextSpaceChar', { link = 'IndentBlanklineContextChar' }) -- Highlight of space characters one indent level of the current context. Default: Label
|
||||
else
|
||||
set_hl('IndentBlanklineChar', { fg = '#cbd5d8' }) -- Highlight of indent character. Default: Whitespace
|
||||
set_hl('IndentBlanklineSpaceChar', { link = 'IndentBlanklineChar' }) -- Highlight of space character. Default: Whitespace
|
||||
set_hl('IndentBlanklineContextChar', { fg = '#a8b8bd' }) -- Highlight of indent character when base of current context. Default: Label
|
||||
set_hl('IndentBlanklineContextSpaceChar', { link = 'IndentBlanklineContextChar' }) -- Highlight of space characters one indent level of the current context. Default: Label
|
||||
end
|
||||
set_hl('IndentBlanklineChar', { fg = c.base01 }) -- Highlight of indent character. Default: Whitespace
|
||||
set_hl('IndentBlanklineSpaceChar', { link = 'IndentBlanklineChar' }) -- Highlight of space character. Default: Whitespace
|
||||
set_hl('IndentBlanklineContextChar', { fg = c.base0 }) -- Highlight of indent character when base of current context. Default: Label
|
||||
set_hl('IndentBlanklineContextSpaceChar', { link = 'IndentBlanklineContextChar' }) -- Highlight of space characters one indent level of the current context. Default: Label
|
||||
set_hl('IblIndent', { fg = c.base0, nocombine = true })
|
||||
set_hl('IblScope', { fg = c.base01, nocombine = true })
|
||||
|
||||
-- set_hl('IndentBlanklineSpaceCharBlankline', {}) -- Highlight of space character on blank lines. Default: Whitespace
|
||||
-- set_hl('IndentBlanklineContextStart', {}) -- Highlight of the first line of the current context. Default: Label
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
return function()
|
||||
return function(c)
|
||||
local utils = require('solarized.utils')
|
||||
local set_hl = utils.set_hl
|
||||
|
||||
|
|
@ -6,11 +6,7 @@ return function()
|
|||
set_hl('LspReferenceRead', { link = 'Visual' }) -- used for highlighting "read" references
|
||||
set_hl('LspReferenceWrite', { link = 'Visual' }) -- used for highlighting "write" references
|
||||
|
||||
if vim.o.background == 'dark' then
|
||||
set_hl('LspInlayHint', { fg = '#8f6b00' }) -- used for highlighting inlay hints
|
||||
else
|
||||
set_hl('LspInlayHint', { fg = '#ffc517' })
|
||||
end
|
||||
set_hl('LspInlayHint', { fg = c.yellow })
|
||||
|
||||
-- if you want to me to enable the highlight groups bellow, please send a screenshot for me to see how
|
||||
-- they look like or how to config for me to test.
|
||||
|
|
|
|||
|
|
@ -1,17 +1,24 @@
|
|||
return function(c, config)
|
||||
return function(c)
|
||||
local utils = require('solarized.utils')
|
||||
local colortool = require('solarized.utils.colors')
|
||||
local darken = colortool.darken
|
||||
local lighten = colortool.lighten
|
||||
local set_hl = utils.set_hl
|
||||
|
||||
if vim.o.background == 'dark' then
|
||||
set_hl('IndentBlanklineChar', { fg = '#424d00' }) -- Highlight of indent character. Default: Whitespace
|
||||
set_hl('IndentBlanklineChar', { fg = darken(c.green, 20) }) -- Highlight of indent character. Default: Whitespace
|
||||
set_hl('IndentBlanklineSpaceChar', { link = 'IndentBlanklineChar' }) -- Highlight of space character. Default: Whitespace
|
||||
set_hl('IndentBlanklineContextChar', { fg = '#5d6b00' }) -- Highlight of indent character when base of current context. Default: Label
|
||||
set_hl('IndentBlanklineContextChar', { fg = c.green }) -- Highlight of indent character when base of current context. Default: Label
|
||||
set_hl('IndentBlanklineContextSpaceChar', { link = 'IndentBlanklineContextChar' }) -- Highlight of space characters one indent level of the current context. Default: Label
|
||||
set_hl('IblIndent', { fg = darken(c.green, 20), nocombine = true })
|
||||
set_hl('IblScope', { fg = c.green, nocombine = true })
|
||||
else
|
||||
set_hl('IndentBlanklineChar', { fg = '#bddcf3' }) -- Highlight of indent character. Default: Whitespace
|
||||
set_hl('IndentBlanklineChar', { fg = lighten(c.blue, 20) }) -- Highlight of indent character. Default: Whitespace
|
||||
set_hl('IndentBlanklineSpaceChar', { link = 'IndentBlanklineChar' }) -- Highlight of space character. Default: Whitespace
|
||||
set_hl('IndentBlanklineContextChar', { fg = '#91c5eb' }) -- Highlight of indent character when base of current context. Default: Label
|
||||
set_hl('IndentBlanklineContextChar', { fg = c.blue }) -- Highlight of indent character when base of current context. Default: Label
|
||||
set_hl('IndentBlanklineContextSpaceChar', { link = 'IndentBlanklineContextChar' }) -- Highlight of space characters one indent level of the current context. Default: Label
|
||||
set_hl('IblIndent', { fg = lighten(c.blue, 20), nocombine = true })
|
||||
set_hl('IblScope', { fg = c.blue, nocombine = true })
|
||||
end
|
||||
|
||||
-- set_hl('IndentBlanklineSpaceCharBlankline', {}) -- Highlight of space character on blank lines. Default: Whitespace
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
return function()
|
||||
return function(c)
|
||||
local utils = require('solarized.utils')
|
||||
local colortool = require('solarized.utils.colors')
|
||||
local darken = colortool.darken
|
||||
local lighten = colortool.lighten
|
||||
local set_hl = utils.set_hl
|
||||
|
||||
set_hl('LspReferenceText', { link = 'Visual' }) -- used for highlighting "text" references
|
||||
|
|
@ -7,9 +10,9 @@ return function()
|
|||
set_hl('LspReferenceWrite', { link = 'Visual' }) -- used for highlighting "write" references
|
||||
|
||||
if vim.o.background == 'dark' then
|
||||
set_hl('LspInlayHint', { fg = '#8f6b00' }) -- used for highlighting inlay hints
|
||||
set_hl('LspInlayHint', { fg = darken(c.yellow, 20) }) -- used for highlighting inlay hints
|
||||
else
|
||||
set_hl('LspInlayHint', { fg = '#ffc517' })
|
||||
set_hl('LspInlayHint', { fg = lighten(c.yellow, 20) })
|
||||
end
|
||||
|
||||
-- if you want to me to enable the highlight groups bellow, please send a screenshot for me to see how
|
||||
|
|
|
|||
|
|
@ -176,9 +176,9 @@ function M.blend(hex_fg, hex_bg, alpha)
|
|||
local floor = math.floor
|
||||
|
||||
local function blend_channel(fg, bg)
|
||||
local blended_channel = alpha * fg + ((1 - alpha) * bg)
|
||||
local ret = alpha * fg + ((1 - alpha) * bg)
|
||||
|
||||
return floor(min(max(0, blended_channel), 255) + 0.5)
|
||||
return floor(min(max(0, ret), 255) + 0.5)
|
||||
end
|
||||
|
||||
return M.rgb_to_hex(blend_channel(red_fg, red_bg), blend_channel(green_fg, green_bg), blend_channel(blue_fg, blue_bg))
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
local M = {}
|
||||
|
||||
---Sets a highlight group
|
||||
---@param name string
|
||||
---@param val? table
|
||||
--- Sets a highlight group
|
||||
--- @param name string
|
||||
--- @param val? table
|
||||
--- @param opts? table The opts object..
|
||||
--- - opts.transparent: (boolean) Specifies whether transparency is enabled.
|
||||
--- - opts.styles: (table) A table of custom styles for various elements.
|
||||
|
|
@ -28,9 +28,9 @@ function M.set_hl(name, val, opts)
|
|||
vim.api.nvim_set_hl(0, name, val)
|
||||
end
|
||||
|
||||
---get highlight group
|
||||
---@param highlight_name string
|
||||
---@return table highlight
|
||||
--- get highlight group
|
||||
--- @param highlight_name string
|
||||
--- @return table highlight
|
||||
function M.get_hl(highlight_name)
|
||||
local highlight = vim.api.nvim_get_hl(0, { name = highlight_name, link = true })
|
||||
|
||||
|
|
@ -41,4 +41,16 @@ function M.get_hl(highlight_name)
|
|||
return highlight
|
||||
end
|
||||
|
||||
--- @param opts table The user-specified custom configuration
|
||||
--- - fnc (function): callback type configuration
|
||||
--- - tbl (function): table type configuration
|
||||
--- @param config (table|function): config to be used
|
||||
function M.on_config(opts, config)
|
||||
if type(config) == 'table' and not vim.tbl_isempty(config) then
|
||||
opts.tbl()
|
||||
elseif type(config) == 'function' then
|
||||
opts.fnc()
|
||||
end
|
||||
end
|
||||
|
||||
return M
|
||||
|
|
|
|||
|
|
@ -1,41 +1,13 @@
|
|||
vim.api.nvim_create_user_command('SolarizedColors', function()
|
||||
local colors = require('solarized.palette').get_colors()
|
||||
local buf = vim.api.nvim_create_buf(true, true)
|
||||
local max_length = vim.tbl_count(colors)
|
||||
vim.api.nvim_create_user_command('Solarized', function(args)
|
||||
require('solarized.command').load(args.fargs[1], vim.list_slice(args.fargs, 2))
|
||||
end, {
|
||||
range = true,
|
||||
nargs = '+',
|
||||
complete = function(arg)
|
||||
local list = require('solarized.command').list()
|
||||
|
||||
local function color_desc(color)
|
||||
local colors_desc = {
|
||||
base04 = 'background tone (column/nvim-tree)',
|
||||
base03 = 'background tone (main)',
|
||||
base02 = 'background tone (highlight/menu/LineNr)',
|
||||
base01 = 'content tone (comment)',
|
||||
base00 = 'content tone (winseparator)',
|
||||
base0 = 'content tone (foreground)',
|
||||
base1 = 'content tone (statusline/tabline)',
|
||||
base2 = 'background tone (main)',
|
||||
base3 = 'background tone (highlight)',
|
||||
}
|
||||
local desc = colors_desc[color]
|
||||
|
||||
if not desc then
|
||||
return ''
|
||||
end
|
||||
|
||||
return desc
|
||||
end
|
||||
|
||||
local line = 0
|
||||
for color, hex in pairs(colors) do
|
||||
if color ~= 'none' and color ~= 'name' and color ~= 'background' then
|
||||
vim.api.nvim_buf_set_lines(buf, line, (line + 1), false, {
|
||||
color .. string.rep('.', max_length - #color) .. ' = "' .. tostring(hex) .. '" ' .. color_desc(color),
|
||||
})
|
||||
line = line + 1
|
||||
end
|
||||
end
|
||||
|
||||
vim.api.nvim_set_option_value('modifiable', false, { buf = buf })
|
||||
vim.api.nvim_set_option_value('filetype', 'Solarized', { buf = buf })
|
||||
vim.api.nvim_buf_set_name(buf, 'Solarized Colors')
|
||||
vim.api.nvim_win_set_buf(0, buf)
|
||||
end, {})
|
||||
return vim.tbl_filter(function(s)
|
||||
return string.match(s, '^' .. arg)
|
||||
end, list)
|
||||
end,
|
||||
})
|
||||
|
|
|
|||
Loading…
Reference in a new issue