HiPhish / nvim-ts-rainbow2

Rainbow delimiters for Neovim through Tree-sitter
https://gitlab.com/HiPhish/nvim-ts-rainbow2
Apache License 2.0
338 stars 35 forks source link

ts-rainbow not found #38

Closed cova-fe closed 1 year ago

cova-fe commented 1 year ago

Describe the bug

I'm trying to use this module with lunarvim setup. However, on startup I get this error:

16:43:36 [WARN ] lvim: "Invalid configuration: /home/cova/.config/lvim/config.lua:311: module 'ts-rainbow' not found:\n\tno field package.preload['ts-rainbow']\n\tno file './ts-rainbow.lua'\n\tno file
 '/usr/share/luajit-2.1.0-beta3/ts-rainbow.lua'\n\tno file '/usr/local/share/lua/5.1/ts-rainbow.lua'\n\tno file '/usr/local/share/lua/5.1/ts-rainbow/init.lua'\n\tno file '/usr/share/lua/5.1/ts-rainbow
.lua'\n\tno file '/usr/share/lua/5.1/ts-rainbow/init.lua'\n\tno file './ts-rainbow.so'\n\tno file '/usr/local/lib/lua/5.1/ts-rainbow.so'\n\tno file '/usr/lib64/lua/5.1/ts-rainbow.so'\n\tno file '/usr/
local/lib/lua/5.1/loadall.so'" file="[C]", line=-1

And it seems not completely off, as the ts-rainbow.lua is not present, only rainbow.ts can be found searching in plugins directory. Please note that lunarvim uses Lazy to load plugins, not Packer. I can investigate if the issue can be related to Lazy, not sure if the error above can be related to Lazy, though. Steps to reproduce I use this configuration in config.lua:

  { "HiPhish/nvim-ts-rainbow2",
    lazy = true,
    require('nvim-treesitter.configs').setup {
      rainbow = {
        enable = true,
        -- list of languages you want to disable the plugin for
        disable = { 'jsx', 'cpp' },
        -- Which query to use for finding delimiters
        query = 'rainbow-parens',
        -- Highlight the entire buffer all at once
        strategy = require('ts-rainbow').strategy.global,
      },
    },
  },

Expected behavior

No error in loading plugin.

Screenshots rainbow

cova-fe commented 1 year ago

Never mind, I found that I had to enclose the configuration in a function block. Here it is, in case someone gets the same issue with lazy:

  {
    "HiPhish/nvim-ts-rainbow2",
    config = function()
      -- lazy = true,
      require('nvim-treesitter.configs').setup {
        rainbow = {
          enable = true,
          -- list of languages you want to disable the plugin for
          disable = { 'jsx', 'cpp' },
          -- Which query to use for finding delimiters
          query = 'rainbow-parens',
          -- Highlight the entire buffer all at once
          strategy = require('ts-rainbow').strategy.global,
        },
      }
    end
  },