Skip to content

Commit

Permalink
初始化 VSCode 插件项目 #658
Browse files Browse the repository at this point in the history
  • Loading branch information
Soltus committed Apr 30, 2024
1 parent 9febc61 commit 00f4da8
Show file tree
Hide file tree
Showing 8 changed files with 136 additions and 6 deletions.
3 changes: 1 addition & 2 deletions _vscode_plugin/Sillot/.gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
**/dist/
**/out/
**.vsix
**/protected.txt
**/test.dosc
**/SavedFileCompletionItemProvider.json
/.vscode-test
src/test/files
92 changes: 92 additions & 0 deletions _vscode_plugin/Sillot/grammars/sy.tmLanguage.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
{
"name": "siyuan as json",
"scopeName": "source.sy",
"patterns": [
{
"include": "#value"
}
],
"repository": {
"value": {
"patterns": [
{
"include": "#object"
},
{
"include": "#array"
},
{
"include": "#string"
},
{
"include": "#number"
},
{
"include": "#null"
},
{
"include": "#true"
},
{
"include": "#false"
}
]
},
"object": {
"begin": "\\{",
"end": "\\}",
"patterns": [
{
"include": "#pair"
}
]
},
"pair": {
"match": "\\s*\"(\\\\.|[^\"])*\"\\s*:\\s*\"(\\\\.|[^\"])*\"\\s*",
"captures": {
"1": {
"name": "string.quoted.double.json"
},
"2": {
"name": "string.quoted.double.json"
}
}
},
"array": {
"begin": "\\[",
"end": "\\]",
"patterns": [
{
"include": "#value"
}
]
},
"string": {
"begin": "\"",
"end": "\"",
"name": "string.quoted.double.json",
"patterns": [
{
"match": "\\\\(x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4}|.)",
"name": "constant.character.escape.json"
}
]
},
"number": {
"match": "-?(0|[1-9]\\d*)(\\.(\\d+)([eE][-+]?\\d+)?)?",
"name": "constant.numeric.json"
},
"null": {
"match": "\\bnull\\b",
"name": "constant.language.null.json"
},
"true": {
"match": "\\btrue\\b",
"name": "constant.language.boolean.true.json"
},
"false": {
"match": "\\bfalse\\b",
"name": "constant.language.boolean.false.json"
}
}
}
18 changes: 14 additions & 4 deletions _vscode_plugin/Sillot/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "sillot",
"displayName": "汐洛 Sillot",
"description": "汐洛(Sillot)孵化自思源笔记(siyuan-note),致力于服务智慧新彖乄。此插件为汐洛官方插件,提供多功能一体化集成。",
"version": "0.1.1500",
"version": "0.1.1600",
"preview": true,
"repository": "https://github.com/Hi-Windom/Sillot",
"publisher": "Hi-Windom",
Expand Down Expand Up @@ -167,7 +167,7 @@
"extensions": [
".dosc"
],
"configuration": "./src/_dosc.language-configuration.json"
"configuration": "./languages/_dosc.language-configuration.json"
},
{
"id": "sy",
Expand All @@ -178,14 +178,24 @@
"extensions": [
".sy"
],
"configuration": "./src/_sy.language-configuration.json"
"configuration": "./languages/_sy.language-configuration.json"
}
],
"grammars": [
{
"language": "sy",
"scopeName": "source.sy",
"path": "./src/sy.tmLanguage.json"
"path": "./grammars/sy.tmLanguage.json"
}
],
"snippets": [
{
"language": "javascript",
"path": "./snippets/sofill.json"
},
{
"language": "typescript",
"path": "./snippets/sofill.json"
}
]
},
Expand Down
12 changes: 12 additions & 0 deletions _vscode_plugin/Sillot/snippets/sofill.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"等效于 dayjs().format(\"YYYYMMDDHHmmss\")": {
"prefix": [
"formatDate_newDate",
"dayjs().format"
],
"body": [
"formatDate(new Date($1), 'yyyyMMddHHmmss')"
],
"description": "等效于 dayjs().format(\"YYYYMMDDHHmmss\")\nformatDate 是 sofill/mid 中的一个代理函数,最终调用 date-fns 库的 format 函数"
}
}
16 changes: 16 additions & 0 deletions _vscode_plugin/Sillot/vsc-extension-quickstart.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
### [术语表和说明 | VS Code 插件开发中文文档 (rackar.github.io)](https://rackar.github.io/vscode-ext-doccn/)

.vscodeignore 文件

类似于 .gitignore ,用于定义哪些文件不被打包到插件里。

### language-configuration.json里的定义如何理解 😀

`language-configuration.json` 文件是用于定义一种编程语言的特定行为的配置文件。它告诉VSCode如何处理这种语言的各种特性,例如注释、括号匹配、自动闭合字符对等。这个文件通常与 `package.json` 中的 `languages` 部分一起使用,以提供完整的语言支持。
Expand Down Expand Up @@ -32,3 +36,15 @@
#### galleryBanner

只在[网页版](https://marketplace.visualstudio.com/items?itemName=Hi-Windom.sillot)有效,VSCode里是看不到效果的

#### contributes

这是非常重要的字段,是插件作出贡献的地方,包含多个子字段

##### grammars:语法高亮

嘿嘿

##### snippets:代码片段

注意:"path": "./snippets/sofill.json" 这里的路径不能在 ./src 目录下(这是因为 .vscodeignore 中忽略了 src,因此 src 里最好只包含源代码)
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"dep:check": "pnpm outdated --filter *",
"dev:docs": "pnpm --filter ./docs/starlight run dev",
"git:tag-app": "pnpm --filter ./app run git:tag",
"vsce:package": "pnpm --filter ./_vscode_plugin/Sillot run vsce:package",
"test": "pnpm -r run test"
},
"keywords": [],
Expand Down

0 comments on commit 00f4da8

Please sign in to comment.