Adding option to follow symlinks when resolving symbols #707
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When using clangd in vscode with Bazel — trying to do symbol resolution (Go To Definition, Go To Declaration) will result in a file being opened in the Bazel build intermediate folder. This PR adds a settings flag and middlewares on the symbol resolution functions to follow symlinks back to their actual source file.
This issue has been discussed on the clangd project itself a few years ago. 1 2. From my reading whether or not to follow the symlinks was too deep in the compiler infrastructure itself to change on the LSP server, and that whether or not to follow the symlinks might be situationally dependent.
I attempted to solve the issue using the
--path-mappings
flag but it doesn't seem suitable for this situation.[Hedron's](https://github.com/hedronvision/bazel-compile-commands-extractor generator
compile_commands.json
also seemed like an opportunity to generate different compile commands but 3 it doesn't seem like one could get working compile commands that aren't pointing into bazel's sandbox directoryHaving it here behind a feature flag seems like a reasonable middle ground. Folks that need symlink resolution would be able to check the box, and uncheck it if they were getting funky behavior.
I've created a project here to demonstrate the behavior
Symbol Resolution
Without Symlink Following
With Symlink Following