Skip to content
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

Ability to use and override default profile settings in a custom profile #188612

Open
sandy081 opened this issue Jul 23, 2023 · 26 comments
Open

Ability to use and override default profile settings in a custom profile #188612

sandy081 opened this issue Jul 23, 2023 · 26 comments
Assignees
Labels
under-discussion Issue is under discussion for relevance, priority, approach user-profiles User profile management

Comments

@sandy081
Copy link
Member

sandy081 commented Jul 23, 2023

Ability to use and override default profile settings in a custom profile

NOTE: Please mention your use case / scenario (NOT how you want to use) for this requirement. Also try if available Profiles features including #156144 are helping

@sandy081 sandy081 added under-discussion Issue is under discussion for relevance, priority, approach user-profiles User profile management labels Jul 23, 2023
@sandy081 sandy081 self-assigned this Jul 23, 2023
@tanishqmanuja
Copy link

Use case: #156144 (comment)

This was referenced Aug 29, 2023
@tanishqmanuja
Copy link

tanishqmanuja commented Sep 7, 2023

I have recently updated my approach towards maintaining my vscode settings.
Purpose of sharing it here is:

  • Feedback for improving/ Discussing any alternative method
  • Reporting the pain points in this approach to vscode devs

vsc-profiles
EDIT: In C/C++ extensions block, I meant C/C++ specific extensions instead of JS.
LINK: tldraw

Pain Points

These are marked with red arrow

  • Have to copy all defaults manually
  • No way of enabling extensions for workspace via code/json. Code can be copy-pasted/automated but not GUI actions.

@cdce8p
Copy link

cdce8p commented Sep 7, 2023

No way of enabling extensions for workspace via code/json. Code can be copy-pasted/automated but not GUI actions.

Would love to do that as well. I frequently need to enable the same extensions for new (temporary) workspaces.
In theory it would be possible to edit the state.vscdb database files and overwrite extensionsIdentifiers/enabled but that's something which should be simpler to accomplish.

@jcrben
Copy link

jcrben commented Sep 11, 2023

The use case I envision is for team sharing of settings. I want to create base default settings for all my team members which they can easily override if they feel so inclined. Then I want them to be able to use a profile as well on top of this foundation. If I could do that via something like https://learn.microsoft.com/en-us/windows/terminal/json-fragment-extensions that could be nice altho maybe that's overcomplicating it - I just want a single base.

@thernstig
Copy link
Contributor

thernstig commented Oct 24, 2023

I believe the solution should be akin ESLint extends, or Ruff extends, or any other similar tool.

The current way of using workbench.settings.applyToAllProfiles is not sufficient to capture everything. Here is an example of this shortcoming. Imagine I have this in the applications setting (Default Profile):

{
  "workbench.settings.applyToAllProfiles": [
    "editor.codeActionsOnSave"
  ],
  "editor.codeActionsOnSave": {
    "source.organizeImports": "never"
  }
}

Imagine I have this in a Web Profile setting.json:

{
  "editor.codeActionsOnSave": {
    "source.organizeImports": "always",
    "source.fixAll.eslint": "always",
    "source.fixAll.markdownlint": "always",
    "source.fixAll.stylelint": "always"
  }
}

There is no way for me to override the individual items in the object.

Setting values can be of various types. Such merging is well handled by normal settings.json merging between user, remote, workspace settings etc, see https://code.visualstudio.com/docs/getstarted/settings#_settings-precedence.

Here is an idea of a better solution:

Default Profile

  "editor.codeActionsOnSave": {
    "source.organizeImports": "never"
  }
}

Web Profile

{
  "extends": ["Default Profile"],
  "editor.codeActionsOnSave": {
    "source.organizeImports": "always",
    "source.fixAll.eslint": "always",
    "source.fixAll.markdownlint": "always",
    "source.fixAll.stylelint": "always"
  }
}

This has several benefits:

  • You can nest multiple extends where precedence is from right-to-left (i.e. last item has highest precedence). This enables a hierarchy of profiles e.g. "default -> web -> web with Golang backend" OR "default -> web -> web with Python backend".
  • You easily see in the lower-layer profiles what they extend, instead of having to go to the Default Profile to see what gets into lower profiles.
  • https://code.visualstudio.com/docs/getstarted/settings#_settings-precedence can be respected with type merging, meaning objects merge better.

