Dmitrij Kultasev
Dmitrij Kultasev

Reputation: 5745

Saving user preferences/settings for vscode extension

What are the best practices to store user settings for the extension? I can think of saving them in some specific format in the text file. Is there any integrated way of doing that using vscode API?

Upvotes: 11

Views: 7134

Answers (1)

Gama11
Gama11

Reputation: 34138

VSCode extensions typically contribute settings to be used in user and workspace settings.json files.

Settings are registered via contributes.configuration in an extension's package.json, and the allowed values can flexibly be described with a JSON schema (which also allows for code completion in the JSON file). The value of settings can then be checked by using the workspace.getConfiguration() API.

There is also a sample extension that showcases the Configuration API in vscode-extension-samples.

Having a separate file just for a specific extension's settings would be a bit unusual.

Upvotes: 14

Related Questions