@astrojs/language-server 0.18.0 → 0.18.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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @astrojs/language-server
2
2
 
3
+ ## 0.18.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 666739a: Revert update to latest LSP and inlay hints support
8
+
3
9
  ## 0.18.0
4
10
 
5
11
  ### Minor Changes
@@ -2,7 +2,7 @@ import { VSCodeEmmetConfig } from '@vscode/emmet-helper';
2
2
  import { LSConfig, LSCSSConfig, LSFormatConfig, LSHTMLConfig, LSTypescriptConfig } from './interfaces';
3
3
  import { Connection, FormattingOptions } from 'vscode-languageserver';
4
4
  import { TextDocument } from 'vscode-languageserver-textdocument';
5
- import { FormatCodeSettings, InlayHintsOptions, UserPreferences } from 'typescript';
5
+ import { FormatCodeSettings, UserPreferences } from 'typescript';
6
6
  export declare const defaultLSConfig: LSConfig;
7
7
  declare type DeepPartial<T> = T extends Record<string, unknown> ? {
8
8
  [P in keyof T]?: DeepPartial<T[P]>;
@@ -25,18 +25,14 @@ export declare class ConfigManager {
25
25
  getAstroFormatConfig(document: TextDocument): Promise<LSFormatConfig>;
26
26
  getTSFormatConfig(document: TextDocument, vscodeOptions?: FormattingOptions): Promise<FormatCodeSettings>;
27
27
  getTSPreferences(document: TextDocument): Promise<UserPreferences>;
28
- getTSInlayHintsPreferences(document: TextDocument): Promise<InlayHintsOptions>;
29
28
  /**
30
29
  * Return true if a plugin and an optional feature is enabled
31
30
  */
32
31
  isEnabled(document: TextDocument, plugin: keyof LSConfig, feature?: keyof LSTypescriptConfig | keyof LSCSSConfig | keyof LSHTMLConfig): Promise<boolean>;
33
32
  /**
34
33
  * Updating the global config should only be done in cases where the client doesn't support `workspace/configuration`
35
- * or inside of tests.
36
- *
37
- * The `outsideAstro` parameter can be set to true to change configurations in the global scope.
38
- * For example, to change TypeScript settings
34
+ * or inside of tests
39
35
  */
40
- updateGlobalConfig(config: DeepPartial<LSConfig> | any, outsideAstro?: boolean): void;
36
+ updateGlobalConfig(config: DeepPartial<LSConfig>): void;
41
37
  }
42
38
  export {};
@@ -124,20 +124,6 @@ class ConfigManager {
124
124
  includeCompletionsWithInsertText: true,
125
125
  };
126
126
  }
127
- async getTSInlayHintsPreferences(document) {
128
- const config = (await this.getConfig('typescript', document.uri)) ?? {};
129
- const tsPreferences = this.getTSPreferences(document);
130
- return {
131
- ...tsPreferences,
132
- includeInlayParameterNameHints: getInlayParameterNameHintsPreference(config),
133
- includeInlayParameterNameHintsWhenArgumentMatchesName: !(config.inlayHints?.parameterNames?.suppressWhenArgumentMatchesName ?? true),
134
- includeInlayFunctionParameterTypeHints: config.inlayHints?.parameterTypes?.enabled ?? false,
135
- includeInlayVariableTypeHints: config.inlayHints?.variableTypes?.enabled ?? false,
136
- includeInlayPropertyDeclarationTypeHints: config.inlayHints?.propertyDeclarationTypes?.enabled ?? false,
137
- includeInlayFunctionLikeReturnTypeHints: config.inlayHints?.functionLikeReturnTypes?.enabled ?? false,
138
- includeInlayEnumMemberValueHints: config.inlayHints?.enumMemberValues?.enabled ?? false,
139
- };
140
- }
141
127
  /**
142
128
  * Return true if a plugin and an optional feature is enabled
143
129
  */
@@ -147,18 +133,10 @@ class ConfigManager {
147
133
  }
148
134
  /**
149
135
  * Updating the global config should only be done in cases where the client doesn't support `workspace/configuration`
150
- * or inside of tests.
151
- *
152
- * The `outsideAstro` parameter can be set to true to change configurations in the global scope.
153
- * For example, to change TypeScript settings
136
+ * or inside of tests
154
137
  */
