Skip to content

Best practices for supporting tool-specific configuration file? #2045

@nmoroze

Description

@nmoroze

I'm wondering what the best practice is for how a language server should support an existing language-specific configuration file? For example, say I'm developing a language server for a tool that supports configuration via a myconfig.toml file in the project root. I want the language server to pull configuration from this file if it exists. I see two possible solutions:

1: Have the language server search for and read this file itself.

This option feels relatively straightforward, and doesn't require special client support. However, I'd like to re-run analytics on open files when the configuration is updated. It's less clear to me how to do so cleanly in this case. In addition, it seems more in the spirit of the spec not to assume that the client and server are both running with access to a shared local filesystem, which I believe this method would require (although this seems to be the common case, so perhaps it's an acceptable assumption).

2: Have the client parse the local configuration and pass it to the language server.

This option would use the "proper" LSP configuration mechanisms (i.e. workspace/configuration, workspace/didChangeConfiguration) to configure the server, and leave it up to the client to search for and parse the local project configuration. However, this requires a specialized client implementation per-editor, which seems to defeat the point of the LSP.

Any guidance would be appreciated!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions