Gruntfuggly / global-config

Allows copying of shared config settings in vscode
MIT License
12 stars 4 forks source link

[Question] How best to set up multiple projects #12

Closed lonix1 closed 3 years ago

lonix1 commented 3 years ago

Continuation from issue #11: a question about how to use the extension.

Let's say I have all my config in my project's .vscode/settings.json. And I want to use it in other projects too, so I'd copy that file to ~/.vscode/settings.json say, with the intent of using it in all my projects. Of course I'd need to add to that file "global-config.hardLinks": [ "settings.json", "foo", "bar" ] (or copy, or symlink).

Then I'd open a different project, and run the extension. But... in that project it wouldn't know which files to copy/link. That knowledge is in the "shared" config, which that project doesn't know about.

So there's a chicken and egg scenario here. Or maybe I'm not using the extension properly?

lonix1 commented 3 years ago

I'll play around with it more tomorrow, and report back any tricks I discover.

Gruntfuggly commented 3 years ago

I've always used it by keeping the common files somewhere outside any of the project folders. The default location is common to all workspaces. So when I open a new workspace, I just run 'Copy Global Config' to set it up.

Is that different, or have I misunderstood your usage?

lonix1 commented 3 years ago

Ok I've found a way.

I couldn't just dump files in ~/.vscode/ as it has all sorts of other files in there, including extensions. So I settled on ~/.vscode/common-workspace-config/ - anything in there is for this extension.

So I changed the global config ("user settings" - ~/.config/Code/User/settings.json):

"global-config.folder": "~/.vscode/common-workspace-config/",
"global-config.hardLinks": [
  "**",
],

That would have been ideal, as I could open a project and just run the extension. But it doesn't work as the ** isn't recognised, and a normal copy is done instead of hardlinking. I also tried ./**, ./***, etc.

So I did this instead:

"global-config.folder": "~/.vscode/common-workspace-config/",
"global-config.hardLinks": [
  "settings.json",
  "extensions.json",
  "csharp.code-snippets",
  "typescript.code-snippets",
  "fooextension.config.json",
  "barextension.config.json",
],

Kinda fiddly because one needs to remember to update that if there are changes. But this works!!

With that config you just open a project, run the extension, and all the shared "workspace config" will be added as hardlinks. So you can change workspace config for all projects at once, AND you can commit it to git for every project. Very nice.

If you have any simpler way let me know? Otherwise refer people in the future to this comment as it could be helpful. Thanks!

Gruntfuggly commented 3 years ago

Ah OK - globs aren't supported, but that could be added fairly easily. I'll raise another issue to cover it.