155
- updateGlobalConfig(config, outsideAstro) {
156
- if (outsideAstro) {
157
- this.globalConfig = (0, lodash_1.merge)({}, this.globalConfig, config);
158
- }
159
- else {
160
- this.globalConfig.astro = (0, lodash_1.merge)({}, exports.defaultLSConfig, this.globalConfig.astro, config);
161
- }
138
+ updateGlobalConfig(config) {
139
+ this.globalConfig.astro = (0, lodash_1.merge)({}, exports.defaultLSConfig, this.globalConfig.astro, config);
162
140
  }
163
141
  }
164
142
  exports.ConfigManager = ConfigManager;
@@ -196,15 +174,3 @@ function getImportModuleSpecifierEndingPreference(config) {
196
174
  return 'auto';
197
175
  }
198
176
  }
199
- function getInlayParameterNameHintsPreference(config) {
200
- switch (config.inlayHints?.parameterNames?.enabled) {
201
- case 'none':
202
- return 'none';
203
- case 'literals':
204
- return 'literals';
205
- case 'all':
206
- return 'all';
207
- default:
208
- return undefined;
209
- }
210
- }
@@ -1,4 +1,4 @@
1
- import { CancellationToken, Color, ColorInformation, ColorPresentation, CompletionContext, CompletionItem, CompletionList, DefinitionLink, Diagnostic, FoldingRange, Hover, Position, Range, Location, SignatureHelp, SignatureHelpContext, TextDocumentContentChangeEvent, TextDocumentIdentifier, WorkspaceEdit, SymbolInformation, SemanticTokens, CodeActionContext, CodeAction, InlayHint, FormattingOptions, TextEdit } from 'vscode-languageserver';
1
+ import { CancellationToken, Color, ColorInformation, ColorPresentation, CompletionContext, CompletionItem, CompletionList, DefinitionLink, Diagnostic, FoldingRange, Hover, Position, Range, Location, SignatureHelp, SignatureHelpContext, TextDocumentContentChangeEvent, TextDocumentIdentifier, WorkspaceEdit, SymbolInformation, SemanticTokens, CodeActionContext, CodeAction, FormattingOptions, TextEdit } from 'vscode-languageserver';
2
2
  import type { AppCompletionItem, Plugin } from './interfaces';
3
3
  import { DocumentManager } from '../core/documents/DocumentManager';
4
4
  interface PluginHostConfig {
@@ -25,7 +25,6 @@ export declare class PluginHost {
25
25
  getDefinitions(textDocument: TextDocumentIdentifier, position: Position): Promise<DefinitionLink[] | Location[]>;
26
26
  rename(textDocument: TextDocumentIdentifier, position: Position, newName: string): Promise<WorkspaceEdit | null>;
27
27
  getDocumentColors(textDocument: TextDocumentIdentifier): Promise<ColorInformation[]>;
28
- getInlayHints(textDocument: TextDocumentIdentifier, range: Range, cancellationToken: CancellationToken): Promise<InlayHint[]>;
29
28
  getColorPresentations(textDocument: TextDocumentIdentifier, range: Range, color: Color): Promise<ColorPresentation[]>;
30
29
  getSignatureHelp(textDocument: TextDocumentIdentifier, position: Position, context: SignatureHelpContext | undefined, cancellationToken: CancellationToken): Promise<SignatureHelp | null>;
31
30
  onWatchFileChanges(onWatchFileChangesParams: any[]): void;
@@ -112,10 +112,6 @@ class PluginHost {
112
112
  const document = this.getDocument(textDocument.uri);
113
113
  return (0, lodash_1.flatten)(await this.execute('getDocumentColors', [document], ExecuteMode.Collect));
114
114
  }
115
- async getInlayHints(textDocument, range, cancellationToken) {
116
- const document = this.getDocument(textDocument.uri);
117
- return (0, lodash_1.flatten)(await this.execute('getInlayHints', [document, range], ExecuteMode.FirstNonNull));
118
- }
119
115
  async getColorPresentations(textDocument, range, color) {
120
116
  const document = this.getDocument(textDocument.uri);
121
117
  return (0, lodash_1.flatten)(await this.execute('getColorPresentations', [document, range, color], ExecuteMode.Collect));
@@ -1,4 +1,4 @@
1
- import { CodeAction, CodeActionContext, Color, ColorInformation, ColorPresentation, CompletionContext, CompletionItem, CompletionList, DefinitionLink, Diagnostic, FileChangeType, FoldingRange, FormattingOptions, Hover, InlayHint, LinkedEditingRanges, Position, Range, ReferenceContext, SelectionRange, SemanticTokens, SignatureHelp, SignatureHelpContext, SymbolInformation, TextDocumentContentChangeEvent, TextDocumentIdentifier, TextEdit, WorkspaceEdit } from 'vscode-languageserver';
1
+ import { CodeAction, CodeActionContext, Color, ColorInformation, ColorPresentation, CompletionContext, CompletionItem, CompletionList, DefinitionLink, Diagnostic, FileChangeType, FoldingRange, FormattingOptions, Hover, LinkedEditingRanges, Position, Range, ReferenceContext, SelectionRange, SemanticTokens, SignatureHelp, SignatureHelpContext, SymbolInformation, TextDocumentContentChangeEvent, TextDocumentIdentifier, TextEdit, WorkspaceEdit } from 'vscode-languageserver';
2
2
  import { TextDocument } from 'vscode-languageserver-textdocument';
3
3
  export declare type Resolvable<T> = T | Promise<T>;
4
4
  export interface AppCompletionItem<T extends TextDocumentIdentifier = any> extends CompletionItem {
@@ -52,9 +52,6 @@ export interface FileRename {
52
52
  export interface UpdateImportsProvider {
53
53
  updateImports(fileRename: FileRename): Resolvable<WorkspaceEdit | null>;
54
54
  }
55
- export interface InlayHintsProvider {
56
- getInlayHints(document: TextDocument, range: Range): Resolvable<InlayHint[]>;
57
- }
58
55
  export interface RenameProvider {
59
56
  rename(document: TextDocument, position: Position, newName: string): Resolvable<WorkspaceEdit | null>;
60
57
  prepareRename(document: TextDocument, position: Position): Resolvable<Range | null>;
@@ -84,7 +81,7 @@ export interface OnWatchFileChangesProvider {
84
81
  export interface UpdateNonAstroFile {
85
82
  updateNonAstroFile(fileName: string, changes: TextDocumentContentChangeEvent[]): void;
86
83
  }
87
- declare type ProviderBase = DiagnosticsProvider & HoverProvider & CompletionsProvider & DefinitionsProvider & FormattingProvider & FoldingRangesProvider & TagCompleteProvider & DocumentColorsProvider & ColorPresentationsProvider & DocumentSymbolsProvider & UpdateImportsProvider & CodeActionsProvider & FindReferencesProvider & RenameProvider & SignatureHelpProvider & SemanticTokensProvider & SelectionRangeProvider & OnWatchFileChangesProvider & LinkedEditingRangesProvider & InlayHintsProvider & UpdateNonAstroFile;
84
+ declare type ProviderBase = DiagnosticsProvider & HoverProvider & CompletionsProvider & DefinitionsProvider & FormattingProvider & FoldingRangesProvider & TagCompleteProvider & DocumentColorsProvider & ColorPresentationsProvider & DocumentSymbolsProvider & UpdateImportsProvider & CodeActionsProvider & FindReferencesProvider & RenameProvider & SignatureHelpProvider & SemanticTokensProvider & SelectionRangeProvider & OnWatchFileChangesProvider & LinkedEditingRangesProvider & UpdateNonAstroFile;
88
85
  export declare type LSProvider = ProviderBase;
89
86
  export declare type Plugin = Partial<ProviderBase> & {
90
87
  __name: string;
@@ -1,4 +1,4 @@
1
- import { CancellationToken, CodeAction, CodeActionContext, CompletionContext, DefinitionLink, Diagnostic, FoldingRange, FormattingOptions, Hover, InlayHint, Position, Range, SemanticTokens, SignatureHelp, SignatureHelpContext, SymbolInformation, TextDocumentContentChangeEvent, TextEdit, WorkspaceEdit } from 'vscode-languageserver';
1
+ import { CancellationToken, CodeAction, CodeActionContext, CompletionContext, DefinitionLink, Diagnostic, FoldingRange, FormattingOptions, Hover, Position, Range, SemanticTokens, SignatureHelp, SignatureHelpContext, SymbolInformation, TextDocumentContentChangeEvent, TextEdit, WorkspaceEdit } from 'vscode-languageserver';
2
2
  import { ConfigManager } from '../../core/config';
3
3
  import { AstroDocument, DocumentManager } from '../../core/documents';
4
4
  import { AppCompletionItem, AppCompletionList, OnWatchFileChangesParam, Plugin } from '../interfaces';
@@ -14,7 +14,6 @@ export declare class TypeScriptPlugin implements Plugin {
14
14
  private readonly signatureHelpProvider;
15
15
  private readonly diagnosticsProvider;
16
16
  private readonly documentSymbolsProvider;
17
- private readonly inlayHintsProvider;
18
17
  private readonly semanticTokensProvider;
19
18
  private readonly foldingRangesProvider;
20
19
  private readonly formattingProvider;
@@ -28,7 +27,6 @@ export declare class TypeScriptPlugin implements Plugin {
28
27
  getCodeActions(document: AstroDocument, range: Range, context: CodeActionContext, cancellationToken?: CancellationToken): Promise<CodeAction[]>;
29
28
  getCompletions(document: AstroDocument, position: Position, completionContext?: CompletionContext, cancellationToken?: CancellationToken): Promise<AppCompletionList<CompletionItemData> | null>;
30
29
  resolveCompletion(document: AstroDocument, completionItem: AppCompletionItem<CompletionItemData>, cancellationToken?: CancellationToken): Promise<AppCompletionItem<CompletionItemData>>;
31
- getInlayHints(document: AstroDocument, range: Range): Promise<InlayHint[]>;
32
30
  getDefinitions(document: AstroDocument, position: Position): Promise<DefinitionLink[]>;
33
31
  getDiagnostics(document: AstroDocument, cancellationToken?: CancellationToken): Promise<Diagnostic[]>;
34
32
  onWatchFileChanges(onWatchFileChangesParas: OnWatchFileChangesParam[]): Promise<void>;
@@ -17,7 +17,6 @@ const SemanticTokenProvider_1 = require("./features/SemanticTokenProvider");
17
17
  const FoldingRangesProvider_1 = require("./features/FoldingRangesProvider");
18
18
  const CodeActionsProvider_1 = require("./features/CodeActionsProvider");
19
19
  const DefinitionsProvider_1 = require("./features/DefinitionsProvider");
20
- const InlayHintsProvider_1 = require("./features/InlayHintsProvider");
21
20
  const FormattingProvider_1 = require("./features/FormattingProvider");
22
21
  class TypeScriptPlugin {
23
22
  constructor(docManager, configManager, workspaceUris) {
@@ -32,7 +31,6 @@ class TypeScriptPlugin {
32
31
  this.diagnosticsProvider = new DiagnosticsProvider_1.DiagnosticsProviderImpl(this.languageServiceManager);
33
32
  this.documentSymbolsProvider = new DocumentSymbolsProvider_1.DocumentSymbolsProviderImpl(this.languageServiceManager);
34
33
  this.semanticTokensProvider = new SemanticTokenProvider_1.SemanticTokensProviderImpl(this.languageServiceManager);
35
- this.inlayHintsProvider = new InlayHintsProvider_1.InlayHintsProviderImpl(this.languageServiceManager, this.configManager);
36
34
  this.foldingRangesProvider = new FoldingRangesProvider_1.FoldingRangesProviderImpl(this.languageServiceManager);
37
35
  this.formattingProvider = new FormattingProvider_1.FormattingProviderImpl(this.languageServiceManager, this.configManager);
38
36
  }
@@ -100,9 +98,6 @@ class TypeScriptPlugin {
100
98
  async resolveCompletion(document, completionItem, cancellationToken) {
101
99
  return this.completionProvider.resolveCompletion(document, completionItem, cancellationToken);
102
100
  }
103
- async getInlayHints(document, range) {
104
- return this.inlayHintsProvider.getInlayHints(document, range);
105
- }
106
101
  async getDefinitions(document, position) {
107
102
  return this.definitionsProvider.getDefinitions(document, position);
108
103
  }
package/dist/server.js CHANGED
@@ -134,7 +134,6 @@ function startLanguageServer(connection) {
134
134
  range: true,
135
135
  full: true,
136
136
  },
137
- inlayHintProvider: true,
138
137
  signatureHelpProvider: {
139
138
  triggerCharacters: ['(', ',', '<'],
140
139
  retriggerCharacters: [')'],
@@ -198,7 +197,6 @@ function startLanguageServer(connection) {
198
197
  connection.onDocumentFormatting((params) => pluginHost.formatDocument(params.textDocument, params.options));
199
198
  connection.onDocumentColor((params) => pluginHost.getDocumentColors(params.textDocument));
200
199
  connection.onColorPresentation((params) => pluginHost.getColorPresentations(params.textDocument, params.range, params.color));
201
- connection.onRequest(vscode_languageserver_1.InlayHintRequest.type, (params, cancellationToken) => pluginHost.getInlayHints(params.textDocument, params.range, cancellationToken));
202
200
  connection.onRequest(TagCloseRequest, (evt) => pluginHost.doTagComplete(evt.textDocument, evt.position));
203
201
  connection.onSignatureHelp((evt, cancellationToken) => pluginHost.getSignatureHelp(evt.textDocument, evt.position, evt.context, cancellationToken));
204
202
  connection.onRenameRequest((evt) => pluginHost.rename(evt.textDocument, evt.position, evt.newName));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astrojs/language-server",
3
- "version": "0.18.0",
3
+ "version": "0.18.1",
4
4
  "author": "withastro",
5
5
  "license": "MIT",
6
6
  "type": "commonjs",
@@ -24,13 +24,13 @@
24
24
  "@vscode/emmet-helper": "^2.8.4",
25
25
  "lodash": "^4.17.21",
26
26
  "source-map": "^0.7.3",
27
- "typescript": "~4.6.4",
27
+ "typescript": "~4.6.2",
28
28
  "vscode-css-languageservice": "^5.1.13",
29
29
  "vscode-html-languageservice": "^4.2.5",
30
- "vscode-languageserver": "^8.0.0",
31
- "vscode-languageserver-protocol": "^3.17.0",
30
+ "vscode-languageserver": "7.0.0",
31
+ "vscode-languageserver-protocol": "^3.16.0",
32
32
  "vscode-languageserver-textdocument": "^1.0.1",
33
- "vscode-languageserver-types": "^3.17.0",
33
+ "vscode-languageserver-types": "^3.16.0",
34
34
  "vscode-uri": "^3.0.2"
35
35
  },
36
36
  "devDependencies": {
@@ -1,12 +0,0 @@
1
- import { InlayHint } from 'vscode-languageserver';
2
- import { AstroDocument } from '../../../core/documents';
3
- import { InlayHintsProvider } from '../../interfaces';
4
- import { LanguageServiceManager } from '../LanguageServiceManager';
5
- import { Range } from 'vscode-languageserver-types';
6
- import { ConfigManager } from '../../../core/config';
7
- export declare class InlayHintsProviderImpl implements InlayHintsProvider {
8
- private languageServiceManager;
9
- private configManager;
10
- constructor(languageServiceManager: LanguageServiceManager, configManager: ConfigManager);
11
- getInlayHints(document: AstroDocument, range: Range): Promise<InlayHint[]>;
12
- }
@@ -1,36 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.InlayHintsProviderImpl = void 0;
7
- const vscode_languageserver_1 = require("vscode-languageserver");
8
- const utils_1 = require("../utils");
9
- const vscode_languageserver_types_1 = require("vscode-languageserver-types");
10
- const typescript_1 = __importDefault(require("typescript"));
11
- class InlayHintsProviderImpl {
12
- constructor(languageServiceManager, configManager) {
13
- this.languageServiceManager = languageServiceManager;
14
- this.configManager = configManager;
15
- }
16
- async getInlayHints(document, range) {
17
- const { lang, tsDoc } = await this.languageServiceManager.getLSAndTSDoc(document);
18
- const filePath = (0, utils_1.toVirtualAstroFilePath)(tsDoc.filePath);
19
- const fragment = await tsDoc.createFragment();
20
- const start = fragment.offsetAt(fragment.getGeneratedPosition(range.start));
21
- const end = fragment.offsetAt(fragment.getGeneratedPosition(range.end));
22
- const tsPreferences = await this.configManager.getTSInlayHintsPreferences(document);
23
- const inlayHints = lang.provideInlayHints(filePath, { start, length: end - start }, tsPreferences);
24
- return inlayHints.map((hint) => {
25
- const result = vscode_languageserver_1.InlayHint.create(fragment.getOriginalPosition(fragment.positionAt(hint.position)), hint.text, hint.kind === typescript_1.default.InlayHintKind.Type
26
- ? vscode_languageserver_types_1.InlayHintKind.Type
27
- : hint.kind === typescript_1.default.InlayHintKind.Parameter
28
- ? vscode_languageserver_types_1.InlayHintKind.Parameter
29
- : undefined);
30
- result.paddingLeft = hint.whitespaceBefore;
31
- result.paddingRight = hint.whitespaceAfter;
32
- return result;
33
- });
34
- }
35
- }
36
- exports.InlayHintsProviderImpl = InlayHintsProviderImpl;