Skip to content

Commit

Permalink
Rename keyvalue3 to keyvalue. Fixes #110
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanH-AT committed Dec 5, 2023
1 parent 33eb9d9 commit 173bdbd
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 41 deletions.
File renamed without changes.
41 changes: 19 additions & 22 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
},
"main": "./out/main.js",
"activationEvents": [
"onLanguage:keyvalue3",
"onLanguage:keyvalue",
"onLanguage:vmt",
"onLanguage:captions",
"onLanguage:qc",
Expand All @@ -62,7 +62,7 @@
"path": "./snippets/vmt-snippets.json"
},
{
"language": "keyvalue3",
"language": "keyvalue",
"path": "./snippets/gameinfo-snippets.json"
},
{
Expand All @@ -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",
Expand All @@ -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"
Expand All @@ -119,7 +116,7 @@
},
{
"id": "fgd",
"configuration": "./lang-config-kv3.json",
"configuration": "./lang-config-kv.json",
"aliases": [
"FGD",
"Forge Game Data",
Expand All @@ -131,7 +128,7 @@
},
{
"id": "captions",
"configuration": "./lang-config-kv3.json",
"configuration": "./lang-config-kv.json",
"aliases": [
"Source Engine Captions",
"Source Engine Subtitles"
Expand All @@ -144,7 +141,7 @@
},
{
"id": "cfg",
"configuration": "./lang-config-kv3.json",
"configuration": "./lang-config-kv.json",
"aliases": [
"Source Engine Configuration",
"Source Engine Commands"
Expand All @@ -155,7 +152,7 @@
},
{
"id": "vpc",
"configuration": "./lang-config-kv3.json",
"configuration": "./lang-config-kv.json",
"aliases": [
"Valve Project Creator"
],
Expand All @@ -166,7 +163,7 @@
},
{
"id": "qc",
"configuration": "./lang-config-kv3.json",
"configuration": "./lang-config-kv.json",
"aliases": [
"Valve QC",
"Valve MC",
Expand All @@ -188,7 +185,7 @@
},
{
"id": "soundscript",
"configuration": "./lang-config-kv3.json",
"configuration": "./lang-config-kv.json",
"aliases": [
"Valve Soundscript",
"Source Soundscript"
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -389,7 +386,7 @@
}
},
"configurationDefaults": {
"[keyvalue3]": {
"[keyvalue]": {
"editor.semanticHighlighting.enabled": true
}
}
Expand Down
20 changes: 10 additions & 10 deletions src/KvFileDetection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,28 @@ function isAutoDetectEnabled(): boolean {
return main.config.get<boolean>("kvAutoDetect.enabled", false);
}

type DetectableLanguageId = "keyvalue3" | "soundscript" | "captions";
type DetectableLanguageId = "keyvalue" | "soundscript" | "captions";

interface CommonFileName {
regex: RegExp;
languageId: DetectableLanguageId;
}

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 {
Expand Down Expand Up @@ -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);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/language/LangKv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/language/Shared.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down
2 changes: 1 addition & 1 deletion syntaxes/captions.tmLanguage.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
},
{
"match": "\"?(?i)tokens(?-i)\"?",
"name": "variable.name.keyvalue3"
"name": "variable.name.keyvalue"
},
{
"include": "#data"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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": [{
Expand Down
2 changes: 1 addition & 1 deletion vsc-extension-quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 173bdbd

Please sign in to comment.