smjonas / inc-rename.nvim

Incremental LSP renaming based on Neovim's command-preview feature.
MIT License
637 stars 8 forks source link

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

Closed bennypowers closed 1 year ago

bennypowers commented 1 year ago

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

smjonas commented 1 year ago

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!

bennypowers commented 1 year ago

what about

local origrename = vim.lsp.buf.rename
vim.lsp.buf.rename = function()
  -- do inc-rename
  origrename()
end
smjonas commented 1 year ago

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 commented 1 year ago

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