User defined colors in textmate grammar? - vscode-extensions

I use TexMate grammar to change colors of certain keywords/lines in output pane.:
my-output.tmLanguage.json
{
"$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json",
"name": "my-output",
"scopeName": "source.my-output",
"patterns": [
{
"match": "foo",
"name": "my-bar"
}
]
}
The colors are hardcoded in package.json as:
"contributes": {
"grammars": [
{
"language": "my-output",
"scopeName": "source.my-output",
"path": "my-output.tmLanguage.json"
}
],
"configurationDefaults": {
"editor.tokenColorCustomizations": {
"textMateRules": [
{
"scope": "my-foo",
"settings": {
"foreground": "#123456"
}
}
]
}
}
}
Does VSCode provide ability to override textmate colors if defined in user's config?

Related

How to implement conditional nested properties with JSON Schema [duplicate]

This question already has an answer here:
Is there support in JSON Schema for deep object validation?
(1 answer)
Closed 1 year ago.
I have base json schema base.schema.json
{
"$id": "base.schema.json",
"type": "object",
"properties": {
"remote_os": {
"default": "Windows",
"enum": [
"Linux",
"Windows" ]
}
},
"required": ["remote_os"]
}
Now referenced the schema definition in another json
{
"$id": "update.schema.json",
"properties": {
"common_data": {
"$ref": "base.schema.json"
}
},
"allOf": [
{
"if": {
"properties": {
"common_data": {
"remote_os": {
"const": "Windows"
}
}
}
},
"then": {
"properties": {
"file": {
"pattern": "^(.*.)(exe)$"
}
}
}
},
{
"if": {
"properties": {
"common_data": {
"remote_os": {
"const": "Linux",
"required": [
"remote_os"
]
}
}
}
},
"then": {
"properties": {
"file": {
"pattern": "^(.*.)(bin)$"
}
}
}
}
]
}
Basically adding the if-else logic to make sure for remote_os=Linux file should ended up with .bin and remote_os=Windows file should ended up with .exe
Now I am trying to validate against below data
{
"common_data": {
"remote_os": "Linux"
},
"file": "abc.bin"
}
[<ValidationError: "'abc.bin' does not match '^(.*.)(exe)$'">]. Not sure what's wrong here
I think you are over complicating it - surly just if/then/else?
{
"if": {
"properties": { "common_data": "properties": { "remote_os": { "const": "Windows" } } }
},
"then": {
"properties": { "file": { "pattern": "^(.*.)(exe)$" } }
},
"else": {
"properties": { "file": { "pattern": "^(.*.)(bin)$" } }
}
}

Create a new Google Sheet with row or column groups

I'm trying to create a new spreadsheet using spreadsheets#create, with specified row groups.
In the API Explorer, I am entering in the JSON below. which corresponds to the following appearance:
No errors are flagged or returned when I execute the call, but when the sheet is created, the specified grouping is not created - only the values are set.
{ "properties": {
"title": "Test Spreadsheet",
"locale": "en"
},
"sheets": [
{ "properties": {"title": "Test1"},
"data": [
{
"startRow": 0,
"startColumn": 0,
"rowData": [
{ "values": [
{ "userEnteredValue": { "stringValue": "Top1" } }
]
},
{ "values": [
{ "userEnteredValue": { "stringValue": "Top2" } }
]
},
{ "values": [
{ "userEnteredValue": { "stringValue": "" } },
{ "userEnteredValue": { "stringValue": "Top2A" } }
]
},
{ "values": [
{ "userEnteredValue": { "stringValue": "" } },
{ "userEnteredValue": { "stringValue": "Top2B" } }
]
},
{ "values": [
{ "userEnteredValue": { "stringValue": "" } },
{ "userEnteredValue": { "stringValue": "Top2C" } }
]
},
{ "values": [
{ "userEnteredValue": { "stringValue": "Top3" } }
]
}
]
}
],
"rowGroups": [
{ "range": {
"dimension": "ROWS",
"startIndex": 2,
"endIndex": 5
}
}
]
}
]
}
Even when I create the rowGroups JSON directly on the page, with its structured editor to make sure it is properly defined, the created spreadsheet still doesn't group the specified rows. I have triple-checked all my objects from the top down, and can't see what I am doing wrong.

