Skip to content

Commit 3c4060c

Browse files
authored
perf(collector): improve colorschemes list (#66)
perf(config): by default only enable 'primary' colors
1 parent 2c312d1 commit 3c4060c

File tree

8 files changed

+309
-366
lines changed

8 files changed

+309
-366
lines changed

.github/workflows/collect.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Color Collector
1+
name: Collector
22
on:
33
schedule:
44
- cron: "53 0 * * 1"

COLORSCHEMES.md

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,28 @@
22
ColorSchemes List
33
=================
44

5-
- [folke/tokyonight.nvim](https://github.com/folke/tokyonight.nvim)
6-
- [catppuccin/nvim](https://github.com/catppuccin/nvim)
7-
- [rebelot/kanagawa.nvim](https://github.com/rebelot/kanagawa.nvim)
8-
- [nlknguyen/papercolor-theme](https://github.com/nlknguyen/papercolor-theme)
9-
- [nordtheme/vim](https://github.com/nordtheme/vim)
10-
- [sainnhe/everforest](https://github.com/sainnhe/everforest)
11-
- [cocopon/iceberg.vim](https://github.com/cocopon/iceberg.vim)
12-
- [rakr/vim-one](https://github.com/rakr/vim-one)
13-
- [junegunn/seoul256.vim](https://github.com/junegunn/seoul256.vim)
14-
- [sainnhe/gruvbox-material](https://github.com/sainnhe/gruvbox-material)
15-
- [rose-pine/neovim](https://github.com/rose-pine/neovim)
16-
- [ku1ik/vim-monokai](https://github.com/ku1ik/vim-monokai)
17-
- [sainnhe/sonokai](https://github.com/sainnhe/sonokai)
18-
- [dracula/vim](https://github.com/dracula/vim)
19-
- [navarasu/onedark.nvim](https://github.com/navarasu/onedark.nvim)
20-
- [jacoborus/tender.vim](https://github.com/jacoborus/tender.vim)
21-
- [lifepillar/vim-solarized8](https://github.com/lifepillar/vim-solarized8)
22-
- [mhartington/oceanic-next](https://github.com/mhartington/oceanic-next)
23-
- [projekt0n/github-nvim-theme](https://github.com/projekt0n/github-nvim-theme)
24-
- [ellisonleao/gruvbox.nvim](https://github.com/ellisonleao/gruvbox.nvim)
25-
- [tomasiser/vim-code-dark](https://github.com/tomasiser/vim-code-dark)
26-
- [jnurmine/zenburn](https://github.com/jnurmine/zenburn)
27-
- [romainl/apprentice](https://github.com/romainl/apprentice)
28-
- [marko-cerovac/material.nvim](https://github.com/marko-cerovac/material.nvim)
29-
- [nyoom-engineering/oxocarbon.nvim](https://github.com/nyoom-engineering/oxocarbon.nvim)
5+
- [folke/tokyonight.nvim](https://github.com/folke/tokyonight.nvim) (stars: 4400, last update: 2023-10-25): 'tokyonight-moon', 'tokyonight-night', 'tokyonight-day', 'tokyonight-storm', 'tokyonight'
6+
- [catppuccin/nvim](https://github.com/catppuccin/nvim) (stars: 3700, last update: 2023-11-29): 'catppuccin', 'catppuccin-frappe', 'catppuccin-macchiato', 'catppuccin-mocha', 'catppuccin-latte'
7+
- [rebelot/kanagawa.nvim](https://github.com/rebelot/kanagawa.nvim) (stars: 3000, last update: 2023-10-02): 'kanagawa-wave', 'kanagawa', 'kanagawa-lotus', 'kanagawa-dragon'
8+
- [nlknguyen/papercolor-theme](https://github.com/nlknguyen/papercolor-theme) (stars: 2564, last update: 2022-06-09): 'PaperColor'
9+
- [nordtheme/vim](https://github.com/nordtheme/vim) (stars: 2451, last update: 2023-05-04): 'nord'
10+
- [sainnhe/everforest](https://github.com/sainnhe/everforest) (stars: 2200, last update: 2023-10-25): 'everforest'
11+
- [cocopon/iceberg.vim](https://github.com/cocopon/iceberg.vim) (stars: 2072, last update: 2022-11-23): 'iceberg'
12+
- [rakr/vim-one](https://github.com/rakr/vim-one) (stars: 1968, last update: 2020-12-15): 'one'
13+
- [junegunn/seoul256.vim](https://github.com/junegunn/seoul256.vim) (stars: 1604, last update: 2023-05-03): 'seoul256-light', 'seoul256'
14+
- [sainnhe/gruvbox-material](https://github.com/sainnhe/gruvbox-material) (stars: 1500, last update: 2023-11-22): 'gruvbox-material'
15+
- [rose-pine/neovim](https://github.com/rose-pine/neovim) (stars: 1400, last update: 2023-10-26): 'rose-pine-moon', 'rose-pine-dawn', 'rose-pine', 'rose-pine-main'
16+
- [ku1ik/vim-monokai](https://github.com/ku1ik/vim-monokai) (stars: 1420, last update: 2022-02-09): 'monokai'
17+
- [sainnhe/sonokai](https://github.com/sainnhe/sonokai) (stars: 1400, last update: 2023-10-25): 'sonokai'
18+
- [dracula/vim](https://github.com/dracula/vim) (stars: 1300, last update: 2023-10-29): 'dracula'
19+
- [navarasu/onedark.nvim](https://github.com/navarasu/onedark.nvim) (stars: 1200, last update: 2023-11-23): 'onedark'
20+
- [jacoborus/tender.vim](https://github.com/jacoborus/tender.vim) (stars: 1072, last update: 2021-05-24): 'tender'
21+
- [lifepillar/vim-solarized8](https://github.com/lifepillar/vim-solarized8) (stars: 951, last update: 2023-08-13): 'solarized8', 'solarized8_flat', 'solarized8_high', 'solarized8_low'
22+
- [mhartington/oceanic-next](https://github.com/mhartington/oceanic-next) (stars: 1100, last update: 2023-05-01): 'OceanicNext', 'OceanicNextLight'
23+
- [projekt0n/github-nvim-theme](https://github.com/projekt0n/github-nvim-theme) (stars: 1800, last update: 2023-11-26): 'github_light_high_contrast', 'github_light_tritanopia', 'github_light', 'github_dark_tritanopia', 'github_light_colorblind', 'github_dark_colorblind', 'github_light_default', 'github_dark_dimmed', 'github_dark', 'github_dark_default', 'github_dark_high_contrast', 'github_dimmed'
24+
- [ellisonleao/gruvbox.nvim](https://github.com/ellisonleao/gruvbox.nvim) (stars: 1300, last update: 2023-11-30): 'gruvbox'
25+
- [tomasiser/vim-code-dark](https://github.com/tomasiser/vim-code-dark) (stars: 877, last update: 2023-11-12): 'codedark'
26+
- [jnurmine/zenburn](https://github.com/jnurmine/zenburn) (stars: 862, last update: 2022-08-09): 'zenburn'
27+
- [romainl/apprentice](https://github.com/romainl/apprentice) (stars: 854, last update: 2023-02-15): 'apprentice'
28+
- [marko-cerovac/material.nvim](https://github.com/marko-cerovac/material.nvim) (stars: 843, last update: 2023-11-24): 'material', 'material-deep-ocean', 'material-darker', 'material-palenight', 'material-lighter', 'material-oceanic'
29+
- [nyoom-engineering/oxocarbon.nvim](https://github.com/nyoom-engineering/oxocarbon.nvim) (stars: 808, last update: 2023-11-28): 'oxocarbon'

README.md

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ I'm greedy that I want all the **most popular** Neovim colorschemes than only on
1414

1515
Let's load all the ultra colorschemes into your Neovim player!
1616

17-
![shuffle-per-seconds-v1](https://github.com/linrongbin16/colorbox.nvim/assets/6496887/74cc205f-fbf6-4edb-abdd-72aaea27b50b)
17+
https://github.com/linrongbin16/colorbox.nvim/assets/6496887/8fff55ea-749d-4064-90b8-a3799519898d
1818

1919
<details>
2020
<summary><i>Click here to see how to configure</i></summary>
@@ -32,8 +32,8 @@ It use offline github actions to weekly collect and update the most popular Vim/
3232

3333
> The **most popular** colorschemes are picked from below websites:
3434
>
35-
> - [vimcolorscheme.com/top](https://vimcolorschemes.com/top)
36-
> - [www.trackawesomelist.com/rockerBOO/awesome-neovim](https://www.trackawesomelist.com/rockerBOO/awesome-neovim/readme/#colorscheme)
35+
> - [vimcolorschemes.com/top](https://vimcolorschemes.com/top)
36+
> - [rockerBOO/awesome-neovim](https://www.trackawesomelist.com/rockerBOO/awesome-neovim/readme/#colorscheme)
3737
>
3838
> with below conditions:
3939
>
@@ -177,27 +177,37 @@ You can use command `Colorbox` to control the colorschemes player:
177177

178178
```lua
179179
require('colorbox').setup({
180-
-- by filetype policy: filetype => color name
181-
--- @alias ByFileTypePolicyConfigFileType string
182-
--- @alias ByFileTypePolicyConfigColorName string
183-
--- @alias ByFileTypePolicyConfig {name:"filetype",mapping:table<ByFileTypePolicyConfigFileType, ByFileTypePolicyConfigColorName>}
180+
-- builtin policy
181+
--- @alias colorbox.BuiltinPolicyConfig "shuffle"|"in_order"|"reverse_order"|"single_cycle"
182+
---
183+
-- by filetype policy: buffer filetype => color name
184+
--- @alias colorbox.ByFileTypePolicyConfig {implement:colorbox.BuiltinPolicyConfig|table<string, string>}
184185
---
185186
-- fixed interval seconds
186-
--- @alias FixedIntervalPolicyConfig {name:"interval",seconds:integer,implement:"shuffle"|"in_order"|"reverse_order"|"single"}
187+
--- @alias colorbox.FixedIntervalPolicyConfig {seconds:integer,implement:colorbox.BuiltinPolicyConfig}
187188
---
188-
--- @alias PolicyConfig "shuffle"|"in_order"|"reverse_order"|"single"|ByFileTypePolicyConfig|FixedIntervalPolicyConfig
189-
--- @type PolicyConfig
189+
--- @alias colorbox.PolicyConfig colorbox.BuiltinPolicyConfig|colorbox.ByFileTypePolicyConfig|colorbox.FixedIntervalPolicyConfig
190+
--- @type colorbox.PolicyConfig
190191
policy = "shuffle",
191192

192193
--- @type "startup"|"interval"|"filetype"
193194
timing = "startup",
194195

195-
-- (Optional) filter color by color name. For now there're two types of filters:
196-
-- 1. the "primary" filter: only the primary colors will be selected, other variants will be skip.
197-
-- 2. the function filter: colors will be filtered if function return true.
196+
-- (Optional) filters that disable some colors that you don't want.
197+
-- By default only enable primary color, e.g. only 'tokyonight' is picked, others ('tokyonight-day', 'tokyonight-moon', 'tokyonight-night', 'tokyonight-storm') are excluded.
198198
--
199-
--- @type "primary"|fun(color:string,spec:colorbox.ColorSpec):boolean|nil
200-
filter = nil,
199+
-- builtin filter
200+
--- @alias colorbox.BuiltinFilterConfig "primary"
201+
---
202+
-- function-based filter, disabled if function return true.
203+
--- @alias colorbox.FunctionFilterConfig fun(color:string, spec:colorbox.ColorSpec):boolean
204+
---
205+
---list-based filter, disabled if any of filter hit the conditions.
206+
--- @alias colorbox.AnyFilterConfig (colorbox.BuiltinFilterConfig|colorbox.FunctionFilterConfig)[]
207+
---
208+
--- @alias colorbox.FilterConfig colorbox.BuiltinFilterConfig|colorbox.FunctionFilterConfig|colorbox.AnyFilterConfig
209+
--- @type colorbox.FilterConfig?
210+
filter = "primary",
201211

202212
-- (Optional) setup plugin before running `colorscheme {color}`.
203213
--- @type table<string, function>

collect.py

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
"mini.nvim#minischeme",
2929
"mini.nvim#colorschemes",
3030
"olimorris/onedarkpro.nvim",
31+
"text-to-colorscheme",
3132
]
3233

3334

@@ -37,6 +38,7 @@
3738

3839
# git object
3940
DATETIME_FORMAT = "%Y-%m-%dT%H:%M:%S"
41+
DATE_FORMAT = "%Y-%m-%d"
4042
CANDIDATE_DIR = "candidate"
4143

4244

@@ -102,6 +104,10 @@ def datetime_tostring(
102104
)
103105

104106

107+
def date_tostring(value: typing.Optional[datetime.datetime]) -> typing.Optional[str]:
108+
return value.strftime(DATE_FORMAT) if isinstance(value, datetime.datetime) else None
109+
110+
105111
def datetime_fromstring(
106112
value: typing.Optional[str],
107113
) -> typing.Optional[datetime.datetime]:
@@ -277,7 +283,7 @@ def all() -> list:
277283
except:
278284
return []
279285

280-
def download_git_object(self) -> None:
286+
def download_git_object(self) -> bool:
281287
try:
282288
clone_cmd = None
283289
if isinstance(self.git_branch, str):
@@ -293,8 +299,10 @@ def download_git_object(self) -> None:
293299
else:
294300
logging.debug(clone_cmd)
295301
os.system(clone_cmd)
302+
return True
296303
except Exception as e:
297304
logging.exception(f"failed to download git object: {self.url}", e)
305+
return False
298306

299307
def get_vim_color_names(self) -> list[str]:
300308
colors_dir = pathlib.Path(f"{self.candidate_path}/colors")
@@ -379,7 +387,7 @@ def _parse_spec(self, element: WebElement) -> ColorSpec:
379387
github_stars,
380388
last_git_commit=last_git_commit,
381389
priority=0,
382-
source="https://vimcolorschemes.com/top",
390+
source="vimcolorschemes",
383391
)
384392

385393
def fetch(self) -> list[ColorSpec]:
@@ -391,6 +399,9 @@ def fetch(self) -> list[ColorSpec]:
391399
for element in find_elements(driver, "//article[@class='card']"):
392400
spec = self._parse_spec(element)
393401
logging.debug(f"vsc repo:{spec}")
402+
if len(spec.handle.split("/")) != 2:
403+
logging.info(f"skip for invalid handle - (vcs) spec:{spec}")
404+
continue
394405
if spec.github_stars < GITHUB_STARS:
395406
logging.info(f"skip for lower stars - (vcs) spec:{spec}")
396407
continue
@@ -415,7 +426,7 @@ def _parse_spec(self, element: WebElement) -> ColorSpec:
415426
github_stars,
416427
last_git_commit=None,
417428
priority=100,
418-
source="https://www.trackawesomelist.com/rockerBOO/awesome-neovim/readme/#colorscheme",
429+
source="awesome-neovim",
419430
)
420431

421432
def _parse_colors_list(self, driver: Chrome, tag_id: str) -> list[ColorSpec]:
@@ -426,6 +437,12 @@ def _parse_colors_list(self, driver: Chrome, tag_id: str) -> list[ColorSpec]:
426437
)
427438
for e in colors_group.find_elements(By.XPATH, "./li"):
428439
spec = self._parse_spec(e)
440+
if len(spec.handle.split("/")) != 2:
441+
logging.info(f"skip for invalid handle - (asn) spec:{spec}")
442+
continue
443+
if spec.github_stars < GITHUB_STARS:
444+
logging.info(f"skip for lower stars - (asn) spec:{spec}")
445+
continue
429446
logging.info(f"get (asn) repo:{spec}")
430447
repos.append(spec)
431448
return repos
@@ -454,14 +471,15 @@ def blacklist(sp: ColorSpec) -> bool:
454471
filtered_specs: list[ColorSpec] = []
455472
for sp in specs:
456473
logging.debug(f"process filtering on spec:{sp}")
457-
if blacklist(sp):
458-
logging.info(f"skip for blacklist - spec:{sp}")
459-
need_remove_specs.append(sp)
460-
continue
461474
if sp.github_stars < GITHUB_STARS:
462475
logging.info(f"skip for lower stars - spec:{sp}")
476+
continue
477+
if blacklist(sp):
478+
logging.info(f"skip for blacklist - spec:{sp}")
463479
need_remove_specs.append(sp)
464480
continue
481+
else:
482+
logging.debug(f"no-skip for blacklist - spec:{sp}")
465483
filtered_specs.append(sp)
466484

467485
logging.debug(f"after filter:{[str(s) for s in specs]}")
@@ -554,7 +572,11 @@ def build(self) -> None:
554572

555573
md = MdUtils(file_name="COLORSCHEMES", title="ColorSchemes List")
556574
for spec in ColorSpec.all():
557-
md.new_line("- " + md.new_inline_link(link=spec.url, text=spec.handle))
575+
color_names = spec.get_vim_color_names()
576+
color_names = ", ".join([f"'{c}'" for c in color_names])
577+
md.new_line(
578+
f"- {md.new_inline_link(link=spec.url, text=spec.handle)} (stars: {spec.github_stars}, last update: {date_tostring(spec.last_git_commit)}): {color_names}"
579+
)
558580
md.create_md_file()
559581

560582

0 commit comments

Comments
 (0)