The eglot-rename function uses symbol-at-point to find the "old" name of the symbol under the cursor. Though this follows Emacs tradition, it is not the intent of the LSP, which provides an RPC called prepareRename whose job is to ask the server for the name of the symbol under the cursor, or in other words, pop up a server-informed dialog. eglot should use it.
How might the two differ? Consider an import declaration import "example.com/foo/bar". If the server supports package renaming, it might respond with the value example.com/foo/bar, inviting the user to edit the complete package name, potentially changing path segments other than bar in order to affect a directory move to somewhere else in the tree.
As another example: some servers (e.g. gopls) exploit the fact that Rename is currently the only LSP operation that supports any form of dialog, no matter how limited. (This is something we would like to fix, and we are working on LSP support for more general dialog.) In the meantime, it is convenient to use the Rename dialog as a means to this end. For example, with gopls, "renaming" the func token of a function initiates the "permute parameters" refactoring, which allows the user to edit the list of parameter names. The server will then update the function and all calls to it based on the chosen permutation.
The
eglot-renamefunction usessymbol-at-pointto find the "old" name of the symbol under the cursor. Though this follows Emacs tradition, it is not the intent of the LSP, which provides an RPC called prepareRename whose job is to ask the server for the name of the symbol under the cursor, or in other words, pop up a server-informed dialog. eglot should use it.How might the two differ? Consider an import declaration
import "example.com/foo/bar". If the server supports package renaming, it might respond with the valueexample.com/foo/bar, inviting the user to edit the complete package name, potentially changing path segments other thanbarin order to affect a directory move to somewhere else in the tree.As another example: some servers (e.g. gopls) exploit the fact that Rename is currently the only LSP operation that supports any form of dialog, no matter how limited. (This is something we would like to fix, and we are working on LSP support for more general dialog.) In the meantime, it is convenient to use the Rename dialog as a means to this end. For example, with gopls, "renaming" the
functoken of a function initiates the "permute parameters" refactoring, which allows the user to edit the list of parameter names. The server will then update the function and all calls to it based on the chosen permutation.