smjonas / inc-rename.nvim

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

How to show current variable name in the INC box before changing #38

Closed mortymacs closed 1 year ago

mortymacs commented 1 year ago

Hi,

When I want to change a variable, I should type the whole name again plus the changes, while I was looking for a way to only type the required parts. For example address to addressObj, I'm looking for a way to have address in the INC box when I run :IncRename, and then I just type the Obj part. But the INC box is empty all the time.

Do we have this functionality, or I missed a config?

Cheers, Mort

smjonas commented 1 year ago

Hey, the approach I would recommend is to use a mapping that types :IncRename <word_under_cursor> for you (see readme):

vim.keymap.set("n", "<leader>rn", function()
  return ":IncRename " .. vim.fn.expand("<cword>")
end, { expr = true })

Does that work for you?

mortymacs commented 1 year ago

Hi,

I already saw that, and I tried to use it, but as my keymap function was my own customized, it didn't support {expr = true} parameter, and I tried to use vim.cmd instead, which led to getting an error. But now I updated my keymap function, and it supports it. So, I'm going to close the issue.

Thank you!