Skip to content

Commit e815254

Browse files
authored
Merge pull request #46 from hit9/vscode-syntax-highlighting
Vscode syntax highlighting extension
2 parents 53da128 + d6ae2f5 commit e815254

File tree

12 files changed

+287
-25
lines changed

12 files changed

+287
-25
lines changed

docs/language.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -661,3 +661,9 @@ PyCharm
661661

662662
Syntax highlighting settings for PyCharm is available from
663663
`bitproto's github repository <https://github.com/hit9/bitproto/tree/master/editors/pycharm>`_.
664+
665+
VSCode
666+
""""""
667+
668+
Install the extension from marketplace:
669+
`bitproto vscode extension <https://marketplace.visualstudio.com/items?itemName=hit9.bitproto>`_.

docs/locales/zh/LC_MESSAGES/changelog.po

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ msgid ""
88
msgstr ""
99
"Project-Id-Version: bitproto 0.4.0\n"
1010
"Report-Msgid-Bugs-To: \n"
11-
"POT-Creation-Date: 2022-12-13 22:41+0800\n"
11+
"POT-Creation-Date: 2022-12-26 21:32+0800\n"
1212
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
1313
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
1414
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -21,55 +21,67 @@ msgstr ""
2121
msgid "Changelog"
2222
msgstr "版本历史"
2323

24-
#: ../../../changes.rst:5 9e9740e4c92e4ed595194bd543ebe147
24+
#: ../../../changes.rst:4 fc5a94d17a314c589b3622ad0c32e5a0
25+
msgid "Version 1.0.0"
26+
msgstr ""
27+
28+
#: ../../../changes.rst:8 c894eb85f9834f1b837622fd859c7e98
29+
msgid "First fully release version"
30+
msgstr "第一次发布 1.0 版本"
31+
32+
#: ../../../changes.rst:13 30bc2f453f9a4e4daec1f2b082a6ac91
33+
msgid "Version 0.4.6"
34+
msgstr ""
35+
36+
#: ../../../changes.rst:15 9e9740e4c92e4ed595194bd543ebe147
2537
msgid "Support signed integers with arbitrary bits, e.g. int24 PR#45."
2638
msgstr "支持任意比特数目的有符号整数类型 例如 int24, 见 PR#45"
2739

28-
#: ../../../changes.rst:10 30bc2f453f9a4e4daec1f2b082a6ac91
40+
#: ../../../changes.rst:20 30bc2f453f9a4e4daec1f2b082a6ac91
2941
msgid "Version 0.4.5"
3042
msgstr ""
3143

32-
#: ../../../changes.rst:12 3ba33408fbab4e6e8fa4bd1348e776a9
44+
#: ../../../changes.rst:22 3ba33408fbab4e6e8fa4bd1348e776a9
3345
msgid ""
3446
"Use Python IntEnum for enum generation (respecting backward "
3547
"compatibility) PR#41."
3648
msgstr ""
3749

38-
#: ../../../changes.rst:17 dc7770b7fd674da18fa53f58fea0f06f
50+
#: ../../../changes.rst:27 dc7770b7fd674da18fa53f58fea0f06f
3951
msgid "Version 0.4.4"
4052
msgstr ""
4153

42-
#: ../../../changes.rst:19 ee1e046b6272442181a755b5b744d6ba
54+
#: ../../../changes.rst:29 ee1e046b6272442181a755b5b744d6ba
4355
msgid "Minor fix compiler setup.py path issue."
4456
msgstr ""
4557

46-
#: ../../../changes.rst:24 2cd432670b154c19a01259f94cb33bc3
58+
#: ../../../changes.rst:34 2cd432670b154c19a01259f94cb33bc3
4759
msgid "Version 0.4.2"
4860
msgstr ""
4961

50-
#: ../../../changes.rst:26 a8406cdecd1d4dfc94ad9cebc4c927b5
62+
#: ../../../changes.rst:36 a8406cdecd1d4dfc94ad9cebc4c927b5
5163
msgid "Allow using ``type`` as message field name, fixes issue #39."
5264
msgstr ""
5365

54-
#: ../../../changes.rst:31 fc5a94d17a314c589b3622ad0c32e5a0
66+
#: ../../../changes.rst:41 fc5a94d17a314c589b3622ad0c32e5a0
5567
msgid "Version 0.4.0"
5668
msgstr ""
5769

58-
#: ../../../changes.rst:33 3c499990cd38434f932a3558376617c5
70+
#: ../../../changes.rst:43 3c499990cd38434f932a3558376617c5
5971
msgid ""
6072
"Add support for ``message`` and ``enum`` extensiblity for protocol "
6173
"backward compatibility."
6274
msgstr ""
6375

64-
#: ../../../changes.rst:34 ad10bcd6f05a4e5187b2d8ba2f3e5235
76+
#: ../../../changes.rst:44 ad10bcd6f05a4e5187b2d8ba2f3e5235
6577
msgid "Cut down the code size of generated language-specific files."
6678
msgstr ""
6779

68-
#: ../../../changes.rst:35 a2e47a95cb5c4f44ac3a9d965d8d719c
80+
#: ../../../changes.rst:45 a2e47a95cb5c4f44ac3a9d965d8d719c
6981
msgid "Refactor the bitproto compiler."
7082
msgstr ""
7183

72-
#: ../../../changes.rst:36 480040dd74284c97acfb4dcc47354779
84+
#: ../../../changes.rst:46 480040dd74284c97acfb4dcc47354779
7385
msgid ""
7486
"Refactor the bitproto serialization mechanism, using language-specific "
7587
"libraries instead of pure compiler-generated files."

docs/locales/zh/LC_MESSAGES/language.po

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ msgid ""
88
msgstr ""
99
"Project-Id-Version: bitproto 0.4.0\n"
1010
"Report-Msgid-Bugs-To: \n"
11-
"POT-Creation-Date: 2022-12-13 22:41+0800\n"
11+
"POT-Creation-Date: 2022-12-26 21:32+0800\n"
1212
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
1313
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
1414
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -94,11 +94,14 @@ msgid ""
9494
"integer. For bitproto <= v0.4.5, only ``int8,int16,int32,int64`` are "
9595
"supported. But since bitproto 0.4.6, signed integers with arbitrary bits "
9696
"are supported."
97-
msgstr "有符号的比特级别的整数类型, 其中 ``n`` 是一个从 ``1`` 到 ``64`` 的数字。举例来说,``int24``, ``int32``, ``int64`` 都支持。"
98-
"一个有符号整数 ``int{n}`` 在编码后将占用 ``n`` 个比特。在代码生成时,``int{n}`` 将会被映射成为最小可以容纳这些数量的比特的对应语言中的整数类型,"
99-
"例如生成 C 语言时,``int3`` 将映射成 ``int8_t``, ``int13`` 将映射成 ``int16_t``,依此类推。"
100-
"对于一个有符号类型的整数 ``int{n}`` 而言,第 ``n`` 位比特会被认为是其符号位,比如说 ``int24`` 的符号位是第 ``24`` 个比特。"
101-
"在 bitproto v0.4.5 之前的版本,只有 ``int8,int16,int32,int64`` 才被支持, 但是自从 v0.4.6 以后,任意比特数目大小的有符号整数都支持了。"
97+
msgstr ""
98+
"有符号的比特级别的整数类型, 其中 ``n`` 是一个从 ``1`` 到 ``64`` 的数字。举例来说,``int24``, "
99+
"``int32``, ``int64`` 都支持。一个有符号整数 ``int{n}`` 在编码后将占用 ``n`` "
100+
"个比特。在代码生成时,``int{n}`` 将会被映射成为最小可以容纳这些数量的比特的对应语言中的整数类型,例如生成 C 语言时,``int3``"
101+
" 将映射成 ``int8_t``, ``int13`` 将映射成 ``int16_t``,依此类推。对于一个有符号类型的整数 ``int{n}``"
102+
" 而言,第 ``n`` 位比特会被认为是其符号位,比如说 ``int24`` 的符号位是第 ``24`` 个比特。在 bitproto "
103+
"v0.4.5 之前的版本,只有 ``int8,int16,int32,int64`` 才被支持, 但是自从 v0.4.6 "
104+
"以后,任意比特数目大小的有符号整数都支持了。"
102105

103106
#: ../../language.rst:60 83beae3ea0194637af4e2b8a05064115
104107
msgid "``byte``"
@@ -660,15 +663,21 @@ msgid "PyCharm"
660663
msgstr ""
661664

662665
#: ../../language.rst:662 d8243880ab7145a0ad9b686f35e3dbc1
663-
#, fuzzy
664666
msgid ""
665667
"Syntax highlighting settings for PyCharm is available from `bitproto's "
666-
"github repository "
667-
"<https://github.com/hit9/bitproto/tree/master/editors/pycharm>`_."
668+
"github repository <https://github.com/hit9/bitproto/tree/master/editors/pycharm>`_."
668669
msgstr ""
669-
"在 `bitproto 的 github 仓库 "
670-
"<https://github.com/hit9/bitproto/tree/master/editors/vim>`_ 中包含一个 `vim "
671-
"编辑器 <https://www.vim.org/>`_ 的语法高亮插件。"
670+
"bitproto 的 PyCharm 语法高亮插件: `<https://github.com/hit9/bitproto/tree/master/editors/pycharm>`_."
671+
672+
#: ../../language.rst:666 867939080c3643a6ad15e3ce30b70e9f
673+
msgid "VSCode"
674+
msgstr ""
675+
676+
#: ../../language.rst:668 44ebe8c3d9714e35b3434447f45d400d
677+
msgid ""
678+
"Install the extension from marketplace: `bitproto vscode extension "
679+
"<https://marketplace.visualstudio.com/items?itemName=hit9.bitproto>`_."
680+
msgstr "VSCode 插件可以直接从市场安装: `<https://marketplace.visualstudio.com/items?itemName=hit9.bitproto>`_."
672681

673682
#~ msgid "``int{8,16,32,64}``"
674683
#~ msgstr ""

editors/vscode/bitproto/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.vsix

