ci: systematically pull colors from nvim-web-devicons
This commit is contained in:
parent
ba45790910
commit
e9a1612365
4 changed files with 124 additions and 73 deletions
24
.github/workflows/sync.yaml
vendored
24
.github/workflows/sync.yaml
vendored
|
|
@ -32,10 +32,21 @@ jobs:
|
||||||
echo 'return M'
|
echo 'return M'
|
||||||
} > lua/nonicons/mapping.lua
|
} > lua/nonicons/mapping.lua
|
||||||
|
|
||||||
|
- name: Generate colors from nvim-web-devicons
|
||||||
|
run: |
|
||||||
|
sudo apt-get install -y -qq lua5.4 > /dev/null
|
||||||
|
|
||||||
|
curl -sL https://raw.githubusercontent.com/nvim-tree/nvim-web-devicons/master/lua/nvim-web-devicons/default/icons_by_file_extension.lua \
|
||||||
|
-o /tmp/devicons_ext.lua
|
||||||
|
curl -sL https://raw.githubusercontent.com/nvim-tree/nvim-web-devicons/master/lua/nvim-web-devicons/default/icons_by_filename.lua \
|
||||||
|
-o /tmp/devicons_fname.lua
|
||||||
|
|
||||||
|
lua5.4 scripts/gen-colors.lua > lua/nonicons/colors.lua
|
||||||
|
|
||||||
- name: Check for changes
|
- name: Check for changes
|
||||||
id: diff
|
id: diff
|
||||||
run: |
|
run: |
|
||||||
if git diff --quiet lua/nonicons/mapping.lua; then
|
if git diff --quiet lua/nonicons/mapping.lua lua/nonicons/colors.lua; then
|
||||||
echo "changed=false" >> "$GITHUB_OUTPUT"
|
echo "changed=false" >> "$GITHUB_OUTPUT"
|
||||||
else
|
else
|
||||||
echo "changed=true" >> "$GITHUB_OUTPUT"
|
echo "changed=true" >> "$GITHUB_OUTPUT"
|
||||||
|
|
@ -45,16 +56,17 @@ jobs:
|
||||||
if: steps.diff.outputs.changed == 'true'
|
if: steps.diff.outputs.changed == 'true'
|
||||||
uses: peter-evans/create-pull-request@v7
|
uses: peter-evans/create-pull-request@v7
|
||||||
with:
|
with:
|
||||||
branch: sync/upstream-mapping
|
branch: sync/upstream
|
||||||
title: 'fix(mapping): sync with upstream nonicons font'
|
title: 'fix: sync with upstream nonicons font and devicons colors'
|
||||||
body: |
|
body: |
|
||||||
## Problem
|
## Problem
|
||||||
|
|
||||||
`mapping.lua` is out of sync with the [ya2s/nonicons](https://github.com/ya2s/nonicons) upstream font.
|
`mapping.lua` or `colors.lua` is out of sync with upstream sources.
|
||||||
|
|
||||||
## Solution
|
## Solution
|
||||||
|
|
||||||
Auto-generated `mapping.lua` from upstream `nonicon.json`.
|
Auto-generated from upstream [ya2s/nonicons](https://github.com/ya2s/nonicons) `nonicon.json`
|
||||||
commit-message: 'fix(mapping): sync with upstream nonicons font'
|
and [nvim-web-devicons](https://github.com/nvim-tree/nvim-web-devicons) color definitions.
|
||||||
|
commit-message: 'fix: sync with upstream nonicons font and devicons colors'
|
||||||
labels: upstream-sync
|
labels: upstream-sync
|
||||||
delete-branch: true
|
delete-branch: true
|
||||||
|
|
|
||||||
|
|
@ -1,71 +1,69 @@
|
||||||
---@type table<string, { [1]: string, [2]: integer }>
|
---@type table<string, { [1]: string, [2]: integer }>
|
||||||
local M = {
|
local M = {
|
||||||
['angular'] = { '#e23237', 161 },
|
['babel'] = { '#CBCB41', 185 },
|
||||||
['babel'] = { '#f9dc3e', 185 },
|
['book'] = { '#3D6117', 22 },
|
||||||
['book'] = { '#a8b1c7', 146 },
|
['c'] = { '#A074C4', 140 },
|
||||||
['c'] = { '#599eff', 111 },
|
['c-plusplus'] = { '#A074C4', 140 },
|
||||||
['c-plusplus'] = { '#f34b7d', 204 },
|
['c-sharp'] = { '#596706', 58 },
|
||||||
['c-sharp'] = { '#68217a', 55 },
|
['code'] = { '#3882D2', 32 },
|
||||||
['code'] = { '#a9b7c6', 145 },
|
['css'] = { '#563D7C', 54 },
|
||||||
['css'] = { '#563d7c', 60 },
|
['dart'] = { '#03589C', 25 },
|
||||||
['dart'] = { '#00b4ab', 37 },
|
['database'] = { '#DAD8D8', 188 },
|
||||||
['database'] = { '#dad8d8', 188 },
|
['diff'] = { '#41535B', 239 },
|
||||||
['diff'] = { '#41535b', 59 },
|
['docker'] = { '#458EE6', 68 },
|
||||||
['docker'] = { '#0db7ed', 39 },
|
['elixir'] = { '#A074C4', 140 },
|
||||||
['elixir'] = { '#a074c4', 140 },
|
['elm'] = { '#519ABA', 74 },
|
||||||
['elm'] = { '#60b5cc', 74 },
|
['eslint'] = { '#4B32C3', 56 },
|
||||||
['eslint'] = { '#4b32c3', 56 },
|
['file'] = { '#89E051', 113 },
|
||||||
['file'] = { '#6d8086', 66 },
|
['file-binary'] = { '#4D2C0B', 52 },
|
||||||
['file-binary'] = { '#9f0500', 124 },
|
['file-zip'] = { '#ECA517', 214 },
|
||||||
['file-zip'] = { '#eca517', 214 },
|
['gear'] = { '#6D8086', 66 },
|
||||||
['gear'] = { '#6d8086', 66 },
|
['git-branch'] = { '#F14C28', 196 },
|
||||||
['git-branch'] = { '#f14e32', 196 },
|
['git-commit'] = { '#F54D27', 196 },
|
||||||
['git-commit'] = { '#f14e32', 196 },
|
['globe'] = { '#5D7096', 60 },
|
||||||
['globe'] = { '#519aba', 74 },
|
['go'] = { '#00ADD8', 38 },
|
||||||
['go'] = { '#00add8', 38 },
|
['graphql'] = { '#E535AB', 199 },
|
||||||
['graphql'] = { '#e535ab', 199 },
|
['html'] = { '#E34C26', 196 },
|
||||||
['html'] = { '#e34c26', 166 },
|
['image'] = { '#A074C4', 140 },
|
||||||
['image'] = { '#a074c4', 140 },
|
['java'] = { '#ffaf67', 215 },
|
||||||
['java'] = { '#cc3e44', 167 },
|
['javascript'] = { '#CBCB41', 185 },
|
||||||
['javascript'] = { '#f1e05a', 185 },
|
['json'] = { '#CBCB41', 185 },
|
||||||
['json'] = { '#fbc02d', 220 },
|
['key'] = { '#FAF743', 227 },
|
||||||
['key'] = { '#e6c419', 220 },
|
['kotlin'] = { '#7F52FF', 99 },
|
||||||
['kotlin'] = { '#7f52ff', 99 },
|
['law'] = { '#CBCB41', 185 },
|
||||||
['law'] = { '#cbcb41', 185 },
|
['lock'] = { '#BBBBBB', 250 },
|
||||||
['lock'] = { '#bbbbbb', 250 },
|
['log'] = { '#DDDDDD', 253 },
|
||||||
['log'] = { '#afb42b', 142 },
|
['logo-github'] = { '#E24329', 196 },
|
||||||
['logo-github'] = { '#f0eff1', 255 },
|
['lua'] = { '#00A2FF', 75 },
|
||||||
['lua'] = { '#51a0cf', 74 },
|
['markdown'] = { '#519ABA', 74 },
|
||||||
['markdown'] = { '#519aba', 74 },
|
['next'] = { '#FFFFFF', 231 },
|
||||||
['next'] = { '#a9b7c6', 145 },
|
['npm'] = { '#E8274B', 197 },
|
||||||
['nginx'] = { '#009639', 28 },
|
['package'] = { '#EADCD1', 253 },
|
||||||
['npm'] = { '#cb3837', 160 },
|
['perl'] = { '#519ABA', 74 },
|
||||||
['package'] = { '#cb3837', 160 },
|
['php'] = { '#F05340', 203 },
|
||||||
['perl'] = { '#39457e', 61 },
|
['play'] = { '#0075AA', 24 },
|
||||||
['php'] = { '#4f5d95', 61 },
|
['prettier'] = { '#4285F4', 33 },
|
||||||
['play'] = { '#e37933', 208 },
|
['python'] = { '#5AA7E4', 39 },
|
||||||
['prettier'] = { '#56b3b4', 73 },
|
['r'] = { '#519ABA', 74 },
|
||||||
['python'] = { '#3776ab', 68 },
|
['react'] = { '#1354BF', 26 },
|
||||||
['r'] = { '#276dc3', 68 },
|
['rss'] = { '#FB9D3B', 215 },
|
||||||
['react'] = { '#61dafb', 75 },
|
['ruby'] = { '#701516', 52 },
|
||||||
['rss'] = { '#f26522', 208 },
|
['rust'] = { '#DEA584', 216 },
|
||||||
['ruby'] = { '#cc342d', 160 },
|
['scala'] = { '#CC3E44', 167 },
|
||||||
['rust'] = { '#dea584', 180 },
|
['server'] = { '#A074C4', 140 },
|
||||||
['scala'] = { '#cc3e44', 167 },
|
['shield'] = { '#BEC4C9', 251 },
|
||||||
['server'] = { '#6d8086', 66 },
|
['svelte'] = { '#FF3E00', 196 },
|
||||||
['shield'] = { '#43853d', 35 },
|
['swift'] = { '#E37933', 166 },
|
||||||
['svelte'] = { '#ff3e00', 202 },
|
['terminal'] = { '#4273CA', 68 },
|
||||||
['swift'] = { '#f05138', 203 },
|
['terraform'] = { '#5F43E9', 93 },
|
||||||
['terminal'] = { '#4d4d4d', 239 },
|
['tmux'] = { '#14BA19', 34 },
|
||||||
['terraform'] = { '#844fba', 135 },
|
['toml'] = { '#9C4221', 124 },
|
||||||
['tmux'] = { '#1bb91f', 34 },
|
['typescript'] = { '#519ABA', 74 },
|
||||||
['toml'] = { '#9c4221', 130 },
|
['typography'] = { '#ECECEC', 255 },
|
||||||
['typescript'] = { '#3178c6', 68 },
|
|
||||||
['typography'] = { '#e34c26', 166 },
|
|
||||||
['vim'] = { '#019833', 28 },
|
['vim'] = { '#019833', 28 },
|
||||||
['vue'] = { '#41b883', 35 },
|
['vue'] = { '#8DC149', 113 },
|
||||||
['yaml'] = { '#cb171e', 160 },
|
['yaml'] = { '#6D8086', 66 },
|
||||||
['yarn'] = { '#2c8ebb', 68 },
|
['yarn'] = { '#F9AD02', 214 },
|
||||||
}
|
}
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
|
|
||||||
|
|
@ -29,9 +29,11 @@ function M.setup()
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param icon_name string
|
---@param icon_name string
|
||||||
---@return string hl_group
|
---@return string? hl_group
|
||||||
function M.get(icon_name)
|
function M.get(icon_name)
|
||||||
|
if colors[icon_name] then
|
||||||
return to_hl_group(icon_name)
|
return to_hl_group(icon_name)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
|
|
||||||
39
scripts/gen-colors.lua
Normal file
39
scripts/gen-colors.lua
Normal file
|
|
@ -0,0 +1,39 @@
|
||||||
|
#!/usr/bin/env lua
|
||||||
|
|
||||||
|
local resolve = dofile('lua/nonicons/resolve.lua')
|
||||||
|
local ext_icons = dofile('/tmp/devicons_ext.lua')
|
||||||
|
local fname_icons = dofile('/tmp/devicons_fname.lua')
|
||||||
|
|
||||||
|
local colors = {}
|
||||||
|
|
||||||
|
for ext, icon_name in pairs(resolve.ext_map) do
|
||||||
|
if not colors[icon_name] and ext_icons[ext] then
|
||||||
|
colors[icon_name] = {
|
||||||
|
ext_icons[ext].color,
|
||||||
|
tonumber(ext_icons[ext].cterm_color),
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
for fname, icon_name in pairs(resolve.filename_map) do
|
||||||
|
if not colors[icon_name] and fname_icons[fname] then
|
||||||
|
colors[icon_name] = {
|
||||||
|
fname_icons[fname].color,
|
||||||
|
tonumber(fname_icons[fname].cterm_color),
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local names = {}
|
||||||
|
for name in pairs(colors) do
|
||||||
|
names[#names + 1] = name
|
||||||
|
end
|
||||||
|
table.sort(names)
|
||||||
|
|
||||||
|
io.write("---@type table<string, { [1]: string, [2]: integer }>\n")
|
||||||
|
io.write("local M = {\n")
|
||||||
|
for _, name in ipairs(names) do
|
||||||
|
local c = colors[name]
|
||||||
|
io.write(string.format(" ['%s'] = { '%s', %d },\n", name, c[1], c[2]))
|
||||||
|
end
|
||||||
|
io.write("}\n\nreturn M\n")
|
||||||
Loading…
Add table
Add a link
Reference in a new issue