liquidprompt / liquidprompt

A full-featured & carefully designed adaptive prompt for Bash & Zsh
https://liquidprompt.readthedocs.io/
GNU Affero General Public License v3.0
4.5k stars 425 forks source link

[contrib] Vim & Neovim assets to help editing colors in theme files #835

Open tkapias opened 5 months ago

tkapias commented 5 months ago

Description

I would like to submit some files for the "contrib/colors/vim" folder.

When writing, reading or editing a theme file for Liquid Prompt, there is no out-of-the-box solution, in any editor, to get a visual hint on used colors. The format is hard to read: lp_terminal_format 33 -1 0 0 14 -1, and contain both fg and bg.

There is a nice plugin for Vim and Neovim that lets the user write custom palettes with matching patterns to highlight specific colors in the editor: vim-hexokinase

To get vim-hexokinase to highlight theme files I wrote 2 palettes files, for foreground and background, I put them and also some instruction for vim8+ in a Gist here.

How will this be useful?

Advanced users will probably be happy to get a visual help when editing themes.

Example

Note like the last highlight at the bottom include both foreground and background colors.

image

Rycieos commented 5 months ago

Neat! I use Vim, so I'd love to get this working, personally.

Feel free to make a PR putting this in contrib/vim/colors.

I'm not a fan of the thousands of lines of JSON files, but I'm guessing that is a limitation of the Vim plugin. Which is archived? And it doesn't support setting both the foreground and background color at the same time? That's 3 strikes against it. I would love to see a better plugin used, but I won't let perfect be the enemy of good. If this is the best we can currently have, I can merge it.

tkapias commented 5 months ago

The huge JSON file for the background is ugly, but you guessed right, the plugin uses a pattern for matching but an explicit table to translate them, so I had to list all combinations.

Fortunately, it does not slow down vim's startup or the plugin's operations.

Also, I did not find another plugin that is async, for vim/neovim, and that lets you use custom patterns. And even if vim-hexokinase is archived I had no issues with it until now.

I will make a PR later today.