@spyglassmc/language-server 0.4.2 → 0.4.3

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/lib/server.js CHANGED
@@ -70,12 +70,17 @@ connection.onInitialize(async (params) => {
70
70
  },
71
71
  });
72
72
  service.project
73
- .on('documentErrored', ({ errors, uri, version }) => {
74
- connection.sendDiagnostics({
75
- diagnostics: toLS.diagnostics(errors),
76
- uri: uri,
77
- version: version,
78
- });
73
+ .on('documentErrored', async ({ errors, uri, version }) => {
74
+ try {
75
+ await connection.sendDiagnostics({
76
+ diagnostics: toLS.diagnostics(errors),
77
+ uri: uri,
78
+ version: version,
79
+ });
80
+ }
81
+ catch (e) {
82
+ console.error('[sendDiagnostics]', e);
83
+ }
79
84
  })
80
85
  .on('ready', () => {
81
86
  progressReporter?.done();
@@ -87,7 +92,6 @@ connection.onInitialize(async (params) => {
87
92
  }
88
93
  const customCapabilities = {
89
94
  dataHackPubify: true,
90
- inlayHints: true,
91
95
  resetProjectCache: true,
92
96
  showCacheRoot: true,
93
97
  };
@@ -111,6 +115,7 @@ connection.onInitialize(async (params) => {
111
115
  label: 'Spyglass',
112
116
  },
113
117
  hoverProvider: {},
118
+ inlayHintProvider: {},
114
119
  semanticTokensProvider: {
115
120
  documentSelector: toLS.documentSelector(service.project.meta),
116
121
  legend: toLS.semanticTokensLegend(),
@@ -263,7 +268,7 @@ connection.onHover(async ({ textDocument: { uri }, position }) => {
263
268
  const ans = service.getHover(node, doc, toCore.offset(position, doc));
264
269
  return ans ? toLS.hover(ans, doc) : undefined;
265
270
  });
266
- connection.onRequest('spyglassmc/inlayHints', async ({ textDocument: { uri }, range, }) => {
271
+ connection.languages.inlayHint.on(async ({ textDocument: { uri }, range }) => {
267
272
  const docAndNode = await service.project.ensureClientManagedChecked(uri);
268
273
  if (!docAndNode) {
269
274
  return [];
@@ -1,7 +1,6 @@
1
1
  import * as core from '@spyglassmc/core';
2
2
  import type { TextDocument } from 'vscode-languageserver-textdocument';
3
3
  import * as ls from 'vscode-languageserver/node.js';
4
- import type { MyLspInlayHint } from './types.js';
5
4
  export declare function color(color: core.Color): ls.Color;
6
5
  export declare function colorInformation(info: core.ColorInfo, doc: TextDocument): ls.ColorInformation;
7
6
  export declare function colorInformationArray(info: core.ColorInfo[], doc: TextDocument): ls.ColorInformation[];
@@ -17,8 +16,8 @@ export declare function documentSymbols(map: core.SymbolMap | undefined, doc: Te
17
16
  export declare function documentSymbolsFromTable(table: core.SymbolTable, doc: TextDocument, hierarchicalSupport: boolean | undefined, supportedKinds?: ls.SymbolKind[]): ls.DocumentSymbol[];
18
17
  export declare function documentSymbolsFromTables(tables: core.SymbolTable[], doc: TextDocument, hierarchicalSupport: boolean | undefined, supportedKinds?: ls.SymbolKind[]): ls.DocumentSymbol[];
19
18
  export declare function hover(hover: core.Hover, doc: TextDocument): ls.Hover;
20
- export declare function inlayHint(hint: core.InlayHint, doc: TextDocument): MyLspInlayHint;
21
- export declare function inlayHints(hints: core.InlayHint[], doc: TextDocument): MyLspInlayHint[];
19
+ export declare function inlayHint(hint: core.InlayHint, doc: TextDocument): ls.InlayHint;
20
+ export declare function inlayHints(hints: core.InlayHint[], doc: TextDocument): ls.InlayHint[];
22
21
  export declare function completionItem(completion: core.CompletionItem, doc: TextDocument, requestedOffset: number, insertReplaceSupport: boolean | undefined): ls.CompletionItem;
23
22
  export declare function location(location: {
24
23
  uri: string;
package/lib/util/toLS.js CHANGED
@@ -118,7 +118,9 @@ export function hover(hover, doc) {
118
118
  export function inlayHint(hint, doc) {
119
119
  return {
120
120
  position: doc.positionAt(hint.offset),
121
- text: hint.text,
121
+ label: hint.label,
122
+ ...hint.paddingLeft ? { paddingLeft: hint.paddingLeft } : {},
123
+ ...hint.paddingRight ? { paddingRight: hint.paddingRight } : {},
122
124
  };
123
125
  }
124
126
  export function inlayHints(hints, doc) {
@@ -1,24 +1,12 @@
1
- import type * as ls from 'vscode-languageserver/node.js';
2
1
  export interface CustomInitializationOptions {
3
2
  inDevelopmentMode?: boolean;
4
3
  }
5
4
  export interface CustomServerCapabilities {
6
5
  dataHackPubify?: boolean;
7
- inlayHints?: boolean;
8
6
  resetProjectCache?: boolean;
9
7
  showCacheRoot?: boolean;
10
8
  }
11
9
  export interface MyLspDataHackPubifyRequestParams {
12
10
  initialism: string;
13
11
  }
14
- export interface MyLspInlayHint {
15
- position: ls.Position;
16
- text: string;
17
- }
18
- export interface MyLspInlayHintRequestParams {
19
- textDocument: {
20
- uri: string;
21
- };
22
- range: ls.Range;
23
- }
24
12
  //# sourceMappingURL=types.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spyglassmc/language-server",
3
- "version": "0.4.2",
3
+ "version": "0.4.3",
4
4
  "type": "module",
5
5
  "main": "lib/server.js",
6
6
  "types": "lib/server.d.ts",
@@ -19,12 +19,12 @@
19
19
  },
20
20
  "dependencies": {
21
21
  "env-paths": "^2.2.1",
22
- "vscode-languageserver": "^7.0.0",
23
- "vscode-languageserver-textdocument": "^1.0.1",
24
- "@spyglassmc/core": "0.4.2",
25
- "@spyglassmc/java-edition": "0.3.3",
26
- "@spyglassmc/locales": "0.3.2",
27
- "@spyglassmc/mcdoc": "0.3.3"
22
+ "vscode-languageserver": "^9.0.1",
23
+ "vscode-languageserver-textdocument": "^1.0.11",
24
+ "@spyglassmc/core": "0.4.3",
25
+ "@spyglassmc/java-edition": "0.3.4",
26
+ "@spyglassmc/locales": "0.3.3",
27
+ "@spyglassmc/mcdoc": "0.3.4"
28
28
  },
29
29
  "publishConfig": {
30
30
  "access": "public"