editors/vscode/bitproto/.vscodeignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.vscode/**
2+
.vscode-test/**
3+
.gitignore
4+
vsc-extension-quickstart.md

editors/vscode/bitproto/LICENSE

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
2+
Copyright (c) 2021, hit9
3+
4+
All rights reserved.
5+
6+
Redistribution and use in source and binary forms, with or without modification,
7+
are permitted provided that the following conditions are met:
8+
9+
* Redistributions of source code must retain the above copyright notice,
10+
this list of conditions and the following disclaimer.
11+
* Redistributions in binary form must reproduce the above copyright notice,
12+
this list of conditions and the following disclaimer in the documentation
13+
and/or other materials provided with the distribution.
14+
* Neither the name of bitproto nor the names of its contributors
15+
may be used to endorse or promote products derived from this software
16+
without specific prior written permission.
17+
18+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
22+
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23+
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24+
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
25+
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
26+
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

editors/vscode/bitproto/README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
VSCode syntax highlighting for bitproto
2+
========================================
3+
4+
### Install from Marketplace
5+
6+
https://marketplace.visualstudio.com/items?itemName=hit9.bitproto
7+
8+
### Install from local
9+
10+
Firstly, ensure `vsce` is installed:
11+
12+
```
13+
$ npm install -g @vscode/vsce
14+
```
15+
16+
Clone this repo, and:
17+
18+
```
19+
$ cd path/to/bitproto/editors/vscode/bitproto
20+
$ vsce package
21+
```
22+
23+
This will generates `bitproto-1.0.0.vsix` in current directory.
24+
25+
Start VSCode editor:
26+
27+
* `View` -> `Extensions` -> `···` -> `Install from VSIX...`
28+
* Then browse the `bitproto-1.0.0.vsix`.

editors/vscode/bitproto/README.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
VSCode syntax highlighting for bitproto
2+
========================================
3+
4+
Develop
26 KB
Loading
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"comments": {
3+
"lineComment": "//"
4+
},
5+
// symbols used as brackets
6+
"brackets": [
7+
["{", "}"],
8+
["[", "]"],
9+
["(", ")"]
10+
],
11+
// symbols that are auto closed when typing
12+
"autoClosingPairs": [
13+
["{", "}"],
14+
["[", "]"],
15+
["(", ")"],
16+
["\"", "\""]
17+
],
18+
// symbols that that can be used to surround a selection
19+
"surroundingPairs": [
20+
["{", "}"],
21+
["[", "]"],
22+
["(", ")"],
23+
["\"", "\""]
24+
]
25+
}

editors/vscode/bitproto/package.json

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"name": "bitproto",
3+
"displayName": "bitproto",
4+
"description": "Syntax support for bitproto",
5+
"version": "1.0.0",
6+
"repository": {
7+
"type": "git",
8+
"url": "https://github.com/hit9/bitproto.git"
9+
},
10+
"publisher": "hit9",
11+
"icon": "bitproto-logo.png",
12+
"engines": {
13+
"vscode": "^1.51.0"
14+
},
15+
"categories": [
16+
"Programming Languages"
17+
],
18+
"contributes": {
19+
"languages": [{
20+
"id": "bitproto",
21+
"aliases": ["bitproto", "bitproto"],
22+
"extensions": [".bitproto"],
23+
"configuration": "./language-configuration.json"
24+
}],
25+
"grammars": [{
26+
"language": "bitproto",
27+
"scopeName": "source.bitproto",
28+
"path": "./syntaxes/bitproto.tmLanguage.json"
29+
}]
30+
}
31+
}
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
{
2+
"$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json",
3+
"name": "bitproto",
4+
"patterns": [
5+
{
6+
"include": "#comments"
7+
},
8+
{
9+
"include": "#keywords"
10+
},
11+
{
12+
"include": "#strings"
13+
},
14+
{
15+
"include": "#constants"
16+
},
17+
{
18+
"include": "#types"
19+
},
20+
{
21+
"include": "#defintions"
22+
},
23+
{
24+
"include": "#identifiers"
25+
}
26+
],
27+
"repository": {
28+
"keywords": {
29+
"patterns": [
30+
{
31+
"name": "keyword.other.bitproto",
32+
"match": "\\b(proto|import|const|option)\\b"
33+
},
34+
{
35+
"name": "storage.type.bitproto",
36+
"match": "\\b(typedef|type|message|enum|bool|byte)\\b"
37+
}
38+
]
39+
},
40+
"comments": {
41+
"name": "comment.line.double-slash.bitproto",
42+
"begin": "//",
43+
"end": "$"
44+
},
45+
"strings": {
46+
"name": "string.quoted.double.bitproto",
47+
"begin": "\"",
48+
"end": "\"",
49+
"patterns": [
50+
{
51+
"name": "constant.character.escape.bitproto",
52+
"match": "\\\\."
53+
}
54+
]
55+
},
56+
"constants": {
57+
"patterns": [
58+
{
59+
"name": "constant.numeric.integer.bitproto",
60+
"match": "\\b[0-9]+\\b"
61+
},
62+
{
63+
"name": "constant.numeric.integer.hexadecimal.bitproto",
64+
"match": "\\b0x[0-9A-Fa-f]+\\b"
65+
},
66+
{
67+
"name": "constant.language.bitproto",
68+
"match": "\\b(true)|(false)|(yes)|(no)\\b"
69+
}
70+
]
71+
},
72+
"types": {
73+
"patterns": [
74+
{
75+
"name": "storage.type.bitproto",
76+
"match": "\\b(typedef|type|message|enum|bool|byte)\\b"
77+
},
78+
{
79+
"name": "storage.type.bitproto",
80+
"match": "\\buint\\d+\\b"
81+
},
82+
{
83+
"name": "storage.type.bitproto",
84+
"match": "\\bint\\d+\\b"
85+
}
86+
]
87+
},
88+
"defintions": {
89+
"patterns": [
90+
{
91+
"name": "entity.name.type.bitproto",
92+
"match": "(?<=const)\\s\\w+"
93+
},
94+
{
95+
"name": "entity.name.attribute-name.bitproto",
96+
"match": "(?<=option)\\s\\w+"
97+
},
98+
{
99+
"name": "entity.name.type.bitproto",
100+
"match": "(?<=message)\\s\\w+"
101+
},
102+
{
103+
"name": "entity.name.type.bitproto",
104+
"match": "(?<=enum)\\s\\w+"
105+
}
106+
]
107+
},
108+
"identifiers": {
109+
"name": "variable.name.bitproto",
110+
"match": "\\b([a-zA-Z_][a-zA-Z0-9_]*)\\b"
111+
}
112+
},
113+
"scopeName": "source.bitproto"
114+
}

0 commit comments

Comments
 (0)