Skip to content

Commit 5f7ceba

Browse files
committed
Added: Ability to change indentation level in vscode settings.
1 parent d08557c commit 5f7ceba

File tree

3 files changed

+23
-10
lines changed

3 files changed

+23
-10
lines changed

client/package.json

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
11
{
2-
"name": "lsp-sample-client",
3-
"description": "VSCode part of a language server",
4-
"author": "Microsoft Corporation",
5-
"license": "MIT",
6-
"version": "0.0.1",
7-
"publisher": "vscode",
2+
"name": "ZS-Server",
3+
"displayName": "ZeroSyntax-Highlight",
4+
"description": "Syntax highlighting for Zero Hour map.ini",
5+
"icon": "./images/icon.png",
6+
"version": "0.1.0",
7+
"publisher": "ViTeXFTW",
8+
"author": {
9+
"name": "ViTeXFTW",
10+
"email": "[email protected]"
11+
},
812
"repository": {
913
"type": "git",
10-
"url": "https://github.com/Microsoft/vscode-extension-samples"
14+
"url": "https://github.com/ViTeXFTW/ZeroSyntax-Highlight"
1115
},
16+
"license": "MIT",
1217
"engines": {
13-
"vscode": "^1.75.0"
18+
"vscode": "^1.85.0"
1419
},
1520
"dependencies": {
1621
"vscode-languageclient": "^8.1.0"

client/src/extension.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import { getVSCodeDownloadUrl } from '@vscode/test-electron/out/util';
77
import { time } from 'console';
88
import * as path from 'path';
9+
import { config } from 'process';
910
import * as vscode from 'vscode';
1011

1112
import {
@@ -71,7 +72,9 @@ export function activate(context: vscode.ExtensionContext) {
7172
function formatDocument(document: vscode.TextDocument): vscode.TextEdit[] {
7273
const edits: vscode.TextEdit[] = [];
7374
let indentlevel = 0;
74-
const indentSize = 2;
75+
76+
const config = vscode.workspace.getConfiguration('ZS-Server');
77+
const indentSize = config.get<number>('indentNumber', 2); // Default to 2 if not set
7578

7679
let ObjectsRegex = ["^\\b([Oo]bject)\\s+[a-zA-Z0-9_]", "^\\b([Oo]bject[Rr]eskin)\\s+[a-zA-Z0-9_]", "^\\b([Aa]dd[Mm]odule)$", "^\\b([Rr]eplace[Mm]odule)$", "^\\b([Dd]efault[Cc]ondition[Ss]tate)$", "^\\b([Uu]nit[Ss]pecific[Ss]ounds)$", "^\\b([Pp]rerequisites)$", "^\\b([Aa]rmor[Ss]et)$", "^\\b([Ww]eapon[Ss]et)$", "^\\b([Dd]raw)\\s*=", "^\\b([Cc]ondition[Ss]tate)\\s*=", "^\\b([Tt]ransition[Ss]tate)\\s*=", "^\\b([Bb]ody)\\s*=", "^\\b([Bb]ehavior)\\s*=", "^\\b([Cc]lient[Uu]pdate)\\s*=", "^\\b(Turret)$"];
7780
let SimpleClassesRegex = ["^\\b([Mm]apped[Ii]mage)\\s+[a-zA-Z0-9_]", "^\\b([Pp]article[Ss]ystem)\\s+[a-zA-Z0-9_]", "^\\b([Ll]ocomotor)\\s+[a-zA-Z0-9_]", "^\\b([Aa]udio[Ee]vent)\\s+[a-zA-Z0-9_]", "^\\b([Dd]ialog[Ee]vent)\\s+[a-zA-Z0-9_]", "^\\b([Aa]rmor)\\s+[a-zA-Z0-9_]", "^\\b([Cc]ommand[Ss]et)\\s+[a-zA-Z0-9_]", "^\\b([Cc]ommand[Bb]utton)\\s+[a-zA-Z0-9_]", "^\\b([Ww]eapon)\\s+[a-zA-Z0-9_]", "^\\b([Dd]amage[Ff][Xx])\\s+[A-Za-z0-9_]", "^\\b([Uu]pgrade)\\s+[a-zA-Z0-9_]", "^\\b([Pp]layer[Tt]emplate)\\s+[a-zA-Z0-9_]", "^\\b(Rank)\\s+[1-8]$", "^\\b([Ii]n[Gg]ame[Uu][Ii])$", "^\\b(A10StrikeRadiusCursor)$", "^\\b(AmbushRadiusCursor)$", "^\\b(ClusterMinesRadiusCursor)$", "^\\b(AnthraxBombRadiusCursor)$"];

package.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,13 @@
2323
"contributes": {
2424
"configuration": {
2525
"type": "object",
26-
"title": "Example configuration",
26+
"title": "ZeroSyntax Settings",
2727
"properties": {
28+
"ZeroSyntax.indentNumber": {
29+
"type": "number",
30+
"default": 2,
31+
"description": "Controls the indentation when using the INI formatter"
32+
},
2833
"languageServerExample.maxNumberOfProblems": {
2934
"scope": "resource",
3035
"type": "number",

0 commit comments

Comments
 (0)