neoclide / coc-highlight

Document highlight and document colors LSP support for coc.nvim
226 stars 12 forks source link

Add support to percentage alpha channel #43

Closed neur1n closed 3 years ago

neur1n commented 3 years ago

For instance, rgba(0, 0, 0, 10) in C++ code is highlighted properly while rgba(0, 0, 0, 10%) is not. Therefore I tried to modify the colorFunction in server.js, but nothing changes. I don't know whether I need to build coc-highlight from source.

I've tested the following regexp with an online tester. If it is correct, would you please add it to the next release? Thanks.

const colorFunctions = /(?:\b(rgb|hsl)a?\([\d]{1,3}%?,\s*[\d]{1,3}%?,\s*[\d]{1,3}%?(,\s*\d?\.?\d+%?)?\))/gi;

The difference is that %? is added after the last \d+.

neur1n commented 3 years ago

I found that I can just use rgba(0, 0, 0, 0.1).