hedyhli / outline.nvim

Code outline sidebar powered by LSP. Significantly enhanced & refactored fork of symbols-outline.nvim.
https://sr.ht/~hedy/outline.nvim
MIT License
543 stars 15 forks source link

Opening outline in a lua file crashes immediately to commandline, with no log #74

Open vaqxai opened 2 months ago

vaqxai commented 2 months ago

Description

When trying to open the outline in an empty file, it works correctly. When opening in a .lua file, it crashes to commandline or freezes indefinetely. Tried to run neovim with the -D option, but the log file is 0 bytes. When trying other languages (Rust), symbol list is empty.

Simrat's original version works, though

To reproduce

  1. nvim test.lua
  2. write a function, like:
    function Test()
    end
  3. try to open outline: :OutlineOpen

My lazy.nvim config for loading outline.nvim

    {
        "hedyhli/outline.nvim",
        lazy = true,
        init = function()
            require("outline").setup()
        end,
        cmd = { "Outline", "OutlineOpen" },
        keys = {
            { "<Leader>o", "<cmd>Outline<CR>", desc = "Toggle outline"},
        },
        opts = {
            -- Custom config
        }
    },

Other Info

hedyhli commented 2 months ago

Hello, this looks peculiar. Using your config, I can reproduce having an empty symbol list but I don't experience any freezing or crashing.

However, it works fine if init = ... is removed (note that Lazy.nvim can call the setup function just fine if the opts table is provided, though empty). Let me know if this works for you.

I'm not quite sure how this init key could've made the difference, and even more so, the original symbols-outline works just fine in this situation though, I'll look into it.

vaqxai commented 2 months ago

After some more testing with simrat39's version, I've found that works/doesn't work behaves kind of randomly on me, and I'm not sure what the factor is. Excuse my poor understanding of how Lazy exactly works, but I'll try the method you mentioned, and append this comment with the result.

Edits:

Results:

Conclusion:

My theory is that if opts causes the plugin to be loaded (setup() is called), then my init function causes setup() to be called twice, thus possibly breaking the plugin.

Perhaps solution:

P.S.

It also seems that if the program enters a bugged state (such as by using init), the only way to break out of it is restart the user session (log out and log in again), otherwise, independent of the config file, it will not work anymore)

And also that only the first nvim session works, and any subsequent ones fail even if the config remains unchanged??

On my MacBook, with an identical config, everything seems to work fine, though.