ts-gem-lsp 0.0.0-stage → 0.0.1
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.
- package/README.md +126 -2
- package/dist/bin.js +75383 -0
- package/dist/bin.js.map +7 -0
- package/dist/cli.js +3491 -0
- package/dist/cli.js.map +7 -0
- package/dist/index.js +71987 -0
- package/dist/index.js.map +7 -0
- package/package.json +38 -4
package/README.md
CHANGED
|
@@ -1,3 +1,127 @@
|
|
|
1
|
-
#
|
|
1
|
+
# ts-gem-lsp
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[Gem](https://github.com/mantou132/gem) language features for TypeScript 7.
|
|
4
|
+
|
|
5
|
+
TypeScript 7 (`tsc --lsp`) no longer loads tsserver plugins, so [ts-gem-plugin](../ts-gem-plugin) does not work with it. ts-gem-lsp provides the same features through the TypeScript 7 API:
|
|
6
|
+
|
|
7
|
+
- **LSP proxy** (`ts-gem-lsp`): starts the project's `tsc --lsp` and adds Gem features to its responses, for Zed and other LSP editors
|
|
8
|
+
- **VS Code middleware**: used by the [VS Code extension](../vscode-gem-plugin) through the TypeScript 7 extension's `registerLspMiddleware`
|
|
9
|
+
- **CLI** (`ts-gem`): runs diagnostics and editor requests from the command line
|
|
10
|
+
|
|
11
|
+
The TypeScript API is loaded from the project's own `typescript` package, so it always matches the running language server. When the project does not use TypeScript 7, the proxy starts a server without any capabilities, keep using ts-gem-plugin in that case.
|
|
12
|
+
|
|
13
|
+
## Features
|
|
14
|
+
|
|
15
|
+
- HTML templates (`html`, `raw`, `h`)
|
|
16
|
+
- Completion, hover, folding, highlight, linked editing, closing tag, emmet
|
|
17
|
+
- Custom element tag/attribute/property/event completion and validation
|
|
18
|
+
- Go to definition, find references and rename for tags and properties
|
|
19
|
+
- CSS templates (`css`, `styled`, `<style>`)
|
|
20
|
+
- Completion, hover, validation, folding, emmet
|
|
21
|
+
- Class name completion from element styles, go to definition and find references
|
|
22
|
+
- Element selector and custom property navigation, custom property rename
|
|
23
|
+
- Gem API
|
|
24
|
+
- `@effect`/`@memo`/`@template` etc. allow unused private fields
|
|
25
|
+
- Theme key completion, hide `never` members of state
|
|
26
|
+
|
|
27
|
+
## Zed
|
|
28
|
+
|
|
29
|
+
The [Gem extension](../../crates/zed-plugin-gem) installs and starts ts-gem-lsp automatically. It replaces the built-in TypeScript server, so disable the others for TypeScript 7 projects in `.zed/settings.json`:
|
|
30
|
+
|
|
31
|
+
```json
|
|
32
|
+
{
|
|
33
|
+
"languages": {
|
|
34
|
+
"TypeScript": {
|
|
35
|
+
"language_servers": [
|
|
36
|
+
"ts-gem-lsp",
|
|
37
|
+
"!vtsls",
|
|
38
|
+
"!typescript-language-server",
|
|
39
|
+
"..."
|
|
40
|
+
]
|
|
41
|
+
},
|
|
42
|
+
"TSX": {
|
|
43
|
+
"language_servers": [
|
|
44
|
+
"ts-gem-lsp",
|
|
45
|
+
"!vtsls",
|
|
46
|
+
"!typescript-language-server",
|
|
47
|
+
"..."
|
|
48
|
+
]
|
|
49
|
+
},
|
|
50
|
+
"JavaScript": {
|
|
51
|
+
"language_servers": [
|
|
52
|
+
"ts-gem-lsp",
|
|
53
|
+
"!vtsls",
|
|
54
|
+
"!typescript-language-server",
|
|
55
|
+
"..."
|
|
56
|
+
]
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
"lsp": {
|
|
60
|
+
"ts-gem-lsp": {
|
|
61
|
+
"settings": {
|
|
62
|
+
"gem": { "strict": true }
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
> [!NOTE]
|
|
70
|
+
> `language_servers` must be set per language, and Zed needs to be restarted after changing it.
|
|
71
|
+
|
|
72
|
+
## Other editors
|
|
73
|
+
|
|
74
|
+
Install ts-gem-lsp in the project and use it as the TypeScript language server, it must be started in the project root:
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
npm install -D ts-gem-lsp
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
npx ts-gem-lsp
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
Configuration is read from `initializationOptions.gem` and `workspace/didChangeConfiguration` `settings.gem`.
|
|
85
|
+
|
|
86
|
+
## CLI
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
npx ts-gem check
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Positions are `<file:line:col>`, line and column start from 1:
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
npx ts-gem hover src/app.ts:10:8
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
| Command | Description |
|
|
99
|
+
| ----------------------------------------- | -------------------------------------------------- |
|
|
100
|
+
| `check [files...]` | TypeScript and Gem diagnostics, exit 1 on problems |
|
|
101
|
+
| `hover <file:line:col>` | Hover information |
|
|
102
|
+
| `complete <file:line:col>` | Completion |
|
|
103
|
+
| `definition <file:line:col>` | Go to definition |
|
|
104
|
+
| `references <file:line:col>` | Find references |
|
|
105
|
+
| `highlight <file:line:col>` | Document highlight |
|
|
106
|
+
| `rename <file:line:col> <newName>` | Rename |
|
|
107
|
+
| `request <method> <file:line:col> [json]` | Send any request, `json` is merged into the params |
|
|
108
|
+
|
|
109
|
+
Add `--json` to print the raw LSP result.
|
|
110
|
+
|
|
111
|
+
## Configuration
|
|
112
|
+
|
|
113
|
+
Same as ts-gem-plugin:
|
|
114
|
+
|
|
115
|
+
```json
|
|
116
|
+
{
|
|
117
|
+
// Some suggestions become warnings, for writing standard custom elements
|
|
118
|
+
"strict": false,
|
|
119
|
+
// Same as emmet configuration
|
|
120
|
+
"emmet": {},
|
|
121
|
+
// Let the language service know how to find the element definition
|
|
122
|
+
"elementDefineRules": {
|
|
123
|
+
"Duoyun*Element": "dy-*",
|
|
124
|
+
"*Element": "*"
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
```
|