vim / colorschemes

colorschemes for Vim
274 stars 23 forks source link

Error when applying colorscheme using vim 8.1 #226

Closed matrdr closed 1 year ago

matrdr commented 1 year ago

I am using the vim version that ships with Ubuntu 20.04, vim 8.1. When trying to load practically any of the colorschemes from this pack I get an error stating:

Error detected while processing /home/matthias/.vim/pack/colorschemes/start/colorschemes/colors/evening.vim:
line   16:
E15: Invalid expression: ? 0) : -1
line  128:
E121: Undefined variable: s:t_Co
line  239:
E121: Undefined variable: s:t_Co
line  350:
E121: Undefined variable: s:t_Co
line  412:
E121: Undefined variable: s:t_Co
Press ENTER or type command to continue

After pressing ENTER the color scheme is applied. I was not able to notice any unexpected behaviour.

Is this expected with this version of vim?

As far as I know the same error occurs when using the version of vim that ships with git for Windows.

romainl commented 1 year ago

The colorschemes in this repository are only meant to be included in "current/future" versions of Vim. We currently have no plan to package them for other targets.

FWIW, the error is caused by the new "falsy operator": ??, which your Vim doesn't understand.

If you can convince @lifepillar (the person behind the authoring tool that we use) to try a different strategy we may be able to improve portability.

lifepillar commented 1 year ago

It would probably make sense to revert the use of ??, as it is a relatively new operator. It might get tricky, though, as the use of ?? was the result of several attempts to get the value of t_Co right under every circumstances, including when it's not defined.

romainl commented 1 year ago

@lifepillar FWIW I don't consider this to be of a high priority as backward compatibility is not an explicit goal of this project.

Besides, I should stress that the whole point of this repo is to keep colorscheme-related discussions out of the main repo. This is not a bunch of color nerds crafting and distributing high quality Vim colorschemes for use by anyone anywhere. This is a bunch of color nerds crafting the next colorschemes to be included in the main distribution. 8.1, 8.2, 7.4, etc. are all outside of our scope.

lifepillar commented 1 year ago

I have partially addressed this in Colortemplate by improving backward-compatibility when the template has backward_compatible on. “Partially” because, to use the color schemes in this repo with older Vim, you need to edit the templates and add the line:

Colortemplate Options: backward_compatible=1

and then rebuild the color schemes. But I think that this is a good compromise.

matrdr commented 1 year ago

Thank you for all the info. I do not want to urge anyone to change anything about the color schemes just for the sake of backward compatibility.

All I needed was the clarification that it is this line and this new operator that was hindering me from applying the color schemes without errors. As I am using termguicolor anyway, commenting everything but the termguicolor was sufficient to get rid of the error.

I think a hint that this is supposed to be used on vim >9.0 would be sufficient and maybe add some info that you can prevent the error from happening by commenting some lines and/or defining s:t_Co yourself manually.