Skip to content
This repository has been archived by the owner on Jan 2, 2023. It is now read-only.

Overwriting colors not getting applied #81

Open
gozes opened this issue Dec 8, 2021 · 8 comments
Open

Overwriting colors not getting applied #81

gozes opened this issue Dec 8, 2021 · 8 comments

Comments

@gozes
Copy link

gozes commented Dec 8, 2021

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

@p00f
Copy link
Owner

p00f commented Dec 8, 2021

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

local termcolors = get_colors(configs, "termcolors")

@gozes
Copy link
Author

gozes commented Dec 8, 2021

@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()
      )
  }
}

@p00f
Copy link
Owner

p00f commented Dec 8, 2021

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

@gozes
Copy link
Author

gozes commented Dec 8, 2021

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

@p00f
Copy link
Owner

p00f commented Dec 8, 2021

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

local termcolors = get_colors(configs, "termcolors")

add it after this line

@gozes
Copy link
Author

gozes commented Dec 8, 2021

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

@lockejan
Copy link
Contributor

lockejan commented Mar 3, 2022

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

local termcolors = get_colors(configs, "termcolors")

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 ???

@Kyuuhachi
Copy link

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants