Syntax coloring VSCode extension - syntax

I am trying to make an extension and need to colorize syntax for custom language. I was able to create extension using yo code and edit .tmLanguage.json file to match wanted syntaxes.
As for example in repository
"comment": {
"patterns": [
{
"name": "comment.line.semicolon",
"match": ";.*$"
}
]
},
However i have not been able to set custom color. Only way was to edit settings.json file using "editor.tokenColorCustomizations" and providing textMateRules.
Example:
For the pattern:
{
"name": "positioning.FMAX",
"match": "\\bFMAX\\b"
},
textMateRules
{
"name": "color.positioning.FMAX",
"scope": "positioning.FMAX",
"settings": {
"foreground": "#ff0000",
"fontStyle": "bold"
}
},
But this is not working when i hit F5 to test plugin. Because settings.json is not part of the extension.
I see in scope inspector.
textmate scopes positioning.FMAX
but foreground is
foreground No theme selector
comment.line.semicolon is working and coloring ;comments green
This doesn't work
{
"name": "positioning.FMAX",
"match": "\\bFMAX\\b",
"settings": {
"foreground": "#ff0000"
}
}
I just want simple way to color syntax like in setting.json. I have tried for more than week now. Any help much appreciated.

look at vscode-extension-samples repo:
https://github.com/microsoft/vscode-extension-samples/tree/main/theme-sample
You can describe your colors in json or tmTheme file and set it in package.json in contributes.themes. When debbugging started make sure that your custom theme selected as current for VSCode

Related

How to get just the text from RIch Text JSON? In Contentful?

I'm using contentful. Authors are using a rich text editor for this portion. For my purpose, i just want to be able to take out the text from the rich text editor (but still use the same JSON for other things, so i don't want to get rid of it either), how do i do so?
Currently, the JSON looks like this. What is the most effective way to just get "This text is important".
All i've gotten is to do something similar to the below, but it is inefficient and wordy especially when a post gets really big and complicated.
content[0].content[0].map((content) => content.value)
{
"nodeType": "document",
"data": {},
"content": [
{
"nodeType": "paragraph", // Can be paragraphs, images, lists, embedded entries
"data": {},
"content": [
{
"nodeType": "text",
"value": "This text is ",
"data": {},
"marks": []
},
{
"nodeType": "text",
"value": "important",
"data": {},
"marks": [
"type": "bold" // Can be bold, underline, italicss
]
}
]
}
]
}
The best approach is to use Contentful's provided rich-text-plain-text-renderer package.
If you want to implement it yourself, the source code is well documented and basically a recursive function calling itself until it reaches all the document leafs.

How do we mention or tag someone in using Slack's Block Kit Builder?

I tried creating slack's block kit builder, the desired design were actually fine. But I don't know where to find a button so we can tag a someone on it.
I have here an attempt to tag a person named john but unfortunately it only generated a plain text, it did not notify the person nor became the same the design as expected (see image result below)
view playground
{
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "#juan \n\nis a mrkdwn section block"
}
},
.....
]
}
Here is the result
I found the solution from the following link.
https://api.slack.com/reference/surfaces/formatting#mentioning-users
get the user's id
wrap it with a left and right arrow with an "#" symbol beside it. syntax <#userId>
usage:
{
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Hey <#802AWTP13BZ>, thanks for submitting your report!"
}
}
]
}

CircleCI-Slack integration formatting is not working as it used to be

After an upgrade to slack api, the formatting of circle-ci messages into slack channels is not working properly. I am trying to see what i can do in the config.yaml file to add some colour to it, i am a novice so thought this would be a small task i could take on from the dev team, but I've hit a roadblock
Is there a better way to format this
"elements": [
{
"type": "button",
"text": {
"type": "plain_text",
"text": "View Job"
},
"url": "${CIRCLE_BUILD_URL}"
}
]
Adding emoji: true doesn't really change anything, is there a way to change the formatting of the text and to print out better descriptive messages in a fail and a pas scenario?
If you want to use emojis in your build, besides adding emoji: true you need to add the emojis at the text too. I'll share an example, feel free to edit it.
{
"text":"CircleCI job succeeded!",
"blocks":[
{
"type":"header",
"text":{
"type":"plain_text",
"text":"Deployment Successful! :tada:",
"emoji":true
}
},
{
"type":"section",
"fields":[
{
"type":"mrkdwn",
"text":"*Project*: $CIRCLE_PROJECT_REPONAME"
},
{
"type":"mrkdwn",
"text":"*When*: $(date +'%m/%d/%Y %T')"
},
{
"type":"mrkdwn",
"text":"*Tag*: $CIRCLE_TAG"
}
],
"accessory":{
"type":"image",
"image_url":"https://assets.brandfolder.com/otz5mn-bw4j2w-6jzqo8/original/circle-logo-badge-black.png",
"alt_text":"CircleCI logo"
}
},
{
"type":"actions",
"elements":[
{
"type":"button",
"text":{
"type":"plain_text",
"text":"View Job"
},
"url":"${CIRCLE_BUILD_URL}"
}
]
}
]
}
See the first text block, there is a :tada emoji, also the message is separated into blocks, see the screenshot of this config:

How can I apply token color changes to existing vscode color theme?

I'm trying to make vscode theme by modifying existing color theme.
and having trouble with applying token color changes to existing theme.
I saw official guide of vscode(https://code.visualstudio.com/docs/getstarted/themes) and tried like below.
but lint says 'Property entity.name.function.member is not allowed.' and not applied to current workbench.
"workbench.colorCustomizations": {
"activityBar.background": "#2a2b30",
"[Darktooth]": {
"entity.name.function.member": "#347890"
}
},
I know there is a way to change editor with specifying all tokens, but I think using existing theme would save time.
Also I would like to apply color to some workbenches(workspace) not the entire editor.
"editor.tokenColorCustomizations": {
"comments": "#595436",
"strings": "#D5ECE2",
"functions": "#1ee9a5",
"textMateRules": [
{
"scope": "storage.modifier.ts",
"settings": {
"foreground": "#FFFFFF"
}
},
{
"scope":["entity.name.function.member", "meta.object-literal.key.js"],
"settings": {
"foreground": "#A1E2AA",
}
},
],
},

Is there a way to use variables within URLs of slack workflows actions?

I'm setting up a workflow that takes in a text variable I'd like to use in a later link.
For example, I ask for "Api Name", and then want to send a message that both references the api name as well as constructs a url (e.g. http://swagger.io/docs/"Api Name")
The problem I encounter is the links come up in plaintext if I just try to include that url as plaintext example as above. If I use the editor to try and add a link, the variable is not available.
My next thought was to try and edit the workflow json to supply some markdown in there, but it looks like the richtext is constructed from a series of elements.
A link looks like this:
{
"type": "link",
"url": "https://swagger.io/collections/",
"text": "(Link)"
},
And a token looks like this:
{
"type": "workflowtoken",
"id": "<some uuid>==user",
"property": "",
"data_type": "user",
"style": null
},
If I merely make the link plaintext and try to append the variable after the prefix I get something like this:
{
"type": "text",
"text": "https://swagger.io/thing/",
"style": {
"unlink": true
}
},
{
"type": "workflowtoken",
"id": "<uuid>==text",
"property": "",
"data_type": "text",
"style": null
},
So maybe if we knew all the values "type" could be that would help?
Not sure where to go from here. Anyone have any suggestions?
Here is an answer from Slack Support Service:
We don't yet support Workflow variables outputted in links, I'm
afraid.
This is feedback we hear quite a bit so hopefully it's the something
the team will consider implementing in the future.

Resources