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

Customizable InitializeOptions configuration for each language server #60

Open
AviAvni opened this issue Feb 6, 2025 · 1 comment
Open

Comments

@AviAvni
Copy link
Contributor

AviAvni commented Feb 6, 2025

when using python LSP how to provide workspace.environmentPath?
see https://github.com/pappasam/jedi-language-server

@LakshyAAAgrawal
Copy link
Collaborator

Immediate solution: As shown in the jedi-language-server README (https://github.com/pappasam/jedi-language-server#configuration), you need to edit the initialization options (

line 517). Set the "initializationOptions" > "workspace" > "environmentPath" your desired value, and it should work. Kindly let me know if you face any issues!

Going further, it would be ideal to support to provide a way for the end user to modify the initialization options to whatever they want in multilspy_config (https://github.com/microsoft/multilspy/blob/main/src/multilspy/multilspy_config.py) directly. What I can imagine would be a good way to do this is:

  1. multilspy_config defines a field called "initialization_options_patch" that is a json-like object (nested dicts/lists).
  2. For every language server, after reading the initialization options default config provided by multilspy (in files like https://github.com/microsoft/multilspy/blob/main/src/multilspy/language_servers/jedi_language_server/initialize_params.json, https://github.com/microsoft/multilspy/blob/main/src/multilspy/language_servers/eclipse_jdtls/initialize_params.json, https://github.com/microsoft/multilspy/blob/main/src/multilspy/language_servers/omnisharp/initialize_params.json, etc.), we apply the fields in multilspy_config.initialization_options_patch with an algorithm like the following:
    def update_options(options, patch):
        for k in patch:
            if k in options and type(options[k]) != dict:
                options[k] = patch[k]
            elif k in options and type(options[k]) == dict:
                update_options(options[k], patch[k])
            else:
                options[k] = patch[k]
    

Please do share what would be your preferred way to provide this configuration?

@LakshyAAAgrawal LakshyAAAgrawal changed the title Python LSP Customizable InitializeOptions configuration for each language server Feb 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants