-
Notifications
You must be signed in to change notification settings - Fork 118
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
Add commands to open global and project config #181
Conversation
Global config opening will likely not work on remote setups and is as of yet untested on windows and mac builds.
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.
src/extension.ts
Outdated
context.subscriptions.push( | ||
vscode.commands.registerCommand('clangd.projectSettings', () => { | ||
if (vscode.workspace.workspaceFolders) { | ||
const folder = vscode.workspace.workspaceFolders[0]; |
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.
Hmm, how sure are we that this is the right directory (that workspace folders correspond to the real project root, and folder 0 is the right one?)
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.
There's unfortunately not a great way of going about this. In a single workspace mode this should be sufficient. But once you start working with multi folder workspaces things start getting a little hazy. However a lot of projects users are likely to work on only have 1 root folder so this should be helpful for the majority of users.
I think that depends on everyone's workflow. Just speaking for myself, the current model (assuming the workspacefolders[0] as the project root) at lease works for me, because I use I think this is a useful feature, but the current model seems fragile to me:
I was going to suggest that we can add some extensions like |
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.
LGTM with one nit around initialization that I can fix myself.
Project config:
This isn't going to free people from having to know where .clangd
files go, but it's going to put them in a predictable place that will work a good fraction of the time. I think it's a fair tradeoff.
I was going to suggest that we can add some extensions like getConfigInfo in clangd server, then the client can query clangd to get the config information, but realized that clangd doesn't know the concept of project directory :(
This is obviously pretty heavyweight. I can imagine some refinements to make it work better, but I don't think it's worth it.
It'd be nice to expose these from the status bar item, but that doesn't look possible as we have a primary action already (open log) and microsoft/vscode#27196 isn't done.
src/extension.ts
Outdated
@@ -1,6 +1,7 @@ | |||
import * as vscode from 'vscode'; | |||
|
|||
import {ClangdContext} from './clangd-context'; | |||
import * as OpenConfig from './open-config'; |
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.
nit: OpenConfig -> openConfig
For whatever reason, our idiom is to features from clangd-context.ts, passing in ClangdContext instead of ExtensionContext.
(I think it might be something to do with allowing the server to be restarted, we unload and reload all features. It's not actually important for this feature but best to be consistent)
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.
The reason I passed the ExtensionContext is because the commands don't actually depend on the clangd server being active. However there's very little real world difference in using ClangdContext and consistency is a good thing.
Global config opening will likely not work on remote setups and is as of yet untested on windows and mac builds.
Fixes #176