lifepillar / vim-colortemplate

The Toolkit for Vim Color Scheme Designers!
929 stars 29 forks source link

"Unexpected token" from imported file #80

Closed ghost closed 9 months ago

ghost commented 9 months ago

Hi, there. I started tinkering with Colortemplate v3 because I /really/ enjoy the old https://github.com/chriskempson/base16-vim templates (particularly those specific versions of Gruvbox Dark Hard and Atelier Dune), but there are a lot of missing highlights. I installed v3 and vim-devel, opened a new folder, ran vim and attempted to use the import tool. A couple things happened right away:

  1. The generated "Full Name" and "Short name" both contained hyphens which appear to be disallowed in this syntax so they needed to be changed from the imported values.
  2. The generated file does seem to contain errors that prevent building. Line 353, byte 18178 which contains Bold none none bold (and varying amounts of whitespace) specifically errors at the start of the first none.

Frankly, I think I'm over my head trying to succeed in this endeavor even if the tool worked flawlessly, but I figured I would raise the issues anyway. It would be nice if there was a Colortemplate v3 template with all the modern configurations that could be applied to any of the base16 palettes... but I may not actually be the person to make it happen. 😅

Imported file with adjusted full/short names: https://gist.github.com/riskygit/eedda6cd5f4be91cf0474fd11707935b

lifepillar commented 9 months ago

Thanks for the feedback! I've pushed a fix for those issues.

The problem with the parsing of highlight groups was names such as Bold and Italic, which were treated as keywords by Colortemplate. Consider this example:

Added none none                      
Bold  none none bold

As whitespace doesn't count (except that highlight group names must start at the beginning of a line), Colortemplate parses it as follows:

Added none none Bold

considering Bold a style attribute of Added. Then, it bails out because the following none is syntactically incorrect in that context.

I've fixed it by requiring style attributes to be all lowercase (the syntax highlighting already matched case-sensitively, but the parser did not). That fixes your particular problem, but since highlight group names are case-insensitive, in principle one might write a template like this:

Added none none                      
bold  none none bold

which cannot be parsed. But that is an edge case we can live with.

I think I'm over my head trying to succeed in this endeavor even if the tool worked flawlessly,

First, I hope that after the initial stumbling, the tool will work flawlessly :-) Please feel free to provide more feedback if you encounter more issues: v3 is still in beta stage.

Then, a suggestion: if you want to import a colorscheme, start Vim with vim --clean to avoid cluttering the import with unnecessary highglight group definitions (although you may also delete them after the import).