@knip/language-server 1.1.0 → 1.2.0
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/package.json +2 -2
- package/src/server.js +23 -9
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@knip/language-server",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
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.
|
|
15
|
+
"knip": "^5.83.0"
|
|
16
16
|
},
|
|
17
17
|
"engines": {
|
|
18
18
|
"node": ">=18.18.0"
|
package/src/server.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
1
2
|
import path from 'node:path';
|
|
2
3
|
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
3
4
|
import { createOptions, createSession, KNIP_CONFIG_LOCATIONS } from 'knip/session';
|
|
@@ -23,6 +24,9 @@ import {
|
|
|
23
24
|
} from './constants.js';
|
|
24
25
|
import { issueToDiagnostic } from './diagnostics.js';
|
|
25
26
|
|
|
27
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
28
|
+
const pkg = JSON.parse(fs.readFileSync(path.join(__dirname, '..', 'package.json'), 'utf8'));
|
|
29
|
+
|
|
26
30
|
const RESTART_FOR = new Set(['package.json', ...KNIP_CONFIG_LOCATIONS]);
|
|
27
31
|
|
|
28
32
|
/** @param {string} value */
|
|
@@ -98,7 +102,13 @@ export class LanguageServer {
|
|
|
98
102
|
},
|
|
99
103
|
};
|
|
100
104
|
|
|
101
|
-
return {
|
|
105
|
+
return {
|
|
106
|
+
capabilities,
|
|
107
|
+
serverInfo: {
|
|
108
|
+
name: pkg.name,
|
|
109
|
+
version: pkg.version,
|
|
110
|
+
},
|
|
111
|
+
};
|
|
102
112
|
});
|
|
103
113
|
|
|
104
114
|
this.connection.onInitialized(() => {});
|
|
@@ -361,21 +371,25 @@ export class LanguageServer {
|
|
|
361
371
|
|
|
362
372
|
if (issueType === 'unlisted') {
|
|
363
373
|
codeActions.push({
|
|
364
|
-
title: `
|
|
365
|
-
kind: CodeActionKind.QuickFix,
|
|
366
|
-
diagnostics: [diagnostic],
|
|
367
|
-
});
|
|
368
|
-
|
|
369
|
-
codeActions.push({
|
|
370
|
-
title: `Add '${issue.symbol}' to devDependencies in package.json`,
|
|
374
|
+
title: `Install '${issue.symbol}' as dependency`,
|
|
371
375
|
kind: CodeActionKind.QuickFix,
|
|
372
376
|
diagnostics: [diagnostic],
|
|
377
|
+
command: {
|
|
378
|
+
title: `Install '${issue.symbol}' as dependency`,
|
|
379
|
+
command: 'knip.installDependency',
|
|
380
|
+
arguments: [issue.symbol, 'dependencies', issue.workspace],
|
|
381
|
+
},
|
|
373
382
|
});
|
|
374
383
|
|
|
375
384
|
codeActions.push({
|
|
376
|
-
title: `
|
|
385
|
+
title: `Install '${issue.symbol}' as devDependency`,
|
|
377
386
|
kind: CodeActionKind.QuickFix,
|
|
378
387
|
diagnostics: [diagnostic],
|
|
388
|
+
command: {
|
|
389
|
+
title: `Install '${issue.symbol}' as devDependency`,
|
|
390
|
+
command: 'knip.installDependency',
|
|
391
|
+
arguments: [issue.symbol, 'devDependencies', issue.workspace],
|
|
392
|
+
},
|
|
379
393
|
});
|
|
380
394
|
}
|
|
381
395
|
|