nvim-ts-rainbow icon indicating copy to clipboard operation
nvim-ts-rainbow copied to clipboard

Overwriting colors not getting applied

Open gozes opened this issue 2 years ago • 8 comments

Describe the bug if you try to overwrite the colures use in the rainbow part of the treessitter config the now colors will not get applied Steps to reproduce Steps to reproduce the behavior. use this as your treesiter configuration

local parsers = require("nvim-treesitter.parsers")

local enabled_list = {"clojure", "fennel","racket"}
require'nvim-treesitter.configs'.setup {
  ensure_installed = "maintained", -- one of "all", "maintained" (parsers with maintainers), or a list of languages
  highlight = {
  enable = true,              -- false will disable the whole extension
    disable = { "c", "rust" },  -- list of language that will be disabled
    -- Setting this to true will run `:h syntax` and tree-sitter at the same time.
    -- Set this to `true` if you depend on 'syntax' being enabled (like for indentation).
    -- Using this option may slow down your editor, and you may see some duplicate highlights.
    -- Instead of true it can also be a list of languages
    additional_vim_regex_highlighting = false,
  },
  rainbow = {
      enable = true,
      colors = {
          "#E06C75",
          "#E5C07B",
          "#98C379",
          "#56B6C2",
          "#61AFEF",
          "#C678DD",
          "#E06C75"
        },
      extended_mode = true,
      max_file_lines = nil,
      disable = vim.tbl_filter(
      function(p) 
           local disable = true
           for _, lang in pairs(enabled_list) do
               if p==lang then disable = false end
            end
            return disable
      end, parsers.available_parsers()
      )
  }
}

Expected behavior I expected the the (), [] , and {} to have the colors above not the definition grouvbox colors

gozes avatar Dec 08 '21 11:12 gozes

what happens if you add print(vim.inspect(colors)) after this line? https://github.com/p00f/nvim-ts-rainbow/blob/54ee09f540935c604c9a3d4aed83b7f5314f2caa/lua/rainbow/internal.lua#L20

p00f avatar Dec 08 '21 12:12 p00f

@p00f no differences I can see. sourceing the file and opening a clj file still shows the grouvbox colors

I now have

local parsers = require("nvim-treesitter.parsers")

local enabled_list = {"clojure", "fennel","racket"}
require'nvim-treesitter.configs'.setup {
  ensure_installed = "maintained", -- one of "all", "maintained" (parsers with maintainers), or a list of languages
  highlight = {
  enable = true,              -- false will disable the whole extension
    disable = { "c", "rust" },  -- list of language that will be disabled
    -- Setting this to true will run `:h syntax` and tree-sitter at the same time.
    -- Set this to `true` if you depend on 'syntax' being enabled (like for indentation).
    -- Using this option may slow down your editor, and you may see some duplicate highlights.
    -- Instead of true it can also be a list of languages
    additional_vim_regex_highlighting = false,
  },
  rainbow = {
      enable = true,
      colors = {
          "#E06C75",
          "#E5C07B",
          "#98C379",
          "#56B6C2",
          "#61AFEF",
          "#C678DD",
          "#E06C75"
        },
      extended_mode = true,
      print(vim.inspect(colors))
      max_file_lines = nil,
      disable = vim.tbl_filter(
      function(p) 
           local disable = true
           for _, lang in pairs(enabled_list) do
               if p==lang then disable = false end
            end
            return disable
      end, parsers.available_parsers()
      )
  }
}

gozes avatar Dec 08 '21 18:12 gozes

no i mean the print statement should echo something to the message area, what does it echo?

p00f avatar Dec 08 '21 18:12 p00f

I get nil if I do :lua print(vim.inspect(colors))

gozes avatar Dec 08 '21 18:12 gozes

what happens if you add print(vim.inspect(colors)) after this line?

https://github.com/p00f/nvim-ts-rainbow/blob/54ee09f540935c604c9a3d4aed83b7f5314f2caa/lua/rainbow/internal.lua#L20

add it after this line

p00f avatar Dec 08 '21 19:12 p00f

ok put under that line but nothing. Not even nil when I relaunch nvim

gozes avatar Dec 08 '21 20:12 gozes

what happens if you add print(vim.inspect(colors)) after this line? https://github.com/p00f/nvim-ts-rainbow/blob/54ee09f540935c604c9a3d4aed83b7f5314f2caa/lua/rainbow/internal.lua#L20

add it after this line

Hm, I'm experiencing the same. I can only apply colors using vim.cmd as show in the readme, but the table I define inside treesitter is completely ignored.

The code changed quite a bit since this suggestion. Any more ideas for debugging or where to put the print statement @p00f ???

lockejan avatar Mar 03 '22 12:03 lockejan

While it doesn't solve the root issue, I have this workaround in my config:

local rainbow = { "#CC8888", "#CCCC88", "#88CC88", "#88CCCC", "#8888CC", "#CC88CC" }
require "nvim-treesitter.configs".setup {
	rainbow = { colors = rainbow, termcolors = rainbow }
}
for i, c in ipairs(rainbow) do -- p00f/rainbow#81
	vim.cmd(("hi rainbowcol%d guifg=%s"):format(i, c))
end

Kyuuhachi avatar Mar 03 '22 14:03 Kyuuhachi