Skip to content

Commit

Permalink
feat: support for recent added object literal
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Dec 20, 2019
1 parent ccf868f commit 44eb8c8
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 21 deletions.
31 changes: 24 additions & 7 deletions README.md
Expand Up @@ -29,13 +29,6 @@ View the compiled Javascript side by side or Direct execute it.
![](https://github.com/antfu/wenyan-lang-vscode/raw/master/screenshots/demo-execute.png)


### Snippets

You can write Wenyan quickly by using snippets:

![](https://github.com/antfu/wenyan-lang-vscode/raw/master/screenshots/demo-snippets.gif)


### Punctuations Replacement

Punctuations will be automatically replaced to fit the language.
Expand All @@ -44,6 +37,30 @@ Punctuations will be automatically replaced to fit the language.

*You will get the result immediately, the delay is added for demostraction purpose*


### Snippets

You can write Wenyan quickly by using snippets:

![](https://github.com/antfu/wenyan-lang-vscode/raw/master/screenshots/demo-snippets.gif)

Here are some common snippets. For full list, check out [this file](https://github.com/antfu/wenyan-lang-vscode/blob/master/snippets/static.json).

| Triggers | Snippet |
| --- | --- |
| `if` | `若⋯者。⋯也。` |
| `else` | `若非。⋯也。` |
| `for` | `為是⋯遍。⋯云云。` |
| `break` | `乃止。` |
| `while` | `恆為是。⋯云云。` |
| `function` | `吾有一術。名之曰「⋯」。是術曰。` |
| `int` | `吾有一數。曰⋯。名之曰「⋯」。` |
| `str` | `吾有一言。曰「「⋯」」。名之曰「⋯」。` |
| `bool` | `吾有一爻。曰陰。名之曰「⋯」。` |
| `array` | `吾有一列。名之曰「⋯」。` |
| `object` | `吾有一物。名之曰「⋯」。` |


### Configurations

| Fields | Default | Note |
Expand Down
19 changes: 13 additions & 6 deletions snippets/static.json
Expand Up @@ -114,7 +114,7 @@
""
],
"body": [
"吾有一數。曰$1。名之曰「$2」。"
"吾有一數。曰$1。名之曰「${2:甲}」。"
],
"description": ""
},
Expand All @@ -124,7 +124,7 @@
""
],
"body": [
"吾有一言。曰「「$1」」。名之曰「$2」。"
"吾有一言。曰「「$1」」。名之曰「${2:甲}」。"
],
"description": ""
},
Expand All @@ -134,7 +134,7 @@
""
],
"body": [
"吾有一爻。曰${1:陰}。名之曰「$2」。"
"吾有一爻。曰${1:陰}。名之曰「${2:甲}」。"
],
"description": ""
},
Expand All @@ -145,18 +145,25 @@
""
],
"body": [
"吾有一列。名之曰「$1」。"
"吾有一列。名之曰「${1:甲}」。"
],
"description": ""
},
"var-any": {
"prefix": [
"吾有一",
"var"
"var",
"吾有一"
],
"body": "吾有一${1:形}。曰${2:值}。名之曰「${3:名}」。",
"description": "吾有一「可变者」"
},
"var-object": {
"prefix": [
"var"
],
"body": "吾有一物。名之曰「${1:甲}」。",
"description": ""
},
"log": {
"prefix": [
"log",
Expand Down
5 changes: 1 addition & 4 deletions src/editor/documentProvider.ts
Expand Up @@ -18,10 +18,7 @@ async function getCompiledResult (filepath: string, target: SupportTargetLanguag
}

async function getExecResult (filepath: string, target: SupportTargetLanguage) {
const result = await Exec(filepath, { exec: true, lang: target }) || ''

// remove first line or compiled code
return result.split('\n').slice(1).join('\n')
return await Exec(filepath, { exec: true, lang: target }) || ''
}

class DocumentProvider implements TextDocumentContentProvider {
Expand Down
6 changes: 3 additions & 3 deletions syntaxes/wenyan.tmGrammar.json
Expand Up @@ -37,7 +37,7 @@
},
{
"name": "storage.type",
"match": "數|列|言|術|爻"
"match": "數|列|言|術|爻|物"
},
{
"name": "keyword.control",
Expand All @@ -49,7 +49,7 @@
},
{
"name": "keyword.control",
"match": "乃得|乃歸空無|是謂|之術也|必先得|是術曰|乃行是術曰|欲行是術|也|云云|凡|中之|恆為是|為是|遍|乃止"
"match": "乃得|乃歸空無|是謂|之術也|必先得|是術曰|乃行是術曰|欲行是術|也|云云|凡|中之|恆為是|為是|遍|乃止|其物如是"
},
{
"name": "keyword.operator",
Expand All @@ -61,7 +61,7 @@
},
{
"name": "keyword.operator",
"match": "昔之|今|是矣|其"
"match": "昔之|今|是矣|其|不復存矣"
},
{
"name": "keyword.other",
Expand Down
3 changes: 2 additions & 1 deletion vendor/wenyan.js

Large diffs are not rendered by default.

0 comments on commit 44eb8c8

Please sign in to comment.