GithubHelp home page GithubHelp logo

p00f / nvim-ts-rainbow Goto Github PK

View Code? Open in Web Editor NEW
871.0 11.0 67.0 1.03 MB

Rainbow parentheses for neovim using tree-sitter. Use https://sr.ht/~p00f/nvim-ts-rainbow instead

License: Apache License 2.0

Lua 74.09% Scheme 12.32% TypeScript 6.86% JavaScript 6.46% Vim Script 0.27%
neovim tree-sitter lua rainbow-parentheses rainbow-brackets

nvim-ts-rainbow's Introduction

NO LONGER MAINTAINED

This plugin is no longer maintained.

I'm archiving the GitHub repo and closing the sourcehut issue tracker. Feel free to fork

🌈 nvim-ts-rainbow 🌈

Rainbow parentheses for neovim using tree-sitter. This is a module for nvim-treesitter, not a standalone plugin. It requires and is configured via nvim-treesitter

Should work with any language supported by nvim-treesitter. If any language is missing, please open an issue/PR.

Only neovim nightly is targeted.

Warning/notice/whatever

The queries might be out of date at any time, keeping up with them for languages I don't use is not feasible. If you get errors like invalid node at position xxx, try removing this plugin first before opening an issue in nvim-treesitter. If it fixes the problem, open an issue/PR here.

Installation and setup

Install and set up nvim-treesitter according to their documentation. Install this plugin, then add a rainbow section in the call to require("nvim-treesitter.configs").setup():

require("nvim-treesitter.configs").setup {
  highlight = {
      -- ...
  },
  -- ...
  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 = {}, -- table of hex strings
    -- termcolors = {} -- table of colour name strings
  }
}

If you want to enable it only for some filetypes and disable it for everything else, see #30 (comment)

Colours

To change the colours you can set them in the setup:

require'nvim-treesitter.configs'.setup{
  rainbow = {
    -- Setting colors
    colors = {
      -- Colors here
    },
    -- Term colors
    termcolors = {
      -- Term colors here
    }
  },
}

If you want to override some colours (you can only change colours 1 through 7 this way), you can do it in your init.vim: (thanks @delphinus !). You can also use this while writing a colorscheme

hi rainbowcol1 guifg=#123456

Screenshots

  • Java

alt text

The screenshots below use a different colorscheme

  • Fennel:

alt text alt text

  • C++:

alt text

  • Latex (with tag begin-end matching)

alt text

Credits

Huge thanks to @vigoux, @theHamsta, @sogaiu, @bfredl and @sunjon and @steelsojka for all their help

nvim-ts-rainbow's People

Contributors

6cdh avatar alexander-p30 avatar aspeddro avatar c-a-v-a avatar decodetalkers avatar delphinus avatar dffdff2423 avatar gelio avatar github-actions[bot] avatar gordin avatar hiphish avatar joakker avatar lf- avatar lockejan avatar max397574 avatar nfrid avatar p00f avatar patrick96 avatar perigord-kleisli avatar qsdrqs avatar ram02z avatar reo101 avatar stevenproctor avatar sunjon avatar tbttfox avatar thehamsta avatar tzachar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nvim-ts-rainbow's Issues

Enable for all files

Hi! Thank you a lot for the plugin!
I have a question. Can a plugin be enabled for languages ​​that Treesetter does not currently support? For example, for Vimscript.

Add support for Common Lisp

Support for Common Lisp was recently added to Treesitter, I have already added the current main parens to my clone of the repo, the only ones necessary are square brackets and parenthesis.

Add more languages to levels.lua

I have configured this plugin to show custom colors and I want to make them appear in a certain order.
However, I get random order of appearance.

Screenshot from 2021-05-07 06-56-17

ts-rainbow throws an error when loading

I get the error below when opening a typescript file. Using the latest version of nvim-ts-rainbow.

Error detected while processing FileType Autocommands for "*":
E5108: Error executing lua ...ck/packer/start/nvim-ts-rainbow/lua/rainbow/internal.lua:45: attempt to index local 'query' (a nil value)

This plugin completely messes up my colourscheme

Hello, I installed this plugin, and its a very fun and helpful one, but it seems to mess up my colour scheme when I add the boilerplate code for HTML, here's a screenshot
image

and here is my config for rainbow

rainbow = {
    	enable = true,
    	extended_mode = true, -- Highlight also non-parentheses delimiters, boolean or table: lang -> boolean
    	max_file_lines = 1000, -- Do not enable for files with more than 1000 lines, int
    	colors = {
			"#ff003c",
			"#ca0bd4",
			"#e973f0",
			"#710578",
			"#780527",
			"#a600ff",
			"#eb445d"
		} -- table of hex strings
  	}

and I'm using this colour scheme btw https://github.com/monsonjeremy/onedark.nvim
Thanks

Can't get the plugin to work

Using latest nvim, tree-sitter and minimal config.
Does not work for any language, showing python and json.

json:
Screenshot from 2021-03-21 09-40-59

python:
Screenshot from 2021-03-21 09-38-54

also tried adding a python.scm to the parser, but it did not make any difference.

call plug#begin('~/.vim/plugged')                                                                                                                                             
                                                                                                                                                                              
Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'}                                                                                                                   
Plug 'p00f/nvim-ts-rainbow'                                                                                                                                                   
                                                                                                                                                                              
call plug#end()                                                                                                                                                               
                                                                                                                                                                              
                                                                                                                                                                              
lua << EOF                                                                                                                                                                    
require'nvim-treesitter.configs'.setup {                                                                                                                                      
  rainbow = {                                                                                                                                                                 
    enable = true                                                                                                                                                             
  }                                                                                                                                                                           
}                                                                                                                                                                             
EOF                                             

nvim version:

nvim --version
NVIM v0.5.0-dev+1165-ge5bef5974
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3
Compilation: /usr/bin/cc -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -O2 -g -Og -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=always -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/home/runner/work/neovim/neovim/build/config -I/home/runner/work/neovim/neovim/src -I/home/runner/work/neovim/neovim/.deps/usr/include -I/usr/include -I/home/runner/work/neovim/neovim/build/src/nvim/auto -I/home/runner/work/neovim/neovim/build/include
Compiled by runner@fv-az205-228

Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "
/home/runner/work/neovim/neovim/build/nvim.AppDir/usr/share/nvim"

Ocaml queries breaks `TSModuleInfo`

Steps to reproduce

  1. Run TSModuleInfo after nvim-ts-rainbow has been loaded
  2. Presented with the following error:
    E5018: Error executing lua /usr/share/nvim/runtime/lua/vim/treesitter/query.lua:161: query: invalid node type at position 142

Expected behavior
TSModuleInfo shouldn't throw an error.

Notes
After playing with the respective paren.scm file, turns out the the following line is causing the issue:

You can try removing that query and the error can't be reproduced anymore.

Screenshots
image

Plugin works heavily inconsistently

Describe the bug
Plugin works inconsistently - works fine on some languages or partly at others (i.e. only curly brackets colored)

Steps to reproduce
Absolute barebones setup - 3 plugins (packer.nvim, nvim-treesitter, nvim-ts-rainbow), absolute barebones config (enabled highlight and rainbow), no colorscheme, no other configurations whatsoever
image

Expected behavior
Colored brackets on something like {{{{{{}}}}}}, [[[]]], ((()))

Screenshots
image
It actually sometimes changes when disabling TS' highlight (in this case square brackets changed a bit)
image
Rust, for example, works perfectly fine (although notice that deepest pair of round brackets are blue instead of purple)
image
YAML doesn't work at all
image
Lua work partly
image

:checkhealth is fine, I also tried reinstalling treesitter completely...
NVIM v0.6.0-dev+324-ge8fb0728e
I am at loss about why it doesn't work honestly

Updating with vim-plug is broken

Doing :PlugUpdate with vim-plug has failed for me a couple of times recently, with the following error:

x nvim-ts-rainbow:
    fatal: Not possible to fast-forward, aborting.

When I check my local nvim-ts-rainbow repository, it seems that my copy is behind the GitHub repository by seven commits and ahead by three.

I don't make changes to my local repository, so I'm not sure how this happened. One possible explanation is that history in this repository gets rewritten with git push --force, which makes it impossible to update local remotes with a fast-forward only pull.

If this is what happened, could you please avoid this in the future to avoid breaking updates for your users? If this isn't what happened, it'd be useful to know what did so I can try to fix it. Thanks!

enable for only a single language or list of languages

Hi πŸ‘‹πŸΏ thanks for your work on this plugin.

I've just moved over from luochen1990's plugin and I'm wondering if it's possible to enable this plugin for only a few filetypes primarily since there are only a few languages I use that tend to get a little unmanageable with their parens (e.g. lisps) but for things like lua I don't really need this functionality.

