Skip to content
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

Port all templates to Colortemplate v3 syntax #246

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

lifepillar
Copy link
Contributor

@lifepillar lifepillar commented Jun 3, 2023

This PR updates the syntax of all the templates to Colortemplate v3. I did it so you don't have too 😉

I am not asking to merge this at once. As Colortemplate v3 is still in alpha, this can be used to discuss issues and fix them.

Why upgrade? There are a number of reasons. I will mention just three:

  • a more declarative syntax. The Variant directive has been dropped: instead, each highlight group definition has a unique default definition (which must appear first), and zero or more overriding definitions (which may appear anywhere in any order after the corresponding default definition).
  • Better performance. Just try!
  • A Relational engine. This is an implementation detail, but it's crucially important, as it makes it much easier to enforce integrity constraints. In fact, in a few cases during the porting, I have found a few inconsistencies in the templates (conflicting definitions): please search for FIXME tags.

The generated code is different from v2's, but it is subject to change depending on your feedback. Generating Vim 9 script is also possible, but for now I have rebuilt the colorschemes in legacy Vim script.

Important: I did not check whether the rebuilt colorschemes are visually equivalent to the current ones. It is likely that I've made mistakes.

@lifepillar lifepillar changed the title Port all template fo Colortemplate v3 syntax Port all templates to Colortemplate v3 syntax Jun 3, 2023
@clason
Copy link

clason commented Jun 11, 2023

Generating Vim 9 script is also possible, but for now I have rebuilt the colorschemes in legacy Vim script.

We (Neovim) appreciate that! We include these colorschemes as part of Vim's runtime files, and being able to add a new colorscheme from your project is always one of the highlights of porting a runtime file update. I'm really impressed by all the care and effort that you put into these schemes, and I've heard nothing but praise for them! So I just wanted to take the opportunity to say "Thank you!"

@romainl
Copy link
Collaborator

romainl commented Jun 11, 2023

I've heard nothing but praise for them!

Funny you say that. Beyond a handful of complaints I have heard nothing positive or negative about our efforts.

@clason
Copy link

clason commented Jun 11, 2023

Then I should have commented here much sooner! (I have meant to for a while.) I can assure you that your efforts are seen and appreciated.

