A small Neovim plugin that provides a command for LSP renaming with immediate visual feedback thanks to Neovim's command preview feature.
This plugin requires at least Neovim 0.8
Install using your favorite package manager and call the setup
function.
Simply type :IncRename <new_name>
while your cursor is on an LSP identifier.
You could also create a keymap that types out the command name for you so you only have to
enter the new name:
vim.keymap.set("n", "<leader>rn", ":IncRename ")
If you want to fill in the word under the cursor you can use the following:
vim.keymap.set("n", "<leader>rn", function()
return ":IncRename " .. vim.fn.expand("<cword>")
end, { expr = true })
noice.nvim
supportdressing.nvim
supportThere have been reports of inc-rename
not working with certain plugins and language servers:
Make sure to uninstall these if you are experiencing issues.
You can override the default settings by passing a Lua table to the setup
function.
The default options are:
require("inc_rename").setup {
-- the name of the command
cmd_name = "IncRename",
-- the highlight group used for highlighting the identifier's new name
hl_group = "Substitute",
-- whether an empty new name should be previewed; if false the command preview will be cancelled instead
preview_empty_name = false,
-- whether to display a `Renamed m instances in n files` message after a rename operation
show_message = true,
-- whether to save the "IncRename" command in the commandline history (set to false to prevent issues with
-- navigating to older entries that may arise due to the behavior of command preview)
save_in_cmdline_history = true,
-- the type of the external input buffer to use (the only supported value is currently "dressing")
input_buffer_type = nil,
-- callback to run after renaming, receives the result table (from LSP handler) as an argument
post_hook = nil,
}