Skip to content

Commit

Permalink
feat: provide colors for different color gamut
Browse files Browse the repository at this point in the history
  • Loading branch information
adoyle-h committed Nov 20, 2022
1 parent 2c896fe commit b5974cb
Show file tree
Hide file tree
Showing 8 changed files with 194 additions and 46 deletions.
17 changes: 13 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ You can search `--[[<table 28>--]]` to view its value for `<table 28>` in same b

For `<table id>`, `<function id>`, `<metatable>` tag explanations, read [inspect.lua](https://github.com/kikito/inspect.lua#examples-of-use).

### Plugin Manager
## Plugin Manager

Choose your favorite plugin manager. Now available: `vim-plug` (default) and `packer`.

Expand All @@ -307,7 +307,7 @@ The plugins directory maneged by vim-plug is different from packer. When you mod
- Packer [default config](./lua/one/config/packer.lua)
- Vim-Plug [default config](./lua/one/config/vim-plug.lua)

### Plugin
## Plugin

All plugins can be turned off, overridden default config options, replaced with your favorites.
It is highly flexible to be customized and extended.
Expand All @@ -316,15 +316,24 @@ Read [./doc/plugin.md](./doc/plugin.md) for plugin definitions and references.

You can even set `onlyPlugins = {}` to disable all plugins. Read [Debug - Disable other plugins](./doc/debug.md#disable-other-plugins).

### Colors and Highlights
## Colors and Highlights

It's highly dependent on [treesitter][]. If syntax highlights not work, check your [treesitter parsers](https://github.com/nvim-treesitter/nvim-treesitter#language-parsers) correct.
Read [./doc/treesitter.md](./doc/treesitter.md) for troubleshooting.

You can override the default colors and highlights.
Read [./doc/colors.md](./doc/colors.md) for more details.

### Proxy
### Color Gamut

The colors are desiged based on [Display P3](https://www.color.org/chardata/rgb/DisplayP3.xalter) color gamut. It works for MacOS and iTerm2 users.

If your nvim colors looks different from below picture. Your terminal is not under Display P3 color gamut.
You may try [sRGB colors](lua/one/colors/srgb.lua). Read [Colors - Color Gamut](./doc/colors.md#color-gamut) for details.

![colors.png](https://media.githubusercontent.com/media/adoyle-h/_imgs/master/github/one.nvim/colors.png)

## Proxy

```lua
require('one').setup {
Expand Down
17 changes: 13 additions & 4 deletions README.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ require('one').setup {
会有例如 `<table id>` 这样的标记。这是为了避免重复,对于 `<table 28>` 搜索文件内对应的 `--[[<table 28>--]]` 即可找到相应的值。
`<table id>`, `<function id>`, `<metatable>` 等标记的解释详见 [inspect.lua](https://github.com/kikito/inspect.lua#examples-of-use)

### 插件管理器
## 插件管理器

选择你喜欢的插件管理器,目前提供 `vim-plug` (默认) 和 `packer`

Expand All @@ -304,23 +304,32 @@ vim-plug 管理的插件目录和 packer 管理的是不一样的。当你改变
- Packer [默认配置](./lua/one/config/packer.lua)
- Vim-Plug [默认配置](./lua/one/config/vim-plug.lua)

### 插件
## 插件

所有插件都可以被关闭,覆盖默认配置项,或者替换成你喜欢的插件。自定义配置和扩展非常方便。

插件的定义和使用,详见[./doc/plugin.md](./doc/plugin.md)

你甚至可以设置 `onlyPlugins = {}` 来一键禁用所有插件(不禁用插件管理器)。详见 [Debug - Disable other plugins](./doc/debug.md#disable-other-plugins)

### 颜色和高亮
## 颜色和高亮

本项目高度依赖 [treesitter][]。如果语法高亮失效,检查你的 [treesitter parsers](https://github.com/nvim-treesitter/nvim-treesitter#language-parsers) 是否正常。
阅读 [./doc/treesitter.md](./doc/treesitter.md) 查看如何排查。

你可以修改默认配色和高亮。
阅读 [./doc/colors.md](./doc/colors.md) 查看更多细节。

### 代理
### 色域

本项目的颜色是根据 [Display P3](https://www.color.org/chardata/rgb/DisplayP3.xalter) 色域设计的。对于 MacOS 系统和 iTerm2 用户友好。

如果你的 nvim 配色看起来跟下图有点不一样。你的终端应该不是处于 Display P3 色域。
你可以尝试 [sRGB 配色](lua/one/colors/srgb.lua)。详见[颜色 - 色域](./doc/colors.md#color-gamut)

![colors.png](https://media.githubusercontent.com/media/adoyle-h/_imgs/master/github/one.nvim/colors.png)

## 代理

```lua
require('one').setup {
Expand Down
32 changes: 30 additions & 2 deletions doc/colors.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,45 @@ You can change the colors and highlights.

The priority from high to low:

- [`config.colors`](lua/one/config/colors.lua)
- [`config.colors`](../lua/one/colors/display-p3.lua)
- colors and highlights defined in each plugin
- [`colors/highlights`](lua/one/plugins/colors/highlights.lua)
- colors and highlights defined in [theme plugin](lua/one/plugins/themes/init.lua)
- syntax highlights by nvim-treesitter

## Color Gamut

The colors are desiged based on [Display P3](https://www.color.org/chardata/rgb/DisplayP3.xalter) color gamut. It works for MacOS and iTerm2 users.

If your nvim colors looks different from below picture. Your terminal is not under Display P3 color gamut.
You may try [sRGB colors](../lua/one/colors/srgb.lua).

![colors.png](https://media.githubusercontent.com/media/adoyle-h/_imgs/master/github/one.nvim/colors.png)

The color gamut is managed by your terminal application and operator system.
You should choose the right color gamut for your environment.

Current one.nvim provides [Display P3](../lua/one/colors/display-p3.lua) and [sRGB](../lua/one/colors/srgb.lua) color presets.
And use Display P3 presets by default. You can use sRGB presets like below codes.

```lua
require('one').setup {
config = {
colors = require('one.colors.srgb')
}
}
```

For Kitty users, you should set [`macos_colorspace displayp3`](https://sw.kovidgoyal.net/kitty/conf/#opt-kitty.macos_colorspace) in kitty config. Or set `macos_colorspace srgb` and use the sRGB color presets.

For windows users, read [Microsoft - About Color Management
](https://support.microsoft.com/en-us/windows/about-color-management-2a2ed8fa-cf09-83c5-e55c-d1428519f616) and [Windows Central - How to find the right color profile for your monitor using Windows 10](https://www.windowscentral.com/how-configure-correct-color-profile-your-monitor-windows-10). (Even though one.nvim not work for windows users for current)

## The background, frontground, cursorline colors

Change basic colors via `config.colors`.

Default color configs is defined in [./lua/one/config/colors.lua](./lua/one/config/colors.lua).
Default color configs is defined in [../lua/one/colors/display-p3.lua](../lua/one/colors/display-p3.lua).

```lua
require('one').setup {
Expand Down
51 changes: 51 additions & 0 deletions lua/one/colors/display-p3.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
local colors = { -- basic colors
black = '#101012',
grey1 = '#18191B',
grey2 = '#242629',
grey3 = '#34373B',
grey4 = '#484D52',
grey = '#6C6F7F',
white = '#ACAFB4',
green = '#63D846',
orange = '#D75F00',
blue = '#689AFD',
cyan = '#ACCBE1',
purple = '#765ADA',
yellow = '#C3B11A',
red = '#BF3100',

lightYellow = '#FFFFED',
lightGreen = '#C4D697',
lightPurple = '#B197D6',

darkGreen = '#13230c',
darkBlue = '#181928',
darkCyan = '#0c1820',
darkRed = '#1F0909',
darkYellow = '#212100',
darkOrange = '#371B00',
darkPurple = '#180225',
}

local functionsColors = { --
cursorLine = colors.darkBlue,
cursorLineNrFG = colors.blue,
cursorLineNrBG = colors.darkBlue,

linkFG = '#30B17D',
comment = colors.grey,
scrollbarBG = '#0E2851',

match = { fg = colors.orange },

diff = {
add = { bg = colors.darkGreen },
delete = { fg = colors.red, bg = colors.darkRed },
change = { bg = colors.darkYellow },
text = { bg = '#353513' },
},
}

for k, v in pairs(functionsColors) do colors[k] = v end

return colors
51 changes: 51 additions & 0 deletions lua/one/colors/srgb.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
local colors = { -- basic colors
black = '#101012',
grey1 = '#18191B',
grey2 = '#242629',
grey3 = '#34373B',
grey4 = '#474D53',
grey = '#6B6F80',
white = '#ABAFB5',
green = '#00DB1B',
orange = '#E85500',
blue = '#589CFF',
cyan = '#A4CCE3',
purple = '#7B59E2',
yellow = '#C7B000',
red = '#D01A00',

lightYellow = '#FFFFEB',
lightGreen = '#C0D78F',
lightPurple = '#B696DB',

darkGreen = '#0D2409',
darkBlue = '#181929',
darkCyan = '#081821',
darkRed = '#220708',
darkYellow = '#212100',
darkOrange = '#3B1900',
darkPurple = '#1B0127',
}

local functionsColors = { --
cursorLine = colors.darkBlue,
cursorLineNrFG = colors.blue,
cursorLineNrBG = colors.darkBlue,

linkFG = '#00B479',
comment = colors.grey,
scrollbarBG = '#022954',

match = { fg = colors.orange },

diff = {
add = { bg = colors.darkGreen },
delete = { fg = colors.red, bg = colors.darkRed },
change = { bg = colors.darkYellow },
text = { bg = '#35350C' },
},
}

for k, v in pairs(functionsColors) do colors[k] = v end

return colors
2 changes: 1 addition & 1 deletion lua/one/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ end
-- @param conf {table} user config
function CM.setup(conf)
local defaultConfigFn = require('one.config.default')
local defaultColors = require('one.config.colors')
local defaultColors = require('one.colors.display-p3')

local colors = util.merge(defaultColors, conf.colors)
local defaultConfig = defaultConfigFn(colors)
Expand Down
58 changes: 29 additions & 29 deletions lua/one/config/colors.lua
Original file line number Diff line number Diff line change
@@ -1,48 +1,48 @@
local colors = { -- basic colors
black = '#101012',
grey1 = '#18191B',
grey2 = '#242629',
grey3 = '#34373B',
grey4 = '#484D52',
grey = '#6C6F7F',
white = '#ACAFB4',
green = '#75C44E',
orange = '#D75F00',
blue = '#689AFD',
cyan = '#ACCBE1',
purple = '#765ADA', -- '#574AB2',
yellow = '#C3B11A', -- '#E3D888' '#FFE787' '#D1D0A3'
red = '#BF3100',

lightYellow = '#FFFFED',
lightGreen = '#C4D697',
lightPurple = '#B197D6',

darkGreen = '#13230c',
darkBlue = '#181928',
darkCyan = '#0c1820',
darkRed = '#1F0909', -- '#340009'
darkYellow = '#212100',
darkOrange = '#371B00',
darkPurple = '#180225',
black = '#101012', -- #101012
grey1 = '#18191B', -- #18191B
grey2 = '#242629', -- #242629
grey3 = '#34373B', -- #33373B
grey4 = '#484D52', -- #474D53
grey = '#6C6F7F', -- #6B6F80
white = '#ACAFB4', -- #ABAFB5
green = '#75C44E', -- #00DB1B
orange = '#D75F00', -- #E85500
blue = '#689AFD', -- #589CFF
cyan = '#ACCBE1', -- #A4CCE3
purple = '#765ADA', -- #7B59E2 '#574AB2',
yellow = '#C3B11A', -- #C7B000 '#E3D888' '#FFE787' '#D1D0A3'
red = '#BF3100', -- #D01C00

lightYellow = '#FFFFED', -- #FFFFEB
lightGreen = '#C4D697', -- #C0D78F
lightPurple = '#B197D6', -- #B696DB

darkGreen = '#13230c', -- #0D2409
darkBlue = '#181928', -- #181929
darkCyan = '#0c1820', -- #081821
darkRed = '#1F0909', -- #220708 '#340009'
darkYellow = '#212100', -- #212100
darkOrange = '#371B00', -- #3B1900
darkPurple = '#180225', -- #1B0127
}

local functionsColors = { --
cursorLine = colors.darkBlue,
cursorLineNrFG = colors.blue,
cursorLineNrBG = colors.darkBlue,

linkFG = '#30B17D',
linkFG = '#30B17D', -- #00B479
comment = colors.grey,
scrollbarBG = '#0E2851',
scrollbarBG = '#0E2851', -- #022954

match = { fg = colors.orange },

diff = {
add = { bg = colors.darkGreen },
delete = { fg = colors.red, bg = colors.darkRed },
change = { bg = colors.darkYellow },
text = { bg = '#353513' },
text = { bg = '#353513' }, -- #35350C
},
}

Expand Down
12 changes: 6 additions & 6 deletions lua/one/plugins/treesitter/highlights.lua
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ return function(config)

-- Literals
['@string'] = { link = 'String' },
['@string.regex'] = { fg = '#47A169' },
['@string.regex'] = { fg = '#47A169' }, -- #00A463
['@string.escape'] = { link = 'SpecialChar' }, -- For escape characters within a string.
['@string.special'] = { link = 'SpecialChar' }, -- For strings with special meaning that don't fit into the above categories.

Expand All @@ -42,7 +42,7 @@ return function(config)
-- Functions
['@function'] = { link = 'Function' },
['@function.call'] = { link = 'Function' },
['@function.builtin'] = { fg = '#3D84FF' }, -- For builtin functions: `pairs`, `pcall`, `table.insert` in Lua.
['@function.builtin'] = { fg = '#3D84FF' }, -- #1086FF -- For builtin functions: `pairs`, `pcall`, `table.insert` in Lua.
['@function.macro'] = { link = 'Macro' }, -- For macro defined functions (calls and definitions)
['@method'] = { link = 'Function' },
['@method.call'] = { link = 'Function' },
Expand All @@ -52,7 +52,7 @@ return function(config)

-- Keywords
['@keyword'] = { link = 'Keyword' },
['@keyword.function'] = { fg = '#2F66FF' },
['@keyword.function'] = { fg = '#2F66FF' }, -- #0F68FF
['@keyword.operator'] = { fg = c.purple, italic = true }, -- e.g. `and`, `as`, `or`.
['@keyword.return'] = { link = 'Keyword' },

Expand All @@ -65,13 +65,13 @@ return function(config)

-- Types
['@type'] = { link = 'Type' },
['@type.builtin'] = { fg = '#DB852C' },
['@type.builtin'] = { fg = '#DB852C' }, -- #E98000
['@type.qualifier'] = { link = 'Type' },
['@type.definition'] = { link = 'Typedef' },

['@storageclass'] = { link = 'StorageClass' },
['@field'] = { fg = '#B1A983' }, -- #A99C37 #75902F #90852F '#C75D14'
['@property'] = { fg = '#5098A3' },
['@field'] = { fg = '#B1A983' }, -- #B3A97E #A99C37 #75902F #90852F '#C75D14'
['@property'] = { fg = '#5098A3' }, -- #2E9AA5

-- Identifiers
['@variable'] = { fg = c.white },
Expand Down

0 comments on commit b5974cb

Please sign in to comment.