Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions packages/language-server/src/ls-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { Document } from './lib/documents';
import { returnObjectIfHasKeys } from './utils';
import path from 'path';
import { FileMap } from './lib/documents/fileCollection';
import { ClientCapabilities } from 'vscode-languageserver-protocol';

/**
* Default config for the language server.
Expand Down Expand Up @@ -294,6 +295,7 @@ export class LSConfigManager {
private lessConfig: CssConfig | undefined;
private htmlConfig: HTMLConfig | undefined;
private isTrusted = true;
private clientCapabilities: ClientCapabilities | undefined;

constructor() {
this._updateTsUserPreferences('javascript', {});
Expand All @@ -303,14 +305,14 @@ export class LSConfigManager {
/**
* Updates config.
*/
update(config: DeepPartial<LSConfig>): void {
update(config: DeepPartial<LSConfig> | undefined): void {
// Ideally we shouldn't need the merge here because all updates should be valid and complete configs.
// But since those configs come from the client they might be out of synch with the valid config:
// We might at some point in the future forget to synch config settings in all packages after updating the config.
this.config = merge({}, defaultLSConfig, this.config, config);
// Merge will keep arrays/objects if the new one is empty/has less entries,
// therefore we need some extra checks if there are new settings
if (config.svelte?.compilerWarnings) {
if (config?.svelte?.compilerWarnings) {
this.config.svelte.compilerWarnings = config.svelte.compilerWarnings;
}

Expand Down Expand Up @@ -615,4 +617,13 @@ export class LSConfigManager {
this.listeners.forEach((listener) => listener(this));
});
}

updateClientCapabilities(clientCapabilities: ClientCapabilities) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Put it here so we can access it in the plugins later if needed.

this.clientCapabilities = clientCapabilities;
this.notifyListeners();
}

getClientCapabilities() {
return this.clientCapabilities;
}
}
9 changes: 7 additions & 2 deletions packages/language-server/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ export function startServer(options?: LSOptions) {
configManager.updateScssConfig(evt.initializationOptions?.configuration?.scss);
configManager.updateLessConfig(evt.initializationOptions?.configuration?.less);
configManager.updateHTMLConfig(evt.initializationOptions?.configuration?.html);
configManager.updateClientCapabilities(evt.capabilities);

pluginHost.initialize({
filterIncompleteCompletions:
Expand Down Expand Up @@ -412,10 +413,14 @@ export function startServer(options?: LSOptions) {

const updateAllDiagnostics = debounceThrottle(() => diagnosticsManager.updateAll(), 1000);
const refreshSemanticTokens = debounceThrottle(() => {
connection?.sendRequest(SemanticTokensRefreshRequest.method);
if (configManager?.getClientCapabilities()?.workspace?.semanticTokens?.refreshSupport) {
connection?.sendRequest(SemanticTokensRefreshRequest.method);
}
}, 1500);
const refreshInlayHints = debounceThrottle(() => {
connection?.sendRequest(InlayHintRefreshRequest.method);
if (configManager?.getClientCapabilities()?.workspace?.inlayHint?.refreshSupport) {
connection?.sendRequest(InlayHintRefreshRequest.method);
}
}, 1500);

const refreshCrossFilesSemanticFeatures = () => {
Expand Down