C++ Function {} becomes gray with Neoformat clang-format

C++ Function {} becomes gray with Neoformat clang-format


  1. change some {} position:
    image
  2. use Neoformat cmd:
    image

nvim: 0.6
rainbow:lastest

myconfig:

rainbow = {
    enable = true,
    extended_mode = true, -- Highlight also non-parentheses delimiters, boolean or table: lang -> boolean
    max_file_lines = 1000 -- Do not enable for files with more than 1000 lines, int
},
-- packer
editor['p00f/nvim-ts-rainbow'] = {
    opt = true,
    after = 'nvim-treesitter',
    event = 'BufRead'
}

How should I fix this?

Rails string concat

Hi,
thanks for your plugins, work perfect with indent-blankline context features.

I have a problem with ruby (to be precise with ruby on rails), it's works perfect with all "brackets situation" except for this case

bracket

Probably the format #{ } break the functionality.

consider moving initialisation to lua

I like the plugin very much. Thanks alot for creating!

Reasons to do:

  1. A pure lua profile would decrease startup time.
  2. The lua startup profiler would be more correct or simpler to get correct with this change. Otherwise one gets more wrong results.
  3. Try to be consistent as to use functionality of lua, if possible.
  4. Having a function to initialize makes separating things for user-specific settings while getting updates much easier (user may implement a different function to customize plugin).

Another related reason (bad practice/historical reasons): nvim-treesitter/module-template#1

Relevant content for change:
https://github.com/nanotee/nvim-lua-guide#using-meta-accessors-1

throw error when editing rust file

when i enable this plugin, then edit the rust file. nvim throw error:

Error executing lua callback: /usr/local/share/nvim/runtime/lua/vim/treesitter/query.lua:272: invalid start

I am using:
NVIM v0.5.0-888-g8b2887bd5
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3

[bug] error loading rainbow module from treesitter

this error occurs after manually loading using TSBufEnable rainbow

E5108: Error executing lua ...er/start/nvim-treesitter/lua/nvim-treesitter/configs.lua:
424: loop or previous error loading module 'rainbow.internal'

because by default it doesnt load properly.

my TS config:

require"nvim-treesitter.configs".setup {
    autopairs = { enable = true },
    ensure_installed = "maintained", -- one of "all", "maintained" (parsers with maintainers), or a list of languages
    ignore_install = {}, -- List of parsers to ignore installing
    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
    },
    incremental_selection = {
        enable = false,
        keymaps = {
            init_selection = "gnn",
            node_incremental = "grn",
            scope_incremental = "grc",
            node_decremental = "grm"
        }
    },
    indent = { enable = true },
    autotag = {
        enable = true,
        filetypes = {
            "html",
            "javascript",
            "javascriptreact",
            "typescriptreact",
            "svelte",
            "vue",
            "xml"
        }
    },
    rainbow = {
        enable = true,
        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 = {
            "#cc241d",
            "#a89984",
            "#b16286",
            "#d79921",
            "#689d6a",
            "#d65d0e",
            "#458588"
        }, -- table of hex strings
        termcolors = {
			"red",
			"yellow"
		} -- table of colour name strings
    }
    -- nvimGPS = {
    -- 	enable = true
    -- }
}

all parses are installed. so its not a problem with parsers.

plugin is installed using packer

	use { "p00f/nvim-ts-rainbow" }

when opening neovim i dont get any errors, but rainbow doesnt work because brackets are not colored. maybe because treesitter failed to load it and decided to not tell me anything about it.

after loading module manually it throws error.

is there a setup function for this plugin, to load it manually?

how do i fix the bug?

Q: Shouldn't color depend on level of nesting, instead of order of appearance in buffer?

Note that this may be a duplicate of #33.

I believe the value in coloring parenthesis is in differentiating level of nesting, and should be identical between two sets of parenthesis. I want to be able to look at nested parenthesis and immediately identify the level of nesting of each parenthesis. That doesn't seem to be the case. But maybe I'm misunderstanding the point.

For the sake of argument, lets say we have three colors:

rainbowcol1 = gray
rainbowcol2 = red
rainbowcol3 = green

And three sets of parenthesis:

()
(())
((()))

I would expect them to be colored like this:

image

How they are actually colored is something like this:

image

Is that a bug, or expected behavior?

Parentheses aren't colored for Fennel

Describe the bug
For fennel, parentheses are not colored. They maintain the default syntax color

