Gruntfuggly / global-config

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

FR: Files not based in .vscode directory #14

Closed lonix1 closed 3 years ago

lonix1 commented 3 years ago

Hey again @Gruntfuggly,

I've been using the extension for the past few days and it's really great. I came across something and hoped to discuss it.

There are lots of config files which don't go into .vscode/. For example: .editorconfig, .gitignore, .gitattributes, tsconfig.js, linter configs. These cannot be handled by this extension.

Some of these are examples of "global" files applicable to all projects, e.g. .editorconfig and .gitattributes.

Is there a way to support such files? I have a feeling there isn't, but maybe it's worth thinking about?


Other devs: if you like this idea, thumb up this post!

lonix1 commented 3 years ago

(The reason I came across this problem, is I often checkout sample/example projects from github, and now the first thing I do is "Copy Global Config". :smile: However some config files aren't copied/symlinked/hardlinked so need to be copied over by hand. E.g. editorconfig etc.)

Gruntfuggly commented 3 years ago

Not currently - the extension was only really intended to get round VSCodes limitation of not supporting global files (which I think it does now anyway for some of them at least).

Assuming you would keep the other global files in the same location, it would be quite simple to add another config setting to allow an overridden destination folder to be specified in the same way as the links/hardlinks.

lonix1 commented 3 years ago

I'm not sure that would work - because they need to be copied into the solution root ./, not into ./.vscode/.

Gruntfuggly commented 3 years ago

Sorry, that's what I meant, e.g.

    "global-config.destinations": [
        { 
            "file": ".gitattributes",
            "destination": "${workspaceFolder}"
       }
    ],
lonix1 commented 3 years ago

Ok I thought it would be much more complicated... But to build on that:

  "global-config.destinations": [
        { 
            "file": ".gitattributes",             // assumed to be within `global-config.folder`
            "destination": "${workspaceFolder}",
            "type": "copy"                        // or "softlink" or "hardlink"
       }
    ],
Gruntfuggly commented 3 years ago

I don't think it would need the "type" because that can already be specified in the links/hardlinks sections?

You're probably thinking that it would be neater to provide the information on a per file basis, but the problem is that I would either have to remove the old style configuration setting which would cause issues for existing users, or provide it as an alternative, which then becomes tricky if somebody accidentally specifies both.

If you're happy to do this (for example):

"global-config.links": [
    "file": ".gitattributes"
],
"global-config.destinations": [
    { 
        "file": ".gitattributes",
        "destination": "${workspaceFolder}"
    }
],

then the change is simple and backwards compatible, if not as neat as it could be. 😁

lonix1 commented 3 years ago

Actually that's pretty sweet, and simpler than what I was thinking. :+1:

I'm gonna edit the title to FeatureRequest then. If enough folks give it a "thumbs up", maybe you could take a look at it :wink:

Gruntfuggly commented 3 years ago

I'll add it later today - it won't take very long. 🙂

Gruntfuggly commented 3 years ago

OK - try the latest version. I've made it slightly simpler, so it's just

"global-config.destinations": {
    ".gitattributes": "/home/user/workspace"
}
lonix1 commented 3 years ago

My config:

"global-config.folder": "~/.vscode/global-config/",
"global-config.hardLinks": [ "**" ],
"global-config.destinations": {
  "test.txt": "${workspaceFolder}",
},

All the files are copied/linked across, EXCEPT for test.txt. How should I fix this?

Gruntfuggly commented 3 years ago

${workspaceFolder} won't work unfortunately - I gave you a bum steer with my original example.

At the moment you'll need a path, which can be relative.

I was going to add support for ${workspaceFolder} but I stopped because it gets a bit tricky with workspace folders. However, I can see that it's quite likely to be needed, so I think it's probably worth adding.

lonix1 commented 3 years ago

ok I get it now. With an absolute path it works properly. But that is not ideal as the config is probably gonna be in your "user" config - so you can't put an absolute path in there for every project you open.

But if as you say we can use relative paths, then that's perfectly fine.

I couldn't get it to work though. I assume you mean relative to the workspace's myproject/vscode/ folder, so I tried:


"test.txt": "../"
Gruntfuggly commented 3 years ago

Actually, I'm not sure. I presumed it would be the workspace folder.

I'll add support for ${workspaceFolder} and probably arbitrary environment variables too.

lonix1 commented 3 years ago

Lol it's getting a little too complicated and I feel bad about it as I opened the issue. Maybe just remove the feature for now - and if others thumbs up this issue maybe you could take aother stab at it?

Like they do on the MS repo: at least twenty +1s before they consider a feature request.

Gruntfuggly commented 3 years ago

It's no problem - it's code I already have in another extension anyway. 😁

Gruntfuggly commented 3 years ago

Sorry - I completely forgot to do this! The latest version (0.0.16) should now support ${workspaceFolder} and environment variable substitution, e.g. ${HOME}

lonix1 commented 3 years ago

SORRY I also completely forgot about this! :clown_face:

I can confirm this works like a charm!

Thanks again for this outstanding extension!