Extend VSCode workspace settings from another file
Kalimah Apps
Posted on July 16, 2023
TL;DR
I created a VSCode extension, Tabaqa, to enable extending workspace settings from another source.
One of the great features of the VSCode is that you can customize the settings of the workspace. This is usually done by adding a setting.json file inside .vscode folder.
However, this causes few problems. For example if you push your project to a git repository and commit settings.json file, others who pull the code will have to use the same settings as you do.
Obviously they can customize the settings to their preferred way, but this means that they have to push the new changes to the repo (and change it for everyone else) or make sure they don't push it every time they add a new commit.
Another issue is when you have a monorepo. Typically you would have different projects adjacent to each other. Even though you might have a slight different settings for each project, you still need to duplicate all the settings across all projects.
These approaches well add extra time for maintenance and become a distraction from working on the project itself.
This is why I developed this extension, Tabaqa. It means layer in Arabic. The extension helps extending settings either from a parent folder, a file in the workspace or from a URL.
Getting started
The quickset way to add settings to your workspace is to create a file named tabaqa.json and place it inside the root .vscode. Create it with this content:
If you save tabaqa.json file and restart VSCode, you will see that settings.json is created with the settings pulled from that URL. The settings will be applied to the currently opened workspace.
But what if you wanted to change some of these settings? You can add the changes to settings property inside tabaqa.json. For example,
Another way to extend settings is to inherit them from another tabaqa.json file up the folders tree. This is the default behavior. If you wanted to opt-out you can add root: true to tabaqa.json:
NOTE: Please be aware that this extension updates settings.json file. If you have any custom settings, please make sure to backup your settings.json file before installing this extension.
Extend VSCode settings from a parent folder, another file or a url. You can also nest settings by adding a tabaqa.json file inside a folder. The extension will look for the file and apply the settings to the current workspace.
How does it work?
The extension looks for a file names tabaqa.json inside the top level .vscode folder. If the file is found, it will read the file and apply the settings to the current workspace. The extension will inherit the settings from all tabaqa.json files up the folder tree until it reaches the root folder (or if root: true has been set).