SWITCH in json schema (v5 proposal)

I'm newbie about npm ajv
I have a question:
How many "switch" in a object json?
example:
var schema = {
"type": "object",
"switch": [
{
"if": {
"properties": {
"powerLevel": {"constant": false}
}
},
"then": {
"required": ["disbelief"]
}
},
{
"then": {
"required": ["confidence"]
}
}
],
"switch": [
{
"if": {
"properties": {
"power": {"constant": false}
}
},
"then": {
"required": ["disb"]
}
},
{
"then": {
"required": ["conf"]
}
}
]
};
I test with schema above in this link
it's just check end switch.
please help me! thanks!
You cannot have two keywords switch in the same object.
In this particular instance you can merge the "cases" in one switch:
{
"type": "object",
"switch": [
{
"if": { "properties": { "powerLevel": {"constant": false} } },
"then": { "required": ["disbelief"] }
},
{
"if": { "properties": { "power": {"constant": false} } },
"then": { "required": ["disb"] }
},
{
"then": {
"oneOf": [
{ "required": ["confidence"] },
{ "required": ["conf"] }
]
}
}
]
}
In general case you can use keywords allOf, anyOf, oneOf to merge two schemas containing duplicate keywords between them.

Elasticsearch dynamic mapping convert all to string (using Javascript client)

I have a situation where I'll need to import a bunch of different data that may end up having conflicting data types. I have decided to convert everything to a string and then convert back later if the data is needed. I can't figure out how to do this with Elasticsearches (ES) dynamic mapping using the javascript client.
What ES says in their docs:
{
"mappings": {
"my_type": {
"dynamic_templates": [
{ "es": {
"match": "*_es",
"match_mapping_type": "string",
"mapping": {
"type": "string",
"analyzer": "spanish"
}
}},
{ "en": {
"match": "*",
"match_mapping_type": "string",
"mapping": {
"type": "string",
"analyzer": "english"
}
}}
]
}}}
in their docs it says " Match string fields whose name ends in _es".
"Match all other string fields": https://www.elastic.co/guide/en/elasticsearch/guide/current/custom-dynamic-mapping.html
This is what I've tried, but doesn't convert all to string (also tried without quotes around wildcard):
event.mappings = {
"mytype": {
"match": "*",
"mapping": {
"type": "string"
}
}
}
I've also tried "match_mapping_type" : "*".
I've tried: esClient.indices.putMapping({index:"myindex", type:"mytype", body:mybody})
in the response and outside of the .create function.
Any tips?
Your mapping should look like this
PUT /test
{
"mappings": {
"test": {
"dynamic_templates": [
{
"en": {
"match": "*",
"mapping": {
"type": "string"
}
}
}
]
}
}
}
Test data:
POST /test/test/1
{
"nr": 1,
"jsonDate":"2015-06-08T03:41:12-05:00",
"bool": true
}
The resulting mapping, as seen by ES:
{
"test": {
"mappings": {
"test": {
"dynamic_templates": [
{
"en": {
"mapping": {
"type": "string"
},
"match": "*"
}
}
],
"properties": {
"bool": {
"type": "string"
},
"jsonDate": {
"type": "string"
},
"nr": {
"type": "string"
}
}
}
}
}
}

Intellij IDEA, control page up, page down scroll size

I am not satisfied with the scrolling behaviour in intellij for page up, page down. It doesn't feel right. It always feels as if I get out of the scope.
Is it possible to adjust the scroll size of page up, page down? Perhaps to half a page or similar.
I had taken #yole's answer and implemented all of the actions he had described in a separate plugin:
There is no way to control this through the settings. What you can do is write a plugin that performs scrolling in the way that you prefer. It's fairly easy: all you need to do is copy the existing
PageUpAction/PageDownAction classes and the methods they call
(EditorActionUtil.moveCaretPageUp/Down) to scroll by as much as you want.
This plugin implements new actions "Partial Page Up" and "Partial Page Down" which allow one to scroll a configurable size of screen definable in the usual IDEA settings dialog.
There's an installable version of the plugin in official JetBrains repository.
There is no way to control this through the settings. What you can do is write a plugin that performs scrolling in the way that you prefer. It's fairly easy: all you need to do is copy the existing PageUpAction/PageDownAction classes and the methods they call (EditorActionUtil.moveCaretPageUp/Down) to scroll by as much as you want.
Since many are inquiring about this, for mac users this can be controlled globally instead by instead scrolling on page up/down using karabiner application and adding the following complex rule:
{
"description": "mmm.karabiner.page.up.down.to.scroll",
"manipulators": [
{
"conditions": [
{
"bundle_identifiers": [
"^net.java.openjdk.cmd",
"^com.jetbrains.intellij"
],
"type": "frontmost_application_if"
}
],
"from": {
"key_code": "page_up"
},
"to": [
{
"mouse_key": {
"vertical_wheel": -51
}
}
],
"to_delayed_action": {
"to_if_invoked": [
{
"pointing_button": "button1"
}
]
},
"type": "basic"
},
{
"conditions": [
{
"bundle_identifiers": [
"^net.java.openjdk.cmd",
"^com.jetbrains.intellij"
],
"type": "frontmost_application_unless"
}
],
"from": {
"key_code": "page_up"
},
"to": [
{
"mouse_key": {
"vertical_wheel": -51
}
}
],
"type": "basic"
},
{
"conditions": [
{
"bundle_identifiers": [
"^net.java.openjdk.cmd",
"^com.jetbrains.intellij"
],
"type": "frontmost_application_if"
}
],
"from": {
"key_code": "up_arrow",
"modifiers": {
"mandatory": [
"fn"
]
}
},
"to": [
{
"mouse_key": {
"vertical_wheel": -51
}
}
],
"to_delayed_action": {
"to_if_invoked": [
{
"pointing_button": "button1"
}
]
},
"type": "basic"
},
{
"conditions": [
{
"bundle_identifiers": [
"^net.java.openjdk.cmd",
"^com.jetbrains.intellij"
],
"type": "frontmost_application_unless"
}
],
"from": {
"key_code": "up_arrow",
"modifiers": {
"mandatory": [
"fn"
]
}
},
"to": [
{
"mouse_key": {
"vertical_wheel": -51
}
}
],
"type": "basic"
},
{
"conditions": [
{
"bundle_identifiers": [
"^net.java.openjdk.cmd",
"^com.jetbrains.intellij"
],
"type": "frontmost_application_if"
}
],
"from": {
"key_code": "page_down"
},
"to": [
{
"mouse_key": {
"vertical_wheel": 51
}
}
],
"to_delayed_action": {
"to_if_invoked": [
{
"pointing_button": "button1"
}
]
},
"type": "basic"
},
{
"conditions": [
{
"bundle_identifiers": [
"^net.java.openjdk.cmd",
"^com.jetbrains.intellij"
],
"type": "frontmost_application_unless"
}
],
"from": {
"key_code": "page_down"
},
"to": [
{
"mouse_key": {
"vertical_wheel": 51
}
}
],
"type": "basic"
},
{
"conditions": [
{
"bundle_identifiers": [
"^net.java.openjdk.cmd",
"^com.jetbrains.intellij"
],
"type": "frontmost_application_if"
}
],
"from": {
"key_code": "down_arrow",
"modifiers": {
"mandatory": [
"fn"
]
}
},
"to": [
{
"mouse_key": {
"vertical_wheel": 51
}
}
],
"to_delayed_action": {
"to_if_invoked": [
{
"pointing_button": "button1"
}
]
},
"type": "basic"
},
{
"conditions": [
{
"bundle_identifiers": [
"^net.java.openjdk.cmd",
"^com.jetbrains.intellij"
],
"type": "frontmost_application_unless"
}
],
"from": {
"key_code": "down_arrow",
"modifiers": {
"mandatory": [
"fn"
]
}
},
"to": [
{
"mouse_key": {
"vertical_wheel": 51
}
}
],
"type": "basic"
}
]
},
Also do note, to get smooth scrolling, consider down loading Mos application and adjust the preferences if desired.
https://mos.caldis.me/
This might have other consequences on your Mac so you might need to have to adjust other things since your page_up/down is no longer a page_up/down but mouse scrolls instead.