Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
vaqxai opened this issue Jun 6, 2024 · 2 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@vaqxai
Copy link

vaqxai commented Jun 6, 2024

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
  1. 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

  • OS: Windows 11
  • Nvim version: 0.9.5
  • outline.nvim version: HEAD
@hedyhli
Copy link
Owner

hedyhli commented Jun 8, 2024

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.

@hedyhli hedyhli added bug Something isn't working help wanted Extra attention is needed labels Jun 8, 2024
@vaqxai
Copy link
Author

vaqxai commented Jun 10, 2024

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:

  • Removed init block

Results:

  • In test file (lua) with just one function: works
  • In test file (rust) with just one function: works
  • In complex file (rust) with many functions and other stuff: works
  • In my vim config file (init.lua): works

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.

  • Counterpoint: not including opts, and including init does cause the crash too.
  • Counter-counterpoint: maybe something else also calls setup() and init just does it again. (Perhaps when lazy is set to true calling the commands for the first time causes setup() to be called again

Perhaps solution:

  • Make it so that the plugin ignores any subsequent calls to setup() after the first one, so that it becomes foolproof.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants