Describe the bug
In my C++ project I try to rename a variable in a header file using lsp-rename, the variable name is not changed an the message "lsp-request: Cannot rename symbol: the symbol is used outside main file" is shown in the mini buffer.
Expected behavior
I would expecte that the name of the variable is change in the whole project.
Which Language Server did you use
clangd-10
OS
Debian experimental
Error callstack
...
[Trace - 08:37:03 PM] Sending request 'textDocument/rename - (70)'.
Params: {
"textDocument": {
"uri": "file:///path/to/project/src/someheader.hpp"
},
"position": {
"line": 13,
"character": 42
},
"newName": "net_connection"
}
[Trace - 08:37:03 PM] Received response 'textDocument/rename - (70)' in 7ms.
Result: null
[Trace - 08:37:03 PM] Sending request 'textDocument/hover - (71)'.
Params: {
"textDocument": {
"uri": "file:///path/to/project/src/someheader.hpp"
},
"position": {
"line": 13,
"character": 42
}
}
@sebastiansturm can you take a look?
@bradprob in general, lsp-mode is only a frontend, based on your description it looks like it is language server limitation(or eventually you have to do more configuration).
@yyoncho, it would be nice if the documentation contains some parts about the configuration with supporting back-ends like clangd.
as far as I know, clangd does not (yet) support renaming across different files. I thought they had recently added nonlocal renames to trunk, but apparently this is not the case. If you're using clangd 10 built from source, have a look at clang-tools-extra/clangd/unittests/RenameTests.cpp. That file lists a number of allowed and disallowed scenarios (all allowed ones being file-local)
Closing based on the previous comment.
Just a heads up: clangd 10, which was released two days ago, does include a command-line flag (-cross-file-rename) which should allow renames across different files.
Did not have a chance to test it yet though, will do as soon as llvm 10 is available through Homebrew.
Most helpful comment
Just a heads up: clangd 10, which was released two days ago, does include a command-line flag (
-cross-file-rename) which should allow renames across different files.Did not have a chance to test it yet though, will do as soon as llvm 10 is available through Homebrew.