Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 661
Dmitrij Kultasev Avatar asked Feb 03 '23 19:02

Dmitrij Kultasev


1 Answers

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.

like image 198
Gama11 Avatar answered May 10 '23 23:05

Gama11