My workspace root is a git repository containing couple of files and several git submodules. Each submodule have their own .vscode/settings.json
. I was expecting VSCode to adjust its settings based on which submodule/subfolder I'm working in but it's not working as expected.
Is it possible? I think it's possible if you use a multi-root workspace (which is supported since 1.18), but in my case I'd like to keep that single-root workspace.
The File > Add Folder to Workspace command brings up an Open Folder dialog to select the new folder. Once a root folder is added, the Explorer will show the new folder as a root in the File Explorer. You can right-click on any of the root folders and use the context menu to add or remove folders.
Depending on your platform, the user settings file is located here: Windows: %APPDATA%\Code\User\settings. json. macOS: $HOME/Library/Application Support/Code/User/settings.
The easiest way to open a workspace is using the File menu and selecting one of the available folder entries for opening. Alternatively if you launch VS Code from a terminal, you can pass the path to a folder as the first argument to the code command for opening.
I also couldn't find a decent answer for this, I did find an "hacky" workaround. I have the following project structure:
. ├── apps │ ├── api │ │ ├── Dockerfile │ │ ├── .gitignore │ │ ├── hhapi │ │ ├── manage.py │ │ ├── .pylintrc │ │ ├── requirements.txt │ │ ├── venv │ │ └── .vscode │ └── crawler │ ├── crawler-crontab │ ├── Dockerfile │ ├── .gitignore │ ├── hhcrawler │ ├── .pylintrc │ ├── requirements.txt │ ├── .scrapy │ ├── scrapy.cfg │ ├── venv │ └── .vscode ├── docker-compose.development.yml ├── docker-compose.production.yml ├── .gitignore ├── .gitlab-ci.yml ├── househunter.code-workspace └── .vscode └── settings.json
What I ended up doing was ignoring the apps
directory on the project root and then add both apps to the workspace.
So the ./.vscode/settings.json
looks like this:
{ "files.exclude": { "**/.git": true, "**/.svn": true, "**/.hg": true, "**/CVS": true, "**/.DS_Store": true, "apps": true }, }
And the househunter.code-workspace
file like so:
{ "folders": [ { "path": "apps/api" }, { "path": "apps/crawler" }, { "name": "root", "path": "." } ], "settings": {} }
This is what I see on the editor:
And it is indeed following the subprojects settings.json
. This is far from being a great solution, but for the time being was the only way I found to achieve this - I'd also love to see someone document a proper solution for this. :)
At the time of writing the feature is just not implemented. There's a feature request in the program's issue tracker filed on 17 August 2017: Monolithic structure, multiple project settings #32693.
Meanwhile, if you need it badly you have to abuse multi-root workspaces as described in Diogo's answer.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With