brenoprata10 / nvim-highlight-colors

Highlight colors for neovim
724 stars 33 forks source link

regex [set] does not work #71

Closed Jaehaks closed 7 months ago

Jaehaks commented 7 months ago

If I set the pattern with [set], it does not work

1) label = 'red' => works for all red 2) label = '%'red%'' => works for all 'red' 3) label = '%'red%'' => works for all 'red' 3) label = "[']red[']" => not work

is it normal?

brenoprata10 commented 7 months ago

Hello, What do you mean by "set'? Could you provide more information?

brenoprata10 commented 7 months ago

BTW, as far as i can see, It's working as expected. I recommend experimenting with string.gmatch function in lua as this is what I use to run the lua patterns

Jaehaks commented 7 months ago

@brenoprata10 That may be a siliiy question, Could you give me some example what you tested? the set means that character sets in lua regex pattern as Programming in Lua : 20.2

A char-set allows you to create your own character classes, combining different classes and single characters between square brackets. For instance, the char-set '[%w_]' matches both alphanumeric characters and underscores, the char-set '[01]' matches binary digits, and the char-set '[%[%]]' matches square brackets. To count the number of vowels in a text, you can write

I tested with string.gmatch, its pattern worked, but the pattern does not in only nvim-highlight-colors

I tested the pattern in test.lua file like this

s = "hello world from Lua red 'red' \"red\" UredP"
for w in string.gmatch(s, "[\'\"]red[\"\']") do
    print(w)
end

and the result is successful what I intend to image

If I configure like below code image the 'red' and "red" does not be highlighted

but do you mean that these pattern works successful?

brenoprata10 commented 7 months ago

The custom_colors property is not meant to receive a lua pattern. The mention of gsub is mostly to escape the possible characters that might create a conflict when running the pattern on the plugin side. You should stick with any of the these you already tried: label = 'red' => works for all red label = '%'red%'' => works for all 'red' label = '%'red%'' => works for all 'red'

Jaehaks commented 7 months ago

@brenoprata10 I understand, Thank you~!