nvim-treesitter/nvim-tree-docs

Error when opening Neovim

kristijanhusak opened this issue ยท 15 comments

Hi,

I just tried installing this and when I restarted neovim I got this error:

Error detected while processing FileType Autocommands for "*":                                                                                                                                                                                  
E5108: Error executing lua ...ger/start/nvim-tree-docs/lua/nvim-tree-docs/internal.lua:31: attempt to index local '_1_' (a nil value)

Do you know what can be the issue?

I don't really know, this seems to be related to the compiled fennel code, maybe @steelsojka has more insights on that though.

@kristijanhusak Can you give us some more info? What neovim version are you running? I am using this daily and don't seem to be getting this error.

@steelsojka Sure. Here are some details:

  • Neovim version: Built it today from master, NVIM v0.5.0-dev+1005-ga1ed941a7
  • OS: Manjaro Linux
  • nvim treesitter setup:
require'nvim-treesitter.configs'.setup {
  tree_docs = {
    enable = true,
  },
}

This happens once I add tree_docs = { enable = true } to the config.

I tried removing all my configuration and it still happens to me. Having just nvim-treesitter and this one in pack/start directories.

How can I debug this? This compiled lua is a bit harder to debug.

@kristijanhusak Do you have a minimal reproducable scenario? How are you managing your plugins?

@steelsojka Here's the min vimrc I just tested

" minvimrc
set rtp+=/home/kristijan/.config/nvima/pack/packager/start/nvim-treesitter
set rtp+=/home/kristijan/.config/nvima/pack/packager/start/nvim-tree-docs
 
lua require'nvim-treesitter.configs'.setup { tree_docs = { enable = true, } }
nvim -u minvimrc README.md

Screenshot:
screenshot

I'm using built in packages. In the minvimrc above i moved my ~/.config/nvim to ~/.config/nvima just to be sure it doesn't load anything.

@steelsojka I figured it out. aniseed.core is not properly required everywhere.

Here's the lua diff that made this work for me:

diff --git a/lua/nvim-tree-docs/collector.lua b/lua/nvim-tree-docs/collector.lua
index cdd15c3..a0c8523 100644
--- a/lua/nvim-tree-docs/collector.lua
+++ b/lua/nvim-tree-docs/collector.lua
@@ -17,11 +17,11 @@ end
 local function _2_(...)
   local ok_3f_0_, val_0_ = nil, nil
   local function _2_()
-    return {require("aniseed.core")}
+    return {require("nvim-tree-docs.aniseed.core")}
   end
   ok_3f_0_, val_0_ = pcall(_2_)
   if ok_3f_0_ then
-    _0_0["aniseed/local-fns"] = {require = {core = "aniseed.core"}}
+    _0_0["aniseed/local-fns"] = {require = {core = "nvim-tree-docs.aniseed.core"}}
     return val_0_
   else
     return print(val_0_)
@@ -225,4 +225,4 @@ do
   _0_0["aniseed/locals"]["add-match"] = v_0_
   add_match = v_0_
 end
-return nil
\ No newline at end of file
+return nil
diff --git a/lua/nvim-tree-docs/internal.lua b/lua/nvim-tree-docs/internal.lua
index 3be5ba3..a879ccc 100644
--- a/lua/nvim-tree-docs/internal.lua
+++ b/lua/nvim-tree-docs/internal.lua
@@ -17,11 +17,11 @@ end
 local function _2_(...)
   local ok_3f_0_, val_0_ = nil, nil
   local function _2_()
-    return {require("nvim-tree-docs.collector"), require("aniseed.core"), require("nvim-tree-docs.editing"), require("nvim-tree-docs.template"), require("nvim-tree-docs.utils")}
+    return {require("nvim-tree-docs.collector"), require("nvim-tree-docs.aniseed.core"), require("nvim-tree-docs.editing"), require("nvim-tree-docs.template"), require("nvim-tree-docs.utils")}
   end
   ok_3f_0_, val_0_ = pcall(_2_)
   if ok_3f_0_ then
-    _0_0["aniseed/local-fns"] = {require = {collectors = "nvim-tree-docs.collector", core = "aniseed.core", editing = "nvim-tree-docs.editing", templates = "nvim-tree-docs.template", utils = "nvim-tree-docs.utils"}}
+    _0_0["aniseed/local-fns"] = {require = {collectors = "nvim-tree-docs.collector", core = "nvim-tree-docs.aniseed.core", editing = "nvim-tree-docs.editing", templates = "nvim-tree-docs.template", utils = "nvim-tree-docs.utils"}}
     return val_0_
   else
     return print(val_0_)
@@ -488,4 +488,4 @@ do
   _0_0["aniseed/locals"]["edit_doc_at_cursor"] = v_0_
   edit_doc_at_cursor0 = v_0_
 end
-return nil
\ No newline at end of file
+return nil
diff --git a/lua/nvim-tree-docs/template.lua b/lua/nvim-tree-docs/template.lua
index 0682fc5..1d2a516 100644
--- a/lua/nvim-tree-docs/template.lua
+++ b/lua/nvim-tree-docs/template.lua
@@ -17,11 +17,11 @@ end
 local function _3_(...)
   local ok_3f_0_, val_0_ = nil, nil
   local function _3_()
-    return {require("nvim-tree-docs.collector"), require("aniseed.core"), require("nvim-tree-docs.utils")}
+    return {require("nvim-tree-docs.collector"), require("nvim-tree-docs.aniseed.core"), require("nvim-tree-docs.utils")}
   end
   ok_3f_0_, val_0_ = pcall(_3_)
   if ok_3f_0_ then
-    _0_0["aniseed/local-fns"] = {require = {collectors = "nvim-tree-docs.collector", core = "aniseed.core", utils = "nvim-tree-docs.utils"}}
+    _0_0["aniseed/local-fns"] = {require = {collectors = "nvim-tree-docs.collector", core = "nvim-tree-docs.aniseed.core", utils = "nvim-tree-docs.utils"}}
     return val_0_
   else
     return print(val_0_)
@@ -546,4 +546,4 @@ do
   _0_0["aniseed/locals"]["extend-spec"] = v_0_
   extend_spec = v_0_
 end
-return nil
\ No newline at end of file
+return nil
diff --git a/lua/nvim-tree-docs/utils.lua b/lua/nvim-tree-docs/utils.lua
index 6e04f20..ad3401f 100644
--- a/lua/nvim-tree-docs/utils.lua
+++ b/lua/nvim-tree-docs/utils.lua
@@ -17,11 +17,11 @@ end
 local function _3_(...)
   local ok_3f_0_, val_0_ = nil, nil
   local function _3_()
-    return {require("aniseed.core")}
+    return {require("nvim-tree-docs.aniseed.core")}
   end
   ok_3f_0_, val_0_ = pcall(_3_)
   if ok_3f_0_ then
-    _0_0["aniseed/local-fns"] = {require = {core = "aniseed.core"}}
+    _0_0["aniseed/local-fns"] = {require = {core = "nvim-tree-docs.aniseed.core"}}
     return val_0_
   else
     return print(val_0_)
@@ -375,4 +375,4 @@ do
   _0_0["aniseed/locals"]["highlight-marks"] = v_0_
   highlight_marks = v_0_
 end
-return nil
\ No newline at end of file
+return nil

I see that you updated it, but the issue still persist.
I'm curious how you don't have this issue? Is there some configuration to make this work?

I investigated this a little bit this morning and see the issue, but I think it's an issue with the embed script in aniseed. It works for me because I have aniseed as a plugin since my configuration is using it. I will try and find a fix in the build process, but in the mean time try adding aniseed as a plugin and see if that resolves the issue. I will try and get the compiled files pointing to the embedded instance in the mean time.

Adding aniseed makes it work, thanks. Let me know if you manage to make it work without it as a dependency.

If there's any way I can help out here, let me know, AMA ๐Ÿ™‚ you should be able to rely on the embedded Aniseed copy, it can be tricky to realise that you're depending on the global Aniseed instance sometimes. I'd grep for \saniseed to find unprefixed references.

Cool to see it being used here and I'd like to help you work through issues to help them be avoided in the future.

Same thing, adding anyseed plugin helped. Probably worth adding to the readme.
What is the purpose of aniseed dependency? The plugin can't be written in pure lua?

You can try this fork where I've updated Aniseed and corrected the references to the embedded library so you don't need to have it installed globally.

I'll create a PR too.

@kristijanhusak Can you verify if this is fixed for you? Should be fixed by #12

@steelsojka yeah, works great. Thanks!