rmagatti / goto-preview

A small Neovim plugin for previewing definitions using floating windows.
Apache License 2.0
779 stars 27 forks source link

[BUG] Fails if you haven't done regular go to definition first #74

Closed mrjones2014 closed 1 year ago

mrjones2014 commented 1 year ago

Describe the bug

Error when you try to use any functions.

To Reproduce Steps to reproduce the behavior:

  1. Call require('goto-preview').goto_preview_definition() on a buffer with an LSP enabled

Expected behavior It opens the definition in a floating window

Screenshots image

Baseline (please complete the following information):

Additional context Add any other context about the problem here.

mrjones2014 commented 1 year ago

Interestingly, it seems to work if I do regular LSP go to definition first, then try goto-preview

rmagatti commented 1 year ago

Hi, I haven't been able to reproduce this. From the error it's like at the time you try to call the function, setup for the plugin hasn't been called yet, the setup function is what sets the default config in the plugin which is what defines lsp_configs, so my guess is that some lazy loading is happening and by the time you call the goto-preview function, setup hasn't yet happened.

You can test this out by when first opening Neovim, calling :lua require('goto-preview').setup{} manually and then calling goto_preview_definition() afterwards, you shouldn't run into the error then.

mrjones2014 commented 1 year ago

Hmm, I'm lazy loading based on filetype which I thought should work, but I can figure this out with this info. Thanks.