p00f / nvim-ts-rainbow

Rainbow parentheses for neovim using tree-sitter. Use https://sr.ht/~p00f/nvim-ts-rainbow instead
Apache License 2.0
869 stars 67 forks source link

Default color of brackets is red? #104

Closed xy9485 closed 2 years ago

xy9485 commented 2 years ago

The default color of bracket or the first layer of nested brackets is red which looks not so neat, as show in the screenshot. I find it's different with the color effect I've seen in some videos. Did I miss somewhere in config? image

p00f commented 2 years ago

Yes, the first colour is red. You can change it - https://github.com/p00f/nvim-ts-rainbow#installation-and-setup

p00f commented 2 years ago

red which looks not so neat

I just picked a set of colours from gruvbox, the user is expected to change it/use a colorscheme which changes it

xy9485 commented 2 years ago

I just picked a set of colours from gruvbox, the user is expected to change it/use a colorscheme which changes it

Thanks for the reply. So just changing colorschemes can also change the default order of rainbow colors?

Since I'm a newbie to this plugin, I'm also not sure what's the format for the content to change the color setting below(e.g. change the order of default availible colors). Could you provide an small example?

require'nvim-treesitter.configs'.setup{
  rainbow = {
    -- Setting colors
    colors = {
      -- Colors here
    },
    -- Term colors
    termcolors = {
      -- Term colors here
    }
  },
}
p00f commented 2 years ago

https://github.com/p00f/nvim-ts-rainbow/blob/a62dc50becf8b0fb4348fe02029b49247f9f3db7/lua/rainbow.lua#L13-L30

p00f commented 2 years ago

So just changing colorschemes can also change the default order of rainbow colors?

Some colorschemes support this plugin - https://sr.ht/~novakane/kosmikoa.nvim/, https://github.com/ishan9299/modus-theme-vim etc

xy9485 commented 2 years ago

https://github.com/p00f/nvim-ts-rainbow/blob/a62dc50becf8b0fb4348fe02029b49247f9f3db7/lua/rainbow.lua#L13-L30

I wonder if it works when only modifying termcolors and leaving colors commented? Actually I tried both by changing the order, didn't change colors of brackets. Would colorschemes force the order of color?

p00f commented 2 years ago

Termcolors is for terminal vim without guicolors - ie tty. You don't need that in modern terminals

Actually I tried both by changing the order, didn't change colors of brackets. Would colorschemes force the order of color?

paste your config please

xy9485 commented 2 years ago

Termcolors is for terminal vim without guicolors - ie tty. You don't need that in modern terminals

Actually I tried both by changing the order, didn't change colors of brackets. Would colorschemes force the order of color?

paste your config please

local status_ok, configs = pcall(require, "nvim-treesitter.configs")
if not status_ok then
  return
end

configs.setup {
  ensure_installed = "all", -- one of "all", "maintained" (parsers with maintainers), or a list of languages
  sync_install = false, -- install languages synchronously (only applied to `ensure_installed`)
  ignore_install = { "" }, -- List of parsers to ignore installing
  autopairs = {
    enable = true,
  },
  highlight = {
    enable = true, -- false will disable the whole extension
    disable = { "" }, -- list of language that will be disabled
    additional_vim_regex_highlighting = true,
  },
  indent = { enable = true, disable = { "yaml" } },
  context_commentstring = {
    enable = true,
    enable_autocmd = false,
  },
  rainbow = {
    enable = true,
    -- disable = { "jsx", "cpp" }, list of languages you want to disable the plugin for
    extended_mode = true, -- Also highlight non-bracket delimiters like html tags, boolean or table: lang -> boolean
    max_file_lines = nil, -- Do not enable for files with more than n lines, int
    colors = {
      "#a89984",
      "#cc241d",
      "#b16286",
      "#d79921",
      "#689d6a",
      "#d65d0e",
      "#458588",
    }, -- table of hex strings
    -- termcolors = {
    --   "Red",
    --   "Green",
    --   "Yellow",
    --   "Blue",
    --   "Magenta",
    --   "Cyan",
    --   "White",
    -- }, -- table of colour name strings
  }
}

for example I wanted to make green as the first choice, didn't work out. I use onedarkpro colorscheme which support many plugins including nvim-ts-rainbow Update: I paste the full setting of treesitter

p00f commented 2 years ago

https://github.com/olimorris/onedarkpro.nvim this? You can disable onedark highlighting using this https://github.com/olimorris/onedarkpro.nvim#configuring-plugins

This is the only way out, if I drop default https://github.com/p00f/nvim-ts-rainbow/blob/a62dc50becf8b0fb4348fe02029b49247f9f3db7/lua/rainbow/internal.lua#L138 here then users won't be able to manually override using hi rainbowcol1..

xy9485 commented 2 years ago

Yes, correct link. I might not fully understand, to disable onedark highlighting by configuring onedarkpro's plugin support? Can you explain more detailed? Does this operation independently solve the problem on your side, or is that change in internal.lua additionally needed? Honestly I prefer not to touch internal code since I don't want to make it ad-hoc. Btw, can I just use this hi rainbowcol1 guifg=#123456 to change the order of colors?

p00f commented 2 years ago

I might not fully understand, to disable onedark highlighting by configuring onedarkpro's plugin support?

yes

you dont need to touch internal.lua, just set the colors in your config: https://github.com/p00f/nvim-ts-rainbow#colours

xy9485 commented 2 years ago

You can disable onedark highlighting using this https://github.com/olimorris/onedarkpro.nvim#configuring-plugins

Sorry for my confussion on this point, I assume you refer to disabling nvim-ts-rainbow in onedarkpro's plugin configuration, is that correct?

p00f commented 2 years ago

yes

xy9485 commented 2 years ago

So I disabled nvim-ts-rainbow in oneardkpro, it does make some changes, but still doesn't match the order. For example with the config you gave before:

colors = {
      "#cc241d", --red
      "#a89984", --grey
      "#b16286", --Magenta
      "#d79921", --yellow
      "#689d6a", --green
      "#d65d0e", --orange
      "#458588", --cyan
    }, 

image And looks like the color order remains same if I change the order in config:

colors = {
      "#a89984", --grey
      "#cc241d", --red
      "#b16286", --Magenta
      "#d79921", --yellow
      "#689d6a", --green
      "#d65d0e", --orange
      "#458588", --cyan
    }, 

image

p00f commented 2 years ago

the colours in the picture look like onedark, not gruvbox. are you sure you did

require("onedarkpro").setup({
    plugins = {nvim_ts_rainbow = false}
})
xy9485 commented 2 years ago

Oh my bad, I did mistype onedark when requiring. Now it works, many thanks!!