Steps to reproduce
Install Fennel parser with nvim-treesitter along with this plugin with the default settings

Expected behavior
Parentheses should be colored like brackets and curly brackets, they are not

Screenshots
2021-09-22~13:27:26

Wrong colors after last update

Hello,

I just updated using :PackerUpdate and the colors of the function keyword in lua and parenthesis of functions became red.
Similar behaviour in python for some brackets and parenethesis.

Expected behaviour (before update):
image

Current behaviour:
image

Thank you in advance.

Performance issues

When I enable this plugin and type words, coc's auto completion become very slow and broken. After this, cursor moving also get lag. When I disable it, every thing works well.

Reloading rainbow

Expected behaviour:

change colorscheme while vim is running.
ts-rainbow still continues to work

Actual behaviour:

Change colorscheme while nvim running.
rainbow no more. The colors of parenthesis are back to vanilla Treesitter

Steps to reproduce

  1. Change colorscheme (or in some cases change background to light) when vim is running
  2. Same error on resourcing vimrc

Neovim freezes in large file when only opening bracket is inserted

Describe the bug

I'm seeing extremely slow performance inserting ([ around line 150 in a ~1600 line file. It takes ~20 seconds for the [ to insert. 😡

Steps to reproduce

  1. Open https://github.com/rouge8/jit.rs/blob/2a3e5dbc7d603f465c1f3083c655613d9a69b87d/tests/merge_test.rs#L147
  2. After line 147, type let tree = BTreeMap::from([
  3. Wait ~20 seconds after typing the [ before it appears.

Expected behavior

Text should insert instantly.

[Documentation] Needs help - plugin configuration problems

Where it is stated in the documentation to use the require statement after installing, it is not clear why it won't work to new users (new nvim user here, formerly a well established vim user trying to switch πŸ˜† ).

I would like to add a clarity note that after the plugin is installed, specifically with vim-plug that the require statement must be made after plug#end.

I also did not know I needed to pipe it through lua <<EOF <code goes here> EOF for it to accept it.

Maybe provide this as a sample:

" Example using vim-plug to install the plugins

" Start installing plugins using vim-plug
call plug#begin('~/.config/nvim/plugins')

" Install plugins
Plug 'nvim-treesitter/nvim-treesitter'
Plug 'p00f/nvim-ts-rainbow'

" Finish installing plugins with vim-plug
call plug#end()

" Configure nvim-treesitter
lua <<EOF
require'nvim-treesitter.configs'.setup {
  ensure_installed = "maintained", -- one of "all", "maintained" (parsers with maintainers), or a list of languages
  -- ignore_install = {}, -- List of parsers to ignore installing
  highlight = {
    enable = true,              -- false will disable the whole extension
    -- disable = {},  -- 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,
  },
}
EOF

" Configure nvim-ts-rainbow
lua <<EOF
require'nvim-treesitter.configs'.setup {
  rainbow = {
    enable = true,
    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 = {}, -- table of hex strings
    -- termcolors = {} -- table of colour name strings
  }
}
EOF

Treesitter must also be configured before this plugin is configured or it will not work.

It should also be noted that this plugin will not work unless treesitter has the linter for the language of the file that is open, therefore if treesitter does not contain the language, then this plugin will not work on that type of file.

The code above only configures it to work for the languages in treesitter that are listed as maintained, for full coverage by all languages in treesitter, set maintained to all.

Thoughts on the documentation updates?

Git Issues (with Packer)

Hello,
I am using this plugin (absolutely love it), and installed with Packer. A couple times in the past week I have gotten issues with this plugin while updating (via :PackerSync) with git saying fatal: refusing to merge unrelated histories. I tried going into the git directory directly, and get the same thing when I run git pull. Do you have any idea why this would be happening? Is this an issue in Packer, have there been force pushes here or something? This is the only plugin showing this behavior

Doesn't Seem to Work in NVIM v0.7.0

Describe the bug
Bracket and parethesis no longer show different colors. Adding custom colors doesn't change this.

Steps to reproduce
Install:
Neovim v.0.7.0
tree-sitter 0.20.2
neovim-tree-sitter (git version)
Arch Linux OS

Expected behavior
What used to happend would be bracket, parenthises, and other pairings would have different color combination throughout the document to easily see where a pair occurs using tree-sitter.

Now that feature no longer works
screenshot

Screenshots
If applicable, add screenshots to help explain your problem.

No rainbow on Terraform/HCL files.

I have extended_mode configured as true, but do not see any rainbow parens set on my .tf files, and I have hcl installed for TreeSitter.

When I open up Fennel and Clojure files I see the pretty rainbow, but not when in Terraform files.

Are there any other things that I should check on settings to help give feedback on why they are not showing.

Thanks!

[Documentation/Feature] Enable only to certain languages

I only want to enable this plugin for clojure, because I find the colours to be distracting in non-lisp languages.
Is there a way to do so?

P.S: Which is the colorscheme used on the latter screenshots, and which colours for the rainbows is it using?

Standard install not working

Describe the bug
Installed as per the readme but see no rainbow brackets (tried CSS/TS). Tried with both Tokyo Night and Everforest themes.

Using NVIM v0.6.0-dev+1607-g7d2233fad

:TSConfigInfo output:

{                                                                                                                            
  ensure_installed = {},                                                                                                     
  ignore_install = {},                                                                                                       
  modules = {                                                                                                                
    highlight = {                                                                                                            
      additional_vim_regex_highlighting = false,                                                                             
      custom_captures = {},                                                                                                  
      disable = { "markdown" },                                                                                              
      enable = true,                                                                                                         
      loaded = true,                                                                                                         
      module_path = "nvim-treesitter.highlight"                                                                              
    },                                                                                                                       
    incremental_selection = {                                                                                                
      disable = {},                                                                                                          
      enable = false,                                                                                                        
      keymaps = {                                                                                                            
        init_selection = "gnn",                                                                                              
        node_decremental = "grm",                                                                                            
        node_incremental = "grn",                                                                                            
        scope_incremental = "grc"                                                                                            
      },                                                                                                                     
      module_path = "nvim-treesitter.incremental_selection"                                                                  
    },                                                                                                                       
    indent = {                                                                                                               
      disable = {},                                                                                                          
      enable = false,                                                                                                        
      module_path = "nvim-treesitter.indent"                                                                                 
    },                                                                                                                       
    rainbow = {                                                                                                              
      colors = {},                                                                                                           
      disable = {},                                                                                                          
      enable = true,                                                                                                         
      extended_mode = true,                                                                                                  
      loaded = true,                                                                                                         
      module_path = "rainbow.internal",                                                                                      
      termcolors = {}                                                                                                        
    }                                                                                                                        
  },                                                                                                                         
  update_strategy = "lockfile"                                                                                               
}  

Also tried moving setup until after the colorscheme is set but makes no difference.

Steps to reproduce
Using this init.lua where everything else works as expected: https://gist.github.com/benfrain/97f2b91087121b2d4ba0dcc4202d252f try opening TS/CSS file

Expected behavior
To see rainbow brackets

Screenshots
image

Overwriting colors not getting applied

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

Add support for custom delimeters?

I would like to suggest a feature to add support for specifying custom left and right delimeters, for example \left( and \right) pairs in LaTeX. It seems like \( and \) have already been implemented.

bash errors

when alias s= is added to

PATH=$PATH:~/.local/bin
PATH=$PATH:~/.local/bin/goneovim
PATH=$PATH:~/.gem/ruby/2.7.0/bin
export GPG_TTY=$(tty)
export DIFFPROG='nvim -d'

Error executing lua callback: /usr/share/nvim/runtime/lua/vim/treesitter/query.lua:198: attempt to index local 'node' (a nil value) is thrown on every keystroke (even backspace)

@vigoux (i hope you don't mind me tagging you, stuff gets lost in zulip πŸ˜… )

W:18 Invalid character in group name

The editor throws this message as soon as it displays any () or {} with rainbow turned on. This started happening after updating to NVIM v0.5.0-dev+1197-ga17782042

Not working with typescript

Hi friends i have this module installed but it does not seem to be working for typescript .ts files. To be honest im not even sure if tree-sitter is working at all, ive noticed no difference, but the rainbow parenthesis color is deff no working.

init.vim

lua << EOF
require'nvim-treesitter.configs'.setup {
  rainbow = {
    enable = true,
    extended_mode = true, -- Highlight also non-parentheses delimiters, boolean or table: lang -> boolean
    max_file_lines = 1000, -- Do not enable for files with more than 1000 lines, int
  }
}
EOF

:TSConfigInfo

{                                                                                                                                                                                                                           
  ensure_installed = {},
  ignore_install = {},
  modules = {
    highlight = {
      additional_vim_regex_highlighting = false,
      custom_captures = {},
      disable = { "c", "rust" },
      enable = true,
      loaded = true,
      module_path = "nvim-treesitter.highlight"
    },
    incremental_selection = {
      disable = {},
      enable = false,
      keymaps = {
        init_selection = "gnn",
        node_decremental = "grm",
        node_incremental = "grn",
        scope_incremental = "grc"
      },
      module_path = "nvim-treesitter.incremental_selection"
    },
    indent = {
      disable = {},
      enable = false,
      module_path = "nvim-treesitter.indent"
    },
    rainbow = {
      enable = true,
      extended_mode = true,
      max_file_lines = 1000
    }
  },
  update_strategy = "lockfile"
}

image

:checkhealth nvim_treesitter

health#nvim_treesitter#check
========================================================================
## Installation
  - OK: `tree-sitter` found  0.19.5 (8d8690538ef0029885c7ef1f163b0e32f256a5aa) (parser generator, only needed for :TSInstallFromGrammar)
  - OK: `node` found v12.18.3 (only needed for :TSInstallFromGrammar)
  - OK: `git` executable found.
  - OK: `cc` executable found. Selected from { vim.NIL, "cc", "gcc", "clang", "cl" }
  - OK: Neovim was compiled with tree-sitter runtime ABI version 13 (required >=13). Parsers must be compatible with runtime ABI.

## Parser/Features H L F I
  - c_sharp        βœ“ . βœ“ . βœ“ 
  - bibtex         βœ“ . βœ“ βœ“ . 
  - python         βœ“ βœ“ βœ“ βœ“ βœ“ 
  - r              βœ“ βœ“ . . . 
  - comment        βœ“ . . . . 
  - lua            βœ“ βœ“ βœ“ βœ“ βœ“ 
  - ocaml          βœ“ βœ“ βœ“ . βœ“ 
  - go             βœ“ βœ“ βœ“ βœ“ βœ“ 
  - scss           βœ“ . . βœ“ . 
  - json           βœ“ βœ“ βœ“ βœ“ . 
  - jsdoc          βœ“ . . . . 
  - ledger         βœ“ . βœ“ βœ“ βœ“ 
  - php            βœ“ βœ“ βœ“ βœ“ βœ“ 
  - clojure        βœ“ βœ“ βœ“ . βœ“ 
  - supercollider  βœ“ βœ“ βœ“ βœ“ βœ“ 
  - typescript     βœ“ βœ“ βœ“ βœ“ βœ“ 
  - fennel         βœ“ βœ“ . . βœ“ 
  - query          βœ“ βœ“ βœ“ βœ“ βœ“ 
  - cpp            βœ“ βœ“ βœ“ βœ“ βœ“ 
  - vue            βœ“ . βœ“ . βœ“ 
  - latex          βœ“ . βœ“ . . 
  - rst            βœ“ βœ“ . . βœ“ 
  - css            βœ“ . βœ“ βœ“ βœ“ 
  - zig            βœ“ βœ“ βœ“ βœ“ βœ“ 
  - erlang         . . . . . 
  - regex          βœ“ . . . . 
  - svelte         βœ“ . βœ“ βœ“ βœ“ 
  - c              βœ“ βœ“ βœ“ βœ“ βœ“ 
  - fortran        βœ“ . βœ“ βœ“ . 
  - teal           βœ“ βœ“ βœ“ βœ“ βœ“ 
  - java           βœ“ βœ“ . βœ“ βœ“ 
  - gomod          βœ“ . . . . 
  - dart           βœ“ βœ“ . βœ“ βœ“ 
  - verilog        βœ“ βœ“ βœ“ . βœ“ 
  - bash           βœ“ βœ“ βœ“ . βœ“ 
  - yaml           βœ“ βœ“ βœ“ βœ“ βœ“ 
  - julia          βœ“ βœ“ βœ“ . βœ“ 
  - turtle         βœ“ βœ“ βœ“ βœ“ βœ“ 
  - html           βœ“ βœ“ βœ“ βœ“ βœ“ 
  - beancount      βœ“ . βœ“ . . 
  - commonlisp     βœ“ βœ“ βœ“ . . 
  - swift          . . . . . 
  - glimmer        βœ“ . . . . 
  - elm            . . . . . 
  - ocaml_interfaceβœ“ βœ“ βœ“ . βœ“ 
  - cuda           βœ“ βœ“ βœ“ βœ“ . 
  - haskell        . . . . . 
  - ocamllex       βœ“ . . . βœ“ 
  - kotlin         βœ“ . . . βœ“ 
  - ruby           βœ“ βœ“ βœ“ βœ“ βœ“ 
  - fish           βœ“ βœ“ βœ“ βœ“ βœ“ 
  - devicetree     βœ“ βœ“ βœ“ βœ“ βœ“ 
  - scala          . . . . . 
  - dockerfile     βœ“ . . . βœ“ 
  - rust           βœ“ βœ“ βœ“ βœ“ βœ“ 
  - toml           βœ“ βœ“ βœ“ βœ“ βœ“ 
  - ql             βœ“ βœ“ . βœ“ βœ“ 
  - javascript     βœ“ βœ“ βœ“ βœ“ βœ“ 
  - nix            βœ“ βœ“ βœ“ . βœ“ 
  - jsonc          βœ“ βœ“ βœ“ βœ“ βœ“ 
  - graphql        βœ“ . . βœ“ βœ“ 
  - gdscript       βœ“ βœ“ . . βœ“ 
  - sparql         βœ“ βœ“ βœ“ βœ“ βœ“ 
  - tsx            βœ“ βœ“ βœ“ βœ“ βœ“ 

 Legend: H[ighlight], L[ocals], F[olds], I[ndents]
         +) multiple parsers found, only one will be used
         x) errors found in the query, try to run :TSUpdate {lang}

Not working at all

Describe the bug
There are no colors for matching brackets

Steps to reproduce
Install tree sitter,
(via vim plug) install p00f/nvim-ts-rainbow
open a jsx file.

lua <<EOF
require'nvim-treesitter.configs'.setup {
    ensure_installed = "maintained",
    highlight = {
      enable = true,
      additional_vim_regex_highlighting = true,
    },
    incremental_selection = {
        enable = true,
        keymaps = {
            init_selection = "<leader>so",
            node_incremental = "<leader>",
            scope_incremental = "grc",
            node_decremental = "grm",
        },
    autotag = {
        enable = true,
    },
    rainbow = {
    enable = true,
    termcolors = {
          "#E06C75",
          "#E5C07B",
          "#98C379",
          "#56B6C2",
          "#61AFEF",
          "#C678DD",
          "#E06C75"
        },
      colors = {
            "#E06C75",
            "#E5C07B",
            "#98C379",
            "#56B6C2",
            "#61AFEF",
            "#C678DD",
            "#E06C75"
          },
      extended_mode = true,
      max_file_lines = 1000,
    },
    indent = {
      enable = true
    },
    }
}
EOF

**extra info:
:lua print(vim.inspect(colors))
Returns null nil

Expected behavior
Brackets should be colored.

Screenshots
image

TypeScript only matches <>

The queries for TypeScript should include all the ones for javascript too.

Right now, only < and > are matched.

ts-rainbow stopped working for me

Describe the bug

Rainbow parenthesis stopped working for me. I need some help to debug it. The strange thing is that TSConfigInfo tells me it is loaded an active.

TSConfigInfo

{                                                                                                                                                                                            
  ensure_installed = {},                                                                                                                                                                     
  ignore_install = {},                                                                                                                                                                       
  modules = {                                                                                                                                                                                
    highlight = {                                                                                                                                                                            
      additional_vim_regex_highlighting = false,                                                                                                                                             
      custom_captures = {},                                                                                                                                                                  
      disable = { "markdown" },                                                                                                                                                              
      enable = true,                                                                                                                                                                         
      loaded = true,                                                                                                                                                                         
      module_path = "nvim-treesitter.highlight"                                                                                                                                              
    },                                                                                                                                                                                       
    incremental_selection = {                                                                                                                                                                
      disable = {},                                                                                                                                                                          
      enable = false,                                                                                                                                                                        
      keymaps = {                                                                                                                                                                            
        init_selection = "gnn",                                                                                                                                                              
        node_decremental = "grm",                                                                                                                                                            
        node_incremental = "grn",                                                                                                                                                            
        scope_incremental = "grc"                                                                                                                                                            
      },                                                                                                                                                                                     
      module_path = "nvim-treesitter.incremental_selection"                                                                                                                                  
    },                                                                                                                                                                                       
    indent = {                                                                                                                                                                               
      disable = {},                                                                                                                                                                          
      enable = false,                                                                                                                                                                        
      module_path = "nvim-treesitter.indent"                                                                                                                                                 
    },                                                                                                                                                                                       
    rainbow = {                                                                                                                                                                              
      colors = { "#bf616a", "#d08770", "#ebcb8b", "#a3be8c", "#88c0d0", "#5e81ac", "#b48ead" },                                                                                              
      disable = {},                                                                                                                                                                          
      enable = true,                                                                                                                                                                         
      extended_mode = true,                                                                                                                                                                  
      loaded = true,                                                                                                                                                                         
      max_file_lines = 2500,                                                                                                                                                                 
      module_path = "rainbow.internal"                                                                                                                                                       
    }                                                                                                                                                                                        
  },                                                                                                                                                                                         
  update_strategy = "lockfile"                                                                                                                                                               
}

I've also tried to turn it of manually with

:TSDisableAll rainbow
:TSEnableAll rainbow

But it doesn't fix it. Help is much appreciated!

Steps to reproduce
Config: https://git.cryptomilk.org/users/asn/dotfiles.git/tree/nvim/.config/nvim

Expected behavior
Use use different colors for parenthesis

Screenshots
rainbow

Unable to properly configure

Describe the bug
After install the plugin and adding config to treesitter config I get this. I'm kind of at a loss. Other plugins work as expected and packer shows both nvim-treesitter and nvim-ts-rainbow installed and loaded. I don't see it listed under modules using TSModuleInfo.

Error detected while processing /Users/brandon/.local/share/nvim/site/pack/packer/start/nvim-ts-rainbow/plugin/rainbo
w.vim:
line    1:
E5108: Error executing lua ...m/site/pack/packer/start/nvim-ts-rainbow/lua/rainbow.lua:1: module 'nvim-treesitter.que
ry' not found:
        no field package.preload['nvim-treesitter.query']
        no file './nvim-treesitter/query.lua'
        no file '/opt/homebrew/Cellar/luajit-openresty/2.1-20210510/share/luajit-2.1.0-beta3/nvim-treesitter/query.lu
a'
        no file '/usr/local/share/lua/5.1/nvim-treesitter/query.lua'
        no file '/usr/local/share/lua/5.1/nvim-treesitter/query/init.lua'
        no file '/opt/homebrew/Cellar/luajit-openresty/2.1-20210510/share/lua/5.1/nvim-treesitter/query.lua'
        no file '/opt/homebrew/Cellar/luajit-openresty/2.1-20210510/share/lua/5.1/nvim-treesitter/query/init.lua'
        no file '/Users/brandon/.cache/nvim/packer_hererocks/2.1.0-beta3/share/lua/5.1/nvim-treesitter/query.lua'
        no file '/Users/brandon/.cache/nvim/packer_hererocks/2.1.0-beta3/share/lua/5.1/nvim-treesitter/query/init.lua
'
        no file '/Users/brandon/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/luarocks/rocks-5.1/nvim-treesitter/query
.lua'
        no file '/Users/brandon/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/luarocks/rocks-5.1/nvim-treesitter/query
/init.lua'
        no file './nvim-treesitter/query.so'
        no file '/usr/local/lib/lua/5.1/nvim-treesitter/query.so'
        no file '/opt/homebrew/Cellar/luajit-openresty/2.1-20210510/lib/lua/5.1/nvim-treesitter/query.so'
        no file '/usr/local/lib/lua/5.1/loadall.so'
        no file '/Users/brandon/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/lua/5.1/nvim-treesitter/query.so'
        no file './nvim-treesitter.so'
        no file '/usr/local/lib/lua/5.1/nvim-treesitter.so'
        no file '/opt/homebrew/Cellar/luajit-openresty/2.1-20210510/lib/lua/5.1/nvim-treesitter.so'
        no file '/usr/local/lib/lua/5.1/loadall.so'
        no file '/Users/brandon/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/lua/5.1/nvim-treesitter.so'
stack traceback:
        [C]: in function 'require'
        ...m/site/pack/packer/start/nvim-ts-rainbow/lua/rainbow.lua:1: in main chunk
        [C]: in function 'require'
        [string ":lua"]:1: in main chunk

Steps to reproduce
Install through packer

  use { 
    "p00f/nvim-ts-rainbow",
    opt = false      
  }

Treesitter Config

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

ts_config.setup {
   ensure_installed = "maintained",
   highlight = {
      enable = true,
      use_languagetree = true,
   },
   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 = {}, -- table of hex strings
      -- termcolors = {} -- table of colour name strings
  }
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.