Rename
Usage #
Run :Lspsaga rename. Other than opening the float input window it will also highlight the references in this buffer.
Default Options #
Default options in rename section:
in_select = true- Default is
true. Whether the name is selected when the float opens - In some situation, just like want to change one or less characters,
in_selectis not so useful. You can tell the Lspsaga to start in normal mode using an extra argument like:Lspsaga lsp_rename mode=n
- Default is
auto_save = false- Auto save file when the rename is done
project_max_width = 0.5- Width for the
project_replacefloat window
- Width for the
project_max_height = 0.5- Height for the
project_replacefloat window
- Height for the
Default Keymaps #
Default keymap in rename.keys section:
quit = '<C-k>'quit rename window orproject_replacewindowexec = '<CR>'execute rename inrenamewindow or execute replace inproject_replacewindowselect = 'x'select or cancel select item inproject_replacefloat window
Project-wide Replace #
LSP rename can only rename language symbols. Lspsaga provide async project level search and replace by using rg,
so make sure it’s installed if you want to use this feature.
Run :Lspsaga project_replace old_name new_name. It will search the whole project to find old_name and show if in a float window.
- use
rename.keys.selectto select item to rename - use
rename.keys.execto executenew_namereplace
LSP Integration #
Use ++project flag for the lsp_rename command (:Lspsaga lsp_rename ++project)
After the LSP rename is done, and if the name still exists somewhere within the project, the project_replace window would pop out.
