Skip to content

Commit

Permalink
chore(naming): rename color set to colorset
Browse files Browse the repository at this point in the history
  • Loading branch information
ramojus committed Jun 24, 2024
1 parent 65b2ebf commit 5a3ac8b
Show file tree
Hide file tree
Showing 11 changed files with 73 additions and 73 deletions.
28 changes: 14 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ A colorscheme for [Neovim](https://github.com/neovim/neovim). Pleasant and produ
![preview](https://github.com/ramojus/mellifluous.nvim/assets/41536253/a4b01a46-6ec9-408a-9c2f-08995c53155a)

## Highlighted features
- [**Multiple color sets**](#color-sets): Each color set presents a unique visual theme while adhering to the same set of productive highlight rules. Every color set [can be customised](#overriding-colors-of-a-color-set).
- [**Multiple colorsets**](#color-sets): Each colorset presents a unique visual theme while adhering to the same set of productive highlight rules. Every colorset [can be customised](#overriding-colors-of-a-color-set).

- **Layered backgrounds**: Most UI elements have backgrounds with different shades of the background color and have no borders. This allows for easy differentiation between the relative importance of the elements and keeps the colorscheme looking minimal.

- [**Oklab color space**](https://bottosson.github.io/posts/oklab/): To truly achieve perceptually uniform variations of colors, all color modifications are done in this color space; thanks to [mini.colors](https://github.com/echasnovski/mini.colors) project for the code and idea.

- **Small number of colors**: Color sets use a small number of colors to provide distraction-free coding experience.
- **Small number of colors**: Colorsets use a small number of colors to provide distraction-free coding experience.

- **Stronger highlights on important keywords**: Keywords related to control flow have stronger highlights, making it easier to quickly understand the code.

Expand Down Expand Up @@ -51,7 +51,7 @@ Here is an example with the default config. This is optional, and only relevant
```lua
require 'mellifluous'.setup({
dim_inactive = false,
color_set = 'mellifluous',
colorset = 'mellifluous',
styles = { -- see :h attr-list for options. set {} for NONE, { option = true } for option
comments = { italic = true },
conditionals = {},
Expand Down Expand Up @@ -105,22 +105,22 @@ require 'mellifluous'.setup({
```

### Light theme
For light theme, set `vim.opt.background` to `'light'`. This will only work on color sets that have light theme.
For light theme, set `vim.opt.background` to `'light'`. This will only work on colorsets that have light theme.

### Color sets
Non-original color sets are made to match their original version as closely as possible with the same highlight rules as mellifluous.
### Colorsets
Non-original colorsets are made to match their original version as closely as possible with the same highlight rules as mellifluous.

These color sets don't get loaded, unless you specify them in a `color_set` option, so there is no performance impact.
These colorsets don't get loaded, unless you specify them in a `colorset` option, so there is no performance impact.

Available color sets:
Available colorsets:

- `mellifluous`. Dark and light, original.
- `alduin`. Dark, [link to original](https://github.com/alessandroyorba/alduin).
- `mountain`. Dark, [link to original](https://github.com/mountain-theme/mountain).
- `tender`. Dark, [link to original](https://github.com/jacoborus/tender.vim).
- `kanagawa_dragon`. Dark, [link to original](https://github.com/rebelot/kanagawa.nvim).

#### Mellifluous color set configuration
#### Mellifluous colorset configuration
Default config:

```lua
Expand All @@ -137,7 +137,7 @@ The following snippet shows where and which colors can be overridden:

```lua
require 'mellifluous'.setup({
<color_set_name> = { -- name any of the defined color sets
<colorset_name> = { -- name any of the defined colorsets
color_overrides = {
dark = { -- for dark theme
bg = nil, -- used for bg shades and may be used for some colorset colors
Expand All @@ -156,7 +156,7 @@ require 'mellifluous'.setup({
})
```

To override colors for all colorsets, omit `<color_set_name>` table.
To override colors for all colorsets, omit `<colorset_name>` table.

NOTE: parameter `colors` will have all of the colors set by the colorset, but it will not have shades.

Expand Down Expand Up @@ -212,10 +212,10 @@ require 'mellifluous'.setup({
-- highlight overrides for specific colorset
<colorset_name> = {
highlight_overrides = {
dark = function(highlighter, colors) -- dark variant of the color set
dark = function(highlighter, colors) -- dark variant of the colorset
-- set highlights here (using highlighter)
end,
light = function(highlighter, colors) -- light variant of the color set
light = function(highlighter, colors) -- light variant of the colorset
-- set highlights here (using highlighter)
end,
}
Expand Down Expand Up @@ -308,7 +308,7 @@ Type `:Mellifluous <TAB>` and see the available options.
Options include:

- Toggling transparency.
- Changing color set.
- Changing colorset.

## TODO
- [ ] Support more plugins (contributions are welcome).
Expand Down
22 changes: 11 additions & 11 deletions doc/mellifluous.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Table of Contents *mellifluous-table-of-contents*
2. Installation and usage |mellifluous-installation-and-usage|
3. Configuration |mellifluous-configuration|
- Light theme |mellifluous-configuration-light-theme|
- Color sets |mellifluous-configuration-color-sets|
- Colorsets |mellifluous-configuration-color-sets|
- Color overrides |mellifluous-configuration-color-overrides|
- Highlight overrides |mellifluous-configuration-highlight-overrides|
- Available colors |mellifluous-configuration-available-colors|
Expand Down Expand Up @@ -62,7 +62,7 @@ parts of the config can be included.
>lua
require 'mellifluous'.setup({
dim_inactive = false,
color_set = 'mellifluous',
colorset = 'mellifluous',
styles = { -- see :h attr-list for options. set {} for NONE, { option = true } for option
comments = { italic = true },
conditionals = {},
Expand Down Expand Up @@ -119,18 +119,18 @@ parts of the config can be included.
LIGHT THEME *mellifluous-configuration-light-theme*

For light theme, set `vim.opt.background` to `'light'`. This will only work on
color sets that have light theme.
colorsets that have light theme.


COLOR SETS *mellifluous-configuration-color-sets*

Non-original color sets are made to match their original version as closely as
Non-original colorsets are made to match their original version as closely as
possible with the same highlight rules as mellifluous.

These color sets don’t get loaded, unless you specify them in a `color_set`
These colorsets don’t get loaded, unless you specify them in a `colorset`
option, so there is no performance impact.

Available color sets:
Available colorsets:

- `mellifluous`. Dark and light, original.
- `alduin`. Dark, link to original <https://github.com/alessandroyorba/alduin>.
Expand Down Expand Up @@ -159,7 +159,7 @@ The following snippet shows where and which colors can be overridden:

>lua
require 'mellifluous'.setup({
<color_set_name> = { -- name any of the defined color sets
<colorset_name> = { -- name any of the defined colorsets
color_overrides = {
dark = { -- for dark theme
bg = nil, -- used for bg shades and may be used for some colorset colors
Expand All @@ -178,7 +178,7 @@ The following snippet shows where and which colors can be overridden:
})
<

To override colors for all colorsets, omit `<color_set_name>` table.
To override colors for all colorsets, omit `<colorset_name>` table.

NOTE: parameter `colors` will have all of the colors set by the colorset, but
it will not have shades.
Expand Down Expand Up @@ -238,10 +238,10 @@ The following snippet shows how highlight overrides can be defined:
-- highlight overrides for specific colorset
<colorset_name> = {
highlight_overrides = {
dark = function(highlighter, colors) -- dark variant of the color set
dark = function(highlighter, colors) -- dark variant of the colorset
-- set highlights here (using highlighter)
end,
light = function(highlighter, colors) -- light variant of the color set
light = function(highlighter, colors) -- light variant of the colorset
-- set highlights here (using highlighter)
end,
}
Expand Down Expand Up @@ -351,7 +351,7 @@ Type `:Mellifluous <TAB>` and see the available options.
Options include:

- Toggling transparency.
- Changing color set.
- Changing colorset.


==============================================================================
Expand Down
8 changes: 4 additions & 4 deletions lua/mellifluous/cli.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ function M.create()
local options = {
toggle_transparency = 100,
}
local color_sets = require('mellifluous.colors').get_color_sets_table()
options = vim.tbl_deep_extend('force', options, color_sets)
local colorsets = require('mellifluous.colors').get_colorsets_table()
options = vim.tbl_deep_extend('force', options, colorsets)
local config = require('mellifluous.config').config

vim.api.nvim_create_user_command('Mellifluous', function(input)
Expand All @@ -15,9 +15,9 @@ function M.create()
enabled = not config.transparent_background.enabled
}
})
elseif color_sets[input.args] then
elseif colorsets[input.args] then
require('mellifluous').setup({
color_set = input.args
colorset = input.args
})
else
require('mellifluous').print_error("unrecognised cli argument: '" .. input.args .. "'")
Expand Down
2 changes: 1 addition & 1 deletion lua/mellifluous/color.lua
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ function color_meta:get_hsl()
return hex_to_okhsl(self.hex)
end

function M.color_set_to_hsl(colors)
function M.colorset_to_hsl(colors)
for name, color in pairs(colors) do
local okhsl = hex_to_okhsl(color.hex)
okhsl.h = okhsl.h or 0
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
local M = {}
local color = require('mellifluous.color')

local color_set_name = 'mellifluous'
local colorset_name = 'mellifluous'

local function get_is_neutral(mellifluous_config)
local config = require('mellifluous.config').config
-- for compatibility with configs from before color set specific config was supported
-- for compatibility with configs from before colorset specific config was supported
if config.neutral ~= nil then
return config.neutral
end
Expand All @@ -14,7 +14,7 @@ end

function M.get_bg_dark()
local config = require('mellifluous.config').config
local mellifluous_config = config[color_set_name]
local mellifluous_config = config[colorset_name]
local is_neutral = get_is_neutral(mellifluous_config)

local brightness = 11.5
Expand All @@ -32,7 +32,7 @@ end

function M.get_bg_light()
local config = require('mellifluous.config').config
local mellifluous_config = config[color_set_name]
local mellifluous_config = config[colorset_name]
local is_neutral = get_is_neutral(mellifluous_config)

local brightness = 91.5
Expand Down
File renamed without changes.
File renamed without changes.
44 changes: 22 additions & 22 deletions lua/mellifluous/colors/init.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
local M = {}

function M.get_color_sets_table()
function M.get_colorsets_table()
return {
mellifluous = 1,
alduin = 2,
Expand All @@ -20,7 +20,7 @@ local function get_color_overrides_bg_fn()
local config = require('mellifluous.config').config
local global_color_overrides_bg = vim.tbl_get(config,
'color_overrides', config.is_bg_dark and 'dark' or 'light', 'bg')
local color_overrides_bg_fn = vim.tbl_get(config, config.color_set,
local color_overrides_bg_fn = vim.tbl_get(config, config.colorset,
'color_overrides', config.is_bg_dark and 'dark' or 'light', 'bg')

if color_overrides_bg_fn == nil then
Expand All @@ -34,7 +34,7 @@ local function apply_color_overrides(colors)
local config = require('mellifluous.config').config
local global_color_overrides_fn = vim.tbl_get(config,
'color_overrides', config.is_bg_dark and 'dark' or 'light', 'colors')
local color_overrides_fn = vim.tbl_get(config, config.color_set,
local color_overrides_fn = vim.tbl_get(config, config.colorset,
'color_overrides', config.is_bg_dark and 'dark' or 'light', 'colors')

if global_color_overrides_fn ~= nil then
Expand All @@ -53,12 +53,12 @@ local function ensure_correct_color_types(colors)
end
end

function M.get_is_bg_dark(color_set_name)
local color_set_functions = require('mellifluous.colors.sets.' .. color_set_name)
local is_light_set_available = color_set_functions.get_bg_light ~= nil
and color_set_functions.get_colors_light ~= nil
local is_dark_set_available = color_set_functions.get_bg_dark ~= nil
and color_set_functions.get_colors_dark ~= nil
function M.get_is_bg_dark(colorset_name)
local colorset_functions = require('mellifluous.colors.colorsets.' .. colorset_name)
local is_light_set_available = colorset_functions.get_bg_light ~= nil
and colorset_functions.get_colors_light ~= nil
local is_dark_set_available = colorset_functions.get_bg_dark ~= nil
and colorset_functions.get_colors_dark ~= nil

if vim.o.background == 'light' and is_light_set_available then
return false
Expand All @@ -67,44 +67,44 @@ function M.get_is_bg_dark(color_set_name)
elseif is_light_set_available then
return false
else
require('mellifluous').return_error("Required color set is either incomplete or missing")
require('mellifluous').return_error("Required colorset is either incomplete or missing")
end
end

function M.get_ui_color_base_lightness(color_set_name, is_bg_dark)
return require('mellifluous.colors.sets.' .. color_set_name).get_ui_color_base_lightness(is_bg_dark)
function M.get_ui_color_base_lightness(colorset_name, is_bg_dark)
return require('mellifluous.colors.colorsets.' .. colorset_name).get_ui_color_base_lightness(is_bg_dark)
end

function M.get_colors()
local config = require('mellifluous.config').config
if not M.get_color_sets_table()[config.color_set] then
require('mellifluous').return_error("Color set '" .. config.color_set .. "' not found")
if not M.get_colorsets_table()[config.colorset] then
require('mellifluous').return_error("Colorset '" .. config.colorset .. "' not found")
end

local color_set_functions = require('mellifluous.colors.sets.' .. config.color_set)
local colorset_functions = require('mellifluous.colors.colorsets.' .. config.colorset)

local color_overrides_bg_fn = get_color_overrides_bg_fn()

local color_set_bg
local colorset_bg
if config.is_bg_dark then
color_set_bg = color_set_functions.get_bg_dark()
colorset_bg = colorset_functions.get_bg_dark()
else
color_set_bg = color_set_functions.get_bg_light()
colorset_bg = colorset_functions.get_bg_light()
end

local bg = color_set_bg
local bg = colorset_bg
if type(color_overrides_bg_fn) == 'function' then
local overriden_bg = color_overrides_bg_fn(color_set_bg)
local overriden_bg = color_overrides_bg_fn(colorset_bg)
if overriden_bg ~= nil then
bg = overriden_bg
end
end

local colors
if config.is_bg_dark then
colors = color_set_functions.get_colors_dark(bg)
colors = colorset_functions.get_colors_dark(bg)
else
colors = color_set_functions.get_colors_light(bg)
colors = colorset_functions.get_colors_light(bg)
end

colors = apply_color_overrides(colors)
Expand Down
Loading

0 comments on commit 5a3ac8b

Please sign in to comment.