If doing this, it would be great if a rename of a profile name also updates extends: ["Default Profile"], so the names sync, which could easily be missed otherwise.

@thernstig
Copy link
Contributor

thernstig commented Oct 26, 2023

Thinking more about #188612 (comment), it might even be more beneficial to create this extends functionality directly built into the Profiles. Rationale being that then also Extensions, Keyboard Shortcuts etc. could be merged in a nicer way.

So let's say you have Default -> Python Development -> Python Development Ruff Default -> Python Development -> Python Development Flake8, you could share the Python Development and get the Python extension in both, but different linter extensions Ruff vs. Flake8. Just as a dumb example. So not only settings would be merged, but also the others. So Extensions would be a be a union of the all extended Profiles.

@sharpchen
Copy link

I wonder with current solution, when create new profile from default with settings, does it simply copy settings or references them from default?

@brettcannon
Copy link
Member

I wonder with current solution, when create new profile from default with settings, does it simply copy settings or references them from default?

I believe it references them.

@soimon
Copy link

soimon commented Nov 16, 2023

I wholeheartedly agree with @thernstig on #188612 (comment): this is the way I would expect the system to work, given my experience with various configuration files that follow the same logic.

I would like to propose the idea of multiple inheritance (with the settings being merged in order, i.e., the latter one overwriting the earlier one). This would allow you to truly separate different contexts and environments.

You could have profiles for each language and context, stacking them just like you stack your tech stack:

{
  extends: ["Svelte Profile", "Python Profile"]
  // Svelte frontend with Python backend specific settings here
}
graph TD;
    golang(Golang)
    svelte(Svelte)
    python(Python)
    edu("Presentation (larger fonts, etc.)")
    svelte & golang-->c1[Svelte frontend with Golang backend]
    svelte & python-->c2[Svelte frontend with Python backend]
Loading

In this approach, a profile becomes an expression of extensions and settings you'd like to have available when working in a specific context or using a particular technology. It's like knowing you're heading to the gym and doing groceries afterward: you simply grab your sports bag and wallet, and the union of these allows you to do all your activities without having to think too much about what's inside either of them.

To avoid having to set up a jungle of profile combinations, it makes sense to specify this union in your workspace file, as the combinationary aspect is typically specific to the workspace.

While this idea might extend beyond the initial scope of what this system was intended for, I think it offers the most flexible and (for a lot of developers) familiar approach.

@thernstig
Copy link
Contributor

@soimon yes, multiple inheritance is captured in #188612 (comment) since the example uses an array for extending.

However, I think I make a fair point in #188612 (comment) that this should possibly not go into the settings.json but rather Profiles directly.

@tanishqmanuja
Copy link

Since, this feature is still not supported. I am using the extension enable/disable method, can anyone tell me how to suppress these warning when the extensions are disabled.

image

@jmevel
Copy link

jmevel commented Feb 5, 2024

@tanishqmanuja when you switch to a profile you have to reopen the settings file because VS Code will keep the previous settings file open.

I always add a comment at the top of all my settings file to quickly know which one I'm currently modifying.
For example I have // DEFAULT settings for the default profile and // RUST profile settings for my Rust one.

The default' settings file is located under (for Windows) under %APPDATA%\Roaming\Code\User but any other profile's settings file will be under %APPDATA%\Roaming\Code\User\profiles\profile_ID

Your setting won't be recognized if you don't have this specific extension enabled in the current profile you selected.

@tanishqmanuja
Copy link

@jmevel, Actually I dont want to switch profile at all here ( bc state of profiles is currently a mess ofc ). What I am doing is making my default profile installing all essential extensions and then disabling them as soon as they are installed. I only enable the required extension for the workspace, for example rust analyzer for rust workspace.

@thernstig
Copy link
Contributor

@jmevel, Actually I dont want to switch profile at all here ( bc state of profiles is currently a mess ofc ). What I am doing is making my default profile installing all essential extensions and then disabling them as soon as they are installed. I only enable the required extension for the workspace, for example rust analyzer for rust workspace.

