WIP feature: real-time style picker!
lifepillar opened this issue · 8 comments
For a while I have been thinking hard about how nice it would be to be able to update highlight groups in real-time using a style picker inside Vim. I have long pondered about the design and implementation of such a feature (less easy than you may think—especially the design part), but I believe I have finally nailed it (at least, the path is clear in my mind). Thanks to Vim popups and text properties! The code is far from finished and it is not published yet, but this is a draft of how it might look like:
Not too polished, I know, but I am so excited about this feature! From top to bottom, you see:
- the name of the current highlight group: this may be fixed, or it may change as you move the cursor to pick the highlight group under the cursor;
- RGB “sliders”;
- Information about the current style: hex and term values, whether this is a foreground/background/special color, and letters for attributes (B = bold, I = italic, etc.).
- Recent and favourite colors: the idea is that one could access frequently used colors there (you don't see any colors because the feature does not exist yet).
If you like this idea, or have any questions, please give me some feedback!
Ok, so a draft of this feature has landed in master! The current iteration looks like this:
Many things have to be implemented yet (some are visible in the picture, others include adding counts to some mappings, additional panes, additional information about the current color, etc.), but the popup is working and usable. Edit: performance is acceptable, but can (and will) be improved with time.
Use :ColortemplateStyle
or :ColortemplateStyle <higlight group>
to invoke it, tweak your colors, yank them if you want (y
), and close the popup (use X
to revert your changes, x
to close with the current colors). The details should be pretty intuitive, and a help pane can be opened with ?
.
Ah, the screenshot above is taken from a 256-color terminal (you can tell that because the GUI color is not shown), but of course one should ideally work in an environment supporting millions of colors. Note that, in the current master, opening the popup in such environments raises some (harmless) errors, which I am going to fix soon.
In Gvim I get minor "rendering" issue
Yes, and there are some others (like when ambiwidth
is double
). Your issue with linespace
seems specific to Gvim, though; I cannot reproduce it in MacVim, for example.
I plan to make the bars customizable, eventually. It is probably sensible to provide at least an ASCII-only version. Suggestions for symbols to use are welcome.
command is not available till you open colortemplate file,
That's on purpose and documented. (:help colortemplate-commands
). I want to keep this a pure filetype plugin. I do not want to pay anything, such as loading files from a plugin
folder, when I am not using Colortemplate.
You can easily define a global mapping, e.g.:
nmap gc :<c-u>call colortemplate#style#open()<cr>
I should probably document this as well.
New iteration:
What's new:
- you can now increase/decrease the RGB bars at steps between 1 and 99 (just type the new step and press the arrow keys—the current step is displayed below the bars: it's
10
in the screenshot); - the type of color (foreground/background/special) is now shown in the title, next to the name of the highlight group;
- the pane provides richer information: in particular, it shows the difference (Δ) between the GUI color and its best terminal approximation, and an evaluation of the quality of the GUI and terminal colors against the background of the highlight group. The latter is displayed using up to five stars;
- the popup now keeps track of the position where it was last open.
See :help :ColortemplateStyle
for the details!
In Gvim I get minor "rendering" issue, probably due to font
With the current master, you may use ASCII-only bars by setting g:colortemplate_slider_ascii = 1
. Or define your own symbols with g:colortemplate_slider_symbols
. See the help file.
Helped me a lot, thx for the Picker!