-
Notifications
You must be signed in to change notification settings - Fork 15.4k
Add --project-root to clangd #155905
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Dominicentek
wants to merge
13
commits into
llvm:main
Choose a base branch
from
Dominicentek:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Add --project-root to clangd #155905
Changes from 11 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
9a30c2b
Add --project-root to clangd
Dominicentek 1c040db
Merge branch 'main' of https://github.com/Dominicentek/llvm-project
Dominicentek e80072c
Merge branch 'main' into main
Dominicentek 267071c
Merge branch 'main' into main
Dominicentek d0b4357
Merge branch 'main' into main
Dominicentek 82f80c0
[clangd] Replace --project-root with --strong-workspace-mode
Dominicentek 03b26a6
[clangd] Fallback working directory code cleanup
Dominicentek f824d5d
Fix formatting and errors
Dominicentek 220b823
[clangd] Make tests compile with new CDB constructor
Dominicentek a21f748
Run git-clang-format
Dominicentek f677937
Implement suggestions
Dominicentek 0b56ff5
Consistent naming
Dominicentek ab07087
Run git-clang-format
Dominicentek File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -500,6 +500,17 @@ opt<bool> EnableConfig{ | |
| init(true), | ||
| }; | ||
|
|
||
| opt<bool> StrongWorkspaceMode{ | ||
| "strong-workspace-mode", | ||
| cat(Features), | ||
| desc("An alternate mode of operation for clangd, where the clangd instance " | ||
| "is used to edit a single workspace.\n" | ||
| "When enabled, fallback commands use the workspace directory as their " | ||
| "working directory instead of the parent folder."), | ||
| init(false), | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's make this option hidden for now (example), until the feature is more fleshed out with other behaviours. (This just means it won't show up in |
||
| Hidden, | ||
| }; | ||
|
|
||
| opt<bool> UseDirtyHeaders{"use-dirty-headers", cat(Misc), | ||
| desc("Use files open in the editor when parsing " | ||
| "headers instead of reading from the disk"), | ||
|
|
@@ -907,6 +918,7 @@ clangd accepts flags on the commandline, and in the CLANGD_FLAGS environment var | |
| } | ||
| if (!ResourceDir.empty()) | ||
| Opts.ResourceDir = ResourceDir; | ||
| Opts.StrongWorkspaceMode = StrongWorkspaceMode; | ||
| Opts.BuildDynamicSymbolIndex = true; | ||
| #if CLANGD_ENABLE_REMOTE | ||
| if (RemoteIndexAddress.empty() != ProjectRoot.empty()) { | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's worth a comment explaining why we need a fallback here. Something like "the user asked for strong workspace mode, but the client didn't provide a workspace path, so use the working directory as a fallback".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was wondering if an error instead of a silent fallback helps with immediate user feedback, since this is an opt-in feature. Strong workspace's precondition is that a the directory should be set anyway.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could go either way on this. The advantage of a fallback is that it can help work around a client that's unhelpfully failing to set
rootUri, for which you as a user may not have much other recourse.