Skip to content

Commit

Permalink
fix: plugin not work when colors are more than termcolors
Browse files Browse the repository at this point in the history
If you defined `{colors = { "#cc241d", "#a89984" }, termcolors = {}}`, you can't reproduce the issue.
Because there are seven colors and termcolors in default config.

If you defined colors more than seven,

    colors = { "#cc241d", "#a89984", "#b16286", "#d79921", "#689d6a", "#d65d0e", "#458588", "#005f87" },
    termcolors = {},

Or colors' length more than termcolors',

    colors = { "#cc241d", "#a89984"},
    termcolors = { 3 },

then the issue can be reproduced.

close p00f#120
  • Loading branch information
adoyle-h committed Sep 8, 2022
1 parent c641e22 commit 0e27a1b
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions lua/rainbow/internal.lua
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,10 @@ local function update_range(bufnr, changes, tree, lang)
{ startRow, startCol },
{ endRow, endCol - 1 },
{
regtype = "b",
inclusive = true,
priority = 210,
}
regtype = "b",
inclusive = true,
priority = 210,
}
)
else
vim.highlight.range(
Expand Down Expand Up @@ -156,14 +156,9 @@ local M = {}

--- Define highlight groups. This had to be a function to allow an autocmd doing this at colorscheme change.
function M.defhl()
local set_hl = vim.api.nvim_set_hl
for i = 1, #colors do
local s = string.format(
"highlight default rainbowcol%d guifg=%s ctermfg=%s",
i,
colors[i],
termcolors[i]
)
vim.cmd(s)
set_hl(0, 'rainbowcol' .. i, { fg = colors[i], ctermfg = termcolors[i] })
end
end

Expand Down

0 comments on commit 0e27a1b

Please sign in to comment.