-
Notifications
You must be signed in to change notification settings - Fork 28
Convert templates to Colortemplate v3 syntax #280
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Colortemplate v3 replaces `Website` with `URL`. Besides, by default it generates Vim9 script code. Set an option to keep generating VimL color schemes.
This commit just appends `/0` to each highlight group definition.
My proposal is to use this PR to get a bird's eye view of the changes, familiarize with the new syntax, and fix the most blatant deficiencies. Then, we can decide a gradual upgrade path that allows us to merge one template at a time. |
Thank you! Looks like it misses |
Or is it a part of regular definition with |
@romainl, @neutaaaaan I think the whole migration to v3 should happen in one go, and then gradual clean up of issues. Maybe in a separate branch. We can do it one by one but I don't feel fancy to checkout different colortemplate versions to work on different colorschemes. For now, I will try to convert vim-habamax to v3 and make myself comfortable with new syntax. |
I wish it was a part of a plugin or installed the same way (
|
Exactly. As I've said, that is not set in stone. But that makes a highlight group definition complete, so for example, when a user does
Up to you. I apologize for the inconvenience of these backward-incompatible changes, but I believe that they will simplify future maintainance. I will try to help as much as I can. Btw, do you have some procedure to visually compare two different versions of a color scheme? E.g., tests using
Hopefully, you will find it intuitive and simpler than using
Not sure I get what “it” refers to here. Skimming through the generated code, I see at least two potential issues:
then Colortemplate may generate something like: hi SpellBad […] ctermul=196 […] This will probably cause blinking text in some (most?) terminals. Note that there are several color schemes in this PR with non-
This declares that Another difference is that Other than that, I can't see issues, but I haven't looked too hard. Please don't forget to take a look at the |
I can do this change if I get an ack from you. |
It was referring to the |
Yeah, now it's one more step, but you get some reusable libraries :-) The alternative would be to take the scripts imported from |
I understand the reasoning, but it still one step more to do. And not sure how easy it would be for ppl with something like vim-plug. |
I think plugin managers can install packages, too, right? Another possibility would be to add Colortemplate as a (Git) subtree of vim-devel. Then, you'd just need to get vim-devel. I'd still prefer to keep things separate, though. Let's also see if others have an opinion. |
Thank you @lifepillar. It looks like you put considerable effort into this PR and the whole rewrite. I, too, think that a single branch/PR is the best approach but I would like to try my hands at v3 first. I have the same concerns as @habamax regarding the As for |
Ok, considering that Colortemplate is, in fact, a development plugin, it may make sense to make it available via vim-devel, which is… a development package. There were already third-party plugins in vim-devel, installed via submodules. But I've decided to never use submodules any more. Let me see whether Git subtrees can work. |
For end users like me, the ideal would have been the single repo I can clone and then update with a simple command(s) (clone and then update) without git modules involved. Otherwise if a dependency has been changed I might be in a situation when new colortemplate I have just updated would still use the old libxxx from that dependency. I would be lucky if it explicitly error me about it. vim-plug works with runtimepath manipulation which predates packages and there are still a lot of ppl using it. |
This Colortemplate version fixes an issue causing highlight groups defined by default as linked groups not to be overridden when the overriding definition uses a base group.
Ok, let me look into possible solutions. Btw, Colortemplate checks for compatibility with some imported libraries, so
You will get an informative message if an updated version of Colortemplate requires a newer library than you have installed. This reminds me that I need to add requirements for all the imported scripts. |
So, the simplest thing would be to add Colortemplate to the The less appealing (to me) alternative is to copy (subtree-merge or something) the vim-devel libraries that Colortemplate needs into the Colortemplate plugin. I like this less because I would end up with two copies of the same libraries, as I need vim-devel separately anyway for other purposes. The only potential advantage (?) of this approach is that you would have to install a plugin and not a package, so that is more likely to work with plugin managers (but with packages, why would you need a plugin manager?). In either case, you would clone one repo. Let me know what you prefer. |
Also, the first solution is easy to maintain because a plugin fits in a package, so I can simply use Git subtree merge to update things. The other way round is a bit more involved: I'd probably end up just manually copying the needed scripts into Colortemplate. |
Recall vim#210. In GVim, t_Co only gets set after GUI initialization, so when the color scheme is loaded (if it is loaded from a vimrc, not from a gvimrc) t_Co is still empty. Which means that `str2nr(&t_Co)` is zero, hence the last block—the one guarded by `str2nr(&t_Co) >= 0` gets executed. This commit fixes it.
Small updates:
My plan is now to test this PR using the scripts from #281. If no further issues are encountered, imo this will be safe enough to merge. |
The scripts from #281 were very useful to compare 2520 screen dumps (two for each combination of color scheme, sample script, Note: The reference version of the color schemes I used for comparisons is from Vim 9.1.1128, so some differences may be due to changes merged into Vim after that patch. Summary report:
Additional notes:
I'm now leaving it to you to decide how to proceed from here. My suggestion would be to review and merge #281 first, then double-check the report above, and finally merge this PR. |
Ok, it's actually 2610 screen dumps, and there are a few more differences than I've reported above (I was mistakenly comparing some screen dumps with themself in some cases 🤦), but basically all of them are for 0- and 8-color environments. Most likely, they can be fixed by providing definitions for some missing highlight groups in |
- Added `Float`, `Function`, `Number` and `QuickFixLine to `_tco_zero`. They are all defined to generate `term=NONE`. Accordingly, default definitions for those highlight groups have been added to the color schemes in which they were not present. I consider the remaining (few) visual differences wrt the color schemes before this commit as *fixes of shortcomings in master.* Specifically: - `lunaperche` did not define `String` for dark/light 8-color terminals. - `lunaperche` did not define `Visual` for 8/16-color terminals (except for the combination 16/light), falling back to the `default` color scheme. - `retrobox`'s template removes `bold` for `Error` in 8/16-color terminals (both backgrounds), but that definition was not applied to the color scheme. This is fixed in this PR - `wildcharm` (dark) had this definition: ``` Variant: gui 256 EndOfBuffer colorNonT none Variant: gui 256 16 EndOfBuffer color08 none ``` So, it is not clear what the foreground should be for `gui` and `256`. By comparing with the light background and considering what the intent could have been here, I've opted for `colorNonT` by default, and `color08` for 16-color terminals. This results in a different `EndOfBuffer` background in dark wildcharm than what is currently in Vim. Finally, for wildcharm, the version in Vim's runtime has a `NONE` background for `VertSplit`, but the version in this repo has a solid `VertSplit`. I assume that this is a change that has not been pushed to Vim yet. I've kept the solid appearance. Signed-off-by: Lifepillar <[email protected]>
Reporting back as promised. Some changes I've made to fix some discrepancies:
I consider the remaining (few) visual differences wrt the color schemes in master fixes of shortcomings in master. Specifically:
So, it is not clear what the foreground should be for Finally, for wildcharm, the version in Vim's runtime has a With all that, I'm taking this PR out of draft mode as this is imo ready to be merged. |
Colortemplate v3 is finally (!) ready for prime time and has been merged into master. You may still checkout the
v2
branch if you want to keep using Colortemplate v2. Please read the documentation if you upgrade to v3.This PR brings all the templates to the new syntax introduced in v3. The syntax is fully described in Colortemplate's help file.
In terms of template syntax, the main difference is that
Variant
no longer exists: each highlight group definition is self-contained, as long time ago @romainl suggested. So, the new syntax is totaly declarative: highlight group definitions can be freely reordered (although in this PR I've tried to modify the templates as little as possible).In terms of generated code, the major difference is that gui attributes, (best) cterm attributes and term attributes are merged in a single, complete,
hi
statement. I'm open to change the format of the output, but after a long time working with color schemes I've come to the conclusion that it's best to provide the most complete definition regardless of the actual environment.In several places I've noted missing highlight groups and in few cases some ambiguities that I've encountered (highlight groups defined twice for the same variant). I've marked those with
TODO
in the templates.Everything builds with the current Colortemplate master and, in theory, the color schemes should remain functionally unchanged. It would be unrealistic, though, to assume that these changes do not introduce any issues. As an example, I'm pretty sure that some
ctermul
attribute needs to be fixed.Colortemplate v3 has still some rough edges, especially regarding error reporting, and it has not been optimized for performance yet. All in all, the UX should be pretty similar to what you're used to, though.
Let me know what you think.