Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sending configuration options #32

Closed
jtokoph opened this issue Sep 9, 2017 · 8 comments
Closed

Sending configuration options #32

jtokoph opened this issue Sep 9, 2017 · 8 comments

Comments

@jtokoph
Copy link

jtokoph commented Sep 9, 2017

Is there an example of sending configuration options to the language server? For example, I'd like to be able to send a list of plugin options to the python language server. In vscode, it uses the synchronize option to send vscode config values. How would I go about manually sending config values from the monaco-language client?

These are the options I want to be able to send: https://github.com/palantir/python-language-server/blob/develop/vscode-client/package.json#L19

@akosyakov
Copy link
Contributor

@jtokoph The monaco-languageclient is abstracted away from VS code via services, e.g. Workspace service provides an access to configurations which are used by the language client.
https://github.com/TypeFox/vscode-languageserver-node/blob/9449b41d27e4ffb0d72c1f5a85c47d1beead6073/client/src/services.ts#L144-L163

By the default, the subset of the services is implemented to support the standalone editor. You have to subclass MonacoWorkspace and provide support for configurations.

export class MonacoWorkspace implements Workspace {

@akosyakov
Copy link
Contributor

We could also pass an instance of Configurations to MonacoWorkspace via options (depends on #31). And provide the default InMemoryConfigurations implementation.

@akosyakov
Copy link
Contributor

PRs are welcomed. @jtokoph feel free to look into it

@cdietrich
Copy link
Contributor

#31 is done now

@SamVerschueren
Copy link

@jtokoph Is there a workaround for now? Also struggling with the python language server.

@SamVerschueren
Copy link

SamVerschueren commented Dec 22, 2017

I managed to get this working by implementing my own configuration class.

class WorkspaceConfiguration {
	constructor(
		config: any
	) {
		for (const key of Object.keys(config || {})) {
			this[key] = config[key];
		}
	}

	get<T>(section: string, defaultValue?: T) {
		console.log(this);
		return this[section] || defaultValue;
	}
}


class Configuration {
	private onConfigChanged: Function = () => {};

	getConfiguration(section?: string) {
		return new WorkspaceConfiguration(this[section]);
	}

	update(section: string, value: any, configurationTarget?: any) {
		this[section] = value;

		this.onConfigChanged();
	}

	onDidChangeConfiguration(cb: Function) {
		this.onConfigChanged = cb;
	}
}

After that, you can set the workspace.configurations object.

const config = new Configuration();

// create and start the language client
const languageClient = createLanguageClient(connection);
(languageClient.workspace as any).configurations = config;

config.update('pyls', {
	plugins: {
		pydocstyle: {
			enabled: false
		}
	}
});

If I find some time, and you are interested, I can do a PR.

@akosyakov
Copy link
Contributor

@SamVerschueren feel free to open the PR

@stale
Copy link

stale bot commented Jul 31, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants