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

Error opening floating window and mapping issues #1

Closed
akinsho opened this issue Jun 7, 2021 · 8 comments · Fixed by #3
Closed

Error opening floating window and mapping issues #1

akinsho opened this issue Jun 7, 2021 · 8 comments · Fixed by #3

Comments

@akinsho
Copy link

akinsho commented Jun 7, 2021

Hi @rmagatti,

Just tested this out as I was curious about this functionality, looks quite cool. I ran into an issue which is that I get Error executing vim.schedule lua callback: ...site/pack/packer/start/goto-preview/lua/goto-preview.lua:78: Invalid window id: 1003 when trying to open the floating window i.e. using gpd the go to definition preview mapping.

Also the plugin has a dependency on vimp which isn't documented but tbh I think also not really needed since you could export the functions and use them in the mapping which the plugin creates

e.g.

function M.goto_preview_definition()
-- do stuff
end

vim.api.nvim_set_keymap("n", "gpd", "<Cmd>lua require('goto-preview').goto_preview_definition()<CR>")
-- OR if you need to do it based on some logic in setup then
_G.__goto_preview_definition = M.lsp_request(true)
vim.api.nvim_set_keymap("n", "gpd", "<Cmd>lua _G.__goto_preview_definition()<CR>")
@rmagatti
Copy link
Owner

rmagatti commented Jun 7, 2021

Yeah the hidden dependency on vimp for mappings isn't great, I do plan on cleaning that up. Thanks for the submission @akinsho always a pleasure to have you around 😊

I've only seen that error you mentioned when it fails to create the new window, it's then trying to position the cursor on a window it was ultimately unable to create.

I can fix the error up by not trying to use the new_window value if it doesn't exist but the root of the issue of it being unable to create the window (assumed) is still unknown to me 🤔. Do you see anything else in messages at all? Also does the float even show up?

@akinsho
Copy link
Author

akinsho commented Jun 7, 2021

@rmagatti I wonder if it might be due to how I've tried to work around the mapping issue since I can't see any other way to access this plugins functions without using vimp which I haven't/would rather not install 😅 . Maybe calling the lsp_request function at this point causes some weird issue.

    use {
      "rmagatti/goto-preview",
      config = function()
        local preview = require("goto-preview")
        preview.setup {}
		-- home grown copy of functionality from vimp etc.
        as.nnoremap("gpd", preview.lsp_request(true))
      end
    }

@akinsho
Copy link
Author

akinsho commented Jun 7, 2021

In terms of what else I see, it seems to cause a buffer to be created with the name of the file appended with some characters.
image

@rmagatti
Copy link
Owner

rmagatti commented Jun 7, 2021

Hey @akinsho the PR should address the mapping issues.

@rmagatti
Copy link
Owner

rmagatti commented Jun 7, 2021

In terms of what else I see, it seems to cause a buffer to be created with the name of the file appended with some characters.

Now this one I'm not really sure what it is. Mind trying out the new mapping and letting me know if this new weirdly named buffer still happens?

@akinsho
Copy link
Author

akinsho commented Jun 7, 2021

@rmagatti I just tried the PR which is helpful thanks, I'm still seeing the bug though so I'm trying to whittle it down to a minimal init.lua and see what might be triggering it

@akinsho
Copy link
Author

akinsho commented Jun 7, 2021

@rmagatti done a bit of debugging with quite a minimal init.lua and it seems the underlying error I'm seeing is Error executing vim.schedule lua callback: ...site/pack/packer/start/goto-preview/lua/goto-preview.lua:79: Cursor position outside buffer. Seems setting the cursor is what is failing but I'm not sure why

@rmagatti
Copy link
Owner

rmagatti commented Jun 7, 2021

Created that new issue to track what you're describing, let's continue there so I can merge the PR and close this one. 😊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants