kylechui / nvim-surround

Add/change/delete surrounding delimiter pairs with ease. Written with :heart: in Lua.
MIT License
3.19k stars 62 forks source link

Bug: HTML surrounding not working with `dressing.nvim` #17

Closed fedoranvar closed 2 years ago

fedoranvar commented 2 years ago

Good day to you!

Noticed that with dressing.nvim plugin puts t in place but didn't change them

Thank you!

desilinguist commented 2 years ago

Thanks for an awesome plugin! I just tried this and found that I am having the exact same issue.

kylechui commented 2 years ago

Hey all, I would like to say that I've found the reason---vim.ui.input doesn't block, while vim.fn.input does. What this means is that I'm pretty sure I have a solution that would work with dressing.nvim, but at the cost of being able to actually use dressing.nvim with nvim-surround (e.g. dressing would be used elsewhere, but not for nvim-surround inputs). I'm still looking into alternatives though, and I would like to know what opinions y'all have about this. Thanks for your patience

kylechui commented 2 years ago

@fedoranvar @desilinguist Since it's definitely better to have something that works over something that looks pretty, I've decided to swap the new vim.ui.input for the older vim.fn.input on branch fix-html-tags-dressing (should be available in the sidebar of this issue). If y'all can do me a favor and test it out, that would be great; I can then merge this into main and change this bug into a feature enhancement to use vim.ui.input.

fedoranvar commented 2 years ago

@kylechui

i've tested, and it's works Have you figured why vim.ui.input didn't work with dressing.nvim in this case? could you point direction, where we can look in?

kylechui commented 2 years ago

@fedoranvar I asked the creator of dressing.nvim and they said that by default, vim.ui.input actually relies on vim.fn.input, which is a synchronous (blocking) call, so there are no issues there. However dressing overwrites vim.ui.input with an asynchronous call, since it needs to be unblocked in order to render the input window. Thus the async call for vim.ui.input causes certain areas of my code to run out of order, specifically html.get_tag will return nil, since the return executes before any input is passed in by the user. Hopefully that sheds a bit more light on the issue, but I'm still not 100% sure how to go about "properly" fixing it, since I don't have much experience with async programming

kylechui commented 2 years ago

Going to close this issue for now since I don't really know how to incorporate vim.ui.input in a realistic way, and will just use vim.fn.input for now