From 173bdbda15fcf142d308521471a129043032d87a Mon Sep 17 00:00:00 2001 From: Stefan Heinz Date: Tue, 5 Dec 2023 18:11:39 +0100 Subject: [PATCH] Rename keyvalue3 to keyvalue. Fixes #110 --- lang-config-kv3.json => lang-config-kv.json | 0 package.json | 41 +++++++++---------- src/KvFileDetection.ts | 20 ++++----- src/language/LangKv.ts | 2 +- src/language/Shared.ts | 2 +- syntaxes/captions.tmLanguage.json | 2 +- ...Language.json => keyvalue.tmLanguage.json} | 10 ++--- vsc-extension-quickstart.md | 2 +- 8 files changed, 38 insertions(+), 41 deletions(-) rename lang-config-kv3.json => lang-config-kv.json (100%) rename syntaxes/{keyvalue3.tmLanguage.json => keyvalue.tmLanguage.json} (82%) diff --git a/lang-config-kv3.json b/lang-config-kv.json similarity index 100% rename from lang-config-kv3.json rename to lang-config-kv.json diff --git a/package.json b/package.json index 1f73151..b6436f0 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,7 @@ }, "main": "./out/main.js", "activationEvents": [ - "onLanguage:keyvalue3", + "onLanguage:keyvalue", "onLanguage:vmt", "onLanguage:captions", "onLanguage:qc", @@ -62,7 +62,7 @@ "path": "./snippets/vmt-snippets.json" }, { - "language": "keyvalue3", + "language": "keyvalue", "path": "./snippets/gameinfo-snippets.json" }, { @@ -84,11 +84,12 @@ ], "languages": [ { - "id": "keyvalue3", - "configuration": "./lang-config-kv3.json", + "id": "keyvalue", + "configuration": "./lang-config-kv.json", "aliases": [ - "Valve Keyvalue 3", - "keyvalue3" + "Valve KeyValue", + "keyvalue", + "KV" ], "extensions": [ ".kv", @@ -100,15 +101,11 @@ ".vmf", ".vmm", ".vmx" - ], - "filenames": [ - "gameinfo.txt" - ], - "firstLine": "^([\\w ]+|\"[\\w ]+\")" + ] }, { "id": "vmt", - "configuration": "./lang-config-kv3.json", + "configuration": "./lang-config-kv.json", "aliases": [ "Valve Material Type", "vmt" @@ -119,7 +116,7 @@ }, { "id": "fgd", - "configuration": "./lang-config-kv3.json", + "configuration": "./lang-config-kv.json", "aliases": [ "FGD", "Forge Game Data", @@ -131,7 +128,7 @@ }, { "id": "captions", - "configuration": "./lang-config-kv3.json", + "configuration": "./lang-config-kv.json", "aliases": [ "Source Engine Captions", "Source Engine Subtitles" @@ -144,7 +141,7 @@ }, { "id": "cfg", - "configuration": "./lang-config-kv3.json", + "configuration": "./lang-config-kv.json", "aliases": [ "Source Engine Configuration", "Source Engine Commands" @@ -155,7 +152,7 @@ }, { "id": "vpc", - "configuration": "./lang-config-kv3.json", + "configuration": "./lang-config-kv.json", "aliases": [ "Valve Project Creator" ], @@ -166,7 +163,7 @@ }, { "id": "qc", - "configuration": "./lang-config-kv3.json", + "configuration": "./lang-config-kv.json", "aliases": [ "Valve QC", "Valve MC", @@ -188,7 +185,7 @@ }, { "id": "soundscript", - "configuration": "./lang-config-kv3.json", + "configuration": "./lang-config-kv.json", "aliases": [ "Valve Soundscript", "Source Soundscript" @@ -222,14 +219,14 @@ ], "grammars": [ { - "language": "keyvalue3", + "language": "keyvalue", "scopeName": "source.kv", - "path": "./syntaxes/keyvalue3.tmLanguage.json" + "path": "./syntaxes/keyvalue.tmLanguage.json" }, { "language": "soundscript", "scopeName": "source.kv", - "path": "./syntaxes/keyvalue3.tmLanguage.json" + "path": "./syntaxes/keyvalue.tmLanguage.json" }, { "language": "vmt", @@ -389,7 +386,7 @@ } }, "configurationDefaults": { - "[keyvalue3]": { + "[keyvalue]": { "editor.semanticHighlighting.enabled": true } } diff --git a/src/KvFileDetection.ts b/src/KvFileDetection.ts index 58c5e3d..8c39a45 100644 --- a/src/KvFileDetection.ts +++ b/src/KvFileDetection.ts @@ -6,7 +6,7 @@ function isAutoDetectEnabled(): boolean { return main.config.get("kvAutoDetect.enabled", false); } -type DetectableLanguageId = "keyvalue3" | "soundscript" | "captions"; +type DetectableLanguageId = "keyvalue" | "soundscript" | "captions"; interface CommonFileName { regex: RegExp; @@ -14,20 +14,20 @@ interface CommonFileName { } const commonKvFileNames: CommonFileName[] = [ - { regex: /gameinfo\.txt/i, languageId: "keyvalue3" }, + { regex: /gameinfo\.txt/i, languageId: "keyvalue" }, { regex: /subtitles_.+\.txt/i, languageId: "captions" }, { regex: /captions_.+\.txt/i, languageId: "captions" }, - { regex: /basemodui_.+\.txt/i, languageId: "keyvalue3" }, - { regex: /instructor_lessons\.txt/i, languageId: "keyvalue3" }, - { regex: /instructor_textures\.txt/i, languageId: "keyvalue3" }, + { regex: /basemodui_.+\.txt/i, languageId: "keyvalue" }, + { regex: /instructor_lessons\.txt/i, languageId: "keyvalue" }, + { regex: /instructor_textures\.txt/i, languageId: "keyvalue" }, { regex: /game_sounds_.+\.txt/i, languageId: "soundscript" }, { regex: /npc_sounds_.+\.txt/i, languageId: "soundscript" }, { regex: /level_sounds_.+\.txt/i, languageId: "soundscript" }, { regex: /soundscapes_.+\.txt/i, languageId: "soundscript" }, - { regex: /surfaceproperties_.+\.txt/i, languageId: "keyvalue3" }, - { regex: /weapon_.+\.txt/i, languageId: "keyvalue3" }, - { regex: /vgui_screens\.txt/i, languageId: "keyvalue3" }, - { regex: /credits\.txt/i, languageId: "keyvalue3" } + { regex: /surfaceproperties_.+\.txt/i, languageId: "keyvalue" }, + { regex: /weapon_.+\.txt/i, languageId: "keyvalue" }, + { regex: /vgui_screens\.txt/i, languageId: "keyvalue" }, + { regex: /credits\.txt/i, languageId: "keyvalue" } ]; function getCommonFileNameMatch(fileName: string): CommonFileName | undefined { @@ -78,7 +78,7 @@ function detectKeyvalueFile(editor: vscode.TextEditor, context: vscode.Extension return; } - main.debugOutput.appendLine(`Changing document language of (${editor.document.uri.fsPath}) to keyvalue3`); + main.debugOutput.appendLine(`Changing document language of (${editor.document.uri.fsPath}) to keyvalue`); vscode.languages.setTextDocumentLanguage(editor.document, langId); } } diff --git a/src/language/LangKv.ts b/src/language/LangKv.ts index 49a6e60..90d1675 100644 --- a/src/language/LangKv.ts +++ b/src/language/LangKv.ts @@ -36,7 +36,7 @@ export class KeyvalueSemanticTokensProvider extends KvTokensProviderBase { ]; constructor() { - super(KvDocument.tokenLegend, vscode.languages.createDiagnosticCollection("keyvalue3")); + super(KvDocument.tokenLegend, vscode.languages.createDiagnosticCollection("keyvalue")); } processValueNumber(params: KvSemanticProcessorParams): boolean { diff --git a/src/language/Shared.ts b/src/language/Shared.ts index bdf7fe0..511a53a 100644 --- a/src/language/Shared.ts +++ b/src/language/Shared.ts @@ -1,6 +1,6 @@ import { DocumentFilter } from "vscode"; -export const languageIdKeyvalue = "keyvalue3"; +export const languageIdKeyvalue = "keyvalue"; export const languageIdVmt = "vmt"; export const languageIdSoundscript = "soundscript"; export const languageIdCaptions = "captions"; diff --git a/syntaxes/captions.tmLanguage.json b/syntaxes/captions.tmLanguage.json index 2971524..735a20f 100644 --- a/syntaxes/captions.tmLanguage.json +++ b/syntaxes/captions.tmLanguage.json @@ -30,7 +30,7 @@ }, { "match": "\"?(?i)tokens(?-i)\"?", - "name": "variable.name.keyvalue3" + "name": "variable.name.keyvalue" }, { "include": "#data" diff --git a/syntaxes/keyvalue3.tmLanguage.json b/syntaxes/keyvalue.tmLanguage.json similarity index 82% rename from syntaxes/keyvalue3.tmLanguage.json rename to syntaxes/keyvalue.tmLanguage.json index 0ee7cf1..cae56b7 100644 --- a/syntaxes/keyvalue3.tmLanguage.json +++ b/syntaxes/keyvalue.tmLanguage.json @@ -21,23 +21,23 @@ ], "repository": { "comment": { - "name": "comment.line.keyvalue3", + "name": "comment.line.keyvalue", "match": "//.*" }, "boolean": { - "name": "constant.numeric.keyvalue3", + "name": "constant.numeric.keyvalue", "match": "\\b(true|false)\\b" }, "number": { - "name": "constant.numeric.keyvalue3", + "name": "constant.numeric.keyvalue", "match": "-?([0-9]+)?\\.?[0-9]+" }, "stringUnquoted": { - "name": "string.unquoted.keyvalue3", + "name": "string.unquoted.keyvalue", "match": "[\\w|\\*\\.\\\\/$%#-\\[\\]]+" }, "stringQuoted": { - "name": "string.quoted.double.keyvalue3", + "name": "string.quoted.double.keyvalue", "begin": "\"", "end": "\"", "patterns": [{ diff --git a/vsc-extension-quickstart.md b/vsc-extension-quickstart.md index e7b59c8..49864f7 100644 --- a/vsc-extension-quickstart.md +++ b/vsc-extension-quickstart.md @@ -4,7 +4,7 @@ * This folder contains all of the files necessary for your extension. * `package.json` - this is the manifest file in which you declare your language support and define the location of the grammar file that has been copied into your extension. -* `syntaxes/keyvalue3.tmLanguage.json` - this is the Text mate grammar file that is used for tokenization. +* `syntaxes/keyvalue.tmLanguage.json` - this is the Text mate grammar file that is used for tokenization. * `language-configuration.json` - this is the language configuration, defining the tokens that are used for comments and brackets. ## Get up and running straight away