I am trying to add a simple configuration to my VSCode extension, but I can't find the correct information.
I just want that the user have a string input field, that has a default value, and read it from my typescript code through the vscode library
Can someone provide me and example about which file should I add, where, and how to consume? also if more configurations are needed.
Thanks!
Ok, found
I need to add into my package.json
...
"contributes": {
"commands": [
...
],
"configuration": {
"title": "My Extension",
"properties": {
"myExtension.myProperty": {
"type": "string",
"default": "default",
"description": "description"
}
}
}
},
and consume
vscode.workspace.getConfiguration('myExtension').myProperty;
Related
I am creating a vscode extension which has some custom settings. I have defined the settings in package.json like so:
{
"contributes": {
"configuration":[
{
"title": "Extension",
"properties": {
"Codegenx."A Float": {
"type": "number",
"default": 1.0,
"description": "A sample decimal number"
}
}
}
]
}
}
How can I access these setings in my main extension? And also make sure that I get the updated value if the user changes the settings through the settings.json file or through the VsCode UI?
Steps to Reproduce:
1.Create a new sample project by selecting New Language support.
2.Now add the following code in package.json to register 3 new languages.
"languages": [
{
"id": "db2_z",
"aliases": ["Db2Z"],
"extensions": [".spsql", ".sql",".z"],
"configuration": "./language-configuration.json"
},
{
"id": "db2_i",
"aliases": ["Db2i"],
"extensions": [".spsql", ".sql",".i"],
"configuration": "./language-configuration.json"
},
{
"id": "db2_luw",
"aliases": ["Db2Luw"],
"extensions": [".spsql", ".sql",".luw"],
"configuration": "./language-configuration.json"
}
]
3.Now when I run the extension it displays only one language type while saving. But while selecting the language mode it shows three languages.
Please check the attached screenshots.
But while saving we can see only one language.
I tried all the things but unable to figure out the problem.
Thanks.
According to language overview
"You can add new file extensions to an existing language with the files.associations setting."
"files.associations": {
"*.php4": "php",
"*.php5": "php"
}
"files.associations": {
"**/somefolder/*.*": "php"
}
I have a vs code extension with two configuration values.
"configuration": [
{
"title": "Test",
"properties": {
"conf.test.string2": {
"type": "string",
"description": "Installation Directory",
"scope": "window"
},
"conf.test.string1": {
"type": "string",
"description": "Directory",
"scope": "resource"
}
}
}
I am installing the extension using a custom installer which will run code <extension-name.vsix> for installing. How can I set the default values for these configurations during the installation? The values are derived during the installation by the custom installer.
Is there a way to pass the values in the commandline or any other way during the installation?
Add the configuration value to Settings.json in %APPDATA%/Code/User/settings.json
As the title suggests, I would like to define a vscode defaultSnippet for the additionalProperites of a JSONObject. The JSONSchema looks like the following
"$schema ": "http://json-schema.org/draft-07/schema#",
"type":"object",
"additionalProperties":{
"type": "object",
"properties":{
"name":{"type":"string"}
}
}
So just adding defaultSnippet property does not seem to work:
"$schema ": "http://json-schema.org/draft-07/schema#",
"type":"object",
"additionalProperties":{
"defaultSnippets": [{
"label": "test",
"description": "Additional property template",
"body": {
"$1": {
"name": "$2"
}
}
}],
"type": "object",
"properties":{
"name":{"type":"string"}
}
}
Is there a workaround to obtain the same behavior?
Your code is correct, but vscode at this moment is only checking properties for snippets. I had the same problem, so I've created Pull Request with fix for this issue.
https://github.com/microsoft/vscode-json-languageservice/pull/62
You can replace default extension if you in rush or just wait for merge and update.
I was able to successfully add basic language support for ColdFusion in visual studio code and for the most part it seems to work properly.
The only issue is that the syntax highlighting does not work at all, specifically the colorization. Otherwise the file extension association works and bracket highlight works and even the commenting rules work.
I used the yo code generator to create the new language.
I got the .tmLanguage file from here:
https://github.com/textmate/coldfusion.tmbundle
I feel like there must be a step I'm missing in order to get the new language to work with the theme being used.
Thanks in advance!
EDIT: added package.json
{
"name": "cf",
"displayName": "ColdFusion",
"description": "ColdFusion VSCode Support",
"version": "0.0.1",
"publisher": "epetti",
"engines": {
"vscode": "^0.10.1"
},
"categories": [
"Languages"
],
"contributes": {
"languages": [{
"id": "coldfusion",
"aliases": ["ColdFusion", "coldfusion"],
"extensions": [".cfm",".cfml",".cfc"],
"configuration": "./coldfusion.configuration.json"
}],
"grammars": [{
"language": "coldfusion",
"scopeName": "text.html.cfm",
"path": "./syntaxes/coldfusion.tmLanguage"
}]
}
}