(The bundled colorschemes used to be something of a joke and only really useful as a prank on a coworker; now they are actually useable, and it's even a tough choice which of them to actually use. My personal favorites are habamax, retrobox, lunaperche, and quiet.)

@romainl
Copy link
Collaborator

romainl commented Jun 11, 2023

Well thank you. The original offering was indeed in a sad state and it wasn't exactly easy to fix the mess. We hope to be able to keep up as long as possible.

There is still work to do, though:

  • review/write a proper documentation, both here and in Vim
  • squash remaining highlighting-related bugs and oversights in Vim
  • take a hard look at default
  • etc.

@lifepillar
Copy link
Contributor Author

We (Neovim) appreciate that!

Thanks! I'll take the opportunity to raise a question to everyone involved in this project and to Neovim developers if anyone is reading, since in Colortemplate v3 I have dropped Neovim compatibility.

To what extent should people working on this repo care about Neovim?

Not supporting Neovim means cleaner colorscheme's code, easier troubleshooting (one runtime vs two), and the possibility to move the scripts to Vim 9 script. On the other hand, such a move is going to… disappoint Neovim users and likely cause reactions such as this.

The way I see it, Neovim and Vim are diverging more and more, so IMO the wisest choice is to have colorschemes and templates tailored to each system—which is the solution I have adopted with Solarized 8 and Gruvbox 8, where Neovim templates are in a separate branch and are compiled with Colortemplate v2 (which will continue to support Neovim).

Just a few highlights:

  • Neovim has a new syntax for scoped highlight groups.
  • Neovim has deprecated t_xx settings, so a colorscheme shouldn't rely on t_Co to determine the available colors. See this thread.
  • With termguicolors on, Neovim uses gui colors and attributes, but Vim keeps using cterm attributes.
  • Neovim does not (currently) support ctermul.

@romainl
Copy link
Collaborator

romainl commented Jun 11, 2023

To what extent should people working on this repo care about Neovim?

You already know the answer, don't you? No extent whatsoever.

This project is only concerned with Vim. If the stuff we do here works in Neovim out-of-the-box, then it should be thought of as a happy accident, not a design goal. Just like what is going on in the main repo vim/vim.

You certainly can add Neovim support to colortemplate if you feel like it (that's your project after all) but you should probably put it behind a flag or something if combining Vim and Neovim stuff has any chance of falling apart in Vim.

@clason
Copy link

clason commented Jun 11, 2023

Thanks! I'll take the opportunity to raise a question to everyone involved in this project and to Neovim developers if anyone is reading, since in Colortemplate v3 I have dropped Neovim compatibility.

I didn't even know there was Neovim compatibility before 😅 Can you comment on that?

In any case, I'm mostly concerned with being able to use the finished colorschemes (via Vim) in Neovim, not so much in the Colortemplate script itself (although it definitely looks neat).

To what extent should people working on this repo care about Neovim?

Well, that's obviously up to you; as your stated goal is to be a Vim colorscheme incubator, anything above "not at all" is a nice surprise :)

and the possibility to move the scripts to Vim 9 script. On the other hand, such a move is going to… disappoint Neovim users and likely cause reactions vim/vim#10968.

Yes, that would be pretty much the only thing that would cut us off from your efforts (although there's https://github.com/tjdevries/vim9jit, which might be extendable to cover this). So as long as you feel comfortable sticking to "common vimscript" for these, it will be appreciated.

(I should mention that I feel justified in such an ask -- once, and politely -- since it means you'll have a bigger audience, meaning more people coming with useful bug reports and PRs.)

Everything else you've listed is our problem, and -- so far -- fairly easy to handle manually when I port Vim's runtime updates. And obviously you're not going to add Neovim-only highlight groups to your colorschemes (we handle these by having a reasonable default link to one of the standard groups).

@lifepillar
Copy link
Contributor Author

I didn't even know there was Neovim compatibility before 😅 Can you comment on that?

Answered in Colortemplate's repo.

@brammool
Copy link

brammool commented Jun 11, 2023 via email

@lifepillar
Copy link
Contributor Author

if you advertise that the colorschemes work with Neovim, you will need to test the colorscheme with both Vim and Neovim.

Absolutely. I think it's fair to say that this is not going to happen in this repo, as @romainl has pointed out. This project focuses only on Vim.

Once you find a difference you can hopefully "hide" it in a template or add some kind of test, but you do need to keep checking.

Yes, templating can act as an interface. Neovim developers can take the templates rather than the colorschemes, and use them to generate their own version of the colorschemes. This is already possible with Colortemplate v2. It will be possible with v3 if someone joins the Colortemplate project to take care of Neovim compatibility, as I am not a Neovim user myself.

Dropping t_xx settings means that quite a few legacy Vim scripts stop working.

AFAICS, they have been made read-only and marked as “deprecated”, but they still exist. But that means, for instance, that the user cannot set &t_Co = 16 to force the use of the underlying terminal colors.

the implementation [of ctermul] very much depends on the terminal. […] Depending on the support makes the
colorscheme unusable with quite a few terminals.

That's why ctermul attributes are never present in the colorschemes of this repo. If would be nice if Vim could ignore the special color unless it detects that it is supported.

@brammool
Copy link

brammool commented Jun 11, 2023 via email

@brammool
Copy link

brammool commented Jun 11, 2023 via email

@lifepillar
Copy link
Contributor Author

"Nvim does not have special t_XX options nor <t_XX> keycodes to configure terminal capabilities.". That is not the same as what you mention, where did you find that?

You are right, I can find mentions of “t_xx have been deprecated” only in some relatively old issue reports (e.g., neovim/neovim#16832 and neovim/neovim#11883). echo &t_xx does not raise error for any xx but afaics it returns nothing except for t_Co where it returns 256. So, yes, they are basically unsupported, not just deprecated.

No idea about the rationale, except that being compatible with less capable terminals does not seem a Neovim requirement, and “Nvim startup is not blocked on waiting for the UI, including the TUI. So depending on a particular value of &t_Co during startup isn't going to work.” (neovim/neovim#5538 (comment)).

Isn't it? The code doesn't do anything if t_AU isn't set.

Ah, I see. I have my terminal misconfigured then…

@clason
Copy link

clason commented Jun 12, 2023

No idea about the rationale, except that being compatible with less capable terminals does not seem a Neovim requirement, and “Nvim startup is not blocked on waiting for the UI, including the TUI. So depending on a particular value of &t_Co during startup isn't going to work.”

That is exactly the rationale. We have instead tried to make terminal feature detection as robust as possible.

@brammool
Copy link

brammool commented Jun 12, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants