diff --git a/.github/workflows/sync.yaml b/.github/workflows/sync.yaml index b80393a..08758bc 100644 --- a/.github/workflows/sync.yaml +++ b/.github/workflows/sync.yaml @@ -32,10 +32,21 @@ jobs: echo 'return M' } > 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 id: diff 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" else echo "changed=true" >> "$GITHUB_OUTPUT" @@ -45,16 +56,17 @@ jobs: if: steps.diff.outputs.changed == 'true' uses: peter-evans/create-pull-request@v7 with: - branch: sync/upstream-mapping - title: 'fix(mapping): sync with upstream nonicons font' + branch: sync/upstream + title: 'fix: sync with upstream nonicons font and devicons colors' body: | ## 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 - Auto-generated `mapping.lua` from upstream `nonicon.json`. - commit-message: 'fix(mapping): sync with upstream nonicons font' + Auto-generated from upstream [ya2s/nonicons](https://github.com/ya2s/nonicons) `nonicon.json` + 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 delete-branch: true diff --git a/lua/nonicons/colors.lua b/lua/nonicons/colors.lua index 8927e07..7092f12 100644 --- a/lua/nonicons/colors.lua +++ b/lua/nonicons/colors.lua @@ -1,71 +1,69 @@ ---@type table local M = { - ['angular'] = { '#e23237', 161 }, - ['babel'] = { '#f9dc3e', 185 }, - ['book'] = { '#a8b1c7', 146 }, - ['c'] = { '#599eff', 111 }, - ['c-plusplus'] = { '#f34b7d', 204 }, - ['c-sharp'] = { '#68217a', 55 }, - ['code'] = { '#a9b7c6', 145 }, - ['css'] = { '#563d7c', 60 }, - ['dart'] = { '#00b4ab', 37 }, - ['database'] = { '#dad8d8', 188 }, - ['diff'] = { '#41535b', 59 }, - ['docker'] = { '#0db7ed', 39 }, - ['elixir'] = { '#a074c4', 140 }, - ['elm'] = { '#60b5cc', 74 }, - ['eslint'] = { '#4b32c3', 56 }, - ['file'] = { '#6d8086', 66 }, - ['file-binary'] = { '#9f0500', 124 }, - ['file-zip'] = { '#eca517', 214 }, - ['gear'] = { '#6d8086', 66 }, - ['git-branch'] = { '#f14e32', 196 }, - ['git-commit'] = { '#f14e32', 196 }, - ['globe'] = { '#519aba', 74 }, - ['go'] = { '#00add8', 38 }, - ['graphql'] = { '#e535ab', 199 }, - ['html'] = { '#e34c26', 166 }, - ['image'] = { '#a074c4', 140 }, - ['java'] = { '#cc3e44', 167 }, - ['javascript'] = { '#f1e05a', 185 }, - ['json'] = { '#fbc02d', 220 }, - ['key'] = { '#e6c419', 220 }, - ['kotlin'] = { '#7f52ff', 99 }, - ['law'] = { '#cbcb41', 185 }, - ['lock'] = { '#bbbbbb', 250 }, - ['log'] = { '#afb42b', 142 }, - ['logo-github'] = { '#f0eff1', 255 }, - ['lua'] = { '#51a0cf', 74 }, - ['markdown'] = { '#519aba', 74 }, - ['next'] = { '#a9b7c6', 145 }, - ['nginx'] = { '#009639', 28 }, - ['npm'] = { '#cb3837', 160 }, - ['package'] = { '#cb3837', 160 }, - ['perl'] = { '#39457e', 61 }, - ['php'] = { '#4f5d95', 61 }, - ['play'] = { '#e37933', 208 }, - ['prettier'] = { '#56b3b4', 73 }, - ['python'] = { '#3776ab', 68 }, - ['r'] = { '#276dc3', 68 }, - ['react'] = { '#61dafb', 75 }, - ['rss'] = { '#f26522', 208 }, - ['ruby'] = { '#cc342d', 160 }, - ['rust'] = { '#dea584', 180 }, - ['scala'] = { '#cc3e44', 167 }, - ['server'] = { '#6d8086', 66 }, - ['shield'] = { '#43853d', 35 }, - ['svelte'] = { '#ff3e00', 202 }, - ['swift'] = { '#f05138', 203 }, - ['terminal'] = { '#4d4d4d', 239 }, - ['terraform'] = { '#844fba', 135 }, - ['tmux'] = { '#1bb91f', 34 }, - ['toml'] = { '#9c4221', 130 }, - ['typescript'] = { '#3178c6', 68 }, - ['typography'] = { '#e34c26', 166 }, + ['babel'] = { '#CBCB41', 185 }, + ['book'] = { '#3D6117', 22 }, + ['c'] = { '#A074C4', 140 }, + ['c-plusplus'] = { '#A074C4', 140 }, + ['c-sharp'] = { '#596706', 58 }, + ['code'] = { '#3882D2', 32 }, + ['css'] = { '#563D7C', 54 }, + ['dart'] = { '#03589C', 25 }, + ['database'] = { '#DAD8D8', 188 }, + ['diff'] = { '#41535B', 239 }, + ['docker'] = { '#458EE6', 68 }, + ['elixir'] = { '#A074C4', 140 }, + ['elm'] = { '#519ABA', 74 }, + ['eslint'] = { '#4B32C3', 56 }, + ['file'] = { '#89E051', 113 }, + ['file-binary'] = { '#4D2C0B', 52 }, + ['file-zip'] = { '#ECA517', 214 }, + ['gear'] = { '#6D8086', 66 }, + ['git-branch'] = { '#F14C28', 196 }, + ['git-commit'] = { '#F54D27', 196 }, + ['globe'] = { '#5D7096', 60 }, + ['go'] = { '#00ADD8', 38 }, + ['graphql'] = { '#E535AB', 199 }, + ['html'] = { '#E34C26', 196 }, + ['image'] = { '#A074C4', 140 }, + ['java'] = { '#ffaf67', 215 }, + ['javascript'] = { '#CBCB41', 185 }, + ['json'] = { '#CBCB41', 185 }, + ['key'] = { '#FAF743', 227 }, + ['kotlin'] = { '#7F52FF', 99 }, + ['law'] = { '#CBCB41', 185 }, + ['lock'] = { '#BBBBBB', 250 }, + ['log'] = { '#DDDDDD', 253 }, + ['logo-github'] = { '#E24329', 196 }, + ['lua'] = { '#00A2FF', 75 }, + ['markdown'] = { '#519ABA', 74 }, + ['next'] = { '#FFFFFF', 231 }, + ['npm'] = { '#E8274B', 197 }, + ['package'] = { '#EADCD1', 253 }, + ['perl'] = { '#519ABA', 74 }, + ['php'] = { '#F05340', 203 }, + ['play'] = { '#0075AA', 24 }, + ['prettier'] = { '#4285F4', 33 }, + ['python'] = { '#5AA7E4', 39 }, + ['r'] = { '#519ABA', 74 }, + ['react'] = { '#1354BF', 26 }, + ['rss'] = { '#FB9D3B', 215 }, + ['ruby'] = { '#701516', 52 }, + ['rust'] = { '#DEA584', 216 }, + ['scala'] = { '#CC3E44', 167 }, + ['server'] = { '#A074C4', 140 }, + ['shield'] = { '#BEC4C9', 251 }, + ['svelte'] = { '#FF3E00', 196 }, + ['swift'] = { '#E37933', 166 }, + ['terminal'] = { '#4273CA', 68 }, + ['terraform'] = { '#5F43E9', 93 }, + ['tmux'] = { '#14BA19', 34 }, + ['toml'] = { '#9C4221', 124 }, + ['typescript'] = { '#519ABA', 74 }, + ['typography'] = { '#ECECEC', 255 }, ['vim'] = { '#019833', 28 }, - ['vue'] = { '#41b883', 35 }, - ['yaml'] = { '#cb171e', 160 }, - ['yarn'] = { '#2c8ebb', 68 }, + ['vue'] = { '#8DC149', 113 }, + ['yaml'] = { '#6D8086', 66 }, + ['yarn'] = { '#F9AD02', 214 }, } return M diff --git a/lua/nonicons/highlights.lua b/lua/nonicons/highlights.lua index fbf42e2..0398c49 100644 --- a/lua/nonicons/highlights.lua +++ b/lua/nonicons/highlights.lua @@ -29,9 +29,11 @@ function M.setup() end ---@param icon_name string ----@return string hl_group +---@return string? hl_group function M.get(icon_name) - return to_hl_group(icon_name) + if colors[icon_name] then + return to_hl_group(icon_name) + end end return M diff --git a/scripts/gen-colors.lua b/scripts/gen-colors.lua new file mode 100644 index 0000000..8895e81 --- /dev/null +++ b/scripts/gen-colors.lua @@ -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\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")