@@ -2,40 +2,44 @@ local util = require 'lspconfig.util'
22
33return  {
44  default_config  =  {
5-     --  Enables support for reading code style, naming convention and analyzer
6-     --  settings from .editorconfig.
7-     enable_editorconfig_support  =  true ,
8- 
9-     --  If true, MSBuild project system will only load projects for files that
10-     --  were opened in the editor. This setting is useful for big C# codebases
11-     --  and allows for faster initialization of code navigation features only
12-     --  for projects that are relevant to code that is being edited. With this
13-     --  setting enabled OmniSharp may load fewer projects and may thus display
14-     --  incomplete reference lists for symbols.
15-     enable_ms_build_load_projects_on_demand  =  false ,
16- 
17-     --  Enables support for roslyn analyzers, code fixes and rulesets.
18-     enable_roslyn_analyzers  =  false ,
19- 
20-     --  Specifies whether 'using' directives should be grouped and sorted during
21-     --  document formatting.
22-     organize_imports_on_format  =  false ,
23- 
24-     --  Enables support for showing unimported types and unimported extension
25-     --  methods in completion lists. When committed, the appropriate using
26-     --  directive will be added at the top of the current file. This option can
27-     --  have a negative impact on initial completion responsiveness,
28-     --  particularly for the first few completion sessions after opening a
29-     --  solution.
30-     enable_import_completion  =  false ,
31- 
32-     --  Specifies whether to include preview versions of the .NET SDK when
33-     --  determining which version to use for project loading.
34-     sdk_include_prereleases  =  true ,
35- 
36-     --  Only run analyzers against open files when 'enableRoslynAnalyzers' is
37-     --  true
38-     analyze_open_documents_only  =  false ,
5+     settings  =  {
6+       FormattingOptions  =  {
7+         --  Enables support for reading code style, naming convention and analyzer
8+         --  settings from .editorconfig.
9+         EnableEditorConfigSupport  =  true ,
10+         --  Specifies whether 'using' directives should be grouped and sorted during
11+         --  document formatting.
12+         OrganizeImports  =  nil ,
13+       },
14+       MsBuild  =  {
15+         --  If true, MSBuild project system will only load projects for files that
16+         --  were opened in the editor. This setting is useful for big C# codebases
17+         --  and allows for faster initialization of code navigation features only
18+         --  for projects that are relevant to code that is being edited. With this
19+         --  setting enabled OmniSharp may load fewer projects and may thus display
20+         --  incomplete reference lists for symbols.
21+         LoadProjectsOnDemand  =  nil ,
22+       },
23+       RoslynExtensionsOptions  =  {
24+         --  Enables support for roslyn analyzers, code fixes and rulesets.
25+         EnableAnalyzersSupport  =  nil ,
26+         --  Enables support for showing unimported types and unimported extension
27+         --  methods in completion lists. When committed, the appropriate using
28+         --  directive will be added at the top of the current file. This option can
29+         --  have a negative impact on initial completion responsiveness,
30+         --  particularly for the first few completion sessions after opening a
31+         --  solution.
32+         EnableImportCompletion  =  nil ,
33+         --  Only run analyzers against open files when 'enableRoslynAnalyzers' is
34+         --  true
35+         AnalyzeOpenDocumentsOnly  =  nil ,
36+       },
37+       Sdk  =  {
38+         --  Specifies whether to include preview versions of the .NET SDK when
39+         --  determining which version to use for project loading.
40+         IncludePrereleases  =  true ,
41+       },
42+     },
3943
4044    filetypes  =  { ' cs' ' vb'  
4145    root_dir  =  util .root_pattern (' *.sln' ' *.csproj' ' omnisharp.json' ' function.json' 
@@ -51,32 +55,21 @@ return {
5155      table.insert (new_config .cmd , ' --languageserver' 
5256
5357      --  Append configuration-dependent command arguments
54-       if  new_config .enable_editorconfig_support  then 
55-         table.insert (new_config .cmd , ' FormattingOptions:EnableEditorConfigSupport=true' 
58+       local  function  flatten (tbl )
59+         local  ret  =  {}
60+         for  k , v  in  pairs (tbl ) do 
61+           if  type (v ) ==  ' table'  then 
62+             for  _ , pair  in  ipairs (flatten (v )) do 
63+               ret [# ret  +  1 ] =  k  ..  ' :'  ..  pair 
64+             end 
65+           else 
66+             ret [# ret  +  1 ] =  k  ..  ' ='  ..  vim .inspect (v )
67+           end 
68+         end 
69+         return  ret 
5670      end 
57- 
58-       if  new_config .organize_imports_on_format  then 
59-         table.insert (new_config .cmd , ' FormattingOptions:OrganizeImports=true' 
60-       end 
61- 
62-       if  new_config .enable_ms_build_load_projects_on_demand  then 
63-         table.insert (new_config .cmd , ' MsBuild:LoadProjectsOnDemand=true' 
64-       end 
65- 
66-       if  new_config .enable_roslyn_analyzers  then 
67-         table.insert (new_config .cmd , ' RoslynExtensionsOptions:EnableAnalyzersSupport=true' 
68-       end 
69- 
70-       if  new_config .enable_import_completion  then 
71-         table.insert (new_config .cmd , ' RoslynExtensionsOptions:EnableImportCompletion=true' 
72-       end 
73- 
74-       if  new_config .sdk_include_prereleases  then 
75-         table.insert (new_config .cmd , ' Sdk:IncludePrereleases=true' 
76-       end 
77- 
78-       if  new_config .analyze_open_documents_only  then 
79-         table.insert (new_config .cmd , ' RoslynExtensionsOptions:AnalyzeOpenDocumentsOnly=true' 
71+       if  new_config .settings  then 
72+         vim .list_extend (new_config .cmd , flatten (new_config .settings ))
8073      end 
8174
8275      --  Disable the handling of multiple workspaces in a single instance
@@ -103,40 +96,44 @@ For `go_to_definition` to work fully, extended `textDocument/definition` handler
10396require'lspconfig'.omnisharp.setup { 
10497    cmd = { "dotnet", "/path/to/omnisharp/OmniSharp.dll" }, 
10598
106-     -- Enables support for reading code style, naming convention and analyzer 
107-     -- settings from .editorconfig. 
108-     enable_editorconfig_support = true, 
109- 
110-     -- If true, MSBuild project system will only load projects for files that 
111-     -- were opened in the editor. This setting is useful for big C# codebases 
112-     -- and allows for faster initialization of code navigation features only 
113-     -- for projects that are relevant to code that is being edited. With this 
114-     -- setting enabled OmniSharp may load fewer projects and may thus display 
115-     -- incomplete reference lists for symbols. 
116-     enable_ms_build_load_projects_on_demand = false, 
117- 
118-     -- Enables support for roslyn analyzers, code fixes and rulesets. 
119-     enable_roslyn_analyzers = false, 
120- 
121-     -- Specifies whether 'using' directives should be grouped and sorted during 
122-     -- document formatting. 
123-     organize_imports_on_format = false, 
124- 
125-     -- Enables support for showing unimported types and unimported extension 
126-     -- methods in completion lists. When committed, the appropriate using 
127-     -- directive will be added at the top of the current file. This option can 
128-     -- have a negative impact on initial completion responsiveness, 
129-     -- particularly for the first few completion sessions after opening a 
130-     -- solution. 
131-     enable_import_completion = false, 
132- 
133-     -- Specifies whether to include preview versions of the .NET SDK when 
134-     -- determining which version to use for project loading. 
135-     sdk_include_prereleases = true, 
136- 
137-     -- Only run analyzers against open files when 'enableRoslynAnalyzers' is 
138-     -- true 
139-     analyze_open_documents_only = false, 
99+     settings = { 
100+       FormattingOptions = { 
101+         -- Enables support for reading code style, naming convention and analyzer 
102+         -- settings from .editorconfig. 
103+         EnableEditorConfigSupport = true, 
104+         -- Specifies whether 'using' directives should be grouped and sorted during 
105+         -- document formatting. 
106+         OrganizeImports = nil, 
107+       }, 
108+       MsBuild = { 
109+         -- If true, MSBuild project system will only load projects for files that 
110+         -- were opened in the editor. This setting is useful for big C# codebases 
111+         -- and allows for faster initialization of code navigation features only 
112+         -- for projects that are relevant to code that is being edited. With this 
113+         -- setting enabled OmniSharp may load fewer projects and may thus display 
114+         -- incomplete reference lists for symbols. 
115+         LoadProjectsOnDemand = nil, 
116+       }, 
117+       RoslynExtensionsOptions = { 
118+         -- Enables support for roslyn analyzers, code fixes and rulesets. 
119+         EnableAnalyzersSupport = nil, 
120+         -- Enables support for showing unimported types and unimported extension 
121+         -- methods in completion lists. When committed, the appropriate using 
122+         -- directive will be added at the top of the current file. This option can 
123+         -- have a negative impact on initial completion responsiveness, 
124+         -- particularly for the first few completion sessions after opening a 
125+         -- solution. 
126+         EnableImportCompletion = nil, 
127+         -- Only run analyzers against open files when 'enableRoslynAnalyzers' is 
128+         -- true 
129+         AnalyzeOpenDocumentsOnly = nil, 
130+       }, 
131+       Sdk = { 
132+         -- Specifies whether to include preview versions of the .NET SDK when 
133+         -- determining which version to use for project loading. 
134+         IncludePrereleases = true, 
135+       }, 
136+     }, 
140137} 
141138``` 
142139]] 
0 commit comments