OmniSharp / csharp-language-server-protocol

Language Server Protocol in C#
MIT License
523 stars 104 forks source link

Use of WithInitializationOptions() in LSP Client #873

Open SebastianBolte opened 2 years ago

SebastianBolte commented 2 years ago

Hi,

I'm using OmniSharp LSP Client to communicate with the jedi-language-server. I need to auto import a module and there is an initializationOption for this in the jedi-language-server. The parameter I have to give WithInitializationOptions() is from type object and I can't find an example how to use this function. What I have tried is this

` List extraPathsList = new List() {

           @"path/to/the/module/I/want/to/autoImport",
        };

        Dictionary<string, object> extraPaths = new Dictionary<string, object>
        {
            { "extraPaths", extraPathsList }
        };

        List<string> autoImportModulesList = new List<string>() {
           "theModuleIWantToAutoImport",
        };

        Dictionary<string, object> autoImportModules = new Dictionary<string, object>
        {
            { "autoImportModules", autoImportModulesList }
        };

        Dictionary<string, object> initializationOptions = new Dictionary<string, object>
        {
            { "jediSettings", autoImportModules },
            { "workspace", extraPaths},
        };

`

but this doesn't work. Can you please give me an example how to create the parameter for WithInitializationOption()?

andyleejordan commented 2 years ago

We use it in our tests over here, perhaps that helps?

SebastianBolte commented 2 years ago

What language server are you using? Is there only one initialization option? For the jedi language server this is a nested json structure with key value pairs. But probably the autoImportModule just doesn't do what I thought it did. For the ignorePatterns it works in the way as described above with the dictionaries. My hope was that I would get completions without having to import the module when I set autoImportModule.

andyleejordan commented 2 years ago

I'm using the one that's written in that repository...PowerShell Editor Services is a language server written on top of this OmniSharp project. Right now it has two initialization options.