feat(extra): add colorscheme picker#1789
feat(extra): add colorscheme picker#1789pkazmier wants to merge 10 commits intonvim-mini:backlogfrom pkazmier:main
Conversation
pkazmier
commented
May 7, 2025
- I have read CONTRIBUTING.md
- I have read CODE_OF_CONDUCT.md
|
First draft. Next steps:
|
|
With regards to the placement of the one-time autocommand (didn't know these were a thing, very cool). I placed it in the And, I was unsure of how defensive you like to get, but I suppose to be really cautious, I could create a auto command group that clears any old unexecuted auto commands when the picker is created. That prevents stacking of more than one auto commands that would load a theme. And, also, to be extra safe, I could check the source name in the callback to make sure it was from this colorscheme picker. Again, I'm just not sure how defensive you want to be and if it is really necessary. I'll defer to you as you are the expert. |
|
Thanks for the PR! For posterity, this is a result of #951 discussion.
I think the whole autocommand approach is unnecessary. Any picker waits for the user to finish action and resumes code execution afterwards. So the |
The background needs to be preserved as previewing a theme can inadvertently change that value if you select a light-only theme. While previewing the next theme, if it happens to have both a light and dark variant, then the light will be shown, even if the user originally had 'dark' for their background.
Even better. I removed the autocommand and now preserve the |
Two options are presented. colorschemes_1 is more concise but may result in a colorscheme being set more than once. For example, if you preview one (sets the colorscheme) and then select that one, the colorscheme is set again. Is this really a big deal? colorscheme_2 is more verbose to avoid any duplicate calls to setting the colorscheme. It seems a bit verbose just to avoid calling colorscheme more than once. Thoughts?
|
Added 'mini.color' support. Two versions of the picker are included: The first version is more concise and does not try to avoid setting the colorscheme more than once. For example, in that version, if you open the picker and don't preview or select anything, when you quit, your original colorscheme is set. Likewise, if you preview a colorscheme (results in setting the colorscheme) and then select it, it will set the colorscheme again. The second option is more verbose, but it avoids setting the colorscheme unnecessarily. So, my question to you is what is more important in this specific case: conciseness or avoiding the extra calls to set the colorscheme? As a novice, I guess I don't see the big deal if the colorscheme is set multiple times and I think I favor the conciseness of version 1 given the spirt of mini being as small as possible. Just looking for your feedback. Thanks. |
echasnovski
left a comment
There was a problem hiding this comment.
Yeah, let's try variant 1 first. There indeed shouldn't be too much harm (other than couple of milliseconds of delay) in applying color scheme.
Co-authored-by: Evgeni Chasnovski <evgeni.chasnovski@gmail.com>
pkazmier
left a comment
There was a problem hiding this comment.
Thanks for the feedback and suggestions!
|
Wow. Your 'mini.test' library is very cool and the 'TESTING.md' document was perfect to get me started. I've now added some initial tests, but I need help the "cancel without mini.colors" test. When that test runs, I need to make sure that 'mini.colors' is not available or loaded. I tried different things but could not get it working. The point of this test is to prove that a custom change to a highlight group is not persisted when mini.colors is not present. |
|
Updated the tests to use |
|
Thanks, I will take a closer look after 0.16.0 release. Approved CI to run. Don't worry about commit style checks, those will be squashed. Nice job for making tests pass on all supported versions! |
|
Thanks for giving me the opportunity to collaborate with you. I learned a LOT even with this very small contribution. And I always thought testing in Neovim would be a nightmare, but I was pleasantly surprised. The screenshot capability is very cool as is the use of the child. Now back to revamping my mini configuration, which I’m redoing based on yours. I like using the top-level directories in the config folder. There is nothing much left in my Lua directory, which is so different than any config I’ve ever had since moving to vim from emacs three years ago. |
Thanks for taking interest! There are more "good-first-issue" type of feature requests, if you have time and want to continue (which I'll gladly accept).
Yeah, using 'plugin/' for user config is somewhat counter-intuitive, but nice overall. It is not without its issues, though. For example, |
Yes. I would like to help where I can after I've revamped my configuration. When done I'll take a look at your issues list for something that looks easy. Obviously, your definition of easy will be quite different from mine 😄 |
This fixes a bug introduced in b83127c.
|
Shoot. I meant to submit that last commit as part of a different PR. I'll revert later as I have to head out now. |
This reverts commit 51b2fca.
| local has_colors, colors = pcall(require, 'mini.colors') | ||
| local selected_cs = has_colors and colors.get_colorscheme() or vim.g.colors_name |
There was a problem hiding this comment.
When using the mini.nvim repository, mini.colors is always present. Perhaps it is better to only use mini.colors if it has been setup. Otherwise, mini.colors always parses the current colorscheme, which seems unnecessary.
| local has_colors, colors = pcall(require, 'mini.colors') | |
| local selected_cs = has_colors and colors.get_colorscheme() or vim.g.colors_name | |
| local selected_cs = MiniColors ~= nil and MiniColors.get_colorscheme() or vim.g.colors_name |
|
I am looking forward to using this new picker! Would it be possible to have a |
Hmm... Interesting idea. I wonder if the I plan to polish (still need to decide if there needs to be a more informative preview text) and merge this week. |
Resolve #1789 Co-authored-by: Evgeni Chasnovski <evgeni.chasnovski@gmail.com>
Resolve #1789 Co-authored-by: Evgeni Chasnovski <evgeni.chasnovski@gmail.com>
|
I wanted to merge it today to So I squashed and merged this locally, plus added (quite a few, unfortunately) changes. The current result is in |
|
(A version of) This is now merged into latest Thanks again @pkazmier for the initial implementation and PR! |
|
Nice! Looking forward to adding it to my config later today. Good idea on previewing with highlight groups. Seems so obvious in hindsight. |