Skip to content

Unclear error when my color function ends with "RGB" #111

@idbrii

Description

@idbrii

I have a lua function HexToRGB that converts hex to my rgb color object:

local colorscheme {
    FOCUS =                HexToRGB(0xF6B742FF),
    FOCUS_LIGHT =          HexToRGB(0xFFEE70FF),
    FOCUS_BOLD =           HexToRGB(0xFFCB27FF),
}

When I use Colorizer, it gives this error:

:Verbose ColorToggle
1 match on 1 line
Colorizer: Some error occurred here:  Colorize: ['rgb(\s*\%(\d\+%\?[^)]*\)\{3})', function('<SNR>303_ColorRGBValues'), 'colorizer_rgb', 1, []]
Colorizer: Position: [0, 5, 33, 0]

If I replace HexToRGB -> Hex, then it doesn't give an error.

From the README, it looks like it expects a function like rgb(20, 20, 20). Looks like the regex doesn't have a whole word marker at the start.

Eventually, I figured how to to configure Colorizer to work with my file:

let g:colorizer_hex_pattern = ['0x', '\%(\x\{6,8}\)', '']
let g:colorizer_rgb_disable = 1

But I think that pattern should require a word boundary:

\<rgb(\s*\%(\d\+%\?[^)]*\)\{3})

Also, it'd be nice if Colorizer could suggest setting colorizer_X_disable when it encounters an error like this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions