Comments (1)
Here's a patch that fixed this for me. I'm not a typescript developer, so I actually modified the built JS until it worked, then tried to translate back:
diff --git i/src/languageserver/handlers/settingsHandlers.ts w/src/languageserver/handlers/settingsHandlers.ts
index 95ddba7..2fd4e73 100644
--- i/src/languageserver/handlers/settingsHandlers.ts
+++ w/src/languageserver/handlers/settingsHandlers.ts
@@ -14,6 +14,7 @@ import { Telemetry } from '../../languageservice/telemetry';
import { ValidationHandler } from './validationHandlers';
export class SettingsHandler {
+ private readonly globalSettings: Settings?; // or Settings and initialize to defaults?
constructor(
private readonly connection: Connection,
private readonly languageService: LanguageService,
@@ -31,13 +32,26 @@ export class SettingsHandler {
this.telemetry.sendError('yaml.settings.error', { error: convertErrorToTelemetryMsg(err) });
}
}
- this.connection.onDidChangeConfiguration(() => this.pullConfiguration());
+ this.connection.onDidChangeConfiguration((event) => {
+ // probably missing some type annotations to make this work
+ if (event && Object.prototype.hasOwnProperty.call(event, 'settings')) {
+ this.globalSettings = event.settings;
+ }
+ this.pullConfiguration()
+ });
}
/**
* The server pull the 'yaml', 'http.proxy', 'http.proxyStrictSSL', '[yaml]' settings sections
*/
async pullConfiguration(): Promise<void> {
+ // might need a null check on this.globalSettings here; in the JS version I
+ // set globalSettings to {} in the constructor, but that might not pass the
+ // typechecker as a "Settigns" object
+ if (!this.yamlSettings.hasConfigurationCapability) {
+ await this.setConfiguration(this.globalSettings);
+ return;
+ }
const config = await this.connection.workspace.getConfiguration([
{ section: 'yaml' },
{ section: 'http' },
For reference, here's the modified Javascript that definitely works:
class SettingsHandler {
constructor(connection, languageService, yamlSettings, validationHandler, telemetry) {
this.connection = connection;
this.languageService = languageService;
this.yamlSettings = yamlSettings;
this.validationHandler = validationHandler;
this.telemetry = telemetry;
this.globalSettings = {};
}
async registerHandlers() {
if (this.yamlSettings.hasConfigurationCapability && this.yamlSettings.clientDynamicRegisterSupport) {
try {
// Register for all configuration changes.
await this.connection.client.register(vscode_languageserver_1.DidChangeConfigurationNotification.type);
}
catch (err) {
this.telemetry.sendError('yaml.settings.error', { error: (0, objects_1.convertErrorToTelemetryMsg)(err) });
}
}
this.connection.onDidChangeConfiguration((event) => {
if (event && Object.prototype.hasOwnProperty.call(event, 'settings')) {
this.globalSettings = event.settings;
}
this.pullConfiguration()
});
}
/**
* The server pull the 'yaml', 'http.proxy', 'http.proxyStrictSSL', '[yaml]' settings sections
*/
async pullConfiguration() {
if (!this.yamlSettings.hasConfigurationCapability) {
await this.setConfiguration(this.globalSettings);
return;
}
// snip: omitted
from yaml-language-server.
Related Issues (20)
- Show enum values on hover HOT 1
- Github workflow deploy.yml detected as a PHP Deployer config HOT 1
- docs: The examples in the README have their syntax set wrong
- YAML `---` for "Multiple documents within a single stream" doesn't work [YAML Language Server] HOT 2
- Cannot Load content for: schema.json Unknown schema: file
- URL fragment references does not resolve correctly
- Use inline JSON Schema w/o modeline - make `yaml-language-server` string optional HOT 1
- Hover: Show root property title and description when using anyOf untitled un-described types HOT 1
- Schema association with fallbacks (wildcards) HOT 1
- Is there tilde expanstion feature on the horizon (or already supported) in schemas paths?
- yamlls + schema working fine in neovim? HOT 1
- openshift schemas in nvim with yamlls
- Add support for specifying schema via `# $schema: …` HOT 3
- RFC: Support schema from a child definition HOT 1
- How to configure yamlls at a workspace level for neovim?
- Use schema from `"$schema":` for current JSON file HOT 3
- Is path auto completion for $ref not supported?
- Unable to associate schemastore schema with a file path (nvim) HOT 1
- GitlabCI Support
- Specify schema from a Node dependency / node_modules
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from yaml-language-server.