The current solution is not in the best shape, as key aspects like overriding and sync between machines seem to not behave in a great way, but let's stay positive it changes in the future with our feedback :)

I made a smaller summary here of some problems: #196718 (comment)

@jmevel
Copy link

jmevel commented Feb 16, 2024

@jmevel, Actually I dont want to switch profile at all here ( bc state of profiles is currently a mess ofc ). What I am doing is making my default profile installing all essential extensions and then disabling them as soon as they are installed. I only enable the required extension for the workspace, for example rust analyzer for rust workspace.

Oh I see, that's a smart workaround, I didn't even think of it 😅

@mschwandt98
Copy link

Hi! 😊 What is the status of this feature? Has a decision already been made? If not, what exactly is missing for a decision? Many of my colleagues and I would be very happy if this feature would be implemented in VSCode.

@PierreLouisPAUGAM
Copy link

PierreLouisPAUGAM commented Jun 27, 2024

Hi @sandy081 😊
I wonder if this feature is still being worked on or if it is currently stalled.
Would you mind giving us an update ?

@gjsjohnmurray
Copy link
Contributor

@PierreLouisPAUGAM FYI the team is focused on endgame this week and next week.

@sandy081
Copy link
Member Author

This is not in our plan yet.

@dallenbaldwin
Copy link

I found myself here after looking for a way for my profiles to inherit from a default profile. I hate having to constantly remember that some new extension I found in one profile now has to be installed in all my other profiles, and then I have to switch profiles to keep it up to date.

A pretty common use case, I would argue, is markdown. Most people have to write markdown regardless of which language or development environment they work with. There are a lot of really good markdown extensions out there for mermaid, automatic link tables of contents, printing as PDF, etc.

Another would be GitLens. It adds many features to the Source Control panel that are applicable regardless of language, dev tools, etc.

It would make sense to have a base profile hold GitLens and all the markdown extensions I like, and then, as others have mentioned, add/remove based on the framework, development environment, language, etc.

@gjsjohnmurray
Copy link
Contributor

@dallenbaldwin are you aware that extensions can optionally be installed for all profiles?

https://code.visualstudio.com/docs/editor/profiles#_apply-an-extension-to-all-profiles

@dallenbaldwin
Copy link

Ah! I've never noticed that before! Thank you 😁

Does it also apply that extension to new profiles or is it only another way to copy the extension to all current profiles?

@gjsjohnmurray
Copy link
Contributor

Does it also apply that extension to new profiles

This should be easy enough to check. Also relevant is #193446 which is milestoned for the current iteration.

1 similar comment
@gjsjohnmurray
Copy link
Contributor

Does it also apply that extension to new profiles

This should be easy enough to check. Also relevant is #193446 which is milestoned for the current iteration.

@CTNOriginals
Copy link

I have been looking for a feature like this for a while now. The way I would apply this feature is that I would create some sort of "base" profile that all profiles will inherit from so it can then serve as a sort of essentials bundle that i would apply to all profiles no matter what the profile is created and used for. This would make it a lot easier if i would find a new extension that has to be set up in a specific way so I don't have to copy paste those settings across all profiles. This would also apply to keybinds and other profile related settings.

@sanmai-NL
Copy link

I found myself here after looking for a way for my profiles to inherit from a default profile. I hate having to constantly remember that some new extension I found in one profile now has to be installed in all my other profiles, and then I have to switch profiles to keep it up to date.

A pretty common use case, I would argue, is markdown. Most people have to write markdown regardless of which language or development environment they work with. There are a lot of really good markdown extensions out there for mermaid, automatic link tables of contents, printing as PDF, etc.

Another would be GitLens. It adds many features to the Source Control panel that are applicable regardless of language, dev tools, etc.

It would make sense to have a base profile hold GitLens and all the markdown extensions I like, and then, as others have mentioned, add/remove based on the framework, development environment, language, etc.

@dallenbaldwin
See:

  1. Apply extensions to all profiles from within CLI #234258
  2. Feature Request: Enable/disable extensions from config file #40239

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
under-discussion Issue is under discussion for relevance, priority, approach user-profiles User profile management
Projects
None yet
Development

No branches or pull requests