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

drop in handler for vim.lsp.buf.rename()? #28

Closed
bennypowers opened this issue Dec 15, 2022 · 4 comments
Closed

drop in handler for vim.lsp.buf.rename()? #28

bennypowers opened this issue Dec 15, 2022 · 4 comments
Labels
question Further information is requested

Comments

@bennypowers
Copy link

Is it possible to use this as a drop in handler for vim.lsp.buf.rename()?

@smjonas
Copy link
Owner

smjonas commented Dec 15, 2022

I just read the documentation for lsp-handler and from what I understood it's not. The handler would only be called once (when the server responds) so it wouldn't be possible to do any sort of "live preview" anymore. inc_rename calls vim.lsp.buf.rename internally when the user confirms the command.

Let me know if I have misunderstood you though!

@smjonas smjonas added the question Further information is requested label Dec 15, 2022
@bennypowers
Copy link
Author

what about

local origrename = vim.lsp.buf.rename
vim.lsp.buf.rename = function()
  -- do inc-rename
  origrename()
end

@smjonas
Copy link
Owner

smjonas commented Dec 17, 2022

Well you could do something like

vim.lsp.buf.rename = function()
  vim.api.nvim_feedkeys(":IncRename ", "n", false)
end

but I'm not sure if that's what you wanted to do. We don't need to call origrename because that already happens in inc-rename. We can't use the default behavior of the original vim.lsp.buf.rename because that uses vim.ui.input which is not previewable.

@smjonas
Copy link
Owner

smjonas commented Jan 16, 2023

Hey @bennypowers, is this still an issue for you?

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

No branches or pull requests

2 participants