ZedScripts 0.0.2__tar.gz → 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- zedscripts-1.0.0/PKG-INFO +242 -0
- zedscripts-1.0.0/README.md +202 -0
- {zedscripts-0.0.2 → zedscripts-1.0.0}/pyproject.toml +9 -3
- zedscripts-1.0.0/src/ZedScripts/__about__.py +4 -0
- {zedscripts-0.0.2 → zedscripts-1.0.0}/src/ZedScripts/enums/Diagnostic.py +1 -1
- zedscripts-1.0.0/src/ZedScripts/environment/config.py +179 -0
- {zedscripts-0.0.2 → zedscripts-1.0.0}/src/ZedScripts/environment/document.py +10 -14
- {zedscripts-0.0.2 → zedscripts-1.0.0}/src/ZedScripts/environment/workspace.py +46 -18
- {zedscripts-0.0.2 → zedscripts-1.0.0}/src/ZedScripts/providers/diagnostics.py +38 -11
- zedscripts-1.0.0/src/ZedScripts/providers/notifications.py +61 -0
- {zedscripts-0.0.2 → zedscripts-1.0.0}/src/ZedScripts/scripts/block.py +2 -1
- {zedscripts-0.0.2 → zedscripts-1.0.0}/src/ZedScripts/scripts/value.py +1 -1
- {zedscripts-0.0.2 → zedscripts-1.0.0}/src/ZedScripts/server.py +30 -10
- zedscripts-1.0.0/src/ZedScripts.egg-info/PKG-INFO +242 -0
- {zedscripts-0.0.2 → zedscripts-1.0.0}/src/ZedScripts.egg-info/SOURCES.txt +0 -1
- zedscripts-0.0.2/PKG-INFO +0 -105
- zedscripts-0.0.2/README.md +0 -86
- zedscripts-0.0.2/src/ZedScripts/__about__.py +0 -1
- zedscripts-0.0.2/src/ZedScripts/environment/config.py +0 -82
- zedscripts-0.0.2/src/ZedScripts/providers/configuration.py +0 -26
- zedscripts-0.0.2/src/ZedScripts/providers/notifications.py +0 -45
- zedscripts-0.0.2/src/ZedScripts.egg-info/PKG-INFO +0 -105
- {zedscripts-0.0.2 → zedscripts-1.0.0}/LICENSE +0 -0
- {zedscripts-0.0.2 → zedscripts-1.0.0}/setup.cfg +0 -0
- {zedscripts-0.0.2 → zedscripts-1.0.0}/src/ZedScripts/__init__.py +0 -0
- {zedscripts-0.0.2 → zedscripts-1.0.0}/src/ZedScripts/enums/SyntaxErrorType.py +0 -0
- {zedscripts-0.0.2 → zedscripts-1.0.0}/src/ZedScripts/environment/__init__.py +0 -0
- {zedscripts-0.0.2 → zedscripts-1.0.0}/src/ZedScripts/environment/mod.py +0 -0
- {zedscripts-0.0.2 → zedscripts-1.0.0}/src/ZedScripts/environment/version.py +0 -0
- {zedscripts-0.0.2 → zedscripts-1.0.0}/src/ZedScripts/locale/en.json +0 -0
- {zedscripts-0.0.2 → zedscripts-1.0.0}/src/ZedScripts/main.py +0 -0
- {zedscripts-0.0.2 → zedscripts-1.0.0}/src/ZedScripts/providers/actions.py +0 -0
- {zedscripts-0.0.2 → zedscripts-1.0.0}/src/ZedScripts/providers/capabilities.py +0 -0
- {zedscripts-0.0.2 → zedscripts-1.0.0}/src/ZedScripts/providers/debug.py +0 -0
- {zedscripts-0.0.2 → zedscripts-1.0.0}/src/ZedScripts/providers/hover.py +0 -0
- {zedscripts-0.0.2 → zedscripts-1.0.0}/src/ZedScripts/providers/http.py +0 -0
- {zedscripts-0.0.2 → zedscripts-1.0.0}/src/ZedScripts/providers/locale.py +0 -0
- {zedscripts-0.0.2 → zedscripts-1.0.0}/src/ZedScripts/providers/semantic_tokens.py +0 -0
- {zedscripts-0.0.2 → zedscripts-1.0.0}/src/ZedScripts/scripts/__init__.py +0 -0
- {zedscripts-0.0.2 → zedscripts-1.0.0}/src/ZedScripts/scripts/dataset.py +0 -0
- {zedscripts-0.0.2 → zedscripts-1.0.0}/src/ZedScripts/scripts/version.py +0 -0
- {zedscripts-0.0.2 → zedscripts-1.0.0}/src/ZedScripts/structure/ast.py +0 -0
- {zedscripts-0.0.2 → zedscripts-1.0.0}/src/ZedScripts/structure/lexer.py +0 -0
- {zedscripts-0.0.2 → zedscripts-1.0.0}/src/ZedScripts/structure/parser.py +0 -0
- {zedscripts-0.0.2 → zedscripts-1.0.0}/src/ZedScripts/utils.py +0 -0
- {zedscripts-0.0.2 → zedscripts-1.0.0}/src/ZedScripts.egg-info/dependency_links.txt +0 -0
- {zedscripts-0.0.2 → zedscripts-1.0.0}/src/ZedScripts.egg-info/requires.txt +0 -0
- {zedscripts-0.0.2 → zedscripts-1.0.0}/src/ZedScripts.egg-info/top_level.txt +0 -0
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: ZedScripts
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Author: SimKDT
|
|
5
|
+
License: MIT License
|
|
6
|
+
|
|
7
|
+
Copyright (c) 2026 PZ Wiki Modding
|
|
8
|
+
|
|
9
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
10
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
11
|
+
in the Software without restriction, including without limitation the rights
|
|
12
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
13
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
14
|
+
furnished to do so, subject to the following conditions:
|
|
15
|
+
|
|
16
|
+
The above copyright notice and this permission notice shall be included in all
|
|
17
|
+
copies or substantial portions of the Software.
|
|
18
|
+
|
|
19
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
20
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
21
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
22
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
23
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
24
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
25
|
+
SOFTWARE.
|
|
26
|
+
|
|
27
|
+
Requires-Python: >=3.12.3
|
|
28
|
+
Description-Content-Type: text/markdown
|
|
29
|
+
License-File: LICENSE
|
|
30
|
+
Requires-Dist: lsprotocol
|
|
31
|
+
Requires-Dist: pygls
|
|
32
|
+
Requires-Dist: requests-cache
|
|
33
|
+
Requires-Dist: pydantic
|
|
34
|
+
Requires-Dist: deepmerge
|
|
35
|
+
Provides-Extra: build
|
|
36
|
+
Requires-Dist: pyinstaller; extra == "build"
|
|
37
|
+
Provides-Extra: debug
|
|
38
|
+
Requires-Dist: debugpy; extra == "debug"
|
|
39
|
+
Dynamic: license-file
|
|
40
|
+
|
|
41
|
+
# ZedScripts LSP
|
|
42
|
+
|
|
43
|
+
[](LICENSE)
|
|
44
|
+

|
|
45
|
+
[](https://pypi.org/project/ZedScripts/)
|
|
46
|
+
|
|
47
|
+
ZedScripts LSP is a language server protocol implemented in Python for the [scripting format](https://pzwiki.net/wiki/Scripts) of Project Zomboid. Previously a [VSCode extension](https://github.com/PZ-Wiki-Modding/ZedScripts), it is now reimplemented as a standalone LSP.
|
|
48
|
+
|
|
49
|
+
It is powered by the [pz-scripts-data](https://github.com/PZ-Wiki-Modding/pz-scripts-data) to provide up-to-date information about the Scripts format. See [configuration](#configuration) to learn how to specify the dataset version.
|
|
50
|
+
|
|
51
|
+
## Installation
|
|
52
|
+
### Releases
|
|
53
|
+
|
|
54
|
+
### Python package
|
|
55
|
+
|
|
56
|
+
ZedScripts LSP is available directly as a Python package if you ever need to use its functionality outside of an IDE.
|
|
57
|
+
|
|
58
|
+
<details open>
|
|
59
|
+
<summary>PyPI</summary>
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
pip install ZedScripts
|
|
63
|
+
```
|
|
64
|
+
</details>
|
|
65
|
+
|
|
66
|
+
<details>
|
|
67
|
+
<summary>Git</summary>
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
pip install git+https://github.com/PZ-Wiki-Modding/ZedScripts-LSP.git
|
|
71
|
+
```
|
|
72
|
+
</details>
|
|
73
|
+
|
|
74
|
+
<details>
|
|
75
|
+
<summary>Dev</summary>
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
pip install -e .
|
|
79
|
+
```
|
|
80
|
+
</details>
|
|
81
|
+
|
|
82
|
+
## Cache directory
|
|
83
|
+
|
|
84
|
+
A cache directory is used on your system to cache the [pz-scripts-data](https://github.com/PZ-Wiki-Modding/pz-scripts-data) and logs, as well as global configuration. You can find it here:
|
|
85
|
+
|
|
86
|
+
<details>
|
|
87
|
+
<summary>Linux</summary>
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
~/.zedscripts
|
|
91
|
+
```
|
|
92
|
+
</details>
|
|
93
|
+
|
|
94
|
+
<details>
|
|
95
|
+
<summary>Windows</summary>
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
%USERPROFILE%\.zedscripts
|
|
99
|
+
```
|
|
100
|
+
</details>
|
|
101
|
+
|
|
102
|
+
## Configuration
|
|
103
|
+
|
|
104
|
+
The LSP uses configurations files `.zedscripts.json` which provide information to the LSP about various settings.
|
|
105
|
+
|
|
106
|
+
Example of configuration file content:
|
|
107
|
+
```json
|
|
108
|
+
{
|
|
109
|
+
"$schema": "https://raw.githubusercontent.com/PZ-Wiki-Modding/ZedScripts-LSP/refs/heads/main/schema/zedscripts.json",
|
|
110
|
+
"dataset": {
|
|
111
|
+
"latest": true
|
|
112
|
+
},
|
|
113
|
+
"libraries": [
|
|
114
|
+
"~/.steam/debian-installation/steamapps/common/ProjectZomboid/projectzomboid/media",
|
|
115
|
+
]
|
|
116
|
+
}
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
They are optional and should be placed at the root of your workspaces or in the [cache directory](#cache-directory). The local configuration (root of your workspaces) will override the global configuration (cache directory).
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
📁 workspace1
|
|
123
|
+
📁 Contents/mods/YourMod/42/media/scripts
|
|
124
|
+
📄 example_script.txt
|
|
125
|
+
📄 .zedscripts.json
|
|
126
|
+
📁 workspace2
|
|
127
|
+
📄 .zedscripts.json
|
|
128
|
+
```
|
|
129
|
+
```bash
|
|
130
|
+
📁 ~
|
|
131
|
+
📁 .zedscripts
|
|
132
|
+
📄 .zedscripts.json
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
A schema is available to validate the configuration files and can be found in the [schema directory](schema/zedscripts.json).
|
|
136
|
+
|
|
137
|
+
See the following sections for detailed explanation of each parameters.
|
|
138
|
+
|
|
139
|
+
### Dataset
|
|
140
|
+
You can configure the version of the [pz-scripts-data](https://github.com/PZ-Wiki-Modding/pz-scripts-data) dataset.
|
|
141
|
+
|
|
142
|
+
```json
|
|
143
|
+
{
|
|
144
|
+
"dataset": {
|
|
145
|
+
...
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
The key-values which can be set in the `dataset` section are the following:
|
|
151
|
+
- `latest`: a boolean indicating the LSP to use the latest available version for the dataset (latest game version and dataset version)
|
|
152
|
+
- `stable`: a boolean indicating the LSP to use the latest stable version of the dataset
|
|
153
|
+
- `release`: used to indicate a specific release version of the dataset with the following arguments:
|
|
154
|
+
- `major`: major build version (e.g. `42`, `43`)
|
|
155
|
+
- `minor`: minor build version (e.g. `0`, `1`)
|
|
156
|
+
- `patch`: patch build version (e.g. `0`, `1`)
|
|
157
|
+
- `version` (optional): the dataset version (e.g. `0`, `1`, `2`)
|
|
158
|
+
- for example, version `42.21.0` of the game would be specified as:
|
|
159
|
+
```json
|
|
160
|
+
{
|
|
161
|
+
"release": {
|
|
162
|
+
"major": 42,
|
|
163
|
+
"minor": 21,
|
|
164
|
+
"patch": 0
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
It's suggested to use the `stable` option.
|
|
170
|
+
|
|
171
|
+
### Libraries
|
|
172
|
+
A list of paths that should include the base game path, as well as other games that your mod depends on for its scripts. This will provide LSP the ability to find other blocks definitions that you may reference inside your mod's scripts.
|
|
173
|
+
```json
|
|
174
|
+
{
|
|
175
|
+
"libraries": [
|
|
176
|
+
"path/to/base/game",
|
|
177
|
+
"path/to/other/dependent/game"
|
|
178
|
+
]
|
|
179
|
+
}
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
### Ignored
|
|
183
|
+
A list of regex patterns tested on file paths that should be ignored by the LSP, by default this includes large script files that can slow down the LSP.
|
|
184
|
+
```json
|
|
185
|
+
{
|
|
186
|
+
"ignored": [
|
|
187
|
+
"path/to/large/script/file"
|
|
188
|
+
]
|
|
189
|
+
}
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
### Diagnostics
|
|
193
|
+
A list of diagnostics with modifiers to change the diagnostic behavior of the LSP. The following parameters:
|
|
194
|
+
- `type`: the type of the diagnostic, that is the ID shown in the diagnostics hover tooltip (for example, `BLOCK_UNKNOWN_BLOCK`)
|
|
195
|
+
- `enable` (optional): boolean to disable the diagnostic
|
|
196
|
+
- `severity` (optional): the severity level of the diagnostic (accepted values: `Error`, `Warning`, `Information`, `Hint`)
|
|
197
|
+
- `tags` (optional): an array of tags which an IDE may use to provide additional context or behavior for the diagnostic (accepted values: `Unnecessary`, `Deprecated`)
|
|
198
|
+
|
|
199
|
+
Each diagnostic by default have a specific set of modifiers that can be overridden in the configuration.
|
|
200
|
+
|
|
201
|
+
```json
|
|
202
|
+
{
|
|
203
|
+
"diagnostics": [
|
|
204
|
+
{
|
|
205
|
+
"type": "BLOCK_UNKNOWN_BLOCK",
|
|
206
|
+
"enable": true,
|
|
207
|
+
"severity": "Warning",
|
|
208
|
+
"tags": ["Unnecessary"]
|
|
209
|
+
}
|
|
210
|
+
]
|
|
211
|
+
}
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
## IDE configuration
|
|
215
|
+
Based on the IDE you use, you may need to install the ZedScripts LSP application for your OS in the [releases](https://github.com/PZ-Wiki-Modding/ZedScripts-LSP/releases) (Linux, Windows).
|
|
216
|
+
|
|
217
|
+
### Visual Studio Code
|
|
218
|
+
|
|
219
|
+
Install the [ZedScripts extension](https://marketplace.visualstudio.com/items?itemName=SimKDT.ZedScripts) from the Visual Studio Code marketplace. The extension will handle the downloading and setup of the ZedScripts LSP server for you.
|
|
220
|
+
|
|
221
|
+
### VIM
|
|
222
|
+
|
|
223
|
+
Using [yegappan/lsp](https://github.com/yegappan/lsp), setup the ZedScripts LSP server as follows:
|
|
224
|
+
|
|
225
|
+
```vim
|
|
226
|
+
let lspServers = [
|
|
227
|
+
\ #{
|
|
228
|
+
\ name: 'zedscripts',
|
|
229
|
+
\ filetype: ['text', 'zedscripts'],
|
|
230
|
+
\ path: 'path/to/ZedScripts',
|
|
231
|
+
\ args: []
|
|
232
|
+
\ }
|
|
233
|
+
\ ]
|
|
234
|
+
|
|
235
|
+
autocmd User LspSetup call LspAddServer(lspServers)
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
> [!NOTE]
|
|
239
|
+
> You can see [this video](https://www.youtube.com/watch?v=-5lb_jLQmKc) which explains how to set up VIM, and notably setup a LSP server.
|
|
240
|
+
|
|
241
|
+
## License and contribution
|
|
242
|
+
This project is licensed under a [MIT license](LICENSE). Before contributing to the project, please see [CONTRIBUTING](CONTRIBUTING.md).
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
# ZedScripts LSP
|
|
2
|
+
|
|
3
|
+
[](LICENSE)
|
|
4
|
+

|
|
5
|
+
[](https://pypi.org/project/ZedScripts/)
|
|
6
|
+
|
|
7
|
+
ZedScripts LSP is a language server protocol implemented in Python for the [scripting format](https://pzwiki.net/wiki/Scripts) of Project Zomboid. Previously a [VSCode extension](https://github.com/PZ-Wiki-Modding/ZedScripts), it is now reimplemented as a standalone LSP.
|
|
8
|
+
|
|
9
|
+
It is powered by the [pz-scripts-data](https://github.com/PZ-Wiki-Modding/pz-scripts-data) to provide up-to-date information about the Scripts format. See [configuration](#configuration) to learn how to specify the dataset version.
|
|
10
|
+
|
|
11
|
+
## Installation
|
|
12
|
+
### Releases
|
|
13
|
+
|
|
14
|
+
### Python package
|
|
15
|
+
|
|
16
|
+
ZedScripts LSP is available directly as a Python package if you ever need to use its functionality outside of an IDE.
|
|
17
|
+
|
|
18
|
+
<details open>
|
|
19
|
+
<summary>PyPI</summary>
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
pip install ZedScripts
|
|
23
|
+
```
|
|
24
|
+
</details>
|
|
25
|
+
|
|
26
|
+
<details>
|
|
27
|
+
<summary>Git</summary>
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
pip install git+https://github.com/PZ-Wiki-Modding/ZedScripts-LSP.git
|
|
31
|
+
```
|
|
32
|
+
</details>
|
|
33
|
+
|
|
34
|
+
<details>
|
|
35
|
+
<summary>Dev</summary>
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
pip install -e .
|
|
39
|
+
```
|
|
40
|
+
</details>
|
|
41
|
+
|
|
42
|
+
## Cache directory
|
|
43
|
+
|
|
44
|
+
A cache directory is used on your system to cache the [pz-scripts-data](https://github.com/PZ-Wiki-Modding/pz-scripts-data) and logs, as well as global configuration. You can find it here:
|
|
45
|
+
|
|
46
|
+
<details>
|
|
47
|
+
<summary>Linux</summary>
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
~/.zedscripts
|
|
51
|
+
```
|
|
52
|
+
</details>
|
|
53
|
+
|
|
54
|
+
<details>
|
|
55
|
+
<summary>Windows</summary>
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
%USERPROFILE%\.zedscripts
|
|
59
|
+
```
|
|
60
|
+
</details>
|
|
61
|
+
|
|
62
|
+
## Configuration
|
|
63
|
+
|
|
64
|
+
The LSP uses configurations files `.zedscripts.json` which provide information to the LSP about various settings.
|
|
65
|
+
|
|
66
|
+
Example of configuration file content:
|
|
67
|
+
```json
|
|
68
|
+
{
|
|
69
|
+
"$schema": "https://raw.githubusercontent.com/PZ-Wiki-Modding/ZedScripts-LSP/refs/heads/main/schema/zedscripts.json",
|
|
70
|
+
"dataset": {
|
|
71
|
+
"latest": true
|
|
72
|
+
},
|
|
73
|
+
"libraries": [
|
|
74
|
+
"~/.steam/debian-installation/steamapps/common/ProjectZomboid/projectzomboid/media",
|
|
75
|
+
]
|
|
76
|
+
}
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
They are optional and should be placed at the root of your workspaces or in the [cache directory](#cache-directory). The local configuration (root of your workspaces) will override the global configuration (cache directory).
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
📁 workspace1
|
|
83
|
+
📁 Contents/mods/YourMod/42/media/scripts
|
|
84
|
+
📄 example_script.txt
|
|
85
|
+
📄 .zedscripts.json
|
|
86
|
+
📁 workspace2
|
|
87
|
+
📄 .zedscripts.json
|
|
88
|
+
```
|
|
89
|
+
```bash
|
|
90
|
+
📁 ~
|
|
91
|
+
📁 .zedscripts
|
|
92
|
+
📄 .zedscripts.json
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
A schema is available to validate the configuration files and can be found in the [schema directory](schema/zedscripts.json).
|
|
96
|
+
|
|
97
|
+
See the following sections for detailed explanation of each parameters.
|
|
98
|
+
|
|
99
|
+
### Dataset
|
|
100
|
+
You can configure the version of the [pz-scripts-data](https://github.com/PZ-Wiki-Modding/pz-scripts-data) dataset.
|
|
101
|
+
|
|
102
|
+
```json
|
|
103
|
+
{
|
|
104
|
+
"dataset": {
|
|
105
|
+
...
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
The key-values which can be set in the `dataset` section are the following:
|
|
111
|
+
- `latest`: a boolean indicating the LSP to use the latest available version for the dataset (latest game version and dataset version)
|
|
112
|
+
- `stable`: a boolean indicating the LSP to use the latest stable version of the dataset
|
|
113
|
+
- `release`: used to indicate a specific release version of the dataset with the following arguments:
|
|
114
|
+
- `major`: major build version (e.g. `42`, `43`)
|
|
115
|
+
- `minor`: minor build version (e.g. `0`, `1`)
|
|
116
|
+
- `patch`: patch build version (e.g. `0`, `1`)
|
|
117
|
+
- `version` (optional): the dataset version (e.g. `0`, `1`, `2`)
|
|
118
|
+
- for example, version `42.21.0` of the game would be specified as:
|
|
119
|
+
```json
|
|
120
|
+
{
|
|
121
|
+
"release": {
|
|
122
|
+
"major": 42,
|
|
123
|
+
"minor": 21,
|
|
124
|
+
"patch": 0
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
It's suggested to use the `stable` option.
|
|
130
|
+
|
|
131
|
+
### Libraries
|
|
132
|
+
A list of paths that should include the base game path, as well as other games that your mod depends on for its scripts. This will provide LSP the ability to find other blocks definitions that you may reference inside your mod's scripts.
|
|
133
|
+
```json
|
|
134
|
+
{
|
|
135
|
+
"libraries": [
|
|
136
|
+
"path/to/base/game",
|
|
137
|
+
"path/to/other/dependent/game"
|
|
138
|
+
]
|
|
139
|
+
}
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
### Ignored
|
|
143
|
+
A list of regex patterns tested on file paths that should be ignored by the LSP, by default this includes large script files that can slow down the LSP.
|
|
144
|
+
```json
|
|
145
|
+
{
|
|
146
|
+
"ignored": [
|
|
147
|
+
"path/to/large/script/file"
|
|
148
|
+
]
|
|
149
|
+
}
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### Diagnostics
|
|
153
|
+
A list of diagnostics with modifiers to change the diagnostic behavior of the LSP. The following parameters:
|
|
154
|
+
- `type`: the type of the diagnostic, that is the ID shown in the diagnostics hover tooltip (for example, `BLOCK_UNKNOWN_BLOCK`)
|
|
155
|
+
- `enable` (optional): boolean to disable the diagnostic
|
|
156
|
+
- `severity` (optional): the severity level of the diagnostic (accepted values: `Error`, `Warning`, `Information`, `Hint`)
|
|
157
|
+
- `tags` (optional): an array of tags which an IDE may use to provide additional context or behavior for the diagnostic (accepted values: `Unnecessary`, `Deprecated`)
|
|
158
|
+
|
|
159
|
+
Each diagnostic by default have a specific set of modifiers that can be overridden in the configuration.
|
|
160
|
+
|
|
161
|
+
```json
|
|
162
|
+
{
|
|
163
|
+
"diagnostics": [
|
|
164
|
+
{
|
|
165
|
+
"type": "BLOCK_UNKNOWN_BLOCK",
|
|
166
|
+
"enable": true,
|
|
167
|
+
"severity": "Warning",
|
|
168
|
+
"tags": ["Unnecessary"]
|
|
169
|
+
}
|
|
170
|
+
]
|
|
171
|
+
}
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
## IDE configuration
|
|
175
|
+
Based on the IDE you use, you may need to install the ZedScripts LSP application for your OS in the [releases](https://github.com/PZ-Wiki-Modding/ZedScripts-LSP/releases) (Linux, Windows).
|
|
176
|
+
|
|
177
|
+
### Visual Studio Code
|
|
178
|
+
|
|
179
|
+
Install the [ZedScripts extension](https://marketplace.visualstudio.com/items?itemName=SimKDT.ZedScripts) from the Visual Studio Code marketplace. The extension will handle the downloading and setup of the ZedScripts LSP server for you.
|
|
180
|
+
|
|
181
|
+
### VIM
|
|
182
|
+
|
|
183
|
+
Using [yegappan/lsp](https://github.com/yegappan/lsp), setup the ZedScripts LSP server as follows:
|
|
184
|
+
|
|
185
|
+
```vim
|
|
186
|
+
let lspServers = [
|
|
187
|
+
\ #{
|
|
188
|
+
\ name: 'zedscripts',
|
|
189
|
+
\ filetype: ['text', 'zedscripts'],
|
|
190
|
+
\ path: 'path/to/ZedScripts',
|
|
191
|
+
\ args: []
|
|
192
|
+
\ }
|
|
193
|
+
\ ]
|
|
194
|
+
|
|
195
|
+
autocmd User LspSetup call LspAddServer(lspServers)
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
> [!NOTE]
|
|
199
|
+
> You can see [this video](https://www.youtube.com/watch?v=-5lb_jLQmKc) which explains how to set up VIM, and notably setup a LSP server.
|
|
200
|
+
|
|
201
|
+
## License and contribution
|
|
202
|
+
This project is licensed under a [MIT license](LICENSE). Before contributing to the project, please see [CONTRIBUTING](CONTRIBUTING.md).
|
|
@@ -3,9 +3,8 @@ name = "ZedScripts"
|
|
|
3
3
|
description = ""
|
|
4
4
|
readme = { file = "README.md", content-type = "text/markdown" }
|
|
5
5
|
requires-python = ">=3.12.3"
|
|
6
|
-
version = "0.0
|
|
7
|
-
license = "
|
|
8
|
-
license-files = ["LICENSE"]
|
|
6
|
+
version = "1.0.0"
|
|
7
|
+
license = {file = "LICENSE"}
|
|
9
8
|
authors = [
|
|
10
9
|
{ name = "SimKDT" },
|
|
11
10
|
]
|
|
@@ -34,3 +33,10 @@ build-backend = "setuptools.build_meta"
|
|
|
34
33
|
ZedScripts = [
|
|
35
34
|
"locale/*.json"
|
|
36
35
|
]
|
|
36
|
+
|
|
37
|
+
# uv configs
|
|
38
|
+
[[tool.uv.index]]
|
|
39
|
+
name = "testpypi"
|
|
40
|
+
url = "https://test.pypi.org/simple/"
|
|
41
|
+
publish-url = "https://test.pypi.org/legacy/"
|
|
42
|
+
explicit = true
|
|
@@ -7,7 +7,7 @@ from ..enums.SyntaxErrorType import SyntaxErrorType
|
|
|
7
7
|
from ..providers.diagnostics import DiagnosticDefinition
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
class DiagnosticType(enum.
|
|
10
|
+
class DiagnosticType(enum.StrEnum):
|
|
11
11
|
@classmethod
|
|
12
12
|
def _missing_(cls, value: Any) -> 'DiagnosticType | None':
|
|
13
13
|
if isinstance(value, SyntaxErrorType):
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
import enum
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
from typing import Annotated, Optional
|
|
5
|
+
from pydantic import BaseModel, BeforeValidator, Field, WithJsonSchema
|
|
6
|
+
|
|
7
|
+
from lsprotocol.types import DiagnosticSeverity, DiagnosticTag
|
|
8
|
+
|
|
9
|
+
from ..scripts.version import DataVersion
|
|
10
|
+
from ..enums.Diagnostic import DiagnosticType
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
# the auto enum of DiagnosticType makes them lowercase, but we'll want to use
|
|
15
|
+
# uppercase, that is the member's name
|
|
16
|
+
|
|
17
|
+
def _parse_diagnostic_type_name(value: object) -> object:
|
|
18
|
+
if isinstance(value, DiagnosticType):
|
|
19
|
+
return value
|
|
20
|
+
if isinstance(value, str):
|
|
21
|
+
try:
|
|
22
|
+
return DiagnosticType[value]
|
|
23
|
+
except KeyError:
|
|
24
|
+
raise ValueError("type must be a DiagnosticType member name") from None
|
|
25
|
+
return value
|
|
26
|
+
DiagnosticTypeName = Annotated[
|
|
27
|
+
DiagnosticType,
|
|
28
|
+
BeforeValidator(_parse_diagnostic_type_name),
|
|
29
|
+
WithJsonSchema({
|
|
30
|
+
"type": "string",
|
|
31
|
+
"enum": [member.name for member in DiagnosticType],
|
|
32
|
+
}),
|
|
33
|
+
]
|
|
34
|
+
|
|
35
|
+
def _parse_diagnostic_severity_name(value: object) -> object:
|
|
36
|
+
if isinstance(value, DiagnosticSeverity):
|
|
37
|
+
return value
|
|
38
|
+
if isinstance(value, str):
|
|
39
|
+
try:
|
|
40
|
+
return DiagnosticSeverity[value]
|
|
41
|
+
except KeyError:
|
|
42
|
+
raise ValueError("severity must be a DiagnosticSeverity member name") from None
|
|
43
|
+
return value
|
|
44
|
+
DiagnosticSeverityName = Annotated[
|
|
45
|
+
DiagnosticSeverity,
|
|
46
|
+
BeforeValidator(_parse_diagnostic_severity_name),
|
|
47
|
+
WithJsonSchema({
|
|
48
|
+
"type": "string",
|
|
49
|
+
"enum": [member.name for member in DiagnosticSeverity],
|
|
50
|
+
}),
|
|
51
|
+
]
|
|
52
|
+
|
|
53
|
+
def _parse_diagnostic_tag_name(value: object) -> object:
|
|
54
|
+
if isinstance(value, DiagnosticTag):
|
|
55
|
+
return value
|
|
56
|
+
if isinstance(value, str):
|
|
57
|
+
try:
|
|
58
|
+
return DiagnosticTag[value]
|
|
59
|
+
except KeyError:
|
|
60
|
+
raise ValueError("tag must be a DiagnosticTag member name") from None
|
|
61
|
+
return value
|
|
62
|
+
DiagnosticTagName = Annotated[
|
|
63
|
+
DiagnosticTag,
|
|
64
|
+
BeforeValidator(_parse_diagnostic_tag_name),
|
|
65
|
+
WithJsonSchema({
|
|
66
|
+
"type": "string",
|
|
67
|
+
"enum": [member.name for member in DiagnosticTag],
|
|
68
|
+
}),
|
|
69
|
+
]
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
# define the models
|
|
74
|
+
|
|
75
|
+
class DatasetTag(enum.StrEnum):
|
|
76
|
+
LATEST = "latest"
|
|
77
|
+
STABLE = "stable"
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
class ReleaseModel(BaseModel):
|
|
82
|
+
major: int = Field(
|
|
83
|
+
description="Build game version number.",
|
|
84
|
+
ge=42,
|
|
85
|
+
)
|
|
86
|
+
minor: int = Field(
|
|
87
|
+
description="Minor game version number.",
|
|
88
|
+
ge=0,
|
|
89
|
+
)
|
|
90
|
+
patch: int = Field(
|
|
91
|
+
description="Patch game version number.",
|
|
92
|
+
ge=0,
|
|
93
|
+
)
|
|
94
|
+
version: Optional[int] = Field(
|
|
95
|
+
description="Dataset version number for the provided Build release (major.minor.patch). This is incremented whenever the dataset for a specific version is updated.",
|
|
96
|
+
default=None,
|
|
97
|
+
ge=0,
|
|
98
|
+
)
|
|
99
|
+
|
|
100
|
+
class DatasetModel(BaseModel):
|
|
101
|
+
release: Optional[ReleaseModel] = Field(
|
|
102
|
+
description="Provides a configuration for the dataset version to use for validation. This overrides the `latest` and `stable` fields if set.",
|
|
103
|
+
default=None,
|
|
104
|
+
)
|
|
105
|
+
latest: Optional[bool] = Field(
|
|
106
|
+
description="Indicates whether to use the latest dataset version for validation. This is ignored if `release` is set. Overrides the `stable` field if set.",
|
|
107
|
+
default=False,
|
|
108
|
+
)
|
|
109
|
+
stable: Optional[bool] = Field(
|
|
110
|
+
description="Provides a configuration for the stable dataset version to use for validation. Ignored if `release` or `latest` is set.",
|
|
111
|
+
default=True,
|
|
112
|
+
)
|
|
113
|
+
|
|
114
|
+
def to_data_version(self) -> DataVersion | DatasetTag:
|
|
115
|
+
if self.release is None:
|
|
116
|
+
if self.latest:
|
|
117
|
+
return DatasetTag.LATEST
|
|
118
|
+
if self.stable:
|
|
119
|
+
return DatasetTag.STABLE
|
|
120
|
+
logging.warning("No dataset version specified, defaulting to 'stable'.")
|
|
121
|
+
return DatasetTag.STABLE
|
|
122
|
+
from ..scripts.dataset import Manifest
|
|
123
|
+
try:
|
|
124
|
+
return Manifest.from_release_model(self.release)
|
|
125
|
+
except Exception as e:
|
|
126
|
+
logging.error(f"Failed to get data version from release model: {e}. Defaulting to 'stable'.")
|
|
127
|
+
return DatasetTag.STABLE
|
|
128
|
+
|
|
129
|
+
class DiagnosticsModel(BaseModel):
|
|
130
|
+
"""Represents the diagnostics configuration for the workspace environment."""
|
|
131
|
+
type: DiagnosticTypeName = Field(
|
|
132
|
+
description="Specifies the diagnostic member name to enable.",
|
|
133
|
+
)
|
|
134
|
+
enable: Optional[bool] = Field(
|
|
135
|
+
description="Indicates whether diagnostics are enabled.",
|
|
136
|
+
default=True,
|
|
137
|
+
)
|
|
138
|
+
severity: Optional[DiagnosticSeverityName] = Field(
|
|
139
|
+
description="Specifies the severity level of the diagnostics.",
|
|
140
|
+
default=None,
|
|
141
|
+
)
|
|
142
|
+
tags: Optional[list[DiagnosticTagName]] = Field(
|
|
143
|
+
description="Specifies the tags associated with the diagnostics.",
|
|
144
|
+
default=None,
|
|
145
|
+
)
|
|
146
|
+
|
|
147
|
+
class ConfigurationModel(BaseModel):
|
|
148
|
+
"""Represents the content of the configuration files for workspace environments."""
|
|
149
|
+
dataset: DatasetModel = Field(
|
|
150
|
+
description="Provides configuration for the dataset version to use for diagnostics.",
|
|
151
|
+
default_factory=DatasetModel,
|
|
152
|
+
)
|
|
153
|
+
libraries: set[Path] = Field(
|
|
154
|
+
description="Set of library folders to reference. Usually this should contain the base game folder.",
|
|
155
|
+
default_factory=set,
|
|
156
|
+
)
|
|
157
|
+
ignored: set[str] = Field(
|
|
158
|
+
description="Regex patterns for files and folders to ignore in the workspace.",
|
|
159
|
+
default=set([
|
|
160
|
+
r"tileGeometry\.txt",
|
|
161
|
+
r"tileDepthTextureAssignments\.txt",
|
|
162
|
+
r".+\.tiles\.txt"
|
|
163
|
+
]),
|
|
164
|
+
)
|
|
165
|
+
diagnostics: list[DiagnosticsModel] = Field(
|
|
166
|
+
description="List of diagnostics configurations for the workspace environment.",
|
|
167
|
+
default_factory=list,
|
|
168
|
+
)
|
|
169
|
+
|
|
170
|
+
def find_diagnostic(self, type: DiagnosticType) -> DiagnosticsModel | None:
|
|
171
|
+
for diagnostic in self.diagnostics:
|
|
172
|
+
if diagnostic.type == type:
|
|
173
|
+
return diagnostic
|
|
174
|
+
return None
|
|
175
|
+
|
|
176
|
+
if __name__ == "__main__":
|
|
177
|
+
import json
|
|
178
|
+
config = ConfigurationModel()
|
|
179
|
+
print(json.dumps(config.model_json_schema(), indent=4))
|