Skip to content

Commit

Permalink
1.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaoxustudio committed Mar 19, 2024
1 parent ac1f042 commit 0642d69
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 9 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<!--
* @Author: xuranXYS
* @LastEditTime: 2024-03-19 09:28:08
* @LastEditTime: 2024-03-19 11:50:48
* @GitHub: www.github.com/xiaoxustudio
* @WebSite: www.xiaoxustudio.top
* @Description: By xuranXYS
Expand All @@ -13,6 +13,13 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how

## [Unreleased]

## [1.2.1] - 2024.3.19

### Add

- 修复警告中文异常
- 格式化

## [1.2.0] - 2024.3.19

### Add
Expand Down
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<!--
* @Author: xuranXYS
* @LastEditTime: 2024-03-19 09:24:42
* @LastEditTime: 2024-03-19 11:51:46
* @GitHub: www.github.com/xiaoxustudio
* @WebSite: www.xiaoxustudio.top
* @Description: By xuranXYS
Expand Down Expand Up @@ -32,6 +32,10 @@

![插值变量提示](https://raw.githubusercontent.com/xiaoxustudio/webgal-for-vscode/master/images/test/variable.png)

## 格式化

![格式化](https://raw.githubusercontent.com/xiaoxustudio/webgal-for-vscode/master/images/test/format.png)

## 颜色选择器

![颜色选择器](https://raw.githubusercontent.com/xiaoxustudio/webgal-for-vscode/master/images/test/color.png)
Expand Down
Binary file added images/test/format.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "webgal-for-vscode",
"displayName": "webgal for VSCode",
"description": "webgal-for-vscode by xuran",
"version": "1.2.0",
"version": "1.2.1",
"repository": {
"type": "git",
"url": "https://github.com/xiaoxustudio/webgal-for-vscode"
Expand All @@ -12,7 +12,6 @@
},
"publisher": "Xuran1783558957",
"categories": [
"Snippets",
"Programming Languages"
],
"activationEvents": [
Expand Down Expand Up @@ -58,13 +57,14 @@
"verbose"
],
"default": "off",
"description": "Traces the communication between VS Code and the language server."
"description": "跟踪VS Code和语言服务器之间的通信。"
}
}
}
},
"capabilities": {
"colorProvider": "true"
"colorProvider": "true",
"documentFormattingProvider" : "true"
},
"scripts": {
"vscode:prepublish": "npm run compile",
Expand Down
43 changes: 43 additions & 0 deletions src/config/Format.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import * as vscode from "vscode";
class GoDocumentFormatter implements vscode.DocumentFormattingEditProvider {
provideDocumentFormattingEdits(
document: vscode.TextDocument,
options: vscode.FormattingOptions,
token: vscode.CancellationToken
): vscode.ProviderResult<vscode.TextEdit[]> {
const text = document.getText();
const formattedText = this.formatText(text);
const edit = new vscode.TextEdit(
new vscode.Range(
document.positionAt(0),
document.positionAt(text.length)
),
formattedText
);
return [edit];
}
private formatText(text: string): string {
const _text_sp = text.split("\n");
const _out_sp = [];
for (let i of _text_sp) {
const _index = i.indexOf(":");
const _start_formats = i.substring(0, _index);
const _end_formats = i.substring(_index);
if (_index === -1) {
i = _start_formats + _end_formats;
_out_sp.push(i);
continue;
} else if (i.substring(_index + 1, _index + 2) === " ") {
i = _start_formats + _end_formats;
_out_sp.push(i);
continue;
} else {
i = _start_formats + ": " + i.substring(_index + 1);
_out_sp.push(i);
}
}
return _out_sp.join("\n");
}
}

export default GoDocumentFormatter;
4 changes: 2 additions & 2 deletions src/config/Warnings.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* @Author: xuranXYS
* @LastEditTime: 2024-03-19 08:49:15
* @LastEditTime: 2024-03-19 10:32:43
* @GitHub: www.github.com/xiaoxustudio
* @WebSite: www.xiaoxustudio.top
* @Description: By xuranXYS
Expand Down Expand Up @@ -34,7 +34,7 @@ export const Warning: { [key: string]: WarningToken } = {
return `${args[0]} 冒号后面需要添加一个空格`;
},
DiagnosticInformation: "指令不规范(%id%)",
pattern: /([^\n\t]*\S+\s*:([^\s\n\t]*\S+))/g,
pattern: /^([^\n\t:]*\S+:\S+){1}/g,
is_line: true,
},
};
Expand Down
9 changes: 8 additions & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* @Author: xuranXYS
* @LastEditTime: 2024-03-18 21:51:56
* @LastEditTime: 2024-03-19 10:40:49
* @GitHub: www.github.com/xiaoxustudio
* @WebSite: www.xiaoxustudio.top
* @Description: By xuranXYS
Expand All @@ -17,6 +17,7 @@ import DictionaryCompletionItemProvider from "./CompletionProvider";
import DictionaryHoverProvider from "./HoverProvider";
import XColorProvider from "./ColorProvider";
import path from "path";
import GoDocumentFormatter from "./config/Format";

const selector = { scheme: "file", language: "webgal" };
let client: LanguageClient;
Expand Down Expand Up @@ -54,6 +55,12 @@ export function activate(context: ExtensionContext) {
new DictionaryHoverProvider()
)
);
context.subscriptions.push(
vscode.languages.registerDocumentFormattingEditProvider(
selector,
new GoDocumentFormatter()
)
);
context.subscriptions.push(
vscode.languages.registerColorProvider(selector, new XColorProvider())
);
Expand Down

0 comments on commit 0642d69

Please sign in to comment.