Skip to content

Commit

Permalink
feat: colorize output
Browse files Browse the repository at this point in the history
Signed-off-by: Timon Wong <timon86.wang@gmail.com>
  • Loading branch information
timonwong committed Oct 21, 2022
1 parent e179a7e commit df91f4d
Show file tree
Hide file tree
Showing 7 changed files with 119 additions and 4 deletions.
3 changes: 2 additions & 1 deletion cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"overridable",
"linkify",
"deps",
"outputchannel"
"outputchannel",
"datetime"
]
}
25 changes: 25 additions & 0 deletions languages/shellcheck-output/language-configuration.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
// symbols used as brackets
"brackets": [
["{", "}"],
["[", "]"],
["(", ")"],
["<", ">"]
],
// symbols that are auto closed when typing
"autoClosingPairs": [
["{", "}"],
["[", "]"],
["(", ")"],
["\"", "\""],
["'", "'"]
],
// symbols that that can be used to surround a selection
"surroundingPairs": [
["{", "}"],
["[", "]"],
["(", ")"],
["\"", "\""],
["'", "'"]
]
}
77 changes: 77 additions & 0 deletions languages/shellcheck-output/tmLanguage.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
{
"scopeName": "shellcheck-output",
"patterns": [
{
"include": "#string-single-quoted"
},
{
"include": "#string-double-quoted"
},
{
"include": "#datetime-RFC3339"
},
{
"include": "#date-ISO"
},
{
"include": "#time"
},
{
"include": "#error-tag"
},
{
"include": "#warn-tag"
},
{
"include": "#info-tag"
},
{
"include": "#debug-tag"
},
{
"include": "#numeric-decimal"
}
],
"repository": {
"string-double-quoted": {
"match": "\"(.*?)\"",
"name": "string.quoted"
},
"string-single-quoted": {
"match": "'(.*?)'",
"name": "string.quoted"
},
"datetime-RFC3339": {
"match": "\\b(\\d{4}-\\d{2}-\\d{2})T(\\d{2}:\\d{2}:\\d{2}(?:\\.\\d+)?)(Z|[\\+-]\\d{2}:\\d{2})?",
"name": "constant.numeric"
},
"date-ISO": {
"match": "\\b\\d{4}-\\d{2}-\\d{2}(T|\\b)",
"name": "constant.numeric"
},
"time": {
"match": "\\d{1,2}:\\d{1,2}:\\d{2}(:\\d{2}([.,]\\d{1,})?)?(Z| ?[+-]\\d{1,2}:\\d{2})?(.\\d{3})?",
"name": "constant.numeric"
},
"error-tag": {
"match": "\\[ERROR\\]",
"name": "markup.bold invalid.illegal"
},
"warn-tag": {
"match": "\\[WARN\\]",
"name": "markup.bold markup.deleted"
},
"info-tag": {
"match": "\\[INFO\\]",
"name": "markup.bold markup.inserted"
},
"debug-tag": {
"match": "\\[(TRACE|DEBUG)\\]",
"name": "markup.bold markup.changed"
},
"numeric-decimal": {
"match": "\\b\\d+(\\.\\d+)?\\b",
"name": "constant.numeric"
}
}
}
File renamed without changes.
File renamed without changes.
13 changes: 11 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,23 @@
"extensions": [
".shellcheckrc"
],
"configuration": "./shellcheckrc/language-configuration.json"
"configuration": "./languages/shellcheckrc/language-configuration.json"
},
{
"id": "shellcheck-output",
"configuration": "./languages/shellcheck-output/language-configuration.json"
}
],
"grammars": [
{
"language": "shellcheckrc",
"scopeName": "source.shellcheckrc",
"path": "./shellcheckrc/tmLanguage.json"
"path": "./languages/shellcheckrc/tmLanguage.json"
},
{
"language": "shellcheck-output",
"scopeName": "shellcheck-output",
"path": "./languages/shellcheck-output/tmLanguage.json"
}
],
"commands": [
Expand Down
5 changes: 4 additions & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ export function activate(
context: vscode.ExtensionContext
): ShellCheckExtensionApi {
// Setup logging
const outputChannel = vscode.window.createOutputChannel("ShellCheck");
const outputChannel = vscode.window.createOutputChannel(
"ShellCheck",
"shellcheck-output"
);
context.subscriptions.push(outputChannel);

const logger = new OutputChannelLogger(outputChannel);
Expand Down

0 comments on commit df91f4d

Please sign in to comment.