@knip/language-server 0.0.8 → 0.0.9
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 +59 -31
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
## Knip
|
|
4
4
|
|
|
5
|
-
Find unused files, dependencies,
|
|
6
|
-
projects.
|
|
5
|
+
The Knip Language Server is powered by Knip: Find unused files, dependencies,
|
|
6
|
+
and exports in your JavaScript/TypeScript projects.
|
|
7
7
|
|
|
8
8
|
- Website: [knip.dev][1]
|
|
9
9
|
- GitHub repo: [webpro-nl/knip][2]
|
|
@@ -21,29 +21,31 @@ projects.
|
|
|
21
21
|
- [Export Hover][11]
|
|
22
22
|
- [Imports][12]
|
|
23
23
|
- [Exports][13]
|
|
24
|
+
- [File Descriptor for package.json][14]
|
|
25
|
+
- [Dependency Hover][15]
|
|
24
26
|
|
|
25
27
|
## Configuration
|
|
26
28
|
|
|
27
|
-
Latest version of available settings: [types.d.ts][
|
|
29
|
+
Latest version of available settings: [types.d.ts][16]
|
|
28
30
|
|
|
29
31
|
## Diagnostics
|
|
30
32
|
|
|
31
33
|
Diagnostics should work out of the box.
|
|
32
34
|
|
|
33
|
-
Most [Knip issue types][
|
|
35
|
+
Most [Knip issue types][17] are translated to `Diagnostic` items with a
|
|
34
36
|
`DiagnosticSeverity` and emitted using `this.connection.sendDiagnostics()`. Also
|
|
35
|
-
see [diagnostics.js][
|
|
37
|
+
see [diagnostics.js][18] for details.
|
|
36
38
|
|
|
37
39
|
## Code Actions
|
|
38
40
|
|
|
39
41
|
Code actions should work out of the box.
|
|
40
42
|
|
|
41
43
|
Some issues/diagnostics have code actions available. Also see
|
|
42
|
-
[code-actions.js][
|
|
44
|
+
[code-actions.js][19] for details.
|
|
43
45
|
|
|
44
46
|
## File Descriptor
|
|
45
47
|
|
|
46
|
-
Clients request
|
|
48
|
+
Clients request a file descriptor to get available data for a document by
|
|
47
49
|
sending the `REQUEST_FILE_NODE` request, in short:
|
|
48
50
|
|
|
49
51
|
```ts
|
|
@@ -52,23 +54,23 @@ const file = await this.#client.sendRequest(REQUEST_FILE_NODE, {
|
|
|
52
54
|
});
|
|
53
55
|
```
|
|
54
56
|
|
|
55
|
-
Type definition for `File`: [session/types.ts][
|
|
57
|
+
Type definition for `File`: [session/types.ts][20]
|
|
56
58
|
|
|
57
|
-
The
|
|
59
|
+
The file descriptor can be used to implement features like [Annotations][10],
|
|
58
60
|
[Export Hover][11], [Imports][12] and [Exports][13].
|
|
59
61
|
|
|
60
62
|
### Annotations
|
|
61
63
|
|
|
62
64
|
Annotations (aka "Code Lens" or "Inlay Hint") for exported identifiers can be
|
|
63
|
-
implemented using data from the
|
|
65
|
+
implemented using data from the file descriptor.
|
|
64
66
|
|
|
65
67
|
Example:
|
|
66
68
|
|
|
67
|
-
- [registerCodeLensProvider][
|
|
69
|
+
- [registerCodeLensProvider][21]
|
|
68
70
|
|
|
69
71
|
### Export Hover
|
|
70
72
|
|
|
71
|
-
On hover of an export identifier, the
|
|
73
|
+
On hover of an export identifier, the file descriptor can be used to render
|
|
72
74
|
import locations for the exported identifier.
|
|
73
75
|
|
|
74
76
|
Optionally, code snippets can be searched for using the provided locations and
|
|
@@ -76,13 +78,13 @@ mixed into the rendered list.
|
|
|
76
78
|
|
|
77
79
|
Example:
|
|
78
80
|
|
|
79
|
-
- [registerHoverProvider → getHoverContent][
|
|
80
|
-
- [Collect hover snippets][
|
|
81
|
-
- [Render export hover][
|
|
81
|
+
- [registerHoverProvider → getHoverContent][21]
|
|
82
|
+
- [Collect hover snippets][22]
|
|
83
|
+
- [Render export hover][23]
|
|
82
84
|
|
|
83
85
|
### Imports
|
|
84
86
|
|
|
85
|
-
The
|
|
87
|
+
The file desciptor can be used to display an overview of imports of a document
|
|
86
88
|
with direct links to their definition location.
|
|
87
89
|
|
|
88
90
|
Optionally, the client can implement:
|
|
@@ -92,12 +94,12 @@ Optionally, the client can implement:
|
|
|
92
94
|
|
|
93
95
|
Example:
|
|
94
96
|
|
|
95
|
-
- [setupTreeViews + refresh → getFileForTreeViews][
|
|
96
|
-
- [Tree View Imports][
|
|
97
|
+
- [setupTreeViews + refresh → getFileForTreeViews][21]
|
|
98
|
+
- [Tree View Imports][24]
|
|
97
99
|
|
|
98
100
|
### Exports
|
|
99
101
|
|
|
100
|
-
The
|
|
102
|
+
The file desciptor can be used to display an overview of exports of a document
|
|
101
103
|
with direct links to their usage locations.
|
|
102
104
|
|
|
103
105
|
Optionally, the client can implement:
|
|
@@ -108,8 +110,30 @@ Optionally, the client can implement:
|
|
|
108
110
|
|
|
109
111
|
Example:
|
|
110
112
|
|
|
111
|
-
- [setupTreeViews + refresh → getFileForTreeViews][
|
|
112
|
-
- [Tree View Exports][
|
|
113
|
+
- [setupTreeViews + refresh → getFileForTreeViews][21]
|
|
114
|
+
- [Tree View Exports][25]
|
|
115
|
+
|
|
116
|
+
## File Descriptor for package.json
|
|
117
|
+
|
|
118
|
+
Clients request the `package.json` file descriptor to get dependency usage data
|
|
119
|
+
by sending the `REQUEST_PACKAGE_JSON` request:
|
|
120
|
+
|
|
121
|
+
```ts
|
|
122
|
+
const packageJson = await this.#client.sendRequest(REQUEST_PACKAGE_JSON);
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
Type definition for `DependencyNodes`: [session/types.ts][20]
|
|
126
|
+
|
|
127
|
+
### Dependency Hover
|
|
128
|
+
|
|
129
|
+
On hover of a dependency name in `package.json`, the `packageJson` descriptor
|
|
130
|
+
can be used to render import locations for the dependency.
|
|
131
|
+
|
|
132
|
+
Example:
|
|
133
|
+
|
|
134
|
+
- [getDependencyHoverContent][21]
|
|
135
|
+
- [Collect dependency snippets][26]
|
|
136
|
+
- [Render dependency hover][27]
|
|
113
137
|
|
|
114
138
|
[1]: https://knip.dev
|
|
115
139
|
[2]: https://github.com/webpro-nl/knip
|
|
@@ -124,13 +148,17 @@ Example:
|
|
|
124
148
|
[11]: #export-hover
|
|
125
149
|
[12]: #imports
|
|
126
150
|
[13]: #exports
|
|
127
|
-
[14]:
|
|
128
|
-
[15]:
|
|
129
|
-
[16]: ./src/
|
|
130
|
-
[17]:
|
|
131
|
-
[18]:
|
|
132
|
-
[19]:
|
|
133
|
-
[20]: ../
|
|
134
|
-
[21]: ../vscode-knip/src/
|
|
135
|
-
[22]: ../vscode-knip/src/
|
|
136
|
-
[23]: ../vscode-knip/src/
|
|
151
|
+
[14]: #file-descriptor-for-packagejson
|
|
152
|
+
[15]: #dependency-hover
|
|
153
|
+
[16]: ./src/types.d.ts
|
|
154
|
+
[17]: https://knip.dev/reference/issue-types
|
|
155
|
+
[18]: ./src/diagnostics.js
|
|
156
|
+
[19]: ./src/code-actions.js
|
|
157
|
+
[20]: ../knip/src/session/types.ts
|
|
158
|
+
[21]: ../vscode-knip/src/index.js
|
|
159
|
+
[22]: ../vscode-knip/src/collect-export-hover-snippets.js
|
|
160
|
+
[23]: ../vscode-knip/src/render-export-hover.js
|
|
161
|
+
[24]: ../vscode-knip/src/tree-view-imports.js
|
|
162
|
+
[25]: ../vscode-knip/src/tree-view-exports.js
|
|
163
|
+
[26]: ../vscode-knip/src/collect-dependency-hover-snippets.js
|
|
164
|
+
[27]: ../vscode-knip/src/render-dependency-hover.js
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@knip/language-server",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.9",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"vscode-languageserver": "^9.0.1",
|
|
14
14
|
"vscode-languageserver-textdocument": "^1.0.12",
|
|
15
|
-
"knip": "^5.77.
|
|
15
|
+
"knip": "^5.77.3"
|
|
16
16
|
},
|
|
17
17
|
"engines": {
|
|
18
18
|
"node": ">=18.18.0"
|