polirritmico / telescope-lazy-plugins.nvim

🧭 A Telescope picker to quickly access configurations of plugins managed by lazy.nvim.
MIT License
53 stars 1 forks source link

checkhealth :telescope fails for some reason #11

Closed i3d closed 3 months ago

i3d commented 3 months ago

This is a bit of continuous investigation of https://github.com/polirritmico/telescope-lazy-plugins.nvim/issues/10

As recommended to run checkhealth, I did try and looks like it started produce error immedaitely, here is the log

Running healthchecks...
E5009: Invalid $VIMRUNTIME: /home/i3d/.local/share/nvim/runtime
Error executing lua: function health#telescope#check, line 1: Vim(lua):E5108: Error executing lua ...m/lua/telescope/_extensions/lazy_plugins/healthcheck.lua:31: bad argument #1 to 'fs_stat' (string expected, got nil)
stack traceback:
        [C]: in function 'fs_stat'
        ...m/lua/telescope/_extensions/lazy_plugins/healthcheck.lua:31: in function 'extension_healthcheck'
        .../share/nvim/lazy/telescope.nvim/lua/telescope/health.lua:126: in function 'check'
        [string ":lua"]:1: in main chunk
        [C]: in function 'call'
        .../home/jimxu/.local/share/nvim/runtime/lua/vim/health.lua:366: in function '_check'
        [string "<nvim>"]:1: in main chunk
stack traceback:
        [C]: in function 'call'
        .../home/jimxu/.local/share/nvim/runtime/lua/vim/health.lua:366: in function '_check'
        [string "<nvim>"]:1: in main chunk

I have not yet dug into it too much, just wanted to report here. Is there any new config that required to make the plugin work properly? [the README seems to still have the simplest one without any additional required config, and that's what I followed so far]

This could also be just something not configured correctly on my end though, but it would be nice if I could figure out what that might be...

i3d commented 3 months ago

oh btw, that

Can't find 'sainnhe/gruvbox-material' from line 1 inside the '/home/i3d/.config/nvim/lua/plugins/color.lua' file. Maybe a duplicate fragment.

still exist after new session started but apparently no harm to the function of the plugin... I will also try to dig it a bit more and see what might be the cause.

i3d commented 3 months ago

for context, prior to this, I completely removed the plugin, reinstalled without the 'post-11.0' branch, should be a fresh new installment though.

i3d commented 3 months ago

ok, for checkhealth, is like this

if not (vim.uv or vim.loop).fs_stat(opts.lazy_config) then

seems like you do expect lazy_config to be required? I didn't provide that value.

i3d commented 3 months ago

ok, so I printed out the local opts in the checkhealth.lua

Running healthchecks...
{
  custom_entries = {},
  ignore_imports = {},
  live_grep = {},
  mappings = {
    i = {
      ["<C-g>l"] = <function 1>,
      ["<C-g>r"] = <function 2>,
      ["<C-g>x"] = <function 3>
    },
    n = {
      gl = <function 1>,
      gr = <function 2>,
      gx = <function 3>
    }
  },
  name_only = true,
  picker_opts = {
    layout_config = {
      flex = {
        flip_columns = 150
      },
      horizontal = {
        preview_width = { 0.55,
          max = 100,
          min = 30
        }
      },
      vertical = {
        preview_cutoff = 20,
        preview_height = 0.5
      }
    },
    layout_strategy = "flex",
    sorting_strategy = "ascending"
  },
  show_disabled = true
}
E5009: Invalid $VIMRUNTIME: /home/i3d/.local/share/nvim/runtime
Error executing lua: function health#telescope#check, line 1: Vim(lua):E5108: Error executing lua ...m/lua/telescope/_extensions/lazy_plugins/healthcheck.lua:33: bad argument #1 to 'fs_stat' (string expected, got nil)
stack traceback:
        [C]: in function 'fs_stat'
        ...m/lua/telescope/_extensions/lazy_plugins/healthcheck.lua:33: in function 'extension_healthcheck'
        .../share/nvim/lazy/telescope.nvim/lua/telescope/health.lua:126: in function 'check'
        [string ":lua"]:1: in main chunk
        [C]: in function 'call'

for some reason, the lazy_config does not seem to be there at all.

polirritmico commented 3 months ago

Hi! Thanks for the bug report.

No, there's no new config needed. If lazy_config is not set, it should use the default value:

  lazy_config = vim.fn.stdpath("config") .. "/lua/config/lazy.lua",

Could you share the telescope-lazy-plugins' config you are using?

polirritmico commented 3 months ago

Oh. Also could you confirm that the plugin is loaded before executing the healthcheck?

i3d commented 3 months ago

So I currently don't really have any specific config added other than the simplest one [without an entry of opts or extensions = {...} or whatnot].

Though, I did try to add the opts you showed [and for comparison I also tried to use the extensions = { ... } style] and it seems that they do seem to produce some difference...

So if I do this style

  opts = {
    extensions = {
      lazy_plugins = {
        lazy_config = '/home/i3d/.vim/init.lua", -- path to the file containing the lazy spec and setup() call.
        ...
      },
    },
    -- etc.
  },

For some reason, we observe the outcome of the actual config table without the lazy_config value and it raises ERROR ... But if I do this style,

      require('telescope').setup({
        extensions = {
          lazy_plugins = {
            lazy_config = "/home/i3d/.vim/init.lua",
            ... 
          },
        },
      })

I no longer have the ERROR, instead I will see this config table

Running healthchecks...
:checkhealth telescope
Running healthchecks...
{
  custom_entries = {},
  ignore_imports = {},
  lazy_config = "/home/i3d/.vim/init.lua",
  lazy_spec_table = "/home/i3d/.vim/init.lua",
  live_grep = {},
  mappings = {
    i = {
      ["<C-g>l"] = <function 1>,
      ["<C-g>r"] = <function 2>,
      ["<C-g>x"] = <function 3>
    },
    n = {
      gl = <function 1>,
      gr = <function 2>,
      gx = <function 3>
    }
  },
  name_only = true,
  picker_opts = {
    layout_config = {
      flex = {
        flip_columns = 150
      },
      horizontal = {
        preview_width = { 0.55,
          max = 100,
          min = 30
        }
      },
      vertical = {
        preview_cutoff = 20,
        preview_height = 0.5
      }
    },
    layout_strategy = "flex",
    sorting_strategy = "ascending"
  },
  show_disabled = true
}

As you can see, the lazy_config and other config are preserved. This is a VERY interesting observation.

i3d commented 3 months ago

In order to provide you a bit more context, here are the init.lua file and the telescope.lua file that I have initandtelescope tar bz2

polirritmico commented 3 months ago

Could you check the latest update?

Edit: I've downloaded the file. I'm going to look into it.

i3d commented 3 months ago

Ok, for the from line ... superfluous warning message, I found the bug. You should change the finder.lua search to this

if string.find(line_str, search_str:gsub("[\"']", ""), 1, true)

Basically, the input search_str has double quotes but the string in the file has single quotes, they wouldn't match. :)

i3d commented 3 months ago

yeap, with the latest update, using the require('telescope').setup({...}) stype, checkhealth report correctly found everything [other than the superfluous warning, which shall be solved after the quote thing solved]. So I think that's good news. If I use the opts = { ... } way to spec the config, I still get the ERROR No Lazy configuration file found. (Set in lazy_config) error in checkhealth.

polirritmico commented 3 months ago

Basically, the input search_str has double quotes but the string in the file has single quotes, they wouldn't match. :)

Nice catch!

Fixed by 42cebb3

I'm going to look the opts issue now. Thanks for the help!

i3d commented 3 months ago

The plugin now works flawlessly, thanks for all the help. Beautiful